From aecd4b2038e38e825b2cafd74a7ca0bef7028cec Mon Sep 17 00:00:00 2001 From: Jerzy Kasenberg Date: Wed, 16 Jun 2021 11:10:22 +0200 Subject: [PATCH] ctype: Fix undefined behavior in ctype.h usage When parse.c is build against newlib nano following error shows up: iparse.c:304:20: error: array subscript has type 'char' [-Werror=char-subscripts] This can be easily fixed with casting to unsigned type first. --- apps/btshell/src/parse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/btshell/src/parse.c b/apps/btshell/src/parse.c index a2e2ae521..e4dbade42 100644 --- a/apps/btshell/src/parse.c +++ b/apps/btshell/src/parse.c @@ -301,7 +301,7 @@ parse_time_us(const char *str, int *out_status) uint32_t val_mult = 1; uint32_t val_us; - while (isdigit(*str)) { + while (isdigit((unsigned char)*str)) { val *= 10; val += *str - '0'; str++; @@ -309,7 +309,7 @@ parse_time_us(const char *str, int *out_status) if (*str == '.') { str++; - while (isdigit(*str)) { + while (isdigit((unsigned char)*str)) { val *= 10; val += *str - '0'; val_div *= 10;