fix recently appearing warnings in clang-22 and visual studio

clang-22:

invent.c:2621:16: warning: variable 'option' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
 2621 |     } else if (!hit_reroll_limit(u.uroleplay.numrerolls)) {
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
invent.c:2629:9: note: uninitialized use occurs here
 2629 |     if (option == 'y') {
      |         ^~~~~~
invent.c:2621:12: note: remove the 'if' if its condition is always true
 2621 |     } else if (!hit_reroll_limit(u.uroleplay.numrerolls)) {
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
invent.c:2570:16: note: initialize the variable 'option' to silence this warning
 2570 |     char option;
      |                ^
      |                 = '\0'
1 warning generated.

visual studio:

src/invent.c(2629,1): warning C4701: potentially uninitialized local variable 'option' used
This commit is contained in:
nhmall
2026-05-21 10:36:22 -04:00
parent 51f486589c
commit 65646e2a8c
+1 -1
View File
@@ -2567,7 +2567,7 @@ reroll_menu(void)
struct obj *otmp;
int tmpglyph;
glyph_info tmpglyphinfo;
char option;
char option = 'n';
char buf[BUFSZ];
win = create_nhwindow(NHW_MENU);