diff options
author | Simon Glass <sjg@chromium.org> | 2021-02-11 12:20:10 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-12 22:12:19 +0000 |
commit | 21f58b39ee05903a6d3255476e3a32ea124e4191 (patch) | |
tree | fd65c96d7ef2f15b336c209448bceb9c55b6d29d /common/charger.c | |
parent | 0189fc914366562c204e8556a0ac46ef24cc320e (diff) | |
download | chrome-ec-21f58b39ee05903a6d3255476e3a32ea124e4191.tar.gz |
Avoid passing char values to ctype functions
With Zephyr's newlib we get a warning when trying to do this, since it
includes the following note in:
/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/include/ctype.h
"These macros are intentionally written in a manner that will trigger
a gcc -Wall warning if the user mistakenly passes a 'char' instead
of an int containing an 'unsigned char'."
Presumably this is so characters above ASCII 127 are handled correctly,
even if these are seldom used.
Update the few affected call sites to ensure the value is cast to an
unsigned char so that it will not fall afoul of the newlib warning.
Note that the ECOS version of the ctype functions does not make use of
an array, so does not suffer from failure if negative values are
passed. Still, it is harmless to fix it.
BUG=b:180023514
BRANCH=none
TEST=build zephyr volteer with CONFIG_NEWLIB_LIBC and see no warnings
Signed-off-by: Simon Glass <sjg@chromium.org>
Change-Id: Ieae2fab8c20b75baa46d01dd8cdb393c6bb5c2c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2691413
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'common/charger.c')
-rw-r--r-- | common/charger.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/charger.c b/common/charger.c index 4b75d2e5ef..f9fd1c4640 100644 --- a/common/charger.c +++ b/common/charger.c @@ -196,7 +196,7 @@ static int command_charger(int argc, char **argv) return EC_SUCCESS; } - idx_provided = isdigit(argv[1][0]); + idx_provided = isdigit((unsigned char)argv[1][0]); if (idx_provided) chgnum = atoi(argv[1]); else @@ -673,4 +673,4 @@ enum ec_error_list charger_enable_linear_charge(int chgnum, bool enable) enable); return EC_ERROR_UNIMPLEMENTED; -}
\ No newline at end of file +} |