[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.
diff --git a/src/buffers.c b/src/buffers.c
index 79cc45b..2557fe4 100644
--- a/src/buffers.c
+++ b/src/buffers.c
@@ -407,7 +407,7 @@
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 @@
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 b5437a6..147f018 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -727,7 +727,8 @@
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 @@
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 b235d9e..a023bf7 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -906,7 +906,8 @@
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 @@
/* 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 2e68936..8106725 100644
--- a/src/standard.c
+++ b/src/standard.c
@@ -184,7 +184,7 @@
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 @@
return name;
while (*name) {
- if (!isalnum((int)*name) && *name != '.' &&
+ if (!isalnum((int)(unsigned char)*name) && *name != '.' &&
*name != '_' && *name != '-')
return name;