]> granicus.if.org Git - nethack/commitdiff
!DEBUG warnings
authorPatR <rankin@nethack.org>
Fri, 4 Dec 2015 22:58:49 +0000 (14:58 -0800)
committerPatR <rankin@nethack.org>
Fri, 4 Dec 2015 22:58:49 +0000 (14:58 -0800)
With DEBUG suppressed, I started getting
16      warning: empty body in an if-statement
and 2   warning: empty body in an else-statement
from gcc.

Using braces for an empty block instead of just ';' avoids the warning:
    if (foo)
        debugpline("foo");
is bad,
    if (bar) {
        debugpline("bar");
    }
is good.  ;-)

The changes to lint.h are just precautionary.

modified:
    include/lint.h
    src/attrib.c, bones.c, dbridge.c, dig.c, eat.c,
        makemon.c, mkmaze.c, mon.c, sp_lev.c

include/lint.h
src/attrib.c
src/bones.c
src/dbridge.c
src/dig.c
src/eat.c
src/makemon.c
src/mkmaze.c
src/mon.c
src/sp_lev.c

index 8fb79b4a97531347bb68d4a15837997b71735f85..c50446405197c7d867fa8aa1f0aa295c4cf3d9ba 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 lint.h  $NHDT-Date: 1430897871 2015/05/06 07:37:51 $  $NHDT-Branch: master $:$NHDT-Revision: 1.0 $ */
+/* NetHack 3.6 lint.h  $NHDT-Date: 1449269910 2015/12/04 22:58:30 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.3 $ */
 /* NetHack may be freely redistributed.  See license for details. */
 
 /*
@@ -36,19 +36,21 @@ extern unsigned nhUse_dummy;
 #ifdef DEBUG
 #define showdebug(file) debugcore(file, TRUE)
 #define explicitdebug(file) debugcore(file, FALSE)
-#define ifdebug(stmt)            \
-    do {                         \
-        if (showdebug(__FILE__)) \
-            stmt;                \
+#define ifdebug(stmt)                   \
+    do {                                \
+        if (showdebug(__FILE__)) {      \
+            stmt;                       \
+        }                               \
     } while (0)
 #ifdef _MSC_VER
 /* if we have microsoft's C runtime we can use these instead */
 #include <crtdbg.h>
-#define crtdebug(stmt)           \
-    do {                         \
-        if (showdebug(__FILE__)) \
-            stmt;                \
-        _RPT0(_CRT_WARN, "\n");  \
+#define crtdebug(stmt)                  \
+    do {                                \
+        if (showdebug(__FILE__)) {      \
+            stmt;                       \
+        }                               \
+        _RPT0(_CRT_WARN, "\n");         \
     } while (0)
 #define debugpline0(str) crtdebug(_RPT0(_CRT_WARN, str))
 #define debugpline1(fmt, arg) crtdebug(_RPT1(_CRT_WARN, fmt, arg))
index b0ee0fc11664e502cc3a6b1d31614aa0f5f2f1de..3866dbf26e372354dc4d6d7612597d7e391c43be 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 attrib.c        $NHDT-Date: 1446975460 2015/11/08 09:37:40 $  $NHDT-Branch: master $:$NHDT-Revision: 1.49 $ */
+/* NetHack 3.6 attrib.c        $NHDT-Date: 1449269911 2015/12/04 22:58:31 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.51 $ */
 /*      Copyright 1988, 1989, 1990, 1992, M. Stephenson           */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -470,8 +470,9 @@ exerchk()
     /*  Check out the periodic accumulations */
     exerper();
 
-    if (moves >= context.next_attrib_check)
+    if (moves >= context.next_attrib_check) {
         debugpline1("exerchk: ready to test. multi = %d.", multi);
+    }
     /*  Are we ready for a test? */
     if (moves >= context.next_attrib_check && !multi) {
         debugpline0("exerchk: testing.");
@@ -515,8 +516,9 @@ exerchk()
                                               ? "Dex"
                                               : (i == A_CON)
                                                     ? "Con"
-                                                    : (i == A_CHA) ? "Cha?"
-                                                                   : "???",
+                                                    : (i == A_CHA)
+                                                          ? "Cha?"
+                                                          : "???",
                         ax);
             /*
              *  Law of diminishing returns (Part III):
index b068e751a7f8b21b5f70d7f2706345b0b6656268..7ca192599ba0374af0f59cc31300d7c005bc6d6d 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 bones.c $NHDT-Date: 1446369463 2015/11/01 09:17:43 $  $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */
+/* NetHack 3.6 bones.c $NHDT-Date: 1449269914 2015/12/04 22:58:34 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.66 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -608,9 +608,10 @@ getbones()
                 if (has_mname(mtmp))
                     sanitize_name(MNAME(mtmp));
                 if (mtmp->mhpmax == DEFUNCT_MONSTER) {
-                    if (wizard)
+                    if (wizard) {
                         debugpline1("Removing defunct monster %s from bones.",
                                     mtmp->data->mname);
+                    }
                     mongone(mtmp);
                 } else
                     /* to correctly reset named artifacts on the level */
index 1dc43ad4beeefcd19e01bac4371a07612eeb1ef6..7d6bda397ca925443aa5fecfa597299ceeda3906 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 dbridge.c       $NHDT-Date: 1446955279 2015/11/08 04:01:19 $  $NHDT-Branch: master $:$NHDT-Revision: 1.33 $ */
+/* NetHack 3.6 dbridge.c       $NHDT-Date: 1449269914 2015/12/04 22:58:34 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.35 $ */
 /*      Copyright (c) 1989 by Jean-Christophe Collet              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -509,8 +509,9 @@ boolean chunks;
 {
     int misses;
 
-    if (chunks)
+    if (chunks) {
         debugpline0("Do chunks miss?");
+    }
     if (automiss(etmp))
         return TRUE;
 
@@ -590,13 +591,14 @@ struct entity *etmp;
         return;
     }
     if (e_missed(etmp, FALSE)) {
-        if (at_portcullis)
+        if (at_portcullis) {
             pline_The("portcullis misses %s!", e_nam(etmp));
-        else
+        } else {
             debugpline1("The drawbridge misses %s!", e_nam(etmp));
-        if (e_survives_at(etmp, oldx, oldy))
+        }
+        if (e_survives_at(etmp, oldx, oldy)) {
             return;
-        else {
+        else {
             debugpline0("Mon can't survive here");
             if (at_portcullis)
                 must_jump = TRUE;
@@ -978,10 +980,11 @@ int x, y;
                     pline("%s hit by a huge chunk of metal!",
                           E_phrase(etmp1, "are"));
             } else {
-                if (!Deaf && !is_u(etmp1) && !is_pool(x, y))
+                if (!Deaf && !is_u(etmp1) && !is_pool(x, y)) {
                     You_hear("a crushing sound.");
-                else
+                } else {
                     debugpline1("%s from shrapnel", E_phrase(etmp1, "die"));
+                }
             }
             killer.format = KILLED_BY_AN;
             Strcpy(killer.name, "collapsing drawbridge");
index 0d1c24187fd50ab5c3352d46557df54331060d16..bbfef5d0bf6d18ef08d1d09cb0d058e694b6575d 100644 (file)
--- a/src/dig.c
+++ b/src/dig.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 dig.c   $NHDT-Date: 1446369465 2015/11/01 09:17:45 $  $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */
+/* NetHack 3.6 dig.c   $NHDT-Date: 1449269915 2015/12/04 22:58:35 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.103 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1864,8 +1864,9 @@ int x, y;
 {
     struct obj *otmp, *otmp2;
 
-    if (level.objects[x][y] != (struct obj *) 0)
+    if (level.objects[x][y] != (struct obj *) 0) {
         debugpline2("bury_objs: at <%d,%d>", x, y);
+    }
     for (otmp = level.objects[x][y]; otmp; otmp = otmp2)
         otmp2 = bury_an_obj(otmp, (boolean *) 0);
 
index 8056cc19092210b6301ad34e138070f2ab165483..fe3e4e0715414c7215bf03905ddae9fdb2f14c48 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 eat.c   $NHDT-Date: 1446854226 2015/11/06 23:57:06 $  $NHDT-Branch: master $:$NHDT-Revision: 1.152 $ */
+/* NetHack 3.6 eat.c   $NHDT-Date: 1449269916 2015/12/04 22:58:36 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.154 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -728,56 +728,57 @@ register struct permonst *ptr;
 {
     int res = 0;
 
+#ifdef DEBUG
+#define ifdebugresist(Msg)      \
+    do {                        \
+        if (res)                \
+            debugpline0(Msg);   \
+    } while (0)
+#else
+#define ifdebugresist(Msg) /*empty*/
+#endif
     switch (type) {
     case FIRE_RES:
         res = (ptr->mconveys & MR_FIRE) != 0;
-        if (res)
-            debugpline0("can get fire resistance");
+        ifdebugresist("can get fire resistance");
         break;
     case SLEEP_RES:
         res = (ptr->mconveys & MR_SLEEP) != 0;
-        if (res)
-            debugpline0("can get sleep resistance");
+        ifdebugresist("can get sleep resistance");
         break;
     case COLD_RES:
         res = (ptr->mconveys & MR_COLD) != 0;
-        if (res)
-            debugpline0("can get cold resistance");
+        ifdebugresist("can get cold resistance");
         break;
     case DISINT_RES:
         res = (ptr->mconveys & MR_DISINT) != 0;
-        if (res)
-            debugpline0("can get disintegration resistance");
+        ifdebugresist("can get disintegration resistance");
         break;
     case SHOCK_RES: /* shock (electricity) resistance */
         res = (ptr->mconveys & MR_ELEC) != 0;
-        if (res)
-            debugpline0("can get shock resistance");
+        ifdebugresist("can get shock resistance");
         break;
     case POISON_RES:
         res = (ptr->mconveys & MR_POISON) != 0;
-        if (res)
-            debugpline0("can get poison resistance");
+        ifdebugresist("can get poison resistance");
         break;
     case TELEPORT:
         res = can_teleport(ptr);
-        if (res)
-            debugpline0("can get teleport");
+        ifdebugresist("can get teleport");
         break;
     case TELEPORT_CONTROL:
         res = control_teleport(ptr);
-        if (res)
-            debugpline0("can get teleport control");
+        ifdebugresist("can get teleport control");
         break;
     case TELEPAT:
         res = telepathic(ptr);
-        if (res)
-            debugpline0("can get telepathy");
+        ifdebugresist("can get telepathy");
         break;
     default:
         /* res stays 0 */
         break;
     }
+#undef ifdebugresist
     return res;
 }
 
index c2db6f5d11fd2ab18ca4dd9ebec76eacf8a276b1..102379e4aa08a5e2a101f40ee9b8feeaf6132f6b 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 makemon.c       $NHDT-Date: 1449052582 2015/12/02 10:36:22 $  $NHDT-Branch: master $:$NHDT-Revision: 1.104 $ */
+/* NetHack 3.6 makemon.c       $NHDT-Date: 1449269917 2015/12/04 22:58:37 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.105 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -857,9 +857,10 @@ boolean ghostly;
         mvitals[mndx].born++;
     if ((int) mvitals[mndx].born >= lim && !(mons[mndx].geno & G_NOGEN)
         && !(mvitals[mndx].mvflags & G_EXTINCT)) {
-        if (wizard)
+        if (wizard) {
             debugpline1("Automatically extinguished %s.",
                         makeplural(mons[mndx].mname));
+        }
         mvitals[mndx].mvflags |= G_EXTINCT;
         reset_rndmonst(mndx);
     }
@@ -1072,9 +1073,10 @@ int mmflags;
            already been genocided, return */
         if (mvitals[mndx].mvflags & G_GENOD)
             return (struct monst *) 0;
-        if (wizard && (mvitals[mndx].mvflags & G_EXTINCT))
+        if (wizard && (mvitals[mndx].mvflags & G_EXTINCT)) {
             debugpline1("Explicitly creating extinct monster %s.",
                         mons[mndx].mname);
+        }
     } else {
         /* make a random (common) monster that can survive here.
          * (the special levels ask for random monsters at specific
index d1f372b64210cb6de947f4082e1d1862ed810680..eddf6fbd1a7e39065b0f0b848da49c853f3641a6 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mkmaze.c        $NHDT-Date: 1448013594 2015/11/20 09:59:54 $  $NHDT-Branch: master $:$NHDT-Revision: 1.41 $ */
+/* NetHack 3.6 mkmaze.c        $NHDT-Date: 1449269918 2015/12/04 22:58:38 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.42 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -616,9 +616,10 @@ register const char *s;
             y_range = y_maze_max - y_maze_min - 2 * INVPOS_Y_MARGIN - 1;
 
         if (x_range <= INVPOS_X_MARGIN || y_range <= INVPOS_Y_MARGIN
-            || (x_range * y_range) <= (INVPOS_DISTANCE * INVPOS_DISTANCE))
-            debugpline2("inv_pos: maze is too small! (%d x %d)", x_maze_max,
-                        y_maze_max);
+            || (x_range * y_range) <= (INVPOS_DISTANCE * INVPOS_DISTANCE)) {
+            debugpline2("inv_pos: maze is too small! (%d x %d)",
+                        x_maze_max, y_maze_max);
+        }
         inv_pos.x = inv_pos.y = 0; /*{occupied() => invocation_pos()}*/
         do {
             x = rn1(x_range, x_maze_min + INVPOS_X_MARGIN + 1);
index 8116d787773ab7af3ea6d2fb05c983dcaf7bef03..ade59681062f5f5f0185280be3b22cac66048a33 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mon.c   $NHDT-Date: 1447475944 2015/11/14 04:39:04 $  $NHDT-Branch: master $:$NHDT-Revision: 1.196 $ */
+/* NetHack 3.6 mon.c   $NHDT-Date: 1449269918 2015/12/04 22:58:38 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.199 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1470,7 +1470,7 @@ struct monst *mtmp, *mtmp2;
     /* transfer the monster's inventory */
     for (otmp = mtmp2->minvent; otmp; otmp = otmp->nobj) {
         if (otmp->where != OBJ_MINVENT || otmp->ocarry != mtmp)
-            debugpline0("replmon: minvent inconsistency");
+            impossible("replmon: minvent inconsistency");
         otmp->ocarry = mtmp2;
     }
     mtmp->minvent = 0;
index eb0c65793a51bbd3b80b75f7be8bf19a00c56ff3..dc454128a0b718b0b638fce3163319babe4a2bda 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 sp_lev.c        $NHDT-Date: 1449051497 2015/12/02 10:18:17 $  $NHDT-Branch: master $:$NHDT-Revision: 1.76 $ */
+/* NetHack 3.6 sp_lev.c        $NHDT-Date: 1449269920 2015/12/04 22:58:40 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.77 $ */
 /*      Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1033,8 +1033,9 @@ chk:
         lev = &levl[x][y];
         for (; y <= ymax; y++) {
             if (lev++->typ) {
-                if (!vault)
+                if (!vault) {
                     debugpline2("strange area [%d,%d] in check_room.", x, y);
+                }
                 if (!rn2(3))
                     return FALSE;
                 if (x < *lowx)