summaryrefslogtreecommitdiff
path: root/lib/igt_aux.c
diff options
context:
space:
mode:
authorRodrigo Siqueira <rodrigosiqueiramelo@gmail.com>2018-06-16 21:34:29 -0300
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2018-06-21 15:46:52 +0300
commitafff8ad2f1ef546026533e1defaddca946d46050 (patch)
tree9891a61d494a526dbc3bfb520add3de7ee9fc11a /lib/igt_aux.c
parent04afec3ccfcb35e994f2e78254ff499f6b94f097 (diff)
Account for NULL character when using strncpy
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 <rodrigosiqueiramelo@gmail.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib/igt_aux.c')
-rw-r--r--lib/igt_aux.c2
1 files changed, 1 insertions, 1 deletions
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);