NagyD/SDLPoP

lots of build warnings with GCC 9.3

kees opened this issue · 2 comments

kees commented

When building under GCC 9.3, there are a lot of new warnings (and even more when adding default distro compiler flags). For example:

screenshot.c: In function ‘draw_extras’:
screenshot.c:368:40: warning: ‘%d’ directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Wformat-truncation=]
  368 |  snprintf(room_num, sizeof(room_num), "%d", drawn_room);
      |                                        ^~
screenshot.c:368:39: note: directive argument in the range [0, 65535]
  368 |  snprintf(room_num, sizeof(room_num), "%d", drawn_room);
      |                                       ^~~~
screenshot.c:368:2: note: ‘snprintf’ output between 2 and 6 bytes into a destination of size 4
  368 |  snprintf(room_num, sizeof(room_num), "%d", drawn_room);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
options.c: In function ‘check_mod_param’:
options.c:455:3: warning: ‘strncpy’ specified bound 256 equals destination size [-Wstringop-truncation]
  455 |   strncpy(levelset_name, mod_param, sizeof(levelset_name));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
options.c: In function ‘load_mod_options’:
options.c:680:50: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 255 [-Wformat-truncation=]
  680 |   snprintf(folder_name, sizeof(folder_name), "%s/%s", mods_folder, levelset_name);
      |                                                  ^~                ~~~~~~~~~~~~~
options.c:680:3: note: ‘snprintf’ output between 2 and 512 bytes into a destination of size 256
  680 |   snprintf(folder_name, sizeof(folder_name), "%s/%s", mods_folder, levelset_name);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
options.c:688:5: warning: ‘strncpy’ specified bound 256 equals destination size [-Wstringop-truncation]
  688 |     strncpy(mod_data_path, located_folder_name, sizeof(mod_data_path));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
options.c: In function ‘load_mod_options’:
options.c:688:5: warning: ‘strncpy’ specified bound 256 equals destination size [-Wstringop-truncation]
  688 |     strncpy(mod_data_path, located_folder_name, sizeof(mod_data_path));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kees commented

This is fixed in #206

NagyD commented

I have merged #206 now.