mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
gcc-fanalyzer: helping understand answer is not null
gcc can't easily see pointer 'answer' is only being checked once 'ret > 0'.
This commit is contained in:
parent
462ac47003
commit
178df1c8f4
@ -974,7 +974,7 @@ char yes_no_prompt(const char *prompt, ...)
|
||||
|
||||
c = tolower(c);
|
||||
|
||||
if ((ret > 0) && (c == answer[0]))
|
||||
if ((ret > 0) && answer && (c == answer[0]))
|
||||
answer++; /* Matching, next char */
|
||||
else if (c == '\n') {
|
||||
if (feof(stdin))
|
||||
@ -1000,7 +1000,7 @@ char yes_no_prompt(const char *prompt, ...)
|
||||
/* Ignore any whitespace before */
|
||||
--i;
|
||||
goto nextchar;
|
||||
} else if ((ret > 0) && isspace(c)) {
|
||||
} else if ((ret > 0) && answer && isspace(c)) {
|
||||
/* Ignore any whitespace after */
|
||||
while (*answer)
|
||||
answer++; /* jump to end-of-word */
|
||||
|
Loading…
Reference in New Issue
Block a user