dMZX Forums: -Wunused-result -> Archived MegaZeux Bugs -> Tracker

Jump to content

Report ID 698 Title -Wunused-result
Product Archived MegaZeux Bugs Status Fixed (Severity 1 - Low)
Version 2.90d Fixed in 2.92
Introduced In Version ----Operating System Linux

Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Report ID #698: -Wunused-result

#1 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,895
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 05 November 2017 - 01:21 AM

Linux glibc seems to have added the warn_unused_result attribute to every library function call they possibly could have. While our ignoring these return values doesn't do a lot of harm, these warnings should be legitimately fixed as much as possible (i.e. no hacks).

It is possible to add -Wno-unused-result to the cflags for GCC >= 4.6, but I'd rather fix these properly.

2018-10-05 edit: updated remaining instances.

util.c
src/util.c: In function ‘mzx_res_init’:
src/util.c:139:5: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
     chdir(bin_path);
     ^~~~~~~~~~~~~~~
src/util.c:140:5: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
     getcwd(bin_path, MAX_PATH);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/util.c:166:7: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
       chdir(CONFDIR);
       ^~~~~~~~~~~~~~
src/util.c:168:7: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
       chdir(SHAREDIR);
       ^~~~~~~~~~~~~~~
src/util.c:170:5: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
     getcwd(p_dir, MAX_PATH);
     ^~~~~~~~~~~~~~~~~~~~~~~
src/util.c:200:7: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
       chdir(bin_path);
       ^~~~~~~~~~~~~~~


window.c
src/window.c: In function ‘file_manager’:
src/window.c:2761:3: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
   getcwd(return_dir_name, MAX_PATH);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/window.c:2786:5: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
     chdir(current_dir_name);
     ^~~~~~~~~~~~~~~~~~~~~~~
src/window.c:2851:19: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
                   fread(file_list[num_files] + 30, 1, 24, mzx_file);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/window.c:2895:5: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
     chdir(return_dir_name);
     ^~~~~~~~~~~~~~~~~~~~~~
src/window.c: In function ‘remove_files’:
src/window.c:2670:3: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
   getcwd(current_dir_name, MAX_PATH);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/window.c:2671:3: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
   chdir(directory_name);
   ^~~~~~~~~~~~~~~~~~~~~
src/window.c:2695:3: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
   chdir(current_dir_name);
   ^~~~~~~~~~~~~~~~~~~~~~~


world.c
src/world.c: In function ‘reload_world’:
src/world.c:3052:5: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
     getcwd(current_dir, MAX_PATH);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/world.c: In function ‘load_world’:
src/world.c:2510:5: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
     getcwd(current_dir, MAX_PATH);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/world.c:2513:7: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
       chdir(file_path);
       ^~~~~~~~~~~~~~~~
src/world.c: In function ‘reload_swap’:
src/world.c:3116:3: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
   getcwd(full_path, MAX_PATH);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~


main.c
 
src/main.c: In function ‘main’:
src/main.c:90:3: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
   getcwd(current_dir, MAX_PATH);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.c:121:3: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
   chdir(config_dir);
   ^~~~~~~~~~~~~~~~~
src/main.c:136:3: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
   chdir(current_dir);
   ^~~~~~~~~~~~~~~~~~
src/main.c:152:3: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
   chdir(current_dir);
   ^~~~~~~~~~~~~~~~~~


edit.c
src/editor/edit.c: In function ‘__edit_world’:
src/editor/edit.c:3447:3: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
   getcwd(editor->current_listening_dir, MAX_PATH);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor/edit.c: In function ‘editor_key’:
src/editor/edit.c:2767:13: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
             getcwd(current_dir, MAX_PATH);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor/edit.c:2768:13: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
             chdir(editor->current_listening_dir);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor/edit.c:2779:13: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
             chdir(current_dir);
             ^~~~~~~~~~~~~~~~~~
src/editor/edit.c:2983:15: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
               chdir(new_path);
               ^~~~~~~~~~~~~~~
src/editor/edit.c:3014:11: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result [-Wunused-result]
           getcwd(editor->test_reload_dir, MAX_PATH);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor/edit.c: In function ‘editor_resume’:
src/editor/edit.c:3348:5: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
     chdir(editor->test_reload_dir);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository


Page 1 of 1  
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Replies (1 - 5)

#2 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,895
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 05 November 2017 - 01:51 AM

Fixed the warnings in the utils.

src/utils/txt2hlp.c: In function ‘main’:
src/utils/txt2hlp.c:154:9: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]
         fscanf(source, "%3d", &link);
         ^
src/utils/checkres.c: In function ‘load_file’:
src/utils/checkres.c:1463:3: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
   fread(buffer, *buf_size, 1, fp);
   ^

"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#3 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,895
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 06 September 2018 - 11:11 AM

Warnings from graphics.c should be fixed as of 08b5f56.

src/graphics.c: In function ‘ec_load_set_secondary’:
src/graphics.c:184:3: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
   fread(dest, CHAR_SIZE, CHARSET_SIZE, fp);
   ^
src/graphics.c: In function ‘ec_load_set_var’:
src/graphics.c:209:3: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
   fread(graphics.charset + (pos * CHAR_SIZE), CHAR_SIZE, size, fp);
   ^

"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#4 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,895
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 06 October 2018 - 03:38 AM

Fixed most instances that don't involve chdir or getcwd in GIT a4ebe25 and GIT 6faf4ba. The sole exception is an fread in window.c used to grab world names in the file manager.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#5 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,895
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 21 February 2019 - 10:27 PM

Updating status to: Fixed
Updating version to: 2.90d
Issue fixed in: 2.92

Fixed remaining instances in GIT 075c3423 by adding chdir/getcwd wrappers to compat.h. This fix is labeled as "temporary" since the section these were added to is most likely due to be split off to a different file at some point (see: this issue), but future changes shouldn't break this fix.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#6 User is offline  
Terryn 

  • ******
  • Group: DigiStaff
  • Posts: 2,960
  • Joined: 12-October 00
  • Gender:Male

Posted 23 July 2019 - 12:35 AM

Moving to: Archived MegaZeux Bugs


Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

0 User(s) are reading this issue
0 Guests and 0 Anonymous Users


Powered by IP.Tracker 1.3.2 © 2026  IPS, Inc.