From: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
To: Arkadiusz Hiler <arkadiusz.hiler@intel.com>,
igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] tests/perf: Use memcpy for UUIDs for oa_configs
Date: Thu, 16 May 2019 14:27:53 +0100 [thread overview]
Message-ID: <83c54dbc-72ed-c3e1-deaf-d8fd2628711e@intel.com> (raw)
In-Reply-To: <20190516132030.11600-1-arkadiusz.hiler@intel.com>
Sure :
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
On 16/05/2019 14:20, Arkadiusz Hiler wrote:
> drm_i915_perf_oa_config defines uuid as char[36], which does not leave
> space for the terminating NULL. Newer GCC and the fortification options
> leave us with the following complaint:
>
> warning: ‘__builtin_strncpy’ output truncated before terminating nul copying 36 bytes from a string of the same length [-Wstringop-truncation]
>
> Let's switch to memcpy() which does not care about the terminating NULL.
>
> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> ---
> tests/perf.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tests/perf.c b/tests/perf.c
> index f2c0aeb8..5ad8b2db 100644
> --- a/tests/perf.c
> +++ b/tests/perf.c
> @@ -3670,7 +3670,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));
> + memcpy(config.uuid, uuid, sizeof(config.uuid));
> config.n_mux_regs = 1;
> config.mux_regs_ptr = to_user_pointer(invalid_mux_regs);
> config.n_boolean_regs = 0;
> @@ -3679,7 +3679,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));
> + memcpy(config.uuid, uuid, sizeof(config.uuid));
> config.n_mux_regs = 0;
> config.mux_regs_ptr = to_user_pointer(mux_regs);
> config.n_boolean_regs = 0;
> @@ -3688,7 +3688,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));
> + memcpy(config.uuid, uuid, sizeof(config.uuid));
> config.n_mux_regs = 1;
> config.mux_regs_ptr = to_user_pointer(NULL);
> config.n_boolean_regs = 2;
> @@ -3699,7 +3699,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));
> + memcpy(config.uuid, uuid, sizeof(config.uuid));
> config.n_mux_regs = 42;
> config.mux_regs_ptr = to_user_pointer((void *) 0xDEADBEEF);
> config.n_boolean_regs = 0;
> @@ -3786,7 +3786,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));
> + memcpy(config.uuid, uuid, sizeof(config.uuid));
>
> config.n_mux_regs = 1;
> config.mux_regs_ptr = to_user_pointer(mux_regs);
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-05-16 13:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-16 13:20 [igt-dev] [PATCH i-g-t] tests/perf: Use memcpy for UUIDs for oa_configs Arkadiusz Hiler
2019-05-16 13:27 ` Lionel Landwerlin [this message]
2019-05-16 14:17 ` Ser, Simon
2019-05-16 14:28 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-05-16 17:45 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83c54dbc-72ed-c3e1-deaf-d8fd2628711e@intel.com \
--to=lionel.g.landwerlin@intel.com \
--cc=arkadiusz.hiler@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox