aft: Silence format-overflow warning with gcc-10.
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 28 Apr 2021 11:17:03 +0000 (13:17 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 28 Apr 2021 11:22:25 +0000 (13:22 +0200)
commit3ccea2ef0eff8e9acc5d34528645d3e29bc9a4f9
tree0ac9f575df6a132a5f2cc999318cc3790e232b40
parented0be6be160e87486ad93b482323d2579feb3540
aft: Silence format-overflow warning with gcc-10.

aft.c: In function 'print_list_item':
aft.c:736:17: warning: '%*u' directive writing between 1 and 65529 bytes into a region of size 30 [-Wformat-overflow=]
  736 |   sprintf(buf, "%*u:%02u:%02d", max_width - 6, hours, mins,
      |                 ^~~
aft.c:736:16: note: directive argument in the range [1, 4294967295]
  736 |   sprintf(buf, "%*u:%02u:%02d", max_width - 6, hours, mins,
      |                ^~~~~~~~~~~~~~~
aft.c:736:16: note: directive argument in the range [-59, 59]
aft.c:736:3: note: 'sprintf' output between 8 and 65545 bytes into a destination of size 30
  736 |   sprintf(buf, "%*u:%02u:%02d", max_width - 6, hours, mins,
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  737 |    seconds % 60);
      |    ~~~~~~~~~~~~~

The code is correct but gcc can't prove it. Silence the warning by
passing the size of the buffer and asserting that it won't overflow
before printing to it.
aft.c