]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Handle "array subscript has type 'char'" warnings
authorWillem Toorop <willem@nlnetlabs.nl>
Wed, 30 Nov 2016 14:37:35 +0000 (15:37 +0100)
committerWillem Toorop <willem@nlnetlabs.nl>
Wed, 30 Nov 2016 14:37:35 +0000 (15:37 +0100)
dname.c
examples/ldns-dpa.c
examples/nsd-test/ldns-testns.c
host2str.c
rr.c
str2host.c
util.c

diff --git a/dname.c b/dname.c
index 1c41b7c72807b8482396618e7999db97930cac70..17afe1d333d0c20b0f795e2955a59a5cd6ce766e 100644 (file)
--- a/dname.c
+++ b/dname.c
@@ -530,10 +530,11 @@ ldns_dname_str_absolute(const char *dname_str)
         for(s=dname_str; *s; s++) {
                 if(*s == '\\') {
                         if(s[1] && s[2] && s[3] /* check length */
-                                && isdigit(s[1]) && isdigit(s[2]) && 
-                                isdigit(s[3]))
+                                && isdigit((unsigned char)s[1])
+                               && isdigit((unsigned char)s[2])
+                               && isdigit((unsigned char)s[3]))
                                 s += 3;
-                        else if(!s[1] || isdigit(s[1])) /* escape of nul,0-9 */
+                        else if(!s[1] || isdigit((unsigned char)s[1])) /* escape of nul,0-9 */
                                 return 0; /* parse error */
                         else s++; /* another character escaped */
                 }
index 0bc8a84032969e0fa91bff3de758f3ea7bc14087..f60e77037c984339ccf4f78689e6e9d6b061f100 100644 (file)
@@ -920,7 +920,7 @@ match_opcode(type_operator operator,
                a = lt->id;
        } else {
                i = atoi(value);
-               if (i >= 0 && !isdigit(value[0]) == 0) {
+               if (i >= 0 && !isdigit((unsigned char)value[0]) == 0) {
                        lt = ldns_lookup_by_id(ldns_opcodes, i);
                        if (lt) {
                                a = lt->id;
@@ -941,7 +941,7 @@ match_opcode(type_operator operator,
                b = lt->id;
        } else {
                i = atoi(mvalue);
-               if (i >= 0 && !isdigit(mvalue[0]) == 0) {
+               if (i >= 0 && !isdigit((unsigned char)mvalue[0]) == 0) {
                        lt = ldns_lookup_by_id(ldns_opcodes, i);
                        if (lt) {
                                b = lt->id;
@@ -1053,7 +1053,7 @@ match_rcode(type_operator operator,
                a = lt->id;
        } else {
                i = atoi(value);
-               if (i >= 0 && !isdigit(value[0]) == 0) {
+               if (i >= 0 && !isdigit((unsigned char)value[0]) == 0) {
                        lt = ldns_lookup_by_id(ldns_rcodes, i);
                        if (lt) {
                                a = lt->id;
@@ -1075,7 +1075,7 @@ match_rcode(type_operator operator,
        } else {
                i = atoi(mvalue);
 
-               if (i >= 0 && !isdigit(mvalue[0]) == 0) {
+               if (i >= 0 && !isdigit((unsigned char)mvalue[0]) == 0) {
                        lt = ldns_lookup_by_id(ldns_rcodes, i);
                        if (lt) {
                                b = lt->id;
@@ -1663,7 +1663,7 @@ parse_match_expression(char *string)
 
        j = 0;
        for (i = 0; i < strlen(string); i++) {
-               if(!isspace(string[i])) {
+               if(!isspace((unsigned char)string[i])) {
                        str[j] = string[i];
                        j++;
                }
@@ -2505,7 +2505,7 @@ parse_uniques(match_id ids[], size_t *count, char *string)
        str = malloc(strlen(string) + 1);
        j = 0;
        for (i = 0; i < strlen(string); i++) {
-               if (!isspace(string[i])) {
+               if (!isspace((unsigned char)string[i])) {
                        str[j] = string[i];
                        j++;
                }
index 6a7c17305a9d14322a179ad11e78aed9d632b74f..7c71cb4cf88a21315789ac3781b8699d241bc1c9 100644 (file)
@@ -177,7 +177,7 @@ static bool str_keyword(const char** str, const char* keyword)
        if(strncmp(*str, keyword, len) != 0)
                return false;
        *str += len;
-       while(isspace(**str))
+       while(isspace((unsigned char)**str))
                (*str)++;
        return true;
 }
@@ -220,7 +220,7 @@ static void matchline(const char* line, struct entry* e)
                                error("expected = or : in MATCH: %s", line);
                        parse++;
                        e->ixfr_soa_serial = (uint32_t)strtol(parse, (char**)&parse, 10);
-                       while(isspace(*parse)) 
+                       while(isspace((unsigned char)*parse)) 
                                parse++;
                } else {
                        error("could not parse MATCH: '%s'", parse);
@@ -298,11 +298,11 @@ static void adjustline(const char* line, struct entry* e,
                        e->copy_id = true;
                } else if(str_keyword(&parse, "sleep=")) {
                        e->sleeptime = strtol(parse, (char**)&parse, 10);
-                       while(isspace(*parse)) 
+                       while(isspace((unsigned char)*parse)) 
                                parse++;
                } else if(str_keyword(&parse, "packet_sleep=")) {
                        pkt->packet_sleep = strtol(parse, (char**)&parse, 10);
-                       while(isspace(*parse)) 
+                       while(isspace((unsigned char)*parse)) 
                                parse++;
                } else {
                        error("could not parse ADJUST: '%s'", parse);
@@ -338,7 +338,7 @@ static void get_origin(const char* name, int lineno, ldns_rdf** origin, char* pa
        *origin = NULL;
 
        end=parse;
-       while(!isspace(*end) && !isendline(*end))
+       while(!isspace((unsigned char)*end) && !isendline(*end))
                end++;
        store = *end;
        *end = 0;
@@ -376,7 +376,7 @@ static struct entry* read_datafile(const char* name)
                parse = line;
                lineno ++;
                
-               while(isspace(*parse))
+               while(isspace((unsigned char)*parse))
                        parse++;
                /* test for keywords */
                if(isendline(*parse))
index 280961b88a29c9bef3565c15dbd475ec7833c123..747d54310cf9849707b33457aac2a87eb8cb46bb 100644 (file)
@@ -1218,7 +1218,7 @@ ldns_rdf2buffer_str_tag(ldns_buffer *output, const ldns_rdf *rdf)
        chars = ldns_rdf_data(rdf) + 1;
        while (nchars > 0) {
                ch = (char)*chars++;
-               if (! isalnum(ch)) {
+               if (! isalnum((unsigned char)ch)) {
                        return LDNS_STATUS_WIRE_RDATA_ERR;
                }
                ldns_buffer_printf(output, "%c", ch);
diff --git a/rr.c b/rr.c
index c8d75ad9c5a0d704dd2c7d248a12f75880e5f576..c971610e96bf3e8899e28221d48400eade267647 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -686,10 +686,10 @@ ldns_strip_ws(char *line)
 {
        char *s = line, *e;
 
-       for (s = line; *s && isspace(*s); s++)
+       for (s = line; *s && isspace((unsigned char)*s); s++)
                ;
 
-       for (e = strchr(s, 0); e > s+2 && isspace(e[-1]) && e[-2] != '\\'; e--)
+       for (e = strchr(s, 0); e > s+2 && isspace((unsigned char)e[-1]) && e[-2] != '\\'; e--)
                ;
        *e = 0;
 
@@ -742,7 +742,7 @@ ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf
                return LDNS_STATUS_SYNTAX_EMPTY;
        }
 
-       if (strncmp(line, "$ORIGIN", 7) == 0 && isspace(line[7])) {
+       if (strncmp(line, "$ORIGIN", 7) == 0 && isspace((unsigned char)line[7])) {
                if (*origin) {
                        ldns_rdf_deep_free(*origin);
                        *origin = NULL;
@@ -756,7 +756,7 @@ ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf
                }
                *origin = tmp;
                s = LDNS_STATUS_SYNTAX_ORIGIN;
-       } else if (strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) {
+       } else if (strncmp(line, "$TTL", 4) == 0 && isspace((unsigned char)line[4])) {
                if (default_ttl) {
                        *default_ttl = ldns_str2period(
                                        ldns_strip_ws(line + 5), &endptr);
index cd07c8935fca1b33c197330271da3f2ba2be876d..4f381dc55cc7ccc4d85b89e1905b02684f082997 100644 (file)
@@ -262,9 +262,9 @@ parse_escape(uint8_t *ch_p, const char** str_p)
 {
        uint16_t val;
 
-       if ((*str_p)[0] && isdigit((*str_p)[0])  &&
-           (*str_p)[1] && isdigit((*str_p)[1])  &&
-           (*str_p)[2] && isdigit((*str_p)[2]))  {
+       if ((*str_p)[0] && isdigit((unsigned char)(*str_p)[0])  &&
+           (*str_p)[1] && isdigit((unsigned char)(*str_p)[1])  &&
+           (*str_p)[2] && isdigit((unsigned char)(*str_p)[2]))  {
 
                val = (uint16_t)(((*str_p)[0] - '0') * 100 +
                                 ((*str_p)[1] - '0') *  10 +
@@ -277,7 +277,7 @@ parse_escape(uint8_t *ch_p, const char** str_p)
                *str_p += 3;
                return true;
 
-       } else if ((*str_p)[0] && !isdigit((*str_p)[0])) {
+       } else if ((*str_p)[0] && !isdigit((unsigned char)(*str_p)[0])) {
 
                *ch_p = (uint8_t)*(*str_p)++;
                return true;
@@ -866,7 +866,7 @@ loc_parse_cm(char* my_str, char** endstr, uint8_t* m, uint8_t* e)
        /* read <digits>[.<digits>][mM] */
        /* into mantissa exponent format for LOC type */
        uint32_t meters = 0, cm = 0, val;
-       while (isblank(*my_str)) {
+       while (isblank((unsigned char)*my_str)) {
                my_str++;
        }
        meters = (uint32_t)strtol(my_str, &my_str, 10);
@@ -971,7 +971,7 @@ north:
        } else {
                latitude = equator - latitude;
        }
-       while (isblank(*my_str)) {
+       while (isblank((unsigned char)*my_str)) {
                my_str++;
        }
 
@@ -993,7 +993,7 @@ north:
                return LDNS_STATUS_INVALID_STR;
        }
 
-       while (isblank(*my_str)) {
+       while (isblank((unsigned char)*my_str)) {
                my_str++;
        }
 
@@ -1002,7 +1002,7 @@ north:
        }
 
 east:
-       while (isblank(*my_str)) {
+       while (isblank((unsigned char)*my_str)) {
                my_str++;
        }
 
@@ -1451,7 +1451,7 @@ ldns_str2rdf_tag(ldns_rdf **rd, const char *str)
                return LDNS_STATUS_INVALID_TAG;
        }
        for (ptr = str; *ptr; ptr++) {
-               if (! isalnum(*ptr)) {
+               if (! isalnum((unsigned char)*ptr)) {
                        return LDNS_STATUS_INVALID_TAG;
                }
        }
diff --git a/util.c b/util.c
index 33060d9637b5bea73eb372e0cae3e0f570c76e33..3dcd8495ebb96fe50d40059eadfbabb8e70eca16 100644 (file)
--- a/util.c
+++ b/util.c
@@ -626,7 +626,7 @@ ldns_b32_pton_base(const char* src, size_t src_sz,
                                ch = *src++;
                                --src_sz;
 
-                       } while (isspace(ch) && src_sz > 0);
+                       } while (isspace((unsigned char)ch) && src_sz > 0);
 
                        if (ch == '=' || ch == '\0')
                                break;
@@ -731,7 +731,7 @@ ldns_b32_pton_base(const char* src, size_t src_sz,
                                        ch = *src++;
                                        src_sz--;
 
-                               } while (isspace(ch));
+                               } while (isspace((unsigned char)ch));
 
                                if (ch != '=')
                                        return -1;