interface: Silence warning from gcc version 8.

When compiling with gcc8 and -O2, the clever compiler complains:

   interface.c: In function ‘interface_ensure_tslabel’:
   interface.c:38:3: error: ‘strncpy’ output may be truncated copying 108 bytes from a string of length 108 [-Werror=stringop-truncation]

Even though this is a false positive, this patch silences the warning
by using memcpy instead of strncpy.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2020-02-10 21:06:48 -08:00
parent a8f742528e
commit b878dd99fa
1 changed files with 1 additions and 1 deletions

View File

@ -35,7 +35,7 @@ void interface_destroy(struct interface *iface)
void interface_ensure_tslabel(struct interface *iface) void interface_ensure_tslabel(struct interface *iface)
{ {
if (!iface->ts_label[0]) { if (!iface->ts_label[0]) {
strncpy(iface->ts_label, iface->name, MAX_IFNAME_SIZE); memcpy(iface->ts_label, iface->name, MAX_IFNAME_SIZE);
} }
} }