]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
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)
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.


No differences found