public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] tests/perf: Use memcpy for UUIDs for oa_configs
@ 2019-05-16 13:20 Arkadiusz Hiler
  2019-05-16 13:27 ` Lionel Landwerlin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Arkadiusz Hiler @ 2019-05-16 13:20 UTC (permalink / raw)
  To: igt-dev

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);
-- 
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-05-16 17:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox