mirror of
git://sourceware.org/git/lvm2.git
synced 2025-09-15 13:44:18 +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:
@@ -974,7 +974,7 @@ char yes_no_prompt(const char *prompt, ...)
|
|||||||
|
|
||||||
c = tolower(c);
|
c = tolower(c);
|
||||||
|
|
||||||
if ((ret > 0) && (c == answer[0]))
|
if ((ret > 0) && answer && (c == answer[0]))
|
||||||
answer++; /* Matching, next char */
|
answer++; /* Matching, next char */
|
||||||
else if (c == '\n') {
|
else if (c == '\n') {
|
||||||
if (feof(stdin))
|
if (feof(stdin))
|
||||||
@@ -1000,7 +1000,7 @@ char yes_no_prompt(const char *prompt, ...)
|
|||||||
/* Ignore any whitespace before */
|
/* Ignore any whitespace before */
|
||||||
--i;
|
--i;
|
||||||
goto nextchar;
|
goto nextchar;
|
||||||
} else if ((ret > 0) && isspace(c)) {
|
} else if ((ret > 0) && answer && isspace(c)) {
|
||||||
/* Ignore any whitespace after */
|
/* Ignore any whitespace after */
|
||||||
while (*answer)
|
while (*answer)
|
||||||
answer++; /* jump to end-of-word */
|
answer++; /* jump to end-of-word */
|
||||||
|
Reference in New Issue
Block a user