From afff8ad2f1ef546026533e1defaddca946d46050 Mon Sep 17 00:00:00 2001 From: Rodrigo Siqueira Date: Sat, 16 Jun 2018 21:34:29 -0300 Subject: Account for NULL character when using strncpy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fix the following gcc warning: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] strncpy(data->name, name, PARAM_NAME_MAX_SZ); This error happens due to the '\0' character appended by strncpy. Notice that reduces by one in the total of bytes to be copied, in this case, is harmless because the strings received in the parameter already have '\0'. Signed-off-by: Rodrigo Siqueira Reviewed-by: Arkadiusz Hiler --- lib/igt_aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/igt_aux.c') diff --git a/lib/igt_aux.c b/lib/igt_aux.c index acafb713..ca8ccfbd 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1240,7 +1240,7 @@ static void igt_save_module_param(const char *name, const char *file_path) data = calloc(1, sizeof (*data)); igt_assert(data); - strncpy(data->name, name, PARAM_NAME_MAX_SZ); + strncpy(data->name, name, PARAM_NAME_MAX_SZ - 1); fd = open(file_path, O_RDONLY); igt_assert(fd >= 0); -- cgit v1.2.3