Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] (PR#4792) compiling with NDEBUG
Home

[Freeciv-Dev] (PR#4792) compiling with NDEBUG

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#4792) compiling with NDEBUG
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 8 Aug 2003 10:11:23 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Several assertions in goto.c generate compiler warnings when compiling 
with --disable-debug.  Some of them appear to be buggy assertions too 
(pointer checks should be (x != NULL) rather than (x)).

jason

? rc
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.54
diff -u -r1.54 goto.c
--- client/goto.c       2003/07/21 19:01:01     1.54
+++ client/goto.c       2003/08/08 17:09:48
@@ -163,13 +163,13 @@
     /* Erase everything we cannot reuse */
     for (; i < p->path->length - 1; i++) {
       struct pf_position *a = &p->path->positions[i];
-      struct pf_position *next =
-         (i == p->path->length - 1) ? NULL : &p->path->positions[i + 1];
 
       if (is_valid_dir(a->dir_to_next_pos)) {
        decrement_drawn(a->x, a->y, a->dir_to_next_pos);
       } else {
-       assert(next && (a->x == next->x && a->y == next->y));
+       assert(i < p->path->length - 1
+              && a->x == p->path->positions[i + 1].x
+              && a->y == p->path->positions[i + 1].y);
       }
     }
     pf_destroy_path(p->path);
@@ -179,13 +179,13 @@
   /* Draw the new path */
   for (i = start_index; i < new_path->length - 1; i++) {
     struct pf_position *a = &new_path->positions[i];
-    struct pf_position *next =
-       (i == new_path->length - 1) ? NULL : &new_path->positions[i + 1];
 
     if (is_valid_dir(a->dir_to_next_pos)) {
       increment_drawn(a->x, a->y, a->dir_to_next_pos);
     } else {
-      assert(next && (a->x == next->x && a->y == next->y));
+      assert(i < new_path->length - 1
+            && a->x == new_path->positions[i + 1].x
+            && a->y == new_path->positions[i + 1].y);
     }
   }
   p->path = new_path;
@@ -271,10 +271,10 @@
 void goto_add_waypoint(void)
 {
   int x, y;
-  struct unit *punit = find_unit_by_id(goto_map.unit_id);
 
   assert(is_active);
-  assert(punit && punit == get_unit_in_focus());
+  assert(find_unit_by_id(goto_map.unit_id)
+        && find_unit_by_id(goto_map.unit_id) == get_unit_in_focus());
   get_line_dest(&x, &y);
   add_part();
 }
@@ -285,12 +285,12 @@
 ***********************************************************************/
 bool goto_pop_waypoint(void)
 {
-  struct unit *punit = find_unit_by_id(goto_map.unit_id);
   struct part *p = &goto_map.parts[goto_map.num_parts - 1];
   int end_x = p->end_x, end_y = p->end_y;
 
   assert(is_active);
-  assert(punit && punit == get_unit_in_focus());
+  assert(find_unit_by_id(goto_map.unit_id)
+        && find_unit_by_id(goto_map.unit_id) == get_unit_in_focus());
 
   if (goto_map.num_parts == 1) {
     /* we don't have any waypoint but the start pos. */

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#4792) compiling with NDEBUG, Jason Short <=