summaryrefslogtreecommitdiff
path: root/common/console.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-11 12:20:10 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-12 22:12:19 +0000
commit21f58b39ee05903a6d3255476e3a32ea124e4191 (patch)
treefd65c96d7ef2f15b336c209448bceb9c55b6d29d /common/console.c
parent0189fc914366562c204e8556a0ac46ef24cc320e (diff)
downloadchrome-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/console.c')
-rw-r--r--common/console.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/common/console.c b/common/console.c
index 1a2a41c9c1..cf25b40c30 100644
--- a/common/console.c
+++ b/common/console.c
@@ -93,7 +93,7 @@ static int split_words(char *input, int *argc, char **argv)
for (c = input; in_line; c++) {
if (!*c)
in_line = 0;
- if (isspace(*c) || !*c) {
+ if (isspace((unsigned char)*c) || !*c) {
if (in_word) {
/* Ending a word */
*c = '\0';
@@ -450,7 +450,7 @@ static int handle_esc(int c)
}
/* Check if the escape code is done */
- if (isalpha(c) || c == '~')
+ if (isalpha((unsigned char)c) || c == '~')
esc_state = ESC_OUTSIDE;
else
esc_state = ESC_BAD;
@@ -610,7 +610,7 @@ static void console_handle_char(int c)
default:
/* Ignore non-printing characters */
- if (!isprint(c))
+ if (!isprint((unsigned char)c))
break;
#ifndef CONFIG_EXPERIMENTAL_CONSOLE