From f1bcc1032f16001f1afa8866607a019774d40d14 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 13 Oct 2014 09:23:12 +0000 Subject: [PATCH] More casts. git-svn-id: file:///svn/unbound/trunk@3244 be551aaa-1e26-0410-a405-d3ace91eadb9 --- compat/strptime.c | 6 +++--- daemon/remote.c | 2 +- ldns/parseutil.c | 4 ++-- ldns/str2wire.c | 16 ++++++++-------- services/modstack.c | 8 ++++---- testcode/replay.c | 28 ++++++++++++++-------------- testcode/testbound.c | 10 +++++----- testcode/testpkts.c | 12 ++++++------ util/config_file.c | 2 +- validator/autotrust.c | 4 ++-- validator/val_anchor.c | 12 ++++++------ 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/compat/strptime.c b/compat/strptime.c index 3dd8a7b48..10ec31574 100644 --- a/compat/strptime.c +++ b/compat/strptime.c @@ -111,11 +111,11 @@ unbound_strptime(const char *s, const char *format, struct tm *tm) while ((c = *format) != '\0') { /* whitespace, literal or format */ - if (isspace(c)) { /* whitespace */ + if (isspace((unsigned char)c)) { /* whitespace */ /** whitespace matches zero or more whitespace characters in the * input string. **/ - while (isspace(*s)) + while (isspace((unsigned char)*s)) s++; } else if (c == '%') { /* format */ @@ -221,7 +221,7 @@ unbound_strptime(const char *s, const char *format, struct tm *tm) break; case 'n': /* arbitrary whitespace */ case 't': - while (isspace(*s)) + while (isspace((unsigned char)*s)) s++; break; case 'p': /* am pm */ diff --git a/daemon/remote.c b/daemon/remote.c index 100aa8be1..e56572048 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -558,7 +558,7 @@ static char* skipwhite(char* str) { /* EOS \0 is not a space */ - while( isspace(*str) ) + while( isspace((unsigned char)*str) ) str++; return str; } diff --git a/ldns/parseutil.c b/ldns/parseutil.c index 7d3841619..5c070aae0 100644 --- a/ldns/parseutil.c +++ b/ldns/parseutil.c @@ -467,7 +467,7 @@ sldns_b32_pton_base(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz, ch = *src++; --src_sz; - } while (isspace(ch) && src_sz > 0); + } while (isspace((unsigned char)ch) && src_sz > 0); if (ch == '=' || ch == '\0') break; @@ -572,7 +572,7 @@ sldns_b32_pton_base(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz, ch = *src++; src_sz--; - } while (isspace(ch)); + } while (isspace((unsigned char)ch)); if (ch != '=') return -1; diff --git a/ldns/str2wire.c b/ldns/str2wire.c index 31ef6e10a..931e28f84 100644 --- a/ldns/str2wire.c +++ b/ldns/str2wire.c @@ -384,7 +384,7 @@ rrinternal_spool_hex(char* token, uint8_t* rr, size_t rr_len, { char* p = token; while(*p) { - if(isspace(*p)) { + if(isspace((unsigned char)*p)) { p++; continue; } @@ -833,9 +833,9 @@ sldns_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; return s; @@ -866,7 +866,7 @@ int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len, return LDNS_WIREPARSE_ERR_OK; } - if(strncmp(line, "$ORIGIN", 7) == 0 && isspace(line[7])) { + if(strncmp(line, "$ORIGIN", 7) == 0 && isspace((unsigned char)line[7])) { int s; *len = 0; *dname_len = 0; @@ -876,7 +876,7 @@ int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len, parse_state->origin, &parse_state->origin_len); if(s) parse_state->origin_len = 0; return s; - } else if(strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) { + } else if(strncmp(line, "$TTL", 4) == 0 && isspace((unsigned char)line[4])) { const char* end = NULL; *len = 0; *dname_len = 0; @@ -1197,7 +1197,7 @@ int sldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len) const char* s = str; size_t dlen = 0; /* number of hexdigits parsed */ while(*s) { - if(isspace(*s)) { + if(isspace((unsigned char)*s)) { s++; continue; } @@ -1703,7 +1703,7 @@ int sldns_str2wire_nsap_buf(const char* str, uint8_t* rd, size_t* len) if(slen > LDNS_MAX_RDFLEN*2) return LDNS_WIREPARSE_ERR_LABEL_OVERFLOW; while(*s) { - if(isspace(*s) || *s == '.') { + if(isspace((unsigned char)*s) || *s == '.') { s++; continue; } @@ -1734,7 +1734,7 @@ int sldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len) if(slen > LDNS_MAX_RDFLEN*2) return LDNS_WIREPARSE_ERR_LABEL_OVERFLOW; while(*s) { - if(isspace(*s) || *s == '.') { + if(isspace((unsigned char)*s) || *s == '.') { s++; continue; } diff --git a/services/modstack.c b/services/modstack.c index a99030bc3..49bb2fd15 100644 --- a/services/modstack.c +++ b/services/modstack.c @@ -60,12 +60,12 @@ count_modules(const char* s) return 0; while(*s) { /* skip whitespace */ - while(*s && isspace((int)*s)) + while(*s && isspace((unsigned char)*s)) s++; - if(*s && !isspace((int)*s)) { + if(*s && !isspace((unsigned char)*s)) { /* skip identifier */ num++; - while(*s && !isspace((int)*s)) + while(*s && !isspace((unsigned char)*s)) s++; } } @@ -152,7 +152,7 @@ module_func_block* module_factory(const char** str) const char* s = *str; const char** names = module_list_avail(); fbgetfunctype* fb = module_funcs_avail(); - while(*s && isspace((int)*s)) + while(*s && isspace((unsigned char)*s)) s++; while(names[i]) { if(strncmp(names[i], s, strlen(names[i])) == 0) { diff --git a/testcode/replay.c b/testcode/replay.c index eb2a7a650..5c1197146 100644 --- a/testcode/replay.c +++ b/testcode/replay.c @@ -130,7 +130,7 @@ strip_end_white(char* p) { size_t i; for(i = strlen(p); i > 0; i--) { - if(isspace((int)p[i-1])) + if(isspace((unsigned char)p[i-1])) p[i-1] = 0; else return; } @@ -170,14 +170,14 @@ replay_range_read(char* remain, FILE* in, const char* name, while(fgets(line, MAX_LINE_LEN-1, in)) { pstate->lineno++; parse = line; - while(isspace((int)*parse)) + while(isspace((unsigned char)*parse)) parse++; if(!*parse || *parse == ';') { pos = ftello(in); continue; } if(parse_keyword(&parse, "ADDRESS")) { - while(isspace((int)*parse)) + while(isspace((unsigned char)*parse)) parse++; strip_end_white(parse); if(!extstrtoaddr(parse, &rng->addr, &rng->addrlen)) { @@ -281,7 +281,7 @@ replay_moment_read(char* remain, FILE* in, const char* name, return NULL; } remain += skip; - while(isspace((int)*remain)) + while(isspace((unsigned char)*remain)) remain++; if(parse_keyword(&remain, "NOTHING")) { mom->evt_type = repevt_nothing; @@ -303,10 +303,10 @@ replay_moment_read(char* remain, FILE* in, const char* name, mom->evt_type = repevt_timeout; } else if(parse_keyword(&remain, "TIME_PASSES")) { mom->evt_type = repevt_time_passes; - while(isspace((int)*remain)) + while(isspace((unsigned char)*remain)) remain++; if(parse_keyword(&remain, "EVAL")) { - while(isspace((int)*remain)) + while(isspace((unsigned char)*remain)) remain++; mom->string = strdup(remain); if(!mom->string) fatal_exit("out of memory"); @@ -316,7 +316,7 @@ replay_moment_read(char* remain, FILE* in, const char* name, } } else if(parse_keyword(&remain, "CHECK_AUTOTRUST")) { mom->evt_type = repevt_autotrust_check; - while(isspace((int)*remain)) + while(isspace((unsigned char)*remain)) remain++; if(strlen(remain)>0 && remain[strlen(remain)-1]=='\n') remain[strlen(remain)-1] = 0; @@ -333,20 +333,20 @@ replay_moment_read(char* remain, FILE* in, const char* name, } else if(parse_keyword(&remain, "INFRA_RTT")) { char *s, *m; mom->evt_type = repevt_infra_rtt; - while(isspace((int)*remain)) + while(isspace((unsigned char)*remain)) remain++; s = remain; remain = strchr(s, ' '); if(!remain) fatal_exit("expected three args for INFRA_RTT"); remain[0] = 0; remain++; - while(isspace((int)*remain)) + while(isspace((unsigned char)*remain)) remain++; m = strchr(remain, ' '); if(!m) fatal_exit("expected three args for INFRA_RTT"); m[0] = 0; m++; - while(isspace((int)*m)) + while(isspace((unsigned char)*m)) m++; if(!extstrtoaddr(s, &mom->addr, &mom->addrlen)) fatal_exit("bad infra_rtt address %s", s); @@ -361,10 +361,10 @@ replay_moment_read(char* remain, FILE* in, const char* name, free(mom); return NULL; } - while(isspace((int)*remain)) + while(isspace((unsigned char)*remain)) remain++; if(parse_keyword(&remain, "ADDRESS")) { - while(isspace((int)*remain)) + while(isspace((unsigned char)*remain)) remain++; if(strlen(remain) > 0) /* remove \n */ remain[strlen(remain)-1] = 0; @@ -408,7 +408,7 @@ static struct replay_scenario* make_scenario(char* line) { struct replay_scenario* scen; - while(isspace((int)*line)) + while(isspace((unsigned char)*line)) line++; if(!*line) { log_err("scenario: no title given"); @@ -442,7 +442,7 @@ replay_scenario_read(FILE* in, const char* name, int* lineno) parse=line; pstate.lineno++; (*lineno)++; - while(isspace((int)*parse)) + while(isspace((unsigned char)*parse)) parse++; if(!*parse) continue; /* empty line */ diff --git a/testcode/testbound.c b/testcode/testbound.c index b994b8f7e..daf8ddd41 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -97,7 +97,7 @@ add_opts(const char* args, int* pass_argc, char* pass_argv[]) { const char *p = args, *np; size_t len; - while(p && isspace((int)*p)) + while(p && isspace((unsigned char)*p)) p++; while(p && *p) { /* find location of next string and length of this one */ @@ -115,7 +115,7 @@ add_opts(const char* args, int* pass_argc, char* pass_argv[]) (*pass_argc)++; /* go to next option */ p = np; - while(p && isspace((int)*p)) + while(p && isspace((unsigned char)*p)) p++; } } @@ -140,7 +140,7 @@ spool_auto_file(FILE* in, int* lineno, FILE* cfg, char* id) char* parse; FILE* spool; /* find filename for new file */ - while(isspace((int)*id)) + while(isspace((unsigned char)*id)) id++; if(strlen(id)==0) fatal_exit("AUTROTRUST_FILE must have id, line %d", *lineno); @@ -158,7 +158,7 @@ spool_auto_file(FILE* in, int* lineno, FILE* cfg, char* id) while(fgets(line, MAX_LINE_LEN-1, in)) { parse = line; (*lineno)++; - while(isspace((int)*parse)) + while(isspace((unsigned char)*parse)) parse++; if(strncmp(parse, "AUTOTRUST_END", 13) == 0) { fclose(spool); @@ -197,7 +197,7 @@ setup_config(FILE* in, int* lineno, int* pass_argc, char* pass_argv[]) while(fgets(line, MAX_LINE_LEN-1, in)) { parse = line; (*lineno)++; - while(isspace((int)*parse)) + while(isspace((unsigned char)*parse)) parse++; if(!*parse || parse[0] == ';') continue; diff --git a/testcode/testpkts.c b/testcode/testpkts.c index 725e3a4ba..a494d9f01 100644 --- a/testcode/testpkts.c +++ b/testcode/testpkts.c @@ -81,7 +81,7 @@ static int str_keyword(char** str, const char* keyword) if(strncmp(*str, keyword, len) != 0) return 0; *str += len; - while(isspace((int)**str)) + while(isspace((unsigned char)**str)) (*str)++; return 1; } @@ -138,7 +138,7 @@ static void matchline(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((int)*parse)) + while(isspace((unsigned char)*parse)) parse++; } else { error("could not parse MATCH: '%s'", parse); @@ -226,11 +226,11 @@ static void adjustline(char* line, struct entry* e, e->copy_query = 1; } else if(str_keyword(&parse, "sleep=")) { e->sleeptime = (unsigned int) strtol(parse, (char**)&parse, 10); - while(isspace((int)*parse)) + while(isspace((unsigned char)*parse)) parse++; } else if(str_keyword(&parse, "packet_sleep=")) { pkt->packet_sleep = (unsigned int) strtol(parse, (char**)&parse, 10); - while(isspace((int)*parse)) + while(isspace((unsigned char)*parse)) parse++; } else { error("could not parse ADJUST: '%s'", parse); @@ -422,7 +422,7 @@ get_origin(const char* name, struct sldns_file_parse_state* pstate, char* parse) int status; end=parse; - while(!isspace((int)*end) && !isendline(*end)) + while(!isspace((unsigned char)*end) && !isendline(*end)) end++; store = *end; *end = 0; @@ -518,7 +518,7 @@ read_entry(FILE* in, const char* name, struct sldns_file_parse_state* pstate, parse = line; pstate->lineno++; - while(isspace((int)*parse)) + while(isspace((unsigned char)*parse)) parse++; /* test for keywords */ if(isendline(*parse)) diff --git a/util/config_file.c b/util/config_file.c index 1fb534625..35bc6452a 100644 --- a/util/config_file.c +++ b/util/config_file.c @@ -1105,7 +1105,7 @@ cfg_count_numbers(const char* s) /* sp ::= (space|tab)* */ int num = 0; while(*s) { - while(*s && isspace((int)*s)) + while(*s && isspace((unsigned char)*s)) s++; if(!*s) /* end of string */ break; diff --git a/validator/autotrust.c b/validator/autotrust.c index a59763382..5e1dc4ef3 100644 --- a/validator/autotrust.c +++ b/validator/autotrust.c @@ -902,13 +902,13 @@ static int handle_origin(char* line, uint8_t** origin, size_t* origin_len) { size_t len = 0; - while(isspace((int)*line)) + while(isspace((unsigned char)*line)) line++; if(strncmp(line, "$ORIGIN", 7) != 0) return 0; free(*origin); line += 7; - while(isspace((int)*line)) + while(isspace((unsigned char)*line)) line++; *origin = sldns_str2wire_dname(line, &len); *origin_len = len; diff --git a/validator/val_anchor.c b/validator/val_anchor.c index a4adfe2d9..3a67fff45 100644 --- a/validator/val_anchor.c +++ b/validator/val_anchor.c @@ -563,7 +563,7 @@ readkeyword_bindfile(FILE* in, sldns_buffer* buf, int* line, int comments) /* not a comment, complete the keyword */ if(numdone > 0) { /* check same type */ - if(isspace(c)) { + if(isspace((unsigned char)c)) { ungetc(c, in); return numdone; } @@ -582,12 +582,12 @@ readkeyword_bindfile(FILE* in, sldns_buffer* buf, int* line, int comments) } sldns_buffer_write_u8(buf, (uint8_t)c); numdone++; - if(isspace(c)) { + if(isspace((unsigned char)c)) { /* collate whitespace into ' ' */ while((c = getc(in)) != EOF ) { if(c == '\n') (*line)++; - if(!isspace(c)) { + if(!isspace((unsigned char)c)) { ungetc(c, in); break; } @@ -607,7 +607,7 @@ skip_to_special(FILE* in, sldns_buffer* buf, int* line, int spec) int rdlen; sldns_buffer_clear(buf); while((rdlen=readkeyword_bindfile(in, buf, line, 1))) { - if(rdlen == 1 && isspace((int)*sldns_buffer_begin(buf))) { + if(rdlen == 1 && isspace((unsigned char)*sldns_buffer_begin(buf))) { sldns_buffer_clear(buf); continue; } @@ -648,7 +648,7 @@ process_bind_contents(struct val_anchors* anchors, sldns_buffer* buf, sldns_buffer_clear(buf); while((rdlen=readkeyword_bindfile(in, buf, line, comments))) { if(rdlen == 1 && sldns_buffer_position(buf) == 1 - && isspace((int)*sldns_buffer_begin(buf))) { + && isspace((unsigned char)*sldns_buffer_begin(buf))) { /* starting whitespace is removed */ sldns_buffer_clear(buf); continue; @@ -703,7 +703,7 @@ process_bind_contents(struct val_anchors* anchors, sldns_buffer* buf, } return 1; } else if(rdlen == 1 && - isspace((int)sldns_buffer_current(buf)[-1])) { + isspace((unsigned char)sldns_buffer_current(buf)[-1])) { /* leave whitespace here */ } else { /* not space or whatnot, so actual content */ -- 2.47.2