GCC 16 at -O3 rejects the WKS port bitmap loop with:
error: '%u' directive output may be truncated writing between 1 and
10 bytes into a region of size 6 [-Werror=format-truncation=]
The INSIST() bounding the bitmap length keeps the printed port below
65536, but 'sr' escapes into inet_totext(), so the compiler must
assume every later call can clobber it and loses the range it needs
to prove the port fits. Printing the port with '%hu' states the
16-bit bound in the format string instead of leaving it to be
re-derived from the bitmap length.
for (j = 0; j < 8; j++) {
if ((sr.base[i] & (0x80 >> j)) != 0) {
{
- snprintf(buf, sizeof(buf), "%u",
- i * 8 + j);
+ snprintf(buf, sizeof(buf),
+ "%hu", i * 8 + j);
RETERR(str_totext(" ", target));
RETERR(str_totext(buf, target));
}