Closed WindowsUser closed 11 months ago
Throwing the GCC static analyzer at it with -fanalyzer
yields the following:
gcc -DHAVE_CONFIG_H -I. -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -Wall -Wextra -fanalyzer -MT jma.o -MD -MP -MF .deps/jma.Tpo -c -o jma.o jma.c
jma.c: In function ‘read_header’:
jma.c:42:9: warning: ‘strncpy’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Wstringop-truncation]
42 | strncpy(header.basin, "WP", 2);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Any of the options at https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstringop-truncation is acceptable as a fix.
header.name is not guaranteed to be initialized to an empty char array, so we need to make this explicit. Need to consider making an init_header macro.