titoxd / wptc-track

WikiProject Tropical Cyclones' track map generator -- see http://en.wikipedia.org/wiki/WP:WPTC/M
22 stars 27 forks source link

Fix bug with multiple storms #13

Closed WindowsUser closed 11 months ago

WindowsUser commented 1 year ago

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.

titoxd commented 1 year 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.