From b878dd99fab24112bfbfb1383d6e7abbb116e529 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Mon, 10 Feb 2020 21:06:48 -0800 Subject: [PATCH] interface: Silence warning from gcc version 8. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface.c b/interface.c index 7cd5b41..2cf3b1e 100644 --- a/interface.c +++ b/interface.c @@ -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); } }