]> granicus.if.org Git - nethack/commitdiff
clear five warnings for "set but not used" variables
authornhmall <nhmall@nethack.org>
Mon, 25 Jan 2021 17:57:47 +0000 (12:57 -0500)
committernhmall <nhmall@nethack.org>
Mon, 25 Jan 2021 17:57:47 +0000 (12:57 -0500)
Note: the line numbers referenced in the warning messages below are not in sync
with the NetHack-3.7 branch and should be disregarded

files.c: In function 'get_saved_games':
files.c:1168:9: warning: unused variable 'n' [-Wunused-variable]
 1168 |     int n, j = 0;
      |         ^

mhitm.c: In function 'mdamagem':
mhitm.c:843:13: warning: variable 'cancelled' set but not used [-Wunused-but-set-variable]
  843 |     boolean cancelled;
      |             ^~~~~~~~~

mhitu.c: In function 'hitmu':
mhitu.c:943:9: warning: variable 'uncancelled' set but not used [-Wunused-but-set-variable]
  943 |     int uncancelled;
      |         ^~~~~~~~~~~

mklev.c: In function 'place_branch':
mklev.c:1214:20: warning: variable 'br_room' set but not used [-Wunused-but-set-variable]
 1214 |     struct mkroom *br_room;
      |                    ^~~~~~~

monmove.c: In function 'm_move':
monmove.c:874:43: warning: variable 'doorbuster' set but not used [-Wunused-but-set-variable]
  874 |     boolean can_open = 0, can_unlock = 0, doorbuster = 0;
      |                                           ^~~~~~~~~~

src/files.c
src/mhitm.c
src/mhitu.c
src/mklev.c
src/monmove.c

index 5f85fc3d8d27a671100861caa48d023e6c6e8716..78c9f894f94b4b6bd098acc78963819121221e62 100644 (file)
@@ -1204,7 +1204,10 @@ char **
 get_saved_games()
 {
 #if defined(SELECTSAVED)
-    int n, j = 0;
+#if defined(WIN32) || defined(UNIX)
+    int n;
+#endif
+    int j = 0;
     char **result = 0;
 #ifdef WIN32
     {
index 797b3ee3295c6a151cd8a00390307632813d784e..27b8f4b2a935fa9bf3df91705d0fe5566542f1c2 100644 (file)
@@ -858,7 +858,8 @@ int dieroll;
 {
     struct permonst *pa = magr->data, *pd = mdef->data;
     int armpro;
-    boolean cancelled;
+    /* this was moved downstream during a 2020 refactor */
+    /* boolean cancelled; */
     struct mhitm_data mhm;
     mhm.damage = d((int) mattk->damn, (int) mattk->damd);
     mhm.hitflags = MM_MISS;
@@ -896,7 +897,7 @@ int dieroll;
 
     /* cancellation factor is the same as when attacking the hero */
     armpro = magic_negation(mdef);
-    cancelled = magr->mcan || !(rn2(10) >= 3 * armpro);
+    /* cancelled = magr->mcan || !(rn2(10) >= 3 * armpro); */
 
     mhitm_adtyping(magr, mattk, mdef, &mhm);
     if (mhm.done)
index f4260cbc128569a0c1afaab94e0ec843d361e852..e2fdd17f9d34aabb29a0eb5723468733db129832 100644 (file)
@@ -964,7 +964,7 @@ register struct monst *mtmp;
 register struct attack *mattk;
 {
     struct permonst *mdat = mtmp->data;
-    int uncancelled;
+    /* int uncancelled; */
     int armpro;
     struct permonst *olduasmon = g.youmonst.data;
     int res;
@@ -1010,7 +1010,8 @@ register struct attack *mattk;
      *  armor's special magic protection.  Otherwise just use !mtmp->mcan.
      */
     armpro = magic_negation(&g.youmonst);
-    uncancelled = !mtmp->mcan && (rn2(10) >= 3 * armpro);
+    /* this was moved downstream during a 2020 refactor */
+    /* uncancelled = !mtmp->mcan && (rn2(10) >= 3 * armpro); */
 
     mhitm_adtyping(mtmp, mattk, &g.youmonst, &mhm);
     if (mhm.done)
index 51616aaf4b960758a11c90000b9994689ae47819..5806a340b8e67076a73e078727228dbf14701ea8 100644 (file)
@@ -1247,10 +1247,10 @@ place_branch(br, x, y)
 branch *br; /* branch to place */
 xchar x, y; /* location */
 {
-    coord m;
+    coord m = {0};
     d_level *dest;
     boolean make_stairs;
-    struct mkroom *br_room;
+    /* struct mkroom *br_room; */
 
     /*
      * Return immediately if there is no branch to make or we have
@@ -1262,11 +1262,12 @@ xchar x, y; /* location */
         return;
 
     if (!x) { /* find random coordinates for branch */
-        br_room = find_branch_room(&m);
+        /* br_room = find_branch_room(&m); */
+        (void) find_branch_room(&m);  /* sets m via mazexy() or somexy() */
         x = m.x;
         y = m.y;
     } else {
-        br_room = pos_to_room(x, y);
+        /* br_room = pos_to_room(x, y); */
     }
 
     if (on_level(&br->end1, &u.uz)) {
index 85e970dda7cd2ad77203263968401f5736cadf11..48ba3ccc7260a643997b0925d1d9d2bf32be0376 100644 (file)
@@ -895,7 +895,7 @@ register int after;
     boolean likegold = 0, likegems = 0, likeobjs = 0, likemagic = 0,
             conceals = 0;
     boolean likerock = 0, can_tunnel = 0;
-    boolean can_open = 0, can_unlock = 0, doorbuster = 0;
+    boolean can_open = 0, can_unlock = 0 /*, doorbuster = 0 */;
     boolean uses_items = 0, setlikes = 0;
     boolean avoid = FALSE;
     boolean better_with_displacing = FALSE;
@@ -937,7 +937,7 @@ register int after;
     can_open = !(nohands(ptr) || verysmall(ptr));
     can_unlock = ((can_open && monhaskey(mtmp, TRUE))
                   || mtmp->iswiz || is_rider(ptr));
-    doorbuster = is_giant(ptr);
+    /* doorbuster = is_giant(ptr); */
     if (mtmp->wormno)
         goto not_special;
     /* my dog gets special treatment */