kill some compiler warnings on NetBSD

pull/816/head
Brad House 7 months ago
parent 1e44e0bb80
commit 094aa9c6e3
  1. 4
      src/lib/ares_dns_name.c
  2. 2
      src/lib/ares_event_kqueue.c
  3. 2
      src/lib/ares_getaddrinfo.c
  4. 2
      src/lib/ares_send.c
  5. 14
      src/lib/ares_str.h
  6. 23
      src/lib/inet_net_pton.c
  7. 37
      src/tools/adig.c

@ -212,7 +212,7 @@ static ares_status_t ares_parse_dns_name_escape(ares__buf_t *namebuf,
}
/* If next character is a digit, read 2 more digits */
if (isdigit(c)) {
if (ares__isdigit(c)) {
size_t i;
unsigned int val = 0;
@ -224,7 +224,7 @@ static ares_status_t ares_parse_dns_name_escape(ares__buf_t *namebuf,
return ARES_EBADNAME;
}
if (!isdigit(c)) {
if (!ares__isdigit(c)) {
return ARES_EBADNAME;
}
val *= 10;

@ -198,7 +198,7 @@ static size_t ares_evsys_kqueue_wait(ares_event_thread_t *e,
size_t cnt = 0;
if (timeout_ms != 0) {
ts.tv_sec = timeout_ms / 1000;
ts.tv_sec = (time_t)timeout_ms / 1000;
ts.tv_nsec = (timeout_ms % 1000) * 1000 * 1000;
timeout = &ts;
}

@ -252,7 +252,7 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port,
ares_bool_t valid = ARES_TRUE;
const char *p;
for (p = name; *p; p++) {
if (!isdigit(*p) && *p != '.') {
if (!ares__isdigit(*p) && *p != '.') {
valid = ARES_FALSE;
break;
} else if (*p == '.') {

@ -81,7 +81,7 @@ static ares_status_t ares_apply_dns0x20(ares_channel_t *channel,
size_t bit;
/* Only apply 0x20 to alpha characters */
if (!isalpha(name[i])) {
if (!ares__isalpha(name[i])) {
dns0x20name[i] = name[i];
continue;
}

@ -72,5 +72,19 @@ ares_bool_t ares__is_hostname(const char *str);
*/
ares_bool_t ares__str_isprint(const char *str, size_t len);
/* We only care about ASCII rules */
#define ares__isascii(x) (((unsigned char)x) <= 127)
#define ares__isdigit(x) (((unsigned char)x) >= '0' && \
((unsigned char)x) <= '9')
#define ares__isxdigit(x) (ares__isdigit(x) || \
(((unsigned char)x) >= 'a' && \
((unsigned char)x) <= 'f') || \
(((unsigned char)x) >= 'A' && \
((unsigned char)x) <= 'Z'))
#define ares__isupper(x) (((unsigned char)x) >= 'A' && \
((unsigned char)x) <= 'Z')
#define ares__islower(x) (((unsigned char)x) >= 'a' && \
((unsigned char)x) <= 'z')
#define ares__isalpha(x) (ares__islower(x) || ares__isupper(x))
#endif /* __ARES_STR_H */

@ -32,11 +32,6 @@
#include "ares_ipv6.h"
#include "ares_inet_net_pton.h"
#define ISDIGIT(x) (isdigit((int)((unsigned char)x)))
#define ISXDIGIT(x) (isxdigit((int)((unsigned char)x)))
#define ISASCII(x) (((unsigned char)x) <= 127 ? 1 : 0)
#define ISUPPER(x) (isupper((int)((unsigned char)x)))
const struct ares_in6_addr ares_in6addr_any = { { { 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0 } } };
@ -74,16 +69,16 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst,
const unsigned char *odst = dst;
ch = *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X') && ISASCII(src[1]) &&
ISXDIGIT(src[1])) {
if (ch == '0' && (src[0] == 'x' || src[0] == 'X') && ares__isascii(src[1]) &&
ares__isxdigit(src[1])) {
/* Hexadecimal: Eat nybble string. */
if (!size) {
goto emsgsize;
}
dirty = 0;
src++; /* skip x or X. */
while ((ch = *src++) != '\0' && ISASCII(ch) && ISXDIGIT(ch)) {
if (ISUPPER(ch)) {
while ((ch = *src++) != '\0' && ares__isascii(ch) && ares__isxdigit(ch)) {
if (ares__isupper(ch)) {
ch = ares__tolower((unsigned char)ch);
}
n = (int)(strchr(xdigits, ch) - xdigits);
@ -106,7 +101,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst,
}
*dst++ = (unsigned char)(tmp << 4);
}
} else if (ISASCII(ch) && ISDIGIT(ch)) {
} else if (ares__isascii(ch) && ares__isdigit(ch)) {
/* Decimal: eat dotted digit string. */
for (;;) {
tmp = 0;
@ -117,7 +112,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst,
if (tmp > 255) {
goto enoent;
}
} while ((ch = *src++) != '\0' && ISASCII(ch) && ISDIGIT(ch));
} while ((ch = *src++) != '\0' && ares__isascii(ch) && ares__isdigit(ch));
if (!size--) {
goto emsgsize;
}
@ -129,7 +124,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst,
goto enoent;
}
ch = *src++;
if (!ISASCII(ch) || !ISDIGIT(ch)) {
if (!ares__isascii(ch) || !ares__isdigit(ch)) {
goto enoent;
}
}
@ -138,7 +133,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst,
}
bits = -1;
if (ch == '/' && ISASCII(src[0]) && ISDIGIT(src[0]) && dst > odst) {
if (ch == '/' && ares__isascii(src[0]) && ares__isdigit(src[0]) && dst > odst) {
/* CIDR width specifier. Nothing can follow it. */
ch = *src++; /* Skip over the /. */
bits = 0;
@ -149,7 +144,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst,
if (bits > 32) {
goto enoent;
}
} while ((ch = *src++) != '\0' && ISASCII(ch) && ISDIGIT(ch));
} while ((ch = *src++) != '\0' && ares__isascii(ch) && ares__isdigit(ch));
if (ch != '\0') {
goto enoent;
}

@ -219,26 +219,33 @@ static ares_bool_t read_cmdline(int argc, const char * const * argv,
break;
case 'T':
/* Set the TCP port number. */
if (!isdigit(*state.optarg)) {
snprintf(config->error, sizeof(config->error), "invalid port number");
return ARES_FALSE;
{
/* Set the TCP port number. */
long port = strtol(state.optarg, NULL, 0);
if (port <= 0 || port > 65535) {
snprintf(config->error, sizeof(config->error), "invalid port number");
return ARES_FALSE;
}
config->options.tcp_port = (unsigned short)port;
config->options.flags |= ARES_FLAG_USEVC;
config->optmask |= ARES_OPT_TCP_PORT;
}
config->options.tcp_port =
(unsigned short)strtol(state.optarg, NULL, 0);
config->options.flags |= ARES_FLAG_USEVC;
config->optmask |= ARES_OPT_TCP_PORT;
break;
case 'U':
/* Set the UDP port number. */
if (!isdigit(*state.optarg)) {
snprintf(config->error, sizeof(config->error), "invalid port number");
return ARES_FALSE;
{
/* Set the TCP port number. */
long port = strtol(state.optarg, NULL, 0);
if (port <= 0 || port > 65535) {
snprintf(config->error, sizeof(config->error), "invalid port number");
return ARES_FALSE;
}
config->options.udp_port = (unsigned short)port;
config->options.flags |= ARES_FLAG_USEVC;
config->optmask |= ARES_OPT_UDP_PORT;
}
config->options.udp_port =
(unsigned short)strtol(state.optarg, NULL, 0);
config->optmask |= ARES_OPT_UDP_PORT;
break;
case ':':

Loading…
Cancel
Save