News:

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

[PATCH] fix some compiler warnings

Started by ansgar, August 29, 2008, 06:54:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ansgar

Hi,

This patch series fixes some compiler warning with gcc 4.3.1.  They are mostly of the form
Quotewarning: suggest parentheses around && within ||

I think one of them was a bug, see the first patch.

Regards,
Ansgar

PS: I think a mailing list to send patches to would be more comfortable :-)

prissi

The patch for line id seems wrong too me, really a number above 12345 is desired ... But there was indeed an error with the map. Thank you.

And given the amount of patches submitted in the last year (above 30) so far this forum does well. But if the number increases we can think of setting up a mailing list. (Another possibility would be opening of the tracker at sourceforge.)

ansgar


- id += 12345+(7*id)&0x0FFF;
+ id += (12345 + 7*id) & 0x0FFF;


Operator precedence in C is *, +, & (with * being the strongest), so the first line is the same as
id += (12345 + (7*id)) & 0x0FFF;
then I only dropped the parenthesis around the multiplication.

All patches except the first one should not change the behavior of the program in any way.

Ansgar

prissi

Then the code did not do what it was intended to do. Then this is another cases of warnings showing an error.