Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Tue Sep 26, 2017 5:47 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Apr 20, 2010 10:35 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
I've noticed that there are a lot of warnings like "ignoring return value of ‘fread’, declared with attribute warn_unused_result".
It's always related with standard functions that return values ignored by us. After a seeking over internet. it looks like this behaviour can not be deactivated , at least with o3 activated, and that's "our fault" cause all those returned values should be token in care for a good error handling.

I propose changing this (warned) line:

Code:
fscanf(fp,"%i\n",&visu);

with this one:

Code:
if(!fscanf(fp,"%i\n",&visu)) {raydium_log("ERROR: can not read data from file.");return 0;}

I think is important to choose a default solution to this warning, cause it appears a lot of times during the compilation. I think those warnings are making hard to see real errors/warnings.


Top
 Profile  
 
PostPosted: Tue Apr 20, 2010 11:25 am 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
Yep, true, recent GCC releases now generates this message by default.

I hope we will find a better solution than using if() everywhere, because is waaaay less readable to me ! Your example is very good at showing this :) If we must add such tests all over the engine, it will end in a giant stack of bloated code.

Perhaps a solution would be to use some macro to create some self testing version of these functions, but until we do more research about that, the better thing to do is probably : nothing :)


Top
 Profile  
 
PostPosted: Tue Apr 20, 2010 3:07 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
ok then. Time for waiting


Top
 Profile  
 
PostPosted: Tue Apr 20, 2010 4:14 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
Wow, just done a few searches about this warning, some answers are pretty rude :) "Fix the code. All those warnings are problems.", "Programs which fail to test return values are unreliable at best.", ...

I'll try to have a look at the (probably huge) list of these warnings to see if there's an interesting way to get rid of these warnings ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group