Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation warnings on ArchLinux #176

Open
MCMic opened this issue Jan 15, 2019 · 13 comments
Open

Compilation warnings on ArchLinux #176

MCMic opened this issue Jan 15, 2019 · 13 comments

Comments

@MCMic
Copy link
Contributor

MCMic commented Jan 15, 2019

Hello,

As explained in #25 earlier, I get a lot of warnings when building with gcc 8.2.1.

Here is stderr:

starbase_metadata.c: In function 'read_starbase_model_metadata':
starbase_metadata.c:129:40: warning: '%s' directive output may be truncated writing up to 4095 bytes into a region of size 4088 [-Wformat-truncation=]
    snprintf(path, PATH_MAX, "%s/models/%s", asset_dir, model_file);
                                        ^~              ~~~~~~~~~~
starbase_metadata.c:129:4: note: 'snprintf' output 9 or more bytes (assuming 4104) into a destination of size 4096
    snprintf(path, PATH_MAX, "%s/models/%s", asset_dir, model_file);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
starbase_metadata.c:107:40: warning: '%s' directive output may be truncated writing up to 4095 bytes into a region of size 4088 [-Wformat-truncation=]
    snprintf(path, PATH_MAX, "%s/models/%s", asset_dir, model_file);
                                        ^~              ~~~~~~~~~~
starbase_metadata.c:107:4: note: 'snprintf' output 9 or more bytes (assuming 4104) into a destination of size 4096
    snprintf(path, PATH_MAX, "%s/models/%s", asset_dir, model_file);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
starbase_metadata.c: At top level:
cc1: warning: unrecognized command line option '-Wno-gnu-folding-constant'
cc1: warning: unrecognized command line option '-Wno-extended-offsetof'
snis_server.c: In function 'queue_add_text_to_speech':
snis_server.c:2174:3: warning: 'strncpy' output may be truncated copying 255 bytes from a string of length 255 [-Wstringop-truncation]
   strncpy(bridgelist[c->bridge].last_text_to_speech, tmpbuf,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sizeof(bridgelist[c->bridge].last_text_to_speech) - 1);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_server.c: In function 'calculate_course_and_distance':
snis_server.c:23595:102: warning: ' clicks' directive writing 7 bytes into a region of size between 0 and 116 [-Wformat-overflow=]
    "Course to %s%s calculated.  Destination lies at bearing %3.0lf, mark %3.0lf at a distance of %.0f clicks",
                                                                                                      ^~~~~~~
snis_server.c:23594:3: note: 'sprintf' output between 92 and 1127 bytes into a destination of size 200
   sprintf(directions,
   ^~~~~~~~~~~~~~~~~~~
    "Course to %s%s calculated.  Destination lies at bearing %3.0lf, mark %3.0lf at a distance of %.0f clicks",
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    modifier, destination_name, heading, mark, distance);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_server.c: In function 'nl_set_ship_course_to_dest_helper':
snis_server.c:24612:37: warning: '%s' directive writing up to 99 bytes into a region of size 81 [-Wformat-overflow=]
  sprintf(reply, "Setting course for %s.", destination_name);
                                     ^~
snis_server.c:24660:61:
  nl_set_ship_course_to_direction_helper(c, ship, direction, dest_name);
                                                             ~~~~~~~~~
snis_server.c:24612:2: note: 'sprintf' output between 21 and 120 bytes into a destination of size 100
  sprintf(reply, "Setting course for %s.", destination_name);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_server.c: In function 'send_comms_packet':
snis_server.c:21549:45: warning: '%s' directive output may be truncated writing up to 99 bytes into a region of size 96 [-Wformat-truncation=]
  snprintf(tmpbuf, sizeof(tmpbuf) - 1, "%s | %s", sender, tmpbuf2);
                                             ^~           ~~~~~~~
snis_server.c:21549:2: note: 'snprintf' output 4 or more bytes (assuming 103) into a destination of size 99
  snprintf(tmpbuf, sizeof(tmpbuf) - 1, "%s | %s", sender, tmpbuf2);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_server.c: In function 'send_comms_packet.constprop':
snis_server.c:21549:45: warning: '%s' directive output may be truncated writing up to 99 bytes into a region of size 96 [-Wformat-truncation=]
  snprintf(tmpbuf, sizeof(tmpbuf) - 1, "%s | %s", sender, tmpbuf2);
                                             ^~           ~~~~~~~
snis_server.c:21549:2: note: 'snprintf' output 4 or more bytes (assuming 103) into a destination of size 99
  snprintf(tmpbuf, sizeof(tmpbuf) - 1, "%s | %s", sender, tmpbuf2);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_server.c: In function 'respawn_player':
snis_server.c:10237:9: warning: '%s' directive output may be truncated writing up to 19 bytes into a region of size 16 [-Wformat-truncation=]
    "MNR-%s", mining_bot_name);
         ^~   ~~~~~~~~~~~~~~~
snis_server.c:10236:2: note: 'snprintf' output between 5 and 24 bytes into a destination of size 20
  snprintf(o->tsd.ship.mining_bot_name, sizeof(o->tsd.ship.mining_bot_name),
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "MNR-%s", mining_bot_name);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_server.c:10237:9: warning: '%s' directive output may be truncated writing up to 19 bytes into a region of size 16 [-Wformat-truncation=]
    "MNR-%s", mining_bot_name);
         ^~   ~~~~~~~~~~~~~~~
snis_server.c:10236:2: note: 'snprintf' output between 5 and 24 bytes into a destination of size 20
  snprintf(o->tsd.ship.mining_bot_name, sizeof(o->tsd.ship.mining_bot_name),
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "MNR-%s", mining_bot_name);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_server.c:10237:9: warning: '%s' directive output may be truncated writing up to 19 bytes into a region of size 16 [-Wformat-truncation=]
    "MNR-%s", mining_bot_name);
         ^~   ~~~~~~~~~~~~~~~
snis_server.c:10236:2: note: 'snprintf' output between 5 and 24 bytes into a destination of size 20
  snprintf(o->tsd.ship.mining_bot_name, sizeof(o->tsd.ship.mining_bot_name),
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "MNR-%s", mining_bot_name);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_server.c: In function 'launch_mining_bot':
snis_server.c:10372:52: warning: '-MINER-' directive output may be truncated writing 7 bytes into a region of size between 1 and 20 [-Wformat-truncation=]
  snprintf(o->sdata.name, sizeof(o->sdata.name), "%s-MINER-%02d",
                                                    ^~~~~~~
snis_server.c:10372:49: note: directive argument in the range [0, 255]
  snprintf(o->sdata.name, sizeof(o->sdata.name), "%s-MINER-%02d",
                                                 ^~~~~~~~~~~~~~~
snis_server.c:10372:2: note: 'snprintf' output between 10 and 30 bytes into a destination of size 20
  snprintf(o->sdata.name, sizeof(o->sdata.name), "%s-MINER-%02d",
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   parent_ship->sdata.name, parent_ship->tsd.ship.mining_bots);
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'register_with_game_lobby.constprop',
    inlined from 'main' at snis_server.c:27429:3:
snis_server.c:22662:2: warning: 'strncpy' output may be truncated copying 19 bytes from a string of length 19 [-Wstringop-truncation]
  strncpy(gs.game_instance, gameinstance, 19);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'dequeue_lua_command.constprop',
    inlined from 'process_lua_commands' at snis_server.c:22874:3,
    inlined from 'main' at snis_server.c:27462:4:
snis_server.c:701:2: warning: 'strncpy' output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  strncpy(cmdbuf, qe->lua_command, bufsize - 1);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_server.c: At top level:
cc1: warning: unrecognized command line option '-Wno-gnu-folding-constant'
cc1: warning: unrecognized command line option '-Wno-extended-offsetof'
material.c: In function 'material_nebula_read_from_file':
material.c:36:30: warning: '%s' directive writing up to 4096 bytes into a region of size 4087 [-Wformat-overflow=]
  sprintf(fname, "%s/textures/%s", asset_dir, filename);
                              ^~
material.c:78:23:
   mt->texture_id[i] = load_texture(asset_dir, texture_filename);
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
material.c:36:2: note: 'sprintf' output 11 or more bytes (assuming 4107) into a destination of size 4097
  sprintf(fname, "%s/textures/%s", asset_dir, filename);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
material.c: At top level:
cc1: warning: unrecognized command line option '-Wno-gnu-folding-constant'
cc1: warning: unrecognized command line option '-Wno-extended-offsetof'
stl_parser.c: In function 'read_obj_file':
stl_parser.c:815:41: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
  snprintf(fname2, sizeof(fname2), "%s/%s", dname, fname);
                                         ^
stl_parser.c:815:2: note: 'snprintf' output 2 or more bytes (assuming 4097) into a destination of size 4096
  snprintf(fname2, sizeof(fname2), "%s/%s", dname, fname);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stl_parser.c:843:36: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
    snprintf(tfile, tfilelen, "%s/%s", dname, texturefile);
                                    ^
stl_parser.c:843:4: note: 'snprintf' output 2 or more bytes (assuming 4097) into a destination of size 4096
    snprintf(tfile, tfilelen, "%s/%s", dname, texturefile);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stl_parser.c:849:36: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
    snprintf(efile, efilelen, "%s/%s", dname, texturefile);
                                    ^
stl_parser.c:849:4: note: 'snprintf' output 2 or more bytes (assuming 4097) into a destination of size 4096
    snprintf(efile, efilelen, "%s/%s", dname, texturefile);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stl_parser.c:858:36: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
    snprintf(nfile, nfilelen, "%s/%s", dname, texturefile);
                                    ^
stl_parser.c:858:4: note: 'snprintf' output 2 or more bytes (assuming 4097) into a destination of size 4096
    snprintf(nfile, nfilelen, "%s/%s", dname, texturefile);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stl_parser.c: At top level:
cc1: warning: unrecognized command line option '-Wno-gnu-folding-constant'
cc1: warning: unrecognized command line option '-Wno-extended-offsetof'
snis_preferences.c: In function 'snis_prefs_read_default_ship_name':
snis_preferences.c:54:2: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=]
  strncpy(default_ship_name, name, n);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_preferences.c:51:6: note: length computed here
  n = strlen(name);
      ^~~~~~~~~~~~
snis_preferences.c: In function 'snis_prefs_save_default_ship_name':
snis_preferences.c:84:35: warning: '%s' directive output may be truncated writing 21 bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
  snprintf(filename, PATH_MAX, "%s/%s", path, "default_ship_name.txt");
                                   ^~         ~~~~~~~~~~~~~~~~~~~~~~~
snis_preferences.c:84:2: note: 'snprintf' output between 23 and 4118 bytes into a destination of size 4096
  snprintf(filename, PATH_MAX, "%s/%s", path, "default_ship_name.txt");
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_preferences.c:75:2: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=]
  strncpy(default_ship_name, name, n);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_preferences.c:71:10: note: length computed here
  int n = strlen(name);
          ^~~~~~~~~~~~
snis_preferences.c: In function 'snis_prefs_save_checkbox_defaults':
snis_preferences.c:119:35: warning: '%s' directive output may be truncated writing 17 bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
  snprintf(filename, PATH_MAX, "%s/%s", path, "role_defaults.txt");
                                   ^~         ~~~~~~~~~~~~~~~~~~~
snis_preferences.c:119:2: note: 'snprintf' output between 19 and 4114 bytes into a destination of size 4096
  snprintf(filename, PATH_MAX, "%s/%s", path, "role_defaults.txt");
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_preferences.c: At top level:
cc1: warning: unrecognized command line option '-Wno-gnu-folding-constant'
cc1: warning: unrecognized command line option '-Wno-extended-offsetof'
snis_client.c: In function 'override_asset_dir':
snis_client.c:19990:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if (!d)
  ^~
snis_client.c:19992:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   return;
   ^~~~~~
In function 'main_screen_add_text',
    inlined from 'process_comm_transmission' at snis_client.c:6018:2:
snis_client.c:8206:2: warning: 'strncpy' output may be truncated copying 99 bytes from a string of length 255 [-Wstringop-truncation]
  strncpy(main_screen_text.text[main_screen_text.last], msg, 99);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'start_lobbyserver_button_pressed':
snis_client.c:17980:32: warning: '/ssgl_server' directive output may be truncated writing 12 bytes into a region of size between 1 and 4096 [-Wformat-truncation=]
  snprintf(cmd, sizeof(cmd), "%s/ssgl_server", bindir);
                                ^~~~~~~~~~~~
snis_client.c:17980:2: note: 'snprintf' output between 13 and 4108 bytes into a destination of size 4096
  snprintf(cmd, sizeof(cmd), "%s/ssgl_server", bindir);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'do_text_to_speech':
snis_client.c:6396:68: warning: '%s' directive output may be truncated writing up to 4095 bytes into a region of size between 3758 and 4068 [-Wformat-truncation=]
  snprintf(command, sizeof(command), "export SNIS_TTS_VOLUME=%1.2f; %s/snis_text_to_speech.sh '%s'",
                                                                    ^~
     text_to_speech_volume, bindir, fixed_text);
                            ~~~~~~                                   
snis_client.c:6396:2: note: 'snprintf' output 55 or more bytes (assuming 4151) into a destination of size 4096
  snprintf(command, sizeof(command), "export SNIS_TTS_VOLUME=%1.2f; %s/snis_text_to_speech.sh '%s'",
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     text_to_speech_volume, bindir, fixed_text);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'draw_science_details.isra.109':
snis_client.c:15168:21: warning: ': ' directive writing 2 bytes into a region of size between 1 and 70 [-Wformat-overflow=]
   sprintf(buf, "%30s: %3.2f%%\n", compound_name, atm->major_fraction[i] * 100.0);
                     ^~
snis_client.c:15168:16: note: assuming directive output of 4 bytes
   sprintf(buf, "%30s: %3.2f%%\n", compound_name, atm->major_fraction[i] * 100.0);
                ^~~~~~~~~~~~~~~~~
snis_client.c:15168:3: note: 'sprintf' output between 38 and 417 bytes into a destination of size 100
   sprintf(buf, "%30s: %3.2f%%\n", compound_name, atm->major_fraction[i] * 100.0);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c:15177:21: warning: ': ' directive writing 2 bytes into a region of size between 1 and 70 [-Wformat-overflow=]
   sprintf(buf, "%30s: %4.2f ppm\n", compound_name, atm->minor_ppm[i]);
                     ^~
snis_client.c:15177:3: note: 'sprintf' output between 42 and 420 bytes into a destination of size 100
   sprintf(buf, "%30s: %4.2f ppm\n", compound_name, atm->minor_ppm[i]);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'start_gameserver_button_pressed':
snis_client.c:18050:40: warning: '/snis_server' directive output may be truncated writing 12 bytes into a region of size between 1 and 4096 [-Wformat-truncation=]
  snprintf(command, sizeof(command), "%s/snis_server", bindir);
                                        ^~~~~~~~~~~~
snis_client.c:18050:2: note: 'snprintf' output between 13 and 4108 bytes into a destination of size 4096
  snprintf(command, sizeof(command), "%s/snis_server", bindir);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'connect_to_gameserver_thread':
snis_client.c:7685:40: warning: '%s' directive output may be truncated writing up to 49 bytes into a region of size between 19 and 68 [-Wformat-truncation=]
     "snis_client: Failed looking up %s:%s: %s\n",
                                        ^~
     hoststr, portstr, gai_strerror(rc));
              ~~~~~~~                    
snis_client.c:7684:3: note: 'snprintf' output 36 or more bytes (assuming 134) into a destination of size 100
   snprintf(connecting_to_server_msg, sizeof(connecting_to_server_msg),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     "snis_client: Failed looking up %s:%s: %s\n",
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     hoststr, portstr, gai_strerror(rc));
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: At top level:
cc1: warning: unrecognized command line option '-Wno-gnu-folding-constant'
cc1: warning: unrecognized command line option '-Wno-extended-offsetof'
snis_client.c: In function 'override_asset_dir':
snis_client.c:19990:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if (!d)
  ^~
snis_client.c:19992:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   return;
   ^~~~~~
In function 'main_screen_add_text',
    inlined from 'process_comm_transmission' at snis_client.c:6018:2:
snis_client.c:8206:2: warning: 'strncpy' output may be truncated copying 99 bytes from a string of length 255 [-Wstringop-truncation]
  strncpy(main_screen_text.text[main_screen_text.last], msg, 99);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'start_lobbyserver_button_pressed':
snis_client.c:17980:32: warning: '/ssgl_server' directive output may be truncated writing 12 bytes into a region of size between 1 and 4096 [-Wformat-truncation=]
  snprintf(cmd, sizeof(cmd), "%s/ssgl_server", bindir);
                                ^~~~~~~~~~~~
snis_client.c:17980:2: note: 'snprintf' output between 13 and 4108 bytes into a destination of size 4096
  snprintf(cmd, sizeof(cmd), "%s/ssgl_server", bindir);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'do_text_to_speech':
snis_client.c:6396:68: warning: '%s' directive output may be truncated writing up to 4095 bytes into a region of size between 3758 and 4068 [-Wformat-truncation=]
  snprintf(command, sizeof(command), "export SNIS_TTS_VOLUME=%1.2f; %s/snis_text_to_speech.sh '%s'",
                                                                    ^~
     text_to_speech_volume, bindir, fixed_text);
                            ~~~~~~                                   
snis_client.c:6396:2: note: 'snprintf' output 55 or more bytes (assuming 4151) into a destination of size 4096
  snprintf(command, sizeof(command), "export SNIS_TTS_VOLUME=%1.2f; %s/snis_text_to_speech.sh '%s'",
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     text_to_speech_volume, bindir, fixed_text);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'draw_science_details.isra.110':
snis_client.c:15168:21: warning: ': ' directive writing 2 bytes into a region of size between 1 and 70 [-Wformat-overflow=]
   sprintf(buf, "%30s: %3.2f%%\n", compound_name, atm->major_fraction[i] * 100.0);
                     ^~
snis_client.c:15168:16: note: assuming directive output of 4 bytes
   sprintf(buf, "%30s: %3.2f%%\n", compound_name, atm->major_fraction[i] * 100.0);
                ^~~~~~~~~~~~~~~~~
snis_client.c:15168:3: note: 'sprintf' output between 38 and 417 bytes into a destination of size 100
   sprintf(buf, "%30s: %3.2f%%\n", compound_name, atm->major_fraction[i] * 100.0);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c:15177:21: warning: ': ' directive writing 2 bytes into a region of size between 1 and 70 [-Wformat-overflow=]
   sprintf(buf, "%30s: %4.2f ppm\n", compound_name, atm->minor_ppm[i]);
                     ^~
snis_client.c:15177:3: note: 'sprintf' output between 42 and 420 bytes into a destination of size 100
   sprintf(buf, "%30s: %4.2f ppm\n", compound_name, atm->minor_ppm[i]);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'start_gameserver_button_pressed':
snis_client.c:18050:40: warning: '/snis_server' directive output may be truncated writing 12 bytes into a region of size between 1 and 4096 [-Wformat-truncation=]
  snprintf(command, sizeof(command), "%s/snis_server", bindir);
                                        ^~~~~~~~~~~~
snis_client.c:18050:2: note: 'snprintf' output between 13 and 4108 bytes into a destination of size 4096
  snprintf(command, sizeof(command), "%s/snis_server", bindir);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: In function 'connect_to_gameserver_thread':
snis_client.c:7685:40: warning: '%s' directive output may be truncated writing up to 49 bytes into a region of size between 19 and 68 [-Wformat-truncation=]
     "snis_client: Failed looking up %s:%s: %s\n",
                                        ^~
     hoststr, portstr, gai_strerror(rc));
              ~~~~~~~                    
snis_client.c:7684:3: note: 'snprintf' output 36 or more bytes (assuming 134) into a destination of size 100
   snprintf(connecting_to_server_msg, sizeof(connecting_to_server_msg),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     "snis_client: Failed looking up %s:%s: %s\n",
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     hoststr, portstr, gai_strerror(rc));
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snis_client.c: At top level:
cc1: warning: unrecognized command line option '-Wno-gnu-folding-constant'
cc1: warning: unrecognized command line option '-Wno-extended-offsetof'
ssgl_log.c: In function 'ssgl_log':
ssgl_log.c:51:32: warning: '%06ld' directive output may be truncated writing between 6 and 20 bytes into a region of size between 0 and 63 [-Wformat-truncation=]
  snprintf(buf, sizeof buf, "%s.%06ld", tmbuf, tv.tv_usec);
                                ^~~~~
ssgl_log.c:51:2: note: 'snprintf' output between 8 and 85 bytes into a destination of size 64
  snprintf(buf, sizeof buf, "%s.%06ld", tmbuf, tv.tv_usec);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@MCMic
Copy link
Contributor Author

MCMic commented Jan 15, 2019

Also, if bin folder is not existing and make is run with several threads (make -j5 in my case), building fails with this:

cp: cannot create regular file 'bin/snis_text_to_speech.sh': No such file or directory
make: *** [Makefile:841: bin/snis_text_to_speech.sh] Error 1
make: *** Waiting for unfinished jobs....

This is a problem because when building the AUR package it is triggered (as it starts with a clean plate and no bin folder)

@smcameron
Copy link
Owner

Thanks! I'll try to get to these, but probably not today.

@MCMic
Copy link
Contributor Author

MCMic commented Jan 16, 2019

Regarding #176 (comment), it appears it’s easy to fix by adding the same @mkdir -p bin as in the other bin/* targets here: https://github.com/smcameron/space-nerds-in-space/blob/master/Makefile#L880

@smcameron
Copy link
Owner

Committed 0f10a5a

@smcameron
Copy link
Owner

Comitted 9f3b63d which should fix the issue that "make -j5" with ./bin failing to exist and crapping out at that particular point.

However, if I do:

make -j8

I still (sometimes, not always) see things like:

make[1]: Entering directory '/home/scameron/github/space-nerds-in-space/ssgl'
  COMPILE ssgl_sanitize.c
  COMPILE ssgl_sleep.c
(cd ssgl ; make )
make[1]: Entering directory '/home/scameron/github/space-nerds-in-space/ssgl'
  COMPILE ssgl_socket_io.c
(cd ssgl ; make )
make[1]: Entering directory '/home/scameron/github/space-nerds-in-space/ssgl'
  COMPILE ssgl_socket_io.c
  COMPILE ssgl_log.c
  COMPILE ssgl_get_primary_host_ip_addr.c
  COMPILE ssgl_log.c
  COMPILE ssgl_log.c
  COMPILE ssgl_recv_game_servers.c
  COMPILE ssgl_get_primary_host_ip_addr.c
  COMPILE ssgl_connect_to_lobby.c
  COMPILE ssgl_get_primary_host_ip_addr.c
  COMPILE ssgl_register_gameserver.c
  COMPILE ssgl_recv_game_servers.c
  COMPILE ssgl_register_for_bcast_packet.c
  COMPILE ssgl_connect_to_lobby.c
  COMPILE ssgl_register_gameserver.c
  GATHER BUILD INFO
  COMPILE ssgl_register_for_bcast_packet.c
  COMPILE ssgl_register_gameserver.c
  COMPILE ssgl_server.c
  COMPILE snis_server.c
  ARCHIVE libssglclient.a
  LINK ssgl_server.o
  COMPILE ssgl_server.c
  ARCHIVE libssglclient.a
ssgl_server.o: file not recognized: File truncated
collect2: error: ld returned 1 exit status
Makefile:129: recipe for target 'ssgl_server' failed
make[1]: *** [ssgl_server] Error 1
make[1]: Leaving directory '/home/scameron/github/space-nerds-in-space/ssgl'
Makefile:900: recipe for target 'ssgl/lsssgl' failed
make: *** [ssgl/lsssgl] Error 2
make: *** Waiting for unfinished jobs....

which I don't yet understand.

@MCMic
Copy link
Contributor Author

MCMic commented Feb 24, 2019

Nice fix for bin folder, I guess all the other mkdir bin should be removed then.

@smcameron
Copy link
Owner

smcameron commented Feb 24, 2019

Nice fix for bin folder, I guess all the other mkdir bin should be removed then.

Good idea. Done. 902adfb

make -j8 ... [sometimes fails] ... which I don't yet understand.

It was due to concurrent execution of multiple instances of (cd ssgl; make). Fixed by 1a3b0bd

Edit: I should add, I think it's fixed. Previously it didn't fail every time, but every other time or so. I ran "make mostly-clean; rmdir bin; make -j8" about 10 times in a row without a failure though.

@bmdrake919
Copy link

@smcameron, I am using gcc 8.3.1 and make 4.2.1 on Fedora 29. I have no apparent problems with dependencies, but I get a lot of the same compilation warnings like those in the OP. I also noticed the following: in files that get the warnings, I also see

snis_client.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-gnu-folding-constant’
cc1: warning: unrecognized command line option ‘-Wno-extended-offsetof’
(cd ssgl && make )

This appears in a number of files.

However, the first problem I encountered when doing a make all is that I get

make: *** No rule to make target 'bin', needed by 'all'. Stop.

So, I go and delete the 'bin' target after 'all:' and the project compiles!

There must be some default dependency for bin that is absent in my environment, that is all I can figure, because how does it compile for you if the target definition is missing? Odd. But, you are more familiar with your code, so I wanted to check with you to see if it is OK to remove the 'bin' reference.

@smcameron
Copy link
Owner

@bmdrake919 Thanks, for pointing that out.

I think I happen to have bin/ lying around. If I "rm -fr bin", I can duplicate your problem. I'll try to solve it.

@smcameron
Copy link
Owner

@bmdrake919 Ok, I think 24a0b37 should fix it. Let me know if it doesn't, or if you bump into anything else.

@MCMic
Copy link
Contributor Author

MCMic commented May 9, 2019

I tried to look into the «directive output may be truncated» and «'strncpy' output may be truncated copying…» warnings and from what I understand these are shown because in case strncpy truncates, it does not add the NULL terminating characters (and for snprintf it seems to depend on implementations).

That said, fixing those is a bit hard as it means you always need to have a big enough destination to contain all the input.

The best way may be writing a new function that does truncate if needed but adds the \0 terminating char in all cases (and maybe even \n if wanted).

Note that from What I understood gcc will not complain if you are testing the result of snprintf, because it then considers that you handle the case where truncation happens (as the result is >0 in this case).

Not sure if this is worth the hassle.

@smcameron
Copy link
Owner

I changed a bunch of sprintf to snprintf with:

$ git log --oneline | grep sprintf
6d893a1 Replace sprintf with snprintf in snis_client where it's easy
f6dcdb5 Replace sprintf by snprintf in snis_multiverse where easy
c152752 Replace sprintf by snprintf in snis_server where it's easy.
9acbb40 Use snprintf not sprintf in comms menu code

But there are still some left:

 $ grep sprintf *.c */*.c | wc -l
 64

@smcameron
Copy link
Owner

and for snprintf it seems to depend on implementations

On linux, it seems to truncate with a '\0' inserted early if need be.

scameron@sirius ~ $ cat testsnprintf.c
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	char x[100] = { 0 };

	memset(x, 'x', sizeof(x));
	snprintf(x, 4, "12345");
	printf("x = '%s'\n", x);
	return 0;
}
scameron@sirius ~ $ gcc -o testsnprintf testsnprintf.c
scameron@sirius ~ $ ./testsnprintf 
x = '123'
scameron@sirius ~ $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants