From 2a6bd3e8ac9c1e84e181d330f72e7f9abaae8f76 Mon Sep 17 00:00:00 2001 From: Bart House Date: Tue, 20 Nov 2018 10:48:44 -0800 Subject: [PATCH] Addressed compiler warnings. Added the initialization of several locals. In check_fields, validate that we have a valid index (idx) before using. --- win/tty/wintty.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 8ebac1267..d5cac96c3 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -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); -- 2.49.0