From 1af2cd56248b449f4bca7e5763c27043c4a78873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Thu, 23 May 2019 19:00:19 +0200 Subject: fix isdigit taking unsigned as input fixes the following error warnings when cross-compiling using: ./configure --enable-static --prefix=/usr/local/arm-none-eabi --host=arm-none-eabi --enable-embedded --disable-doxygen --disable-shared --disable-pseudotalloc --enable-external-tests CFLAGS="-Os -ffunction-sections -fdata-sections -nostartfiles -nodefaultlibs -Werror -Wno-error=deprecated -Wno-error=deprecated-declarations -Wno-error=cpp -mthumb -Os -mlong-calls -g3 -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -Wno-error=format" utils.c:1002:18: error: array subscript has type 'char' [-Werror=char-subscripts] 1002 | if (!isdigit(in[i])) gsm23003.c:414:34: error: array subscript has type 'char' [-Werror=char-subscripts] 414 | if (!mnc_str || !isdigit(mnc_str[0]) || strlen(mnc_str) > 3) Change-Id: Ia13fd5ee79fc6dc3291c0b99958ab3c01afee17d --- src/gsm/gsm23003.c | 2 +- src/utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c index 4cc2671f..e20afcbc 100644 --- a/src/gsm/gsm23003.c +++ b/src/gsm/gsm23003.c @@ -411,7 +411,7 @@ int osmo_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits) char *endptr; int rc = 0; - if (!mnc_str || !isdigit(mnc_str[0]) || strlen(mnc_str) > 3) + if (!mnc_str || !isdigit((unsigned char)mnc_str[0]) || strlen(mnc_str) > 3) return -EINVAL; errno = 0; diff --git a/src/utils.c b/src/utils.c index 7b7178ca..7364bfb1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -999,7 +999,7 @@ char osmo_luhn(const char* in, int in_len) /* All input must be numbers */ for (i = 0; i < in_len; i++) { - if (!isdigit(in[i])) + if (!isdigit((unsigned char)in[i])) return -EINVAL; } -- cgit v1.2.3