Skip to content

Commit

Permalink
interface: Silence warning from gcc version 8.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
richardcochran committed Mar 4, 2020
1 parent a8f7425 commit b878dd9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void interface_destroy(struct interface *iface)
void interface_ensure_tslabel(struct interface *iface)
{
if (!iface->ts_label[0]) {
strncpy(iface->ts_label, iface->name, MAX_IFNAME_SIZE);
memcpy(iface->ts_label, iface->name, MAX_IFNAME_SIZE);
}
}

Expand Down

0 comments on commit b878dd9

Please sign in to comment.