Quell gcc 8.2.0 warning of possible truncation

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.
pull/58/head^2
Nate Bargmann 2018-10-25 16:58:51 -05:00
rodzic 2d7d3d21df
commit ac540c82cc
1 zmienionych plików z 1 dodań i 1 usunięć

Wyświetl plik

@ -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);