From 21d6e302f670ccff702d6d785b95637555ea9e4d Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Wed, 11 Jul 2018 15:31:59 -0500 Subject: [PATCH] net: lwm2m: Fix warning when building with newlib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we use newlib the isdigit (and other similar functions) return an error as char can possibly be viewed as signed: usr/include/ctype.h:57:54: error: array subscript has type ‘char’ [-Werror=char-subscripts] #define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)]) Explicity cast to unsigned char so we deal with both this warning and possible warning when -Wpointer-sign is enabled. Signed-off-by: Kumar Gala --- subsys/net/lib/lwm2m/lwm2m_engine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index bfdf9544f9c..01de7a28885 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -845,7 +845,7 @@ static int atof32(const char *input, float32_value_t *out) return 0; } - while (*(++pos) && base > 1 && isdigit(*pos)) { + while (*(++pos) && base > 1 && isdigit((unsigned char)*pos)) { out->val2 = out->val2 * 10 + (*pos - '0'); base /= 10; } @@ -1209,7 +1209,7 @@ static int string_to_path(char *pathstr, struct lwm2m_obj_path *path, for (i = 0; i <= end_index; i++) { /* search for first numeric */ if (tokstart == -1) { - if (!isdigit(pathstr[i])) { + if (!isdigit((unsigned char)pathstr[i])) { continue; }