From ac540c82ccb5225d06f364335fd84531c744c5b1 Mon Sep 17 00:00:00 2001 From: Nate Bargmann Date: Thu, 25 Oct 2018 16:58:51 -0500 Subject: [PATCH] Quell gcc 8.2.0 warning of possible truncation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Debian Buster gcc ((Debian 8.2.0-8) 8.2.0) was throwing the following warning: CC network.lo ../../hamlib/src/network.c: In function ‘network_open’: ../../hamlib/src/network.c:245:46: warning: ‘%s’ directive output may be truncated writing up to 511 bytes into a region of size 139 [-Wformat-truncation=] snprintf(msg,sizeof(msg),"connect to %s failed, (trying next interface)",rp->pathname); ^~ ../../hamlib/src/network.c:245:9: note: ‘snprintf’ output between 44 and 555 bytes into a destination of size 150 snprintf(msg,sizeof(msg),"connect to %s failed, (trying next interface)",rp->pathname); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Raising the size of the msg buffer to 1024 quelled the warning. --- src/network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network.c b/src/network.c index fc011fe4c..143f59c4f 100644 --- a/src/network.c +++ b/src/network.c @@ -241,7 +241,7 @@ int network_open(hamlib_port_t *rp, int default_port) { break; } - char msg[150]; + char msg[1024]; snprintf(msg,sizeof(msg),"connect to %s failed, (trying next interface)",rp->pathname); handle_error(RIG_DEBUG_WARN, msg);