diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-07-21 09:58:56 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-07-21 09:58:56 +0000 |
commit | c4f8be6d9ec57742aa6ac11d67eca9928500c064 (patch) | |
tree | 3829470efbc1f5dbbf7434589daac7d42ca2e6f3 | |
parent | 347942d23de815c810539daf60806d3999754c3b (diff) |
Use explicit idiom when testing the result of strcmp() and strncmp().
i.e. == 0 and != 0 as appropriate. No intentional functional change.
Suggested by & ok tom@
-rw-r--r-- | sbin/dhclient/dhclient.c | 20 | ||||
-rw-r--r-- | sbin/dhclient/dispatch.c | 4 | ||||
-rw-r--r-- | sbin/dhclient/kroute.c | 6 |
3 files changed, 15 insertions, 15 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index e05c1ed6561..691f23ae71f 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.376 2016/07/20 19:40:04 deraadt Exp $ */ +/* $OpenBSD: dhclient.c,v 1.377 2016/07/21 09:58:55 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -736,14 +736,14 @@ state_reboot(void) if (client->active->expiry <= cur_time) client->active = NULL; else if (addressinuse(client->active->address, ifname) && - strncmp(ifname, ifi->name, IF_NAMESIZE)) + strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) client->active = NULL; } /* Run through the list of leases and see if one can be used. */ TAILQ_FOREACH(lp, &client->leases, next) { if (addressinuse(lp->address, ifname) && - strncmp(ifname, ifi->name, IF_NAMESIZE)) + strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) continue; if (client->active || lp->is_static) break; @@ -1156,7 +1156,7 @@ addressinuse(struct in_addr address, char *ifname) if (memcmp(&address, &sin->sin_addr, sizeof(address)) == 0) { strlcpy(ifname, ifa->ifa_name, IF_NAMESIZE); used = 1; - if (strncmp(ifname, ifi->name, IF_NAMESIZE)) + if (strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) break; } } @@ -1188,7 +1188,7 @@ packet_to_lease(struct in_addr client_addr, struct option_data *options) if (options[i].len == 0) continue; if (!unknown_ok && strncmp("option-", - dhcp_options[i].name, 7)) { + dhcp_options[i].name, 7) != 0) { warning("dhcpoffer: unknown option %d", i); lease->is_invalid = 1; } @@ -1258,7 +1258,7 @@ packet_to_lease(struct in_addr client_addr, struct option_data *options) lease->address.s_addr = client->packet.yiaddr.s_addr; memset(ifname, 0, sizeof(ifname)); if (addressinuse(lease->address, ifname) && - strncmp(ifname, ifi->name, IF_NAMESIZE)) { + strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) { warning("%s already configured on %s", inet_ntoa(lease->address), ifname); lease->is_invalid = 1; @@ -1421,7 +1421,7 @@ state_panic(void) time(&cur_time); TAILQ_FOREACH(lp, &client->leases, next) { if (addressinuse(lp->address, ifname) && - strncmp(ifname, ifi->name, IF_NAMESIZE)) + strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) continue; if (lp->is_static) { set_lease_times(lp); @@ -2162,7 +2162,7 @@ get_ifname(char *arg) struct ifg_req *ifg; int s, len; - if (!strcmp(arg, "egress")) { + if (strcmp(arg, "egress") == 0) { s = socket(AF_INET, SOCK_DGRAM, 0); if (s == -1) error("socket error"); @@ -2725,14 +2725,14 @@ compare_lease(struct client_lease *active, struct client_lease *new) if (active->server_name != new->server_name) { if (!active->server_name || !new->server_name) return (1); - if (strcmp(active->server_name, new->server_name)) + if (strcmp(active->server_name, new->server_name) != 0) return (1); } if (active->filename != new->filename) { if (!active->filename || !new->filename) return (1); - if (strcmp(active->filename, new->filename)) + if (strcmp(active->filename, new->filename) != 0) return (1); } diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index d396eb2b228..f3d8489c58f 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.105 2016/02/06 19:30:52 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.106 2016/07/21 09:58:55 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -90,7 +90,7 @@ get_hw_address(void) (!(ifa->ifa_flags & IFF_UP))) continue; - if (strcmp(ifi->name, ifa->ifa_name)) + if (strcmp(ifi->name, ifa->ifa_name) != 0) continue; found = 1; diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index c0eea23aeb5..66a5ea00c14 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.79 2016/02/06 19:30:52 krw Exp $ */ +/* $OpenBSD: kroute.c,v 1.80 2016/07/21 09:58:55 krw Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -329,7 +329,7 @@ delete_addresses(void) (ifa->ifa_flags & IFF_POINTOPOINT) || (!(ifa->ifa_flags & IFF_UP)) || (ifa->ifa_addr->sa_family != AF_INET) || - (strcmp(ifi->name, ifa->ifa_name))) + (strcmp(ifi->name, ifa->ifa_name) != 0)) continue; memcpy(&addr, &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr, @@ -681,7 +681,7 @@ check_route_label(struct sockaddr_rtlabel *label) if (!label) return (ROUTE_LABEL_NONE); - if (strncmp("DHCLIENT ", label->sr_label, 9)) + if (strncmp("DHCLIENT ", label->sr_label, 9) != 0) return (ROUTE_LABEL_NOT_DHCLIENT); pid = (pid_t)strtonum(label->sr_label + 9, 1, INT_MAX, NULL); |