[i-g-t,6/7] Fix truncate string in the strncpy
diff mbox

Message ID 21fd5aa70f19d584559aa2e315fcb6d921696bfc.1531005542.git.rodrigosiqueiramelo@gmail.com
State New
Headers show

Commit Message

Rodrigo Siqueira July 7, 2018, 11:23 p.m. UTC
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 <rodrigosiqueiramelo@gmail.com>
---
 tests/perf.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Patch
diff mbox

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