From patchwork Sat Jul 7 23:23:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10512977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CC20A603D7 for ; Sat, 7 Jul 2018 23:23:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCB0E288E1 for ; Sat, 7 Jul 2018 23:23:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0FC5288EA; Sat, 7 Jul 2018 23:23:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6EEBB288E1 for ; Sat, 7 Jul 2018 23:23:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC8A46E363; Sat, 7 Jul 2018 23:23:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qt0-x242.google.com (mail-qt0-x242.google.com [IPv6:2607:f8b0:400d:c0d::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id E42556E35E; Sat, 7 Jul 2018 23:23:45 +0000 (UTC) Received: by mail-qt0-x242.google.com with SMTP id h4-v6so12811926qtj.7; Sat, 07 Jul 2018 16:23:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=KdLUosSbgUsGQJuSSu/LOun7nrsrIp0Tx3ivD4LzHVQ=; b=mVd+3yuZtIu7ETaWPY4k6+tdywl5OLwX2d2/fnCdFsS3oO6RxjE7iA0S5r1o+iS4rY Z3YDPxli3aTHGZhiQakjAkMjG512JVhjCMCEflM8nB3YBlbGRz4hWfDXsznQcxNXkA3X WDxWn5sktESnFii5X9lcVVdJD89HLonb9pJll6E47qIfAUG/AxS/RBekIZYGdjDbugFc GUEwhZkuP/bplE6DTisLBsOzd5zSVDh2K5qHqLBwR3pmiJUWlyM6XxwYAT04mb/qNPMB FvIvTRS4CAGa0b7JRRbCxbEg6LkNikRwG+hmNdYFJKVkAJLqUSY2TSfEzNYGT4WkUyWO BQGg== X-Gm-Message-State: APt69E0EM+ZyLfDgaXUGJsHKq/ZbPcCei4/zOQwjvj8tDvcQTH/uiDa4 lpDcnpVESWlN+fqAzH/JGmg= X-Google-Smtp-Source: AAOMgpcbpiWoOnK3cEjkCWffxkHnNANEdM40v1IkuFACuUIKq7AvI9E/1uBtLE/A3+YHKMZr/J+v8w== X-Received: by 2002:a0c:ab43:: with SMTP id i3-v6mr7545261qvb.87.1531005825080; Sat, 07 Jul 2018 16:23:45 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id v187-v6sm2752214qka.73.2018.07.07.16.23.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 16:23:44 -0700 (PDT) Date: Sat, 7 Jul 2018 20:23:42 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler Message-ID: <21fd5aa70f19d584559aa2e315fcb6d921696bfc.1531005542.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180622 Subject: [Intel-gfx] [PATCH i-g-t 6/7] Fix truncate string in the strncpy X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This patch fix the following GCC Warnings: warning: ‘strncpy’ output truncated before terminating nul copying 36 bytes from a string of the same length [-Wstringop-truncation] [..] Signed-off-by: Rodrigo Siqueira --- tests/perf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/perf.c b/tests/perf.c index 95048bfa..031bcee8 100644 --- a/tests/perf.c +++ b/tests/perf.c @@ -3693,7 +3693,7 @@ test_invalid_create_userspace_config(void) igt_assert_eq(__i915_perf_add_config(drm_fd, &config), -EINVAL); /* invalid mux_regs */ - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 1; config.mux_regs_ptr = to_user_pointer(invalid_mux_regs); config.n_boolean_regs = 0; @@ -3702,7 +3702,7 @@ test_invalid_create_userspace_config(void) igt_assert_eq(__i915_perf_add_config(drm_fd, &config), -EINVAL); /* empty config */ - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 0; config.mux_regs_ptr = to_user_pointer(mux_regs); config.n_boolean_regs = 0; @@ -3711,7 +3711,7 @@ test_invalid_create_userspace_config(void) igt_assert_eq(__i915_perf_add_config(drm_fd, &config), -EINVAL); /* empty config with null pointers */ - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 1; config.mux_regs_ptr = to_user_pointer(NULL); config.n_boolean_regs = 2; @@ -3722,7 +3722,7 @@ test_invalid_create_userspace_config(void) igt_assert_eq(__i915_perf_add_config(drm_fd, &config), -EINVAL); /* invalid pointers */ - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 42; config.mux_regs_ptr = to_user_pointer((void *) 0xDEADBEEF); config.n_boolean_regs = 0; @@ -3809,7 +3809,7 @@ test_create_destroy_userspace_config(void) i915_perf_remove_config(drm_fd, config_id); memset(&config, 0, sizeof(config)); - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 1; config.mux_regs_ptr = to_user_pointer(mux_regs);