]> The Tcpdump Group git mirrors - tcpdump/commit
BGP: Address a -Wformat-truncation= compiler warning
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 14 Aug 2020 15:22:15 +0000 (17:22 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 14 Aug 2020 15:23:55 +0000 (17:23 +0200)
commit532ef3e8aaf700fdb5e9dec13d37ed21897bf4f9
tree5021b05bdf285b64c94b523ee0c927e9c543bcdf
parent50a72922c564280a420342cc77e91b16227078bd
BGP: Address a -Wformat-truncation= compiler warning

The warning was:
./print-bgp.c: In function 'bgp_vpn_rd_print':
./print-bgp.c:797:65: warning: '%u' directive output may be truncated
writing between 1 and 3 bytes into a region of size between 2 and 31
[-Wformat-truncation=]
  797 |         snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
      |                                                                 ^~
./print-bgp.c:797:48: note: directive argument in the range [0, 255]
  797 |         snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
      |                                                ^~~~~~~~~~~~~~~~~~~~~~~~
./print-bgp.c:797:48: note: directive argument in the range [0, 65535]
./print-bgp.c:797:9: note: 'snprintf' output between 15 and 50 bytes
into a destination of size 41
  797 |         snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  798 |                     as_printf(ndo, astostr, sizeof(astostr), GET_BE_U_4(pptr + 2)),
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  799 |                     GET_BE_U_2(pptr + 6), GET_U_1(pptr + 2),
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  800 |                     GET_U_1(pptr + 3), GET_U_1(pptr + 4),
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  801 |                     GET_U_1(pptr + 5), GET_BE_U_2(pptr + 6));
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
print-bgp.c