diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-10-22 11:42:10 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-10-22 11:42:10 -0700 |
commit | 0bb93230c5263ebfc4cc25125f1c76f1d6a7382a (patch) | |
tree | 6e6f08d2090fb8e9c2c1e1bd4c7ab888a69e875b | |
parent | 00becc220c242cf7f37cc139db1e7f7b9c475d15 (diff) |
cfgscan: check if character is EOF before calling isalpha or isdigit
Resolves cppcheck warnings:
cfgscan.c:475:22: warning: Either the condition 'ch==-1' is redundant or
isalpha() argument nr 1 can have invalid value. The value is -1 but the
valid values are '0:255'. [invalidFunctionArg]
else if (isalpha(ch) || (ch == '_'))
^
cfgscan.c:479:17: note: Assuming that condition 'ch==-1' is not redundant
else if (ch == EOF)
^
cfgscan.c:475:22: note: Invalid argument
else if (isalpha(ch) || (ch == '_'))
^
cfgscan.c:477:22: warning: Either the condition 'ch==-1' is redundant or
isdigit() argument nr 1 can have invalid value. The value is -1 but the
valid values are '0:255'. [invalidFunctionArg]
else if (isdigit(ch))
^
cfgscan.c:479:17: note: Assuming that condition 'ch==-1' is not redundant
else if (ch == EOF)
^
cfgscan.c:477:22: note: Invalid argument
else if (isdigit(ch))
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | cfgscan.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -472,12 +472,12 @@ yylex(void) rtrn = yyGetString(); else if (ch == '<') rtrn = yyGetKeyName(); + else if (ch == EOF) + rtrn = END_OF_FILE; else if (isalpha(ch) || (ch == '_')) rtrn = yyGetIdent(ch); else if (isdigit(ch)) rtrn = yyGetNumber(ch); - else if (ch == EOF) - rtrn = END_OF_FILE; else { fprintf(stderr, "Unexpected character %c (%d) in input stream\n", ch, ch); |