The International Simutrans Forum

 

Author Topic: [PATCH] fix some compiler warnings  (Read 3139 times)

0 Members and 1 Guest are viewing this topic.

Offline ansgar

  • *
  • Posts: 80
[PATCH] fix some compiler warnings
« 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 :-)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
Re: [PATCH] fix some compiler warnings
« Reply #1 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.)

Offline ansgar

  • *
  • Posts: 80
Re: [PATCH] fix some compiler warnings
« Reply #2 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

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
Re: [PATCH] fix some compiler warnings
« Reply #3 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.