[Freeciv-Dev] [bug #18086] comparison is always false due to limited range of data type

2011-05-03 Thread Matthias Pfafferodt

Follow-up Comment #7, bug #18086 (project freeciv):

comment #6 is for S2_3; in trunk the bug is present. Could you please test
the attached patch?

(file #12953)
___

Additional Item Attachment:

File name: 0004-fix-city_repair_size.patch Size:1 KB


___

Reply to this item at:

  http://gna.org/bugs/?18086

___
  Nachricht geschickt von/durch Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #18086] comparison is always false due to limited range of data type

2011-05-01 Thread Matthias Pfafferodt

Follow-up Comment #6, bug #18086 (project freeciv):

That revision do you use? For svn19602 the function header looks like:


/**
  Repair the city population without affecting city size.
  Used by savegame.c and sanitycheck.c
**/
void city_repair_size(struct city *pcity, int change)



___

Reply to this item at:

  http://gna.org/bugs/?18086

___
  Nachricht geschickt von/durch Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #18086] comparison is always false due to limited range of data type

2011-04-30 Thread akfaew

URL:
  http://gna.org/bugs/?18086

 Summary: comparison is always false due to limited range of
data type
 Project: Freeciv
Submitted by: akfaew
Submitted on: Sat 30 Apr 2011 08:30:27 AM GMT
Category: None
Severity: 3 - Normal
Priority: 5 - Normal
  Status: None
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Release: 
 Discussion Lock: Any
Operating System: None
 Planned Release: 

___

Details:

typedef.*citizens found in ../common/fc_types.h:
   107: typedef unsigned char citizens;

cityturn.c:696: warning: comparison is always false due to limited range of
data type
cityturn.c:699: warning: comparison is always false due to limited range of
data type
cityturn.c:829: warning: comparison is always true due to limited range of
data type
cityturn.c:829: warning: comparison is always true due to limited range of
data type

Indeed:
692 void city_repair_size(struct city *pcity, citizens change)
693 {
694   if (change  0) {
695 pcity-specialists[DEFAULT_SPECIALIST] += change;
696   } else if (change  0) {




___

Reply to this item at:

  http://gna.org/bugs/?18086

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #18086] comparison is always false due to limited range of data type

2011-04-30 Thread anonymous

Follow-up Comment #1, bug #18086 (project freeciv):

This is a bug! I'm woundering why you get an error message and I never did
see it? Do you use special compiler options or the default ones for debug?
Which gcc / distribution do you use?

Some background: I had citizens equal to short int but changed it to unsigned
char to save RAM. This should be no problem as the number of citizens can't be
negative. For a change in the number, the corresponding argument is positive
or negative. Thus it must be another data type. Could you check the handling
in the function to change the city size? I think, there I do such an cast.
Similar code would be needed here.

___

Reply to this item at:

  http://gna.org/bugs/?18086

___
  Nachricht geschickt von/durch Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #18086] comparison is always false due to limited range of data type

2011-04-30 Thread akfaew

Follow-up Comment #2, bug #18086 (project freeciv):

Standard compile with --disable-nls. I don't use debug since warnings are
treated as errors and I get hundereds of warnings from those NULLS in
printfs.

[12:11:pts/10][dude@hopek:~:74] gcc --version
gcc (GCC) 4.2.1 20070719  [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
[12:11:pts/10][dude@hopek:~:75] uname -a
FreeBSD hopek.jasminek.net 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19
02:55:53 UTC 2010
r...@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

___

Reply to this item at:

  http://gna.org/bugs/?18086

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #18086] comparison is always false due to limited range of data type

2011-04-30 Thread Marko Lindqvist

Follow-up Comment #3, bug #18086 (project freeciv):

 692 void city_repair_size(struct city *pcity, citizens change)

I think error is in that change is of type citizens in the first place. I
would try to change it to int.

___

Reply to this item at:

  http://gna.org/bugs/?18086

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #18086] comparison is always false due to limited range of data type

2011-04-30 Thread anonymous

Follow-up Comment #4, bug #18086 (project freeciv):

  692 void city_repair_size(struct city *pcity, citizens change)

 I think error is in that change is of type citizens in the 
 first place. I would try to change it to int.

Yes; I think this is that I have done for the function citizens_add() and
city_size_add() (I'm not sure about the names).

___

Reply to this item at:

  http://gna.org/bugs/?18086

___
  Nachricht geschickt von/durch Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #18086] comparison is always false due to limited range of data type

2011-04-30 Thread akfaew

Follow-up Comment #5, bug #18086 (project freeciv):

Also here:

vision_site_size_set found in ./common/vision.c:
   134: void vision_site_size_set(struct vision_site *psite, citizens size)
   135: {
   136:   fc_assert_ret(psite != NULL);
   137:   fc_assert_ret(size = MAX_CITY_SIZE);
   138: 
   139:   psite-size = size;
   140: }


___

Reply to this item at:

  http://gna.org/bugs/?18086

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev