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:
+1
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user