]> granicus.if.org Git - nethack/commitdiff
Addressed compiler warnings.
authorBart House <bart@barthouse.com>
Tue, 20 Nov 2018 18:48:44 +0000 (10:48 -0800)
committerBart House <bart@barthouse.com>
Tue, 20 Nov 2018 18:48:44 +0000 (10:48 -0800)
Added the initialization of several locals.
In check_fields, validate that we have a valid index (idx) before using.

win/tty/wintty.c

index 8ebac1267870f30c3b9fab9f873395213b6ea23e..d5cac96c387b4a5a5aa651f52e88b9f4440bba3d 100644 (file)
@@ -3867,7 +3867,7 @@ boolean forcefields;
 int *topsz, *bottomsz;
 {
     int c, i, row, col, trackx, idx;
-    boolean valid = TRUE, matchprev = FALSE, update_right, disregard;
+    boolean valid = TRUE, matchprev = FALSE, update_right, disregard = FALSE;
 
     if (!windowdata_init && !check_windowdata())
         return FALSE;
@@ -3876,6 +3876,7 @@ int *topsz, *bottomsz;
         col = 1;
         trackx = 1;
         update_right = FALSE;
+        idx = -1;
         for (i = 0; fieldorder[row][i] != BL_FLUSH; ++i) {
             idx = fieldorder[row][i];
             if (!status_activefields[idx])
@@ -3941,10 +3942,12 @@ int *topsz, *bottomsz;
                 tty_status[NOW][idx].redraw = TRUE;
             col += tty_status[NOW][idx].lth;
         }
-        if (row && bottomsz)
-            *bottomsz = col + tty_status[NOW][idx].lth;
-        else if (topsz)
-            *topsz = col + tty_status[NOW][idx].lth;
+        if (idx != -1) {
+            if (row && bottomsz)
+                *bottomsz = col + tty_status[NOW][idx].lth;
+            else if (topsz)
+                *topsz = col + tty_status[NOW][idx].lth;
+        }
     }
     return valid;
 }
@@ -3960,7 +3963,7 @@ struct tty_status_fields *fld;
 const char *val;
 int x, y;
 {
-    int i, n, ncols, lth;
+    int i, n, ncols, lth = 0;
     struct WinDesc *cw = 0;
     const char *text = (char *)0;
 
@@ -4273,7 +4276,7 @@ render_status(VOID_ARGS)
                     /* hitpointbar using hp percent calculation */
                     int bar_pos, bar_len;
                     char *bar2 = (char *)0;
-                    char bar[MAXCO], savedch;
+                    char bar[MAXCO], savedch = 0;
                     boolean twoparts = FALSE;
 
                     bar_len = strlen(text);