summaryrefslogtreecommitdiff
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2017-07-14 16:21:04 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2017-07-14 16:21:04 +0000
commitd8acf8cda47408f2d8b06a198e0b1713ba5b2a86 (patch)
tree9466c8bb9cd780ec682872f1d6b29c5d9676bfa0 /sbin/dhclient
parentbeceb6e45bbd13816725262d25deaad63c6fa051 (diff)
Replace remaining "!var" expressions with
"<var> == 0", "!(<var> & FLAG)" with "(<var> & FLAG) == 0", "!<func()>" with "<func()> == 0" and "!<define>" with "<define> == 0". And the positive cases as well. A few stray == NULL and != NULL as well.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/bpf.c4
-rw-r--r--sbin/dhclient/clparse.c36
-rw-r--r--sbin/dhclient/conflex.c29
-rw-r--r--sbin/dhclient/dhclient.c148
-rw-r--r--sbin/dhclient/dispatch.c16
-rw-r--r--sbin/dhclient/kroute.c26
-rw-r--r--sbin/dhclient/options.c28
-rw-r--r--sbin/dhclient/packet.c4
-rw-r--r--sbin/dhclient/parse.c22
-rw-r--r--sbin/dhclient/privsep.c4
10 files changed, 159 insertions, 158 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index e7aca6f1662..5bcfdd02e0e 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.60 2017/07/10 17:13:24 krw Exp $ */
+/* $OpenBSD: bpf.c,v 1.61 2017/07/14 16:21:03 krw Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -428,6 +428,6 @@ receive_packet(struct interface_info *ifi, struct sockaddr_in *from,
ifi->rbuf_offset = BPF_WORDALIGN(ifi->rbuf_offset +
hdr.bh_caplen);
return hdr.bh_caplen ;
- } while (!length);
+ } while (length == 0);
return 0 ;
}
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 2fbf050df45..1cad50dc153 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.123 2017/07/14 14:03:15 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.124 2017/07/14 16:21:03 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -318,11 +318,11 @@ parse_client_statement(FILE *cfile, char *name)
parse_semi(cfile);
break;
case TOK_FIXED_ADDR:
- if (parse_ip_addr(cfile, &config->address))
+ if (parse_ip_addr(cfile, &config->address) != 0)
parse_semi(cfile);
break;
case TOK_NEXT_SERVER:
- if (parse_ip_addr(cfile, &config->next_server))
+ if (parse_ip_addr(cfile, &config->next_server) != 0)
parse_semi(cfile);
break;
default:
@@ -345,7 +345,7 @@ parse_X(FILE *cfile, uint8_t *buf, int max)
len = 0;
for (token = ':'; token == ':';
token = next_token(NULL, cfile)) {
- if (!parse_hex(cfile, &buf[len]))
+ if (parse_hex(cfile, &buf[len]) == 0)
break;
if (++len == max)
break;
@@ -400,7 +400,7 @@ parse_option_list(FILE *cfile, uint8_t *list, size_t sz)
/* Empty list. */
return 0;
}
- if (!is_identifier(token)) {
+ if (is_identifier(token) == 0) {
parse_warn("expecting option name.");
goto syntaxerror;
}
@@ -429,7 +429,7 @@ parse_option_list(FILE *cfile, uint8_t *list, size_t sz)
token = next_token(NULL, cfile);
} while (token == ',');
- if (parse_semi(cfile))
+ if (parse_semi(cfile) != 0)
return ix;
syntaxerror:
@@ -567,11 +567,11 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease,
}
break;
case TOK_FIXED_ADDR:
- if (!parse_ip_addr(cfile, &lease->address))
+ if (parse_ip_addr(cfile, &lease->address) == 0)
return;
break;
case TOK_NEXT_SERVER:
- if (!parse_ip_addr(cfile, &lease->next_server))
+ if (parse_ip_addr(cfile, &lease->next_server) == 0)
return;
break;
case TOK_FILENAME:
@@ -627,7 +627,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
int nul_term = 0;
token = next_token(&val, cfile);
- if (!is_identifier(token)) {
+ if (is_identifier(token) == 0) {
parse_warn("expecting identifier.");
if (token != ';')
skip_to_semi(cfile);
@@ -673,13 +673,13 @@ parse_option_decl(FILE *cfile, struct option_data *options)
dp = NULL;
break;
case 'I': /* IP address. */
- if (!parse_ip_addr(cfile, &ip_addr))
+ if (parse_ip_addr(cfile, &ip_addr) == 0)
return -1;
len = sizeof(ip_addr);
dp = (uint8_t *)&ip_addr;
break;
case 'l': /* Signed 32-bit integer. */
- if (!parse_decimal(cfile, buf, 'l')) {
+ if (parse_decimal(cfile, buf, 'l') == 0) {
parse_warn("expecting signed 32-bit "
"integer.");
skip_to_semi(cfile);
@@ -689,7 +689,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
dp = buf;
break;
case 'L': /* Unsigned 32-bit integer. */
- if (!parse_decimal(cfile, buf, 'L')) {
+ if (parse_decimal(cfile, buf, 'L') == 0) {
parse_warn("expecting unsigned 32-bit "
"integer.");
skip_to_semi(cfile);
@@ -699,7 +699,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
dp = buf;
break;
case 'S': /* Unsigned 16-bit integer. */
- if (!parse_decimal(cfile, buf, 'S')) {
+ if (parse_decimal(cfile, buf, 'S') == 0) {
parse_warn("expecting unsigned 16-bit "
"integer.");
skip_to_semi(cfile);
@@ -709,7 +709,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
dp = buf;
break;
case 'B': /* Unsigned 8-bit integer. */
- if (!parse_decimal(cfile, buf, 'B')) {
+ if (parse_decimal(cfile, buf, 'B') == 0) {
parse_warn("expecting unsigned 8-bit "
"integer.");
skip_to_semi(cfile);
@@ -719,7 +719,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
dp = buf;
break;
case 'f': /* Boolean flag. */
- if (!parse_boolean(cfile, buf)) {
+ if (parse_boolean(cfile, buf) == 0) {
parse_warn("expecting boolean.");
skip_to_semi(cfile);
return -1;
@@ -728,7 +728,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
dp = buf;
break;
case 'C':
- if (!parse_cidr(cfile, cidr))
+ if (parse_cidr(cfile, cidr) == 0)
return -1;
len = 1 + (cidr[0] + 7) / 8;
dp = cidr;
@@ -755,7 +755,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
token = next_token(NULL, cfile);
} while (*fmt == 'A' && token == ',');
- if (!parse_semi(cfile))
+ if (parse_semi(cfile) == 0)
return -1;
options[code].data = malloc(hunkix + nul_term);
@@ -774,7 +774,7 @@ parse_reject_statement(FILE *cfile)
int token;
do {
- if (!parse_ip_addr(cfile, &addr))
+ if (parse_ip_addr(cfile, &addr) == 0)
return;
elem = malloc(sizeof(struct reject_elem));
diff --git a/sbin/dhclient/conflex.c b/sbin/dhclient/conflex.c
index df5f177fbc3..bf68a0dee12 100644
--- a/sbin/dhclient/conflex.c
+++ b/sbin/dhclient/conflex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conflex.c,v 1.42 2017/07/10 00:47:47 krw Exp $ */
+/* $OpenBSD: conflex.c,v 1.43 2017/07/14 16:21:03 krw Exp $ */
/* Lexical scanner for dhclient config file. */
@@ -113,7 +113,7 @@ static int
get_char(FILE *cfile)
{
int c = getc(cfile);
- if (!ugflag) {
+ if (ugflag == 0) {
if (c == '\n') {
if (cur_line == line1) {
cur_line = line2;
@@ -153,7 +153,7 @@ get_token(FILE *cfile)
c = get_char(cfile);
- if (isascii(c) && isspace(c))
+ if (isascii(c) != 0 && isspace(c) != 0)
continue;
if (c == '#') {
skip_to_eol(cfile);
@@ -164,7 +164,7 @@ get_token(FILE *cfile)
if (c == '"') {
ttok = read_string(cfile);
break;
- } else if (c == '-' || (isascii(c) && isalnum(c))) {
+ } else if (c == '-' || (isascii(c) != 0 && isalnum(c) != 0)) {
ttok = read_num_or_name(c, cfile);
break;
} else {
@@ -183,7 +183,7 @@ next_token(char **rval, FILE *cfile)
{
int rv;
- if (token) {
+ if (token != 0) {
if (lexline != tline)
token_line = cur_line;
lexchar = tlpos;
@@ -194,7 +194,7 @@ next_token(char **rval, FILE *cfile)
rv = get_token(cfile);
token_line = cur_line;
}
- if (rval)
+ if (rval != 0)
*rval = tval;
return rv;
@@ -205,7 +205,7 @@ peek_token(char **rval, FILE *cfile)
{
int x;
- if (!token) {
+ if (token == 0) {
tlpos = lexchar;
tline = lexline;
token = get_token(cfile);
@@ -218,7 +218,7 @@ peek_token(char **rval, FILE *cfile)
lexline = tline;
tline = x;
}
- if (rval)
+ if (rval != 0)
*rval = tval;
return token;
@@ -252,7 +252,7 @@ read_string(FILE *cfile)
break;
tokbuf[i++] = c;
- if (bs)
+ if (bs != 0)
bs = 0;
else if (c == '\\')
bs = 1;
@@ -280,17 +280,18 @@ read_num_or_name(int c, FILE *cfile)
unsigned int i, xdigits;
int rv;
- xdigits = isxdigit(c) ? 1 : 0;
+ xdigits = (isxdigit(c) != 0) ? 1 : 0;
tokbuf[0] = c;
for (i = 1; i < sizeof(tokbuf); i++) {
c = get_char(cfile);
- if (!isascii(c) || (c != '-' && c != '_' && !isalnum(c))) {
+ if (isascii(c) == 0 || (c != '-' && c != '_' &&
+ isalnum(c) == 0)) {
ungetc(c, cfile);
ugflag = 1;
break;
}
- if (isxdigit(c))
+ if (isxdigit(c) != 0)
xdigits++;
tokbuf[i] = c;
}
@@ -298,7 +299,7 @@ read_num_or_name(int c, FILE *cfile)
parse_warn("token larger than internal buffer");
i--;
c = tokbuf[i];
- if (isxdigit(c))
+ if (isxdigit(c) != 0)
xdigits--;
}
tokbuf[i] = 0;
@@ -367,7 +368,7 @@ intern(char *atom, int dfv)
p = bsearch(atom, keywords, sizeof(keywords)/sizeof(keywords[0]),
sizeof(keywords[0]), kw_cmp);
- if (p)
+ if (p != NULL)
return p->k_val;
return dfv;
}
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index c03da128bd4..ea12c64f69f 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.468 2017/07/14 14:03:15 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.469 2017/07/14 16:21:03 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -195,7 +195,7 @@ findproto(char *cp, int n)
if (n == 0)
return -1;
for (i = 1; i; i <<= 1) {
- if (i & n) {
+ if ((i & n) != 0) {
sa = (struct sockaddr *)cp;
switch (i) {
case RTA_IFA:
@@ -225,7 +225,7 @@ get_ifa(char *cp, int n)
if (n == 0)
return NULL;
for (i = 1; i; i <<= 1)
- if (i & n) {
+ if ((i & n) != 0) {
sa = (struct sockaddr *)cp;
if (i == RTA_IFA)
return sa;
@@ -377,7 +377,7 @@ routehandler(struct interface_info *ifi, int routefd)
goto die;
}
- if (ifi->flags & IFI_VALID_LLADDR) {
+ if ((ifi->flags & IFI_VALID_LLADDR) != 0) {
memcpy(&hw, &ifi->hw_address, sizeof(hw));
get_hw_address(ifi);
if (memcmp(&hw, &ifi->hw_address, sizeof(hw))) {
@@ -391,11 +391,11 @@ routehandler(struct interface_info *ifi, int routefd)
if (linkstat != ifi->linkstat) {
#ifdef DEBUG
log_debug("link state %s -> %s",
- ifi->linkstat ? "up" : "down",
- linkstat ? "up" : "down");
+ (ifi->linkstat != 0) ? "up" : "down",
+ (linkstat != 0) ? "up" : "down");
#endif /* DEBUG */
ifi->linkstat = linkstat;
- if (ifi->linkstat) {
+ if (ifi->linkstat != 0) {
if (ifi->state == S_PREBOOT) {
state_preboot(ifi);
get_hw_address(ifi);
@@ -422,8 +422,8 @@ routehandler(struct interface_info *ifi, int routefd)
}
/* Something has happened. Try to write out the resolv.conf. */
- if (ifi->active && ifi->active->resolv_conf &&
- ifi->flags & IFI_IS_RESPONSIBLE)
+ if (ifi->active != NULL && ifi->active->resolv_conf != NULL &&
+ (ifi->flags & IFI_IS_RESPONSIBLE) != 0)
write_resolv_conf(ifi->active->resolv_conf,
strlen(ifi->active->resolv_conf));
@@ -457,7 +457,7 @@ main(int argc, char *argv[])
saved_argv = argv;
- if (isatty(STDERR_FILENO))
+ if (isatty(STDERR_FILENO) != 0)
log_perror = 1; /* log to stderr until daemonized */
else
log_perror = 0; /* can't log to stderr */
@@ -480,7 +480,7 @@ main(int argc, char *argv[])
case 'l':
path_dhclient_db = optarg;
if (lstat(path_dhclient_db, &sb) != -1) {
- if (!S_ISREG(sb.st_mode))
+ if (S_ISREG(sb.st_mode) == 0)
fatalx("'%s' is not a regular file",
path_dhclient_db);
}
@@ -488,7 +488,7 @@ main(int argc, char *argv[])
case 'L':
strlcat(path_option_db, optarg, PATH_MAX);
if (lstat(path_option_db, &sb) != -1) {
- if (!S_ISREG(sb.st_mode))
+ if (S_ISREG(sb.st_mode) == 0)
fatalx("'%s' is not a regular file",
path_option_db);
}
@@ -506,13 +506,13 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (argc != 1 || (q_flag && d_flag))
+ if (argc != 1 || (q_flag != 0 && d_flag != 0))
usage();
- if (d_flag)
+ if (d_flag != 0)
daemonize = 0;
- if (q_flag)
+ if (q_flag != 0)
log_perror = 0;
log_init(log_perror, LOG_DAEMON);
@@ -580,7 +580,7 @@ main(int argc, char *argv[])
fatalx("asprintf");
/* 2nd stage (post fork) config setup. */
- if (ignore_list)
+ if (ignore_list != NULL)
apply_ignore_list(ignore_list);
tailfd = open(tail_path, O_RDONLY);
@@ -680,7 +680,7 @@ main(int argc, char *argv[])
endpwent();
- if (daemonize) {
+ if (daemonize != 0) {
if (pledge("stdio inet dns route proc", NULL) == -1)
fatalx("pledge");
} else {
@@ -691,7 +691,7 @@ main(int argc, char *argv[])
setproctitle("%s", ifi->name);
time(&ifi->startup_time);
- if (ifi->linkstat) {
+ if (ifi->linkstat != 0) {
ifi->state = S_REBOOTING;
state_reboot(ifi);
} else {
@@ -729,13 +729,13 @@ state_preboot(struct interface_info *ifi)
ifi->linkstat = interface_status(ifi->name);
- if (log_perror && interval > 3) {
- if (!preamble && !ifi->linkstat) {
+ if (log_perror != 0 && interval > 3) {
+ if (preamble == 0 && ifi->linkstat == 0) {
fprintf(stderr, "%s: no link ....", ifi->name);
preamble = 1;
}
- if (preamble) {
- if (ifi->linkstat)
+ if (preamble != 0) {
+ if (ifi->linkstat != 0)
fprintf(stderr, " got link\n");
else if (interval > config->link_timeout)
fprintf(stderr, " sleeping\n");
@@ -745,7 +745,7 @@ state_preboot(struct interface_info *ifi)
}
}
- if (ifi->linkstat) {
+ if (ifi->linkstat != 0) {
ifi->state = S_REBOOTING;
set_timeout(ifi, 1, state_reboot);
} else {
@@ -974,7 +974,7 @@ dhcpnak(struct interface_info *ifi, struct option_data *options, char *info)
log_info("%s", info);
/* XXX Do we really want to remove a NAK'd lease from the database? */
- if (!ifi->active->is_static) {
+ if (ifi->active->is_static == 0) {
TAILQ_REMOVE(&ifi->leases, ifi->active, next);
free_client_lease(ifi->active);
}
@@ -1071,11 +1071,11 @@ bind_lease(struct interface_info *ifi)
* is done by the RTM_NEWADDR message being received.
*/
add_address(ifi->active->address, mask);
- if (options[DHO_CLASSLESS_STATIC_ROUTES].len) {
+ if (options[DHO_CLASSLESS_STATIC_ROUTES].len != 0) {
add_classless_static_routes(
&options[DHO_CLASSLESS_STATIC_ROUTES],
ifi->active->address);
- } else if (options[DHO_CLASSLESS_MS_STATIC_ROUTES].len) {
+ } else if (options[DHO_CLASSLESS_MS_STATIC_ROUTES].len != 0) {
add_classless_static_routes(
&options[DHO_CLASSLESS_MS_STATIC_ROUTES],
ifi->active->address);
@@ -1097,7 +1097,7 @@ bind_lease(struct interface_info *ifi)
add_default_route(ifi->active->address, gateway);
}
- if (options[DHO_STATIC_ROUTES].len)
+ if (options[DHO_STATIC_ROUTES].len != 0)
add_static_routes(&options[DHO_STATIC_ROUTES],
ifi->active->address);
}
@@ -1115,7 +1115,7 @@ newlease:
seen = 0;
time(&cur_time);
TAILQ_FOREACH_SAFE(lease, &ifi->leases, next, pl) {
- if (lease->is_static)
+ if (lease->is_static != 0)
break;
if (ifi->active == NULL)
continue;
@@ -1132,7 +1132,7 @@ newlease:
free_client_lease(lease);
}
}
- if (!ifi->active->is_static && !seen)
+ if (ifi->active->is_static == 0 && seen == 0)
TAILQ_INSERT_HEAD(&ifi->leases, ifi->active, next);
/* Write out new leases file. */
@@ -1230,7 +1230,7 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
if (options[i].len == 0)
continue;
name = code_to_name(i);
- if (!unknown_ok && strncmp("option-", name, 7) != 0) {
+ if (unknown_ok == 0 && strncmp("option-", name, 7) != 0) {
log_warnx("lease declined: unknown option %d", i);
goto decline;
}
@@ -1242,7 +1242,7 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
/* Must decode the option into text to check names. */
buf = pretty_print_domain_search(options[i].data,
options[i].len);
- if (buf == NULL || !res_hnok_list(buf)) {
+ if (buf == NULL || res_hnok_list(buf) == 0) {
log_warnx("Ignoring %s in offer: invalid host "
"name(s)", name);
continue;
@@ -1255,7 +1255,7 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
* with DHO_DOMAIN_NAME. Thus allowing multiple
* entries in the resolv.conf 'search' statement.
*/
- if (!res_hnok_list(pretty)) {
+ if (res_hnok_list(pretty) == 0) {
log_warnx("Ignoring %s in offer: invalid host "
"name(s)", name);
continue;
@@ -1263,7 +1263,7 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
break;
case DHO_HOST_NAME:
case DHO_NIS_DOMAIN:
- if (!res_hnok(pretty)) {
+ if (res_hnok(pretty) == 0) {
log_warnx("Ignoring %s in offer: invalid host "
"name", name);
continue;
@@ -1281,7 +1281,7 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
* If this lease doesn't supply a required parameter, blow it off.
*/
for (i = 0; i < config->required_option_count; i++) {
- if (!lease->options[config->required_options[i]].len) {
+ if (lease->options[config->required_options[i]].len == 0) {
name = code_to_name(i);
log_warnx("lease declined: %s required but missing",
name);
@@ -1295,7 +1295,7 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
*/
lease->address.s_addr = packet->yiaddr.s_addr;
memset(ifname, 0, sizeof(ifname));
- if (addressinuse(ifi->name, lease->address, ifname) &&
+ if (addressinuse(ifi->name, lease->address, ifname) != 0 &&
strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) {
log_warnx("lease declined: %s already configured on %s",
inet_ntoa(lease->address), ifname);
@@ -1306,8 +1306,8 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
lease->next_server.s_addr = packet->siaddr.s_addr;
/* If the server name was filled out, copy it. */
- if ((!lease->options[DHO_DHCP_OPTION_OVERLOAD].len ||
- !(lease->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2)) &&
+ if ((lease->options[DHO_DHCP_OPTION_OVERLOAD].len == 0 ||
+ (lease->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2) == 0) &&
packet->sname[0]) {
lease->server_name = malloc(DHCP_SNAME_LEN + 1);
if (lease->server_name == NULL) {
@@ -1316,15 +1316,15 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
}
memcpy(lease->server_name, packet->sname, DHCP_SNAME_LEN);
lease->server_name[DHCP_SNAME_LEN] = '\0';
- if (!res_hnok(lease->server_name)) {
+ if (res_hnok(lease->server_name) == 0) {
log_warnx("lease declined: invalid host name in SNAME");
goto decline;
}
}
/* Ditto for the filename. */
- if ((!lease->options[DHO_DHCP_OPTION_OVERLOAD].len ||
- !(lease->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 1)) &&
+ if ((lease->options[DHO_DHCP_OPTION_OVERLOAD].len == 0 ||
+ (lease->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 1) == 0) &&
packet->file[0]) {
/* Don't count on the NUL terminator. */
lease->filename = malloc(DHCP_FILE_LEN + 1);
@@ -1374,7 +1374,7 @@ send_discover(struct interface_info *ifi)
* number between zero and two times itself. On average, this
* means that it will double with every transmission.
*/
- if (!ifi->interval)
+ if (ifi->interval == 0)
ifi->interval = config->initial_interval;
else {
ifi->interval += arc4random_uniform(2 * ifi->interval);
@@ -1482,7 +1482,7 @@ send_request(struct interface_info *ifi)
}
/* Do the exponential backoff. */
- if (!ifi->interval) {
+ if (ifi->interval == 0) {
if (ifi->state == S_REBOOTING)
ifi->interval = config->reboot_timeout;
else
@@ -1569,7 +1569,7 @@ make_discover(struct interface_info *ifi, struct client_lease *lease)
options[i].len = config->requested_option_count;
/* If we had an address, try to get it again. */
- if (lease) {
+ if (lease != NULL) {
ifi->requested_address = lease->address;
i = DHO_DHCP_REQUESTED_ADDRESS;
options[i].data = (char *)&lease->address;
@@ -1730,7 +1730,7 @@ make_decline(struct interface_info *ifi, struct client_lease *lease)
/* Send the uid if the user supplied one. */
i = DHO_DHCP_CLIENT_IDENTIFIER;
- if (config->send_options[i].len) {
+ if (config->send_options[i].len != 0) {
options[i].data = config->send_options[i].data;
options[i].len = config->send_options[i].len;
}
@@ -1791,7 +1791,7 @@ rewrite_client_leases(struct interface_info *ifi)
char *leasestr;
time_t cur_time;
- if (!leaseFile) /* XXX */
+ if (leaseFile == NULL)
fatalx("lease file not open");
rewind(leaseFile);
@@ -1807,12 +1807,12 @@ rewrite_client_leases(struct interface_info *ifi)
time(&cur_time);
TAILQ_FOREACH_REVERSE(lp, &ifi->leases, client_lease_tq, next) {
/* Don't write out static leases from dhclient.conf. */
- if (lp->is_static)
+ if (lp->is_static != 0)
continue;
if (lp->expiry <= cur_time)
continue;
leasestr = lease_as_string(ifi->name, "lease", lp);
- if (leasestr)
+ if (leasestr != NULL)
fprintf(leaseFile, "%s", leasestr);
else
log_warnx("cannot make lease into string");
@@ -1829,19 +1829,19 @@ rewrite_option_db(char *name, struct client_lease *offered,
{
char *leasestr;
- if (!optionDB)
+ if (optionDB == NULL)
return;
rewind(optionDB);
leasestr = lease_as_string(name, "offered", offered);
- if (leasestr)
+ if (leasestr != NULL)
fprintf(optionDB, "%s", leasestr);
else
log_warnx("cannot make offered lease into string");
leasestr = lease_as_string(name, "effective", effective);
- if (leasestr)
+ if (leasestr != NULL)
fprintf(optionDB, "%s", leasestr);
else
log_warnx("cannot make effective lease into string");
@@ -1886,7 +1886,7 @@ lease_as_proposal(struct client_lease *lease)
proposal->netmask.s_addr = ((struct in_addr *)opt->data)->s_addr;
}
- if (lease->options[DHO_CLASSLESS_STATIC_ROUTES].len) {
+ if (lease->options[DHO_CLASSLESS_STATIC_ROUTES].len != 0) {
opt = &lease->options[DHO_CLASSLESS_STATIC_ROUTES];
/* XXX */
if (opt->len < sizeof(proposal->rtstatic)) {
@@ -1895,7 +1895,7 @@ lease_as_proposal(struct client_lease *lease)
proposal->addrs |= RTA_STATIC;
} else
log_warnx("CLASSLESS_STATIC_ROUTES too long");
- } else if (lease->options[DHO_CLASSLESS_MS_STATIC_ROUTES].len) {
+ } else if (lease->options[DHO_CLASSLESS_MS_STATIC_ROUTES].len != 0) {
opt = &lease->options[DHO_CLASSLESS_MS_STATIC_ROUTES];
/* XXX */
if (opt->len < sizeof(proposal->rtstatic)) {
@@ -1915,7 +1915,7 @@ lease_as_proposal(struct client_lease *lease)
}
}
- if (lease->options[DHO_DOMAIN_SEARCH].len) {
+ if (lease->options[DHO_DOMAIN_SEARCH].len != 0) {
opt = &lease->options[DHO_DOMAIN_SEARCH];
buf = pretty_print_domain_search(opt->data, opt->len);
if (buf == NULL )
@@ -1925,7 +1925,7 @@ lease_as_proposal(struct client_lease *lease)
memcpy(proposal->rtsearch, buf, proposal->rtsearch_len);
proposal->addrs |= RTA_SEARCH;
}
- } else if (lease->options[DHO_DOMAIN_NAME].len) {
+ } else if (lease->options[DHO_DOMAIN_NAME].len != 0) {
opt = &lease->options[DHO_DOMAIN_NAME];
if (opt->len < sizeof(proposal->rtsearch)) {
proposal->rtsearch_len = opt->len;
@@ -1934,7 +1934,7 @@ lease_as_proposal(struct client_lease *lease)
} else
log_warnx("DOMAIN_NAME too long");
}
- if (&lease->options[DHO_DOMAIN_NAME_SERVERS].len) {
+ if (&lease->options[DHO_DOMAIN_NAME_SERVERS].len != 0) {
int servers;
opt = &lease->options[DHO_DOMAIN_NAME_SERVERS];
servers = opt->len / sizeof(struct in_addr);
@@ -1976,14 +1976,14 @@ lease_as_string(char *ifname, char *type, struct client_lease *lease)
append_statement(string, sizeof(string), " next-server ",
inet_ntoa(lease->next_server));
- if (lease->filename) {
+ if (lease->filename != NULL) {
buf = pretty_print_string(lease->filename,
strlen(lease->filename), 1);
if (buf == NULL)
return NULL;
append_statement(string, sizeof(string), " filename ", buf);
}
- if (lease->server_name) {
+ if (lease->server_name != NULL) {
buf = pretty_print_string(lease->server_name,
strlen(lease->server_name), 1);
if (buf == NULL)
@@ -2042,7 +2042,7 @@ go_daemon(void)
{
static int state = 0;
- if (!daemonize || state)
+ if (daemonize == 0 || state != 0)
return;
state = 1;
@@ -2103,9 +2103,9 @@ res_hnok(const char *name)
if (ch == '.') {
;
} else if (pch == '.' || nch == '.' || nch == '\0') {
- if (!isalnum(ch))
+ if (isalnum(ch) == 0)
return 0;
- } else if (!isalnum(ch) && ch != '-' && ch != '_') {
+ } else if (isalnum(ch) == 0 && ch != '-' && ch != '_') {
return 0;
} else if (ch == '_' && warn == 0) {
log_warnx("warning: hostname %s contains an "
@@ -2199,7 +2199,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
continue;
}
- if (nfds == 0 || !(pfd[0].revents & POLLIN))
+ if (nfds == 0 || (pfd[0].revents & POLLIN) == 0)
continue;
if ((n = imsg_read(priv_ibuf)) == -1 && errno != EAGAIN) {
@@ -2216,7 +2216,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
got_imsg_hup = dispatch_imsg(ifi->name, ifi->rdomain, ioctlfd,
routefd, priv_ibuf);
- if (got_imsg_hup)
+ if (got_imsg_hup != 0)
quit = SIGHUP;
}
close(routefd);
@@ -2226,7 +2226,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
close(fd);
if (quit == SIGHUP) {
- if (!got_imsg_hup)
+ if (got_imsg_hup == 0)
log_warnx("%s; restarting.", strsignal(quit));
signal(SIGHUP, SIG_IGN); /* will be restored after exec */
execvp(saved_argv[0], saved_argv);
@@ -2264,7 +2264,7 @@ get_ifname(struct interface_info *ifi, int ioctlfd, char *arg)
for (ifg = ifgr.ifgr_groups;
ifg && len >= sizeof(struct ifg_req); ifg++) {
len -= sizeof(struct ifg_req);
- if (arg)
+ if (arg != NULL)
fatalx("too many interfaces in group egress");
arg = ifg->ifgrq_member;
}
@@ -2287,11 +2287,11 @@ apply_defaults(struct client_lease *lease)
if (newlease == NULL)
fatalx("Unable to clone lease");
- if (config->filename) {
+ if (config->filename != NULL) {
free(newlease->filename);
newlease->filename = strdup(config->filename);
}
- if (config->server_name) {
+ if (config->server_name != NULL) {
free(newlease->server_name);
newlease->server_name = strdup(config->server_name);
}
@@ -2396,7 +2396,7 @@ apply_defaults(struct client_lease *lease)
return newlease;
cleanup:
- if (newlease) {
+ if (newlease != NULL) {
newlease->is_static = 0;
free_client_lease(newlease);
}
@@ -2426,17 +2426,17 @@ clone_lease(struct client_lease *oldlease)
memcpy(newlease->ssid, oldlease->ssid, sizeof(newlease->ssid));
newlease->ssid_len = oldlease->ssid_len;
- if (oldlease->server_name) {
+ if (oldlease->server_name != NULL) {
newlease->server_name = strdup(oldlease->server_name);
if (newlease->server_name == NULL)
goto cleanup;
}
- if (oldlease->filename) {
+ if (oldlease->filename != NULL) {
newlease->filename = strdup(oldlease->filename);
if (newlease->filename == NULL)
goto cleanup;
}
- if (oldlease->resolv_conf) {
+ if (oldlease->resolv_conf != NULL) {
newlease->resolv_conf = strdup(oldlease->resolv_conf);
if (newlease->resolv_conf == NULL)
goto cleanup;
@@ -2457,7 +2457,7 @@ clone_lease(struct client_lease *oldlease)
return newlease;
cleanup:
- if (newlease) {
+ if (newlease != NULL) {
newlease->is_static = 0;
free_client_lease(newlease);
}
@@ -2615,7 +2615,7 @@ take_charge(struct interface_info *ifi, int routefd)
continue;
fatal("routefd poll");
}
- if ((fds[0].revents & (POLLIN | POLLHUP)))
+ if ((fds[0].revents & (POLLIN | POLLHUP)) != 0)
routehandler(ifi, routefd);
}
}
@@ -2642,13 +2642,13 @@ get_recorded_lease(struct interface_info *ifi)
memcmp(lp->options[i].data, config->send_options[i].data,
lp->options[i].len)))
continue;
- if (addressinuse(ifi->name, lp->address, ifname) &&
+ if (addressinuse(ifi->name, lp->address, ifname) != 0 &&
strncmp(ifname, ifi->name, IF_NAMESIZE) != 0)
continue;
if (lp->is_static == 0 && lp->expiry <= cur_time)
continue;
- if (lp->is_static)
+ if (lp->is_static != 0)
set_lease_times(lp);
break;
}
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 43ab9708c8e..6536c2c6fb6 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.133 2017/07/14 13:08:41 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.134 2017/07/14 16:21:03 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -111,7 +111,7 @@ get_hw_address(struct interface_info *ifi)
ifi->flags |= IFI_VALID_LLADDR;
}
- if (!found)
+ if (found == 0)
fatalx("%s: no such interface", ifi->name);
freeifaddrs(ifap);
@@ -134,7 +134,7 @@ dispatch(struct interface_info *ifi, int routefd)
sendhup();
}
- if (ifi->timeout_func) {
+ if (ifi->timeout_func != NULL) {
time(&cur_time);
if (ifi->timeout <= cur_time) {
func = ifi->timeout_func;
@@ -181,16 +181,16 @@ dispatch(struct interface_info *ifi, int routefd)
}
}
- if ((fds[0].revents & (POLLIN | POLLHUP))) {
+ if ((fds[0].revents & (POLLIN | POLLHUP)) != 0) {
do {
packethandler(ifi);
} while (ifi->rbuf_offset < ifi->rbuf_len);
}
- if ((fds[1].revents & (POLLIN | POLLHUP)))
+ if ((fds[1].revents & (POLLIN | POLLHUP)) != 0)
routehandler(ifi, routefd);
- if (fds[2].revents & POLLOUT)
+ if ((fds[2].revents & POLLOUT) != 0)
flush_unpriv_ibuf("dispatch");
- if ((fds[2].revents & (POLLIN | POLLHUP))) {
+ if ((fds[2].revents & (POLLIN | POLLHUP)) != 0) {
/* Pipe to [priv] closed. Assume it emitted error. */
quit = INTERNALSIG;
}
@@ -323,7 +323,7 @@ packethandler(struct interface_info *ifi)
if (rslt == -1)
fatalx("no memory for info string");
- if (handler)
+ if (handler != NULL)
(*handler)(ifi, options, info);
free(info);
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c
index 3df98ad2046..930a19d6024 100644
--- a/sbin/dhclient/kroute.c
+++ b/sbin/dhclient/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.108 2017/07/14 14:03:15 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.109 2017/07/14 16:21:03 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
@@ -182,7 +182,7 @@ priv_flush_routes(char *name, int routefd, int rdomain)
break;
}
- if (errmsg) {
+ if (errmsg != NULL) {
log_warn("route cleanup failed - %s (msize=%zu)", errmsg,
needed);
free(buf);
@@ -349,7 +349,7 @@ add_classless_static_routes(struct option_data *opt, struct in_addr iface)
else if (i + bytes > opt->len)
return;
- if (bits)
+ if (bits != 0)
netmask.s_addr = htonl(0xffffffff << (32 - bits));
else
netmask.s_addr = INADDR_ANY;
@@ -548,9 +548,9 @@ delete_addresses(char *name)
fatal("delete_addresses getifaddrs");
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
- if ((ifa->ifa_flags & IFF_LOOPBACK) ||
- (ifa->ifa_flags & IFF_POINTOPOINT) ||
- (!(ifa->ifa_flags & IFF_UP)) ||
+ if ((ifa->ifa_flags & IFF_LOOPBACK) != 0 ||
+ (ifa->ifa_flags & IFF_POINTOPOINT) != 0 ||
+ ((ifa->ifa_flags & IFF_UP) == 0) ||
(ifa->ifa_addr->sa_family != AF_INET) ||
(strcmp(name, ifa->ifa_name) != 0))
continue;
@@ -744,7 +744,7 @@ priv_write_resolv_conf(uint8_t *contents, size_t sz)
}
/*
- * resolve_conf_priority decides if the interface is the best one to
+ * resolv_conf_priority decides if the interface is the best one to
* suppy the contents of the resolv.conf file.
*/
int
@@ -815,7 +815,7 @@ resolv_conf_priority(int rdomain, int routefd)
if (m_rtmsg.m_rtm.rtm_type == RTM_GET &&
m_rtmsg.m_rtm.rtm_pid == pid &&
m_rtmsg.m_rtm.rtm_seq == seq) {
- if (m_rtmsg.m_rtm.rtm_errno) {
+ if (m_rtmsg.m_rtm.rtm_errno != 0) {
log_warnx("default route read rtm: %s",
strerror(m_rtmsg.m_rtm.rtm_errno));
goto done;
@@ -850,7 +850,7 @@ resolv_conf_contents(char *name,
memset(nss, 0, sizeof(nss));
- if (domainsearch->len) {
+ if (domainsearch->len != 0) {
buf = pretty_print_domain_search(domainsearch->data,
domainsearch->len);
if (buf == NULL)
@@ -860,7 +860,7 @@ resolv_conf_contents(char *name,
if (rslt == -1)
dn = NULL;
}
- } else if (domainname->len) {
+ } else if (domainname->len != 0) {
rslt = asprintf(&dn, "search %s\n",
pretty_print_option(DHO_DOMAIN_NAME, domainname, 0));
if (rslt == -1)
@@ -870,7 +870,7 @@ resolv_conf_contents(char *name,
if (dn == NULL)
fatalx("no memory for domainname");
- if (nameservers->len) {
+ if (nameservers->len != 0) {
ns = pretty_print_option(DHO_DOMAIN_NAME_SERVERS, nameservers,
0);
for (i = 0; i < MAXNS; i++) {
@@ -887,7 +887,7 @@ resolv_conf_contents(char *name,
len = strlen(dn);
for (i = 0; i < MAXNS; i++)
- if (nss[i])
+ if (nss[i] != NULL)
len += strlen(nss[i]);
if (len > 0 && config->resolv_tail)
@@ -915,7 +915,7 @@ resolv_conf_contents(char *name,
free(dn);
for (i = 0; i < MAXNS; i++) {
- if (nss[i]) {
+ if (nss[i] != NULL) {
strlcat(contents, nss[i], len);
free(nss[i]);
}
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c
index 3998274b111..476ae835d0b 100644
--- a/sbin/dhclient/options.c
+++ b/sbin/dhclient/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.100 2017/07/14 14:03:15 krw Exp $ */
+/* $OpenBSD: options.c,v 1.101 2017/07/14 16:21:03 krw Exp $ */
/* DHCP options parsing and reassembly. */
@@ -503,7 +503,7 @@ pack_options(unsigned char *buf, int buflen, struct option_data *options)
memset(buf, 0, buflen);
memcpy(buf, DHCP_OPTIONS_COOKIE, 4);
- if (options[DHO_DHCP_MESSAGE_TYPE].data) {
+ if (options[DHO_DHCP_MESSAGE_TYPE].data != NULL) {
memcpy(&buf[4], DHCP_OPTIONS_MESSAGE_TYPE, 3);
buf[6] = options[DHO_DHCP_MESSAGE_TYPE].data[0];
bufix = 7;
@@ -559,7 +559,7 @@ pretty_print_string(unsigned char *src, size_t srclen, int emit_punct)
memset(string, 0, sizeof(string));
- if (emit_punct)
+ if (emit_punct != 0)
rslt = strlcat(string, "\"", sizeof(string));
for (; src < origsrc + srclen; src++) {
@@ -570,7 +570,7 @@ pretty_print_string(unsigned char *src, size_t srclen, int emit_punct)
rslt = strlcat(string, visbuf, sizeof(string));
}
- if (emit_punct)
+ if (emit_punct != 0)
rslt = strlcat(string, "\"", sizeof(string));
if (rslt >= sizeof(string))
@@ -649,7 +649,7 @@ expand_search_domain_name(unsigned char *src, size_t srclen, int *offset,
*/
*offset = i + 1;
return domain_name_len;
- } else if (label_len & 0xC0) {
+ } else if ((label_len & 0xC0) != 0) {
/* This is a pointer to another list of labels. */
if (i + 1 >= srclen) {
/* The pointer is truncated. */
@@ -774,7 +774,7 @@ pretty_print_option(unsigned int code, struct option_data *option,
goto done;
}
- if (emit_punct)
+ if (emit_punct != 0)
comma = ',';
else
comma = ' ';
@@ -797,7 +797,7 @@ pretty_print_option(unsigned int code, struct option_data *option,
/* Figure out the size of the data. */
for (i = 0; fmt[i]; i++) {
- if (!numhunk) {
+ if (numhunk == 0) {
log_warnx("%s: Excess information in format string: "
"%s", name, &fmt[i]);
goto done;
@@ -817,8 +817,8 @@ pretty_print_option(unsigned int code, struct option_data *option,
break;
case 'X':
for (k = 0; k < len; k++)
- if (!isascii(data[k]) ||
- !isprint(data[k]))
+ if (isascii(data[k]) == 0 ||
+ isprint(data[k]) == 0)
break;
if (k == len) {
fmtbuf[i] = 't';
@@ -869,7 +869,7 @@ pretty_print_option(unsigned int code, struct option_data *option,
}
/* If this is an array, compute its size. */
- if (!numhunk)
+ if (numhunk == 0)
numhunk = len / hunksize;
/* See if we got an exact number of hunks. */
if (numhunk > 0 && numhunk * hunksize != len) {
@@ -982,13 +982,13 @@ unpack_options(struct dhcp_packet *packet)
sizeof(packet->options) - 4);
/* DHCP packets can also use overload areas for options. */
- if (options[DHO_DHCP_MESSAGE_TYPE].data &&
- options[DHO_DHCP_OPTION_OVERLOAD].data) {
- if (options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 1)
+ if (options[DHO_DHCP_MESSAGE_TYPE].data != NULL &&
+ options[DHO_DHCP_OPTION_OVERLOAD].data != NULL) {
+ if ((options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 1) != 0)
parse_option_buffer(options,
(unsigned char *)packet->file,
sizeof(packet->file));
- if (options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2)
+ if ((options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2) != 0)
parse_option_buffer(options,
(unsigned char *)packet->sname,
sizeof(packet->sname));
diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c
index 24bc629fd43..0fda00f9034 100644
--- a/sbin/dhclient/packet.c
+++ b/sbin/dhclient/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.39 2017/07/10 00:47:47 krw Exp $ */
+/* $OpenBSD: packet.c,v 1.40 2017/07/14 16:21:03 krw Exp $ */
/* Packet assembly code, originally contributed by Archie Cobbs. */
@@ -214,7 +214,7 @@ decode_udp_ip_header(unsigned char *buf, uint32_t buflen,
IPPROTO_UDP + (uint32_t)ntohs(udp->uh_ulen)))));
udp_packets_seen++;
- if (usum && usum != sum) {
+ if (usum != 0 && usum != sum) {
udp_packets_bad_checksum++;
if (udp_packets_seen > 4 && udp_packets_bad_checksum != 0 &&
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c
index d88041614f1..fcf366af8a4 100644
--- a/sbin/dhclient/parse.c
+++ b/sbin/dhclient/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.59 2017/07/14 14:03:15 krw Exp $ */
+/* $OpenBSD: parse.c,v 1.60 2017/07/14 16:21:03 krw Exp $ */
/* Common parser code for dhcpd and dhclient. */
@@ -88,8 +88,8 @@ skip_to_semi(FILE *cfile)
do {
token = peek_token(NULL, cfile);
if (token == '}') {
- if (brace_count) {
- if (!--brace_count) {
+ if (brace_count > 0) {
+ if (--brace_count == 0) {
token = next_token(NULL, cfile);
return;
}
@@ -97,7 +97,7 @@ skip_to_semi(FILE *cfile)
return;
} else if (token == '{') {
brace_count++;
- } else if (token == ';' && !brace_count) {
+ } else if (token == ';' && brace_count == 0) {
token = next_token(NULL, cfile);
return;
} else if (token == '\n') {
@@ -172,7 +172,7 @@ parse_cidr(FILE *cfile, unsigned char *cidr)
token = '.';
len = 0;
for (token = '.'; token == '.'; token = next_token(NULL, cfile)) {
- if (!parse_decimal(cfile, cidr + 1 + len, 'B'))
+ if (parse_decimal(cfile, cidr + 1 + len, 'B') == 0)
break;
if (++len == sizeof(addr)) {
token = next_token(NULL, cfile);
@@ -180,7 +180,7 @@ parse_cidr(FILE *cfile, unsigned char *cidr)
}
}
- if (!len) {
+ if (len == 0) {
parse_warn("expecting decimal value.");
skip_to_semi(cfile);
return 0;
@@ -188,7 +188,7 @@ parse_cidr(FILE *cfile, unsigned char *cidr)
parse_warn("expecting '/'.");
skip_to_semi(cfile);
return 0;
- } else if (!parse_decimal(cfile, cidr, 'B') || *cidr > 32) {
+ } else if (parse_decimal(cfile, cidr, 'B') == 0 || *cidr > 32) {
parse_warn("expecting decimal value <= 32.");
skip_to_semi(cfile);
return 0;
@@ -206,7 +206,7 @@ parse_ip_addr(FILE *cfile, struct in_addr *addr)
token = '.';
len = 0;
for (token = '.'; token == '.'; token = next_token(NULL, cfile)) {
- if (!parse_decimal(cfile, (unsigned char *)&buf + len, 'B'))
+ if (parse_decimal(cfile, (unsigned char *)&buf + len, 'B') == 0)
break;
if (++len == sizeof(buf))
break;
@@ -234,7 +234,7 @@ parse_lease_time(FILE *cfile, time_t *timep)
{
uint32_t value;
- if (!parse_decimal(cfile, (char *)&value, 'L')) {
+ if (parse_decimal(cfile, (char *)&value, 'L') == 0) {
parse_warn("expecting unsigned 32-bit decimal value.");
skip_to_semi(cfile);
return;
@@ -252,7 +252,7 @@ parse_boolean(FILE *cfile, unsigned char *buf)
int token;
token = next_token(&val, cfile);
- if (is_identifier(token)) {
+ if (is_identifier(token) != 0) {
if (strcasecmp(val, "true") == 0 ||
strcasecmp(val, "on") == 0) {
buf[0] = 1;
@@ -304,7 +304,7 @@ parse_decimal(FILE *cfile, unsigned char *buf, char fmt)
}
numval = strtonum(val, low, high, &errstr);
- if (errstr)
+ if (errstr != NULL)
return 0;
numval = htobe64(numval);
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index d303e17728c..243df461d98 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.56 2017/07/10 14:11:47 krw Exp $ */
+/* $OpenBSD: privsep.c,v 1.57 2017/07/14 16:21:03 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -93,7 +93,7 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_WRITE_RESOLV_CONF:
if (imsg.hdr.len <= IMSG_HEADER_SIZE)
log_warnx("short IMSG_WRITE_RESOLV_CONF");
- else if (resolv_conf_priority(rdomain, routefd))
+ else if (resolv_conf_priority(rdomain, routefd) != 0)
priv_write_resolv_conf(imsg.data,
imsg.hdr.len - IMSG_HEADER_SIZE);
break;