Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[Freeciv-Dev] (PR#2909) assert(int) on 64 bit machine
Home

[Freeciv-Dev] (PR#2909) assert(int) on 64 bit machine

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2909) assert(int) on 64 bit machine
From: "Davide Pagnin via RT" <rt@xxxxxxxxxxxxxx>
Date: Sun, 26 Jan 2003 09:23:19 -0800
Reply-to: rt@xxxxxxxxxxxxxx

        Hi all!

Just to point out.
AFAIK, this is assert template:

void assert ( int )

Then, on 64 bit machine, code like this:

assert ( p )

Where p is a pointer, will raise a warning, caused by a mismatched size.
(In fact a pointer is 64 bit, instead an int is 32 bit)
We agreed (some time ago) that the solution to this problem, is to use
code like this:

assert ( p != NULL )

This, doesn't mean that you have to use code like this:

if (p != NULL) {

instead of

if (p) {

Just that you need to use such care when you play with assert.

I'll submit here, a patch that I will soon apply, that will correct 2
such cases in the ai/ and client/agents directories.

        Ciao, Davide

P.S. Perhaps it is a good idea to add this little bit of explanation in
the code style?



diff -ur -Xfreeciv/diff_ignore freeciv/ai/aitools.c freeciv-sdl/ai/aitools.c
--- freeciv/ai/aitools.c        Fri Jan 24 14:50:16 2003
+++ freeciv-sdl/ai/aitools.c    Sat Jan 25 17:57:35 2003
@@ -81,7 +81,7 @@
   struct unit *punit;
   punit=fc_calloc(1, sizeof(struct unit));
 
-  assert(pcity);
+  assert(pcity != NULL);
   punit->type = type;
   punit->owner = pplayer->player_no;
   CHECK_MAP_POS(pcity->x, pcity->y);
diff -ur -Xfreeciv/diff_ignore freeciv/client/agents/cma_core.c 
freeciv-sdl/client/agents/cma_core.c
--- freeciv/client/agents/cma_core.c    Fri Jan 24 14:50:17 2003
+++ freeciv-sdl/client/agents/cma_core.c        Sat Jan 25 18:56:42 2003
@@ -592,7 +592,7 @@
   pcity = find_city_by_id(city_id);
 
   if (!handled) {
-    assert(pcity);
+    assert(pcity != NULL);
     freelog(HANDLE_CITY_LOG_LEVEL2, "  not handled");
 
     create_event(pcity->x, pcity->y, E_CITY_CMA_RELEASE,

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2909) assert(int) on 64 bit machine, Davide Pagnin via RT <=