summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Toorop <willem@nlnetlabs.nl>2016-11-30 15:37:35 +0100
committerWillem Toorop <willem@nlnetlabs.nl>2016-11-30 15:37:35 +0100
commit1704cb96a22f754504e5cac8b404ee139d8c544b (patch)
treef509ff4ca38e13bfc17e2de2ca4f65ff3ad47202
parent7762ec6dbed0ba2f030e802450c1825c2bda29cd (diff)
downloadldns-1704cb96a22f754504e5cac8b404ee139d8c544b.tar.gz
Handle "array subscript has type 'char'" warnings
-rw-r--r--dname.c7
-rw-r--r--examples/ldns-dpa.c12
-rw-r--r--examples/nsd-test/ldns-testns.c12
-rw-r--r--host2str.c2
-rw-r--r--rr.c8
-rw-r--r--str2host.c18
-rw-r--r--util.c4
7 files changed, 32 insertions, 31 deletions
diff --git a/dname.c b/dname.c
index 1c41b7c7..17afe1d3 100644
--- 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 */
}
diff --git a/examples/ldns-dpa.c b/examples/ldns-dpa.c
index 0bc8a840..f60e7703 100644
--- a/examples/ldns-dpa.c
+++ b/examples/ldns-dpa.c
@@ -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++;
}
diff --git a/examples/nsd-test/ldns-testns.c b/examples/nsd-test/ldns-testns.c
index 6a7c1730..7c71cb4c 100644
--- a/examples/nsd-test/ldns-testns.c
+++ b/examples/nsd-test/ldns-testns.c
@@ -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))
diff --git a/host2str.c b/host2str.c
index 280961b8..747d5431 100644
--- a/host2str.c
+++ b/host2str.c
@@ -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 c8d75ad9..c971610e 100644
--- 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);
diff --git a/str2host.c b/str2host.c
index cd07c893..4f381dc5 100644
--- a/str2host.c
+++ b/str2host.c
@@ -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 33060d96..3dcd8495 100644
--- 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;