Addressed compiler warnings.

Added the initialization of several locals.
In check_fields, validate that we have a valid index (idx) before using.
This commit is contained in:
Bart House
2018-11-20 10:48:44 -08:00
parent 520b130a5c
commit 2a6bd3e8ac
+6 -3
View File
@@ -3867,7 +3867,7 @@ boolean forcefields;
int *topsz, *bottomsz; int *topsz, *bottomsz;
{ {
int c, i, row, col, trackx, idx; 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()) if (!windowdata_init && !check_windowdata())
return FALSE; return FALSE;
@@ -3876,6 +3876,7 @@ int *topsz, *bottomsz;
col = 1; col = 1;
trackx = 1; trackx = 1;
update_right = FALSE; update_right = FALSE;
idx = -1;
for (i = 0; fieldorder[row][i] != BL_FLUSH; ++i) { for (i = 0; fieldorder[row][i] != BL_FLUSH; ++i) {
idx = fieldorder[row][i]; idx = fieldorder[row][i];
if (!status_activefields[idx]) if (!status_activefields[idx])
@@ -3941,11 +3942,13 @@ int *topsz, *bottomsz;
tty_status[NOW][idx].redraw = TRUE; tty_status[NOW][idx].redraw = TRUE;
col += tty_status[NOW][idx].lth; col += tty_status[NOW][idx].lth;
} }
if (idx != -1) {
if (row && bottomsz) if (row && bottomsz)
*bottomsz = col + tty_status[NOW][idx].lth; *bottomsz = col + tty_status[NOW][idx].lth;
else if (topsz) else if (topsz)
*topsz = col + tty_status[NOW][idx].lth; *topsz = col + tty_status[NOW][idx].lth;
} }
}
return valid; return valid;
} }
@@ -3960,7 +3963,7 @@ struct tty_status_fields *fld;
const char *val; const char *val;
int x, y; int x, y;
{ {
int i, n, ncols, lth; int i, n, ncols, lth = 0;
struct WinDesc *cw = 0; struct WinDesc *cw = 0;
const char *text = (char *)0; const char *text = (char *)0;
@@ -4273,7 +4276,7 @@ render_status(VOID_ARGS)
/* hitpointbar using hp percent calculation */ /* hitpointbar using hp percent calculation */
int bar_pos, bar_len; int bar_pos, bar_len;
char *bar2 = (char *)0; char *bar2 = (char *)0;
char bar[MAXCO], savedch; char bar[MAXCO], savedch = 0;
boolean twoparts = FALSE; boolean twoparts = FALSE;
bar_len = strlen(text); bar_len = strlen(text);