net: lwm2m: Fix warning when building with newlib

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 <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2018-07-11 15:31:59 -05:00 committed by Kumar Gala
commit 21d6e302f6

View file

@ -845,7 +845,7 @@ static int atof32(const char *input, float32_value_t *out)
return 0; return 0;
} }
while (*(++pos) && base > 1 && isdigit(*pos)) { while (*(++pos) && base > 1 && isdigit((unsigned char)*pos)) {
out->val2 = out->val2 * 10 + (*pos - '0'); out->val2 = out->val2 * 10 + (*pos - '0');
base /= 10; 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++) { for (i = 0; i <= end_index; i++) {
/* search for first numeric */ /* search for first numeric */
if (tokstart == -1) { if (tokstart == -1) {
if (!isdigit(pathstr[i])) { if (!isdigit((unsigned char)pathstr[i])) {
continue; continue;
} }