News:

Want to praise Simutrans?
Your feedback is important for us ;D.

[patch] compiler warnings

Started by ras52, October 09, 2012, 02:58:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ras52

When run with -Wall (which the simutrans Makefile includes), gcc 4.5.x and above gives an error whenever the return value of fread, fwrite, etc. are ignored.  The simutrans code ignores these return values very frequently (and, to be honest, it's fairly harmless to do so).  The attached patch suppresses all these warnings, which vastly decreases the number of compiler warnings produced.  I could have done this by adding -Wno-unused-results to the Makefile, but earlier gccs don't have this option and will fail if an unknown option is given.
Richard Smith

prissi

Using -Wall and then removing some again breaks the intention of -Wall, or? ;)

I rather not like to add such things to the code. When you add -Wall to CC_FLGAS (or wherever) in you config.defualt you could as well add this there too.

ras52

Well, I didn't add -Wall to my CFLAGS: it's included by the standard Makefile.  It's simply that its meaning changes between each version of gcc.  Would you prefer me to develop a patch that explicitly tests each of the relevant return values and exits if they fail?  (Which, realistically, is all you can do in the specific circumstances.) I'm happy to do that if that's more helpful.
Richard Smith

Ters

Fixing the warnings rather than silencing them seems like the best idea to me, though it's rather boring. And it's seldom harmless to ignore an error, and when reading data that's going to be used, it certainly isn't.

ras52

Quote from: Ters on October 10, 2012, 04:55:01 AM
Fixing the warnings rather than silencing them seems like the best idea to me, though it's rather boring. And it's seldom harmless to ignore an error, and when reading data that's going to be used, it certainly isn't.

You're right, of course.  The attached patch fixes all of the obj_reader code, which was responsible for a large proportion of the warnings. 
Richard Smith