From 88e058164a9cb7381361aaa97e399495fc3e2b92 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 3 Mar 2010 00:16:00 +0100 Subject: [PATCH] [BUILD] fix some build warnings on Solaris with is* macros isalnum, isdigit and friends are really annoying because they take an int in which we should pass an unsigned char, while strings everywhere use chars. Solaris uses macros relying on an array for those functions, which easily triggers some warnings showing where we have mistakenly passed a char instead of an unsigned char or an int. Those warnings may indicate real bugs on some platforms depending on the implementation. --- src/buffers.c | 4 ++-- src/cfgparse.c | 6 ++++-- src/checks.c | 6 ++++-- src/standard.c | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/buffers.c b/src/buffers.c index 79cc45bf58..2557fe4a0a 100644 --- a/src/buffers.c +++ b/src/buffers.c @@ -407,7 +407,7 @@ int chunk_htmlencode(struct chunk *dst, struct chunk *src) { c = src->str[i]; - if (!isascii(c) || !isprint(c) || c == '&' || c == '"' || c == '\'' || c == '<' || c == '>') { + if (!isascii(c) || !isprint((unsigned char)c) || c == '&' || c == '"' || c == '\'' || c == '<' || c == '>') { l = snprintf(dst->str + dst->len, free, "&#%u;", (unsigned char)c); if (free < l) { @@ -447,7 +447,7 @@ int chunk_asciiencode(struct chunk *dst, struct chunk *src, char qc) { c = src->str[i]; - if (!isascii(c) || !isprint(c) || c == '<' || c == '>' || c == qc) { + if (!isascii(c) || !isprint((unsigned char)c) || c == '<' || c == '>' || c == qc) { l = snprintf(dst->str + dst->len, free, "<%02X>", (unsigned char)c); if (free < l) { diff --git a/src/cfgparse.c b/src/cfgparse.c index b5437a6a1a..147f0185bb 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -727,7 +727,8 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm) for (i=0; args[1][i]; i++) { c = args[1][i]; - if (!isupper(c) && !islower(c) && !isdigit(c) && c != '_' && c != '-' && c != '.') + if (!isupper((unsigned char)c) && !islower((unsigned char)c) && + !isdigit((unsigned char)c) && c != '_' && c != '-' && c != '.') break; } @@ -2506,7 +2507,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) for (i=0; args[2][i]; i++) { c = args[2][i]; - if (!isupper(c) && !islower(c) && !isdigit(c) && c != '_' && c != '-' && c != '.') + if (!isupper((unsigned char)c) && !islower((unsigned char)c) && + !isdigit((unsigned char)c) && c != '_' && c != '-' && c != '.') break; } diff --git a/src/checks.c b/src/checks.c index b235d9e150..a023bf7fdb 100644 --- a/src/checks.c +++ b/src/checks.c @@ -906,7 +906,8 @@ static int event_srv_chk_r(int fd) if ((len < strlen("HTTP/1.0 000\r")) || (memcmp(trash, "HTTP/1.", 7) != 0 || (trash[12] != ' ' && trash[12] != '\r')) || - !isdigit(trash[9]) || !isdigit(trash[10]) || !isdigit(trash[11])) { + !isdigit((unsigned char)trash[9]) || !isdigit((unsigned char)trash[10]) || + !isdigit((unsigned char)trash[11])) { cut_crlf(trash); set_server_check_status(s, HCHK_STATUS_L7RSP, trash); @@ -941,7 +942,8 @@ static int event_srv_chk_r(int fd) /* Check if the server speaks SMTP */ if ((len < strlen("000\r")) || (trash[3] != ' ' && trash[3] != '\r') || - !isdigit(trash[0]) || !isdigit(trash[1]) || !isdigit(trash[2])) { + !isdigit((unsigned char)trash[0]) || !isdigit((unsigned char)trash[1]) || + !isdigit((unsigned char)trash[2])) { cut_crlf(trash); set_server_check_status(s, HCHK_STATUS_L7RSP, trash); diff --git a/src/standard.c b/src/standard.c index 2e68936545..8106725938 100644 --- a/src/standard.c +++ b/src/standard.c @@ -184,7 +184,7 @@ const char *invalid_char(const char *name) return name; while (*name) { - if (!isalnum((int)*name) && *name != '.' && *name != ':' && + if (!isalnum((int)(unsigned char)*name) && *name != '.' && *name != ':' && *name != '_' && *name != '-') return name; name++; @@ -203,7 +203,7 @@ const char *invalid_domainchar(const char *name) { return name; while (*name) { - if (!isalnum((int)*name) && *name != '.' && + if (!isalnum((int)(unsigned char)*name) && *name != '.' && *name != '_' && *name != '-') return name; -- 2.47.3