Build cleanup: strncpy output truncated before terminating nul
gcc 9.2.1 says:
In file included from /usr/include/string.h:494,
from terminal-util.c:24:
In function ‘strncpy’,
inlined from ‘add_separators.part.0’ at terminal-util.c:1000:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
terminal-util.c: In function ‘add_separators.part.0’:
terminal-util.c:990:12: note: length computed here
990 | seplen = strlen(sep);
| ^~~~~~~~~~~
Instead of silencing this warning with a pragma, let's go with man gcc
's recommendation:
To avoid the warning when the result is not expected to be NUL-terminated, call "memcpy" instead.
From the patch it's only the middle one that generates a warning, but let's be consistent and use memcpy throughout that entire function.