This patch fixes the following error while using gcc 8:
liblnetconfig.c: In function ‘lustre_lnet_parse_nids’:
liblnetconfig.c:320:3: error: ‘strncpy’ specified bound depends on
the length of the source argument [-Werror=stringop-overflow=]
strncpy(entry, cur, len - 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
liblnetconfig.c:310:10: note: length computed here
len = strlen(cur) + 1;
^~~~~~~~~~~
cc1: all warnings being treated as errors
Change-Id: I2d5840fd58c7b7d27ef1b2aa12f1f187d30abbfd
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36417
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
finish = i > 0 ? i - 1: 0;
goto failed;
}
- strncpy(entry, cur, len - 1);
+ memcpy(entry, cur, len - 1);
entry[len] = '\0';
new_array[i] = entry;
if (comma) {