The International Simutrans Forum

Development => Patches & Projects => Topic started by: ansgar on August 29, 2008, 06:54:56 pm

Title: [PATCH] fix some compiler warnings
Post by: ansgar on August 29, 2008, 06:54:56 pm
Hi,

This patch series fixes some compiler warning with gcc 4.3.1.  They are mostly of the form
Quote
warning: 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 :-)
Title: Re: [PATCH] fix some compiler warnings
Post by: prissi on August 29, 2008, 07:18:46 pm
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.)
Title: Re: [PATCH] fix some compiler warnings
Post by: ansgar on August 29, 2008, 07:44:26 pm
Code: [Select]
-		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
Code: [Select]
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
Title: Re: [PATCH] fix some compiler warnings
Post by: prissi on August 29, 2008, 07:51:34 pm
Then the code did not do what it was intended to do. Then this is another cases of warnings showing an error.