From: Andre Noll Date: Wed, 28 Apr 2021 11:17:03 +0000 (+0200) Subject: aft: Silence format-overflow warning with gcc-10. X-Git-Tag: v0.6.4~26 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=3ccea2ef0eff8e9acc5d34528645d3e29bc9a4f9;hp=3ccea2ef0eff8e9acc5d34528645d3e29bc9a4f9 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. ---