summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2008-09-15 20:38:18 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2008-09-15 20:38:18 +0000
commitbfe0cc990d0e009e066a5d9f0df3a54522b0abcf (patch)
treec5c6686938aa1a0a84b6bca2a35a09ce2026d988 /usr.sbin
parent2b18e9efee06760a43443f3d47923841b2be512f (diff)
When checking if a syscall like open(), ioctl() or writev() failed compare
directly against -1 and do not use a < 0 test. OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/dhcpd/bpf.c22
-rw-r--r--usr.sbin/dhcpd/dispatch.c6
-rw-r--r--usr.sbin/dhcpd/icmp.c8
-rw-r--r--usr.sbin/dhcpd/sync.c4
4 files changed, 20 insertions, 20 deletions
diff --git a/usr.sbin/dhcpd/bpf.c b/usr.sbin/dhcpd/bpf.c
index cdc4e78cde5..ce3cd3b76b7 100644
--- a/usr.sbin/dhcpd/bpf.c
+++ b/usr.sbin/dhcpd/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.6 2005/07/29 17:26:28 krw Exp $ */
+/* $OpenBSD: bpf.c,v 1.7 2008/09/15 20:38:17 claudio Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -67,7 +67,7 @@ if_register_bpf(struct interface_info *info)
for (b = 0; 1; b++) {
snprintf(filename, sizeof(filename), BPF_FORMAT, b);
sock = open(filename, O_RDWR, 0);
- if (sock < 0) {
+ if (sock == -1) {
if (errno == EBUSY)
continue;
else
@@ -77,7 +77,7 @@ if_register_bpf(struct interface_info *info)
}
/* Set the BPF device to point at this interface. */
- if (ioctl(sock, BIOCSETIF, info->ifp) < 0)
+ if (ioctl(sock, BIOCSETIF, info->ifp) == -1)
error("Can't attach interface %s to bpf device %s: %m",
info->name, filename);
@@ -176,7 +176,7 @@ if_register_receive(struct interface_info *info)
info->rfdesc = if_register_bpf(info);
/* Make sure the BPF version is in range... */
- if (ioctl(info->rfdesc, BIOCVERSION, &v) < 0)
+ if (ioctl(info->rfdesc, BIOCVERSION, &v) == -1)
error("Can't get BPF version: %m");
if (v.bv_major != BPF_MAJOR_VERSION ||
@@ -188,15 +188,15 @@ if_register_receive(struct interface_info *info)
* comes in, rather than waiting for the input buffer to fill
* with packets.
*/
- if (ioctl(info->rfdesc, BIOCIMMEDIATE, &flag) < 0)
+ if (ioctl(info->rfdesc, BIOCIMMEDIATE, &flag) == -1)
error("Can't set immediate mode on bpf device: %m");
/* make sure kernel fills in the source ethernet address */
- if (ioctl(info->rfdesc, BIOCSHDRCMPLT, &cmplt) < 0)
+ if (ioctl(info->rfdesc, BIOCSHDRCMPLT, &cmplt) == -1)
error("Can't set header complete flag on bpf device: %m");
/* Get the required BPF buffer length from the kernel. */
- if (ioctl(info->rfdesc, BIOCGBLEN, &sz) < 0)
+ if (ioctl(info->rfdesc, BIOCGBLEN, &sz) == -1)
error("Can't get bpf buffer length: %m");
info->rbuf_max = sz;
info->rbuf = malloc(info->rbuf_max);
@@ -210,18 +210,18 @@ if_register_receive(struct interface_info *info)
p.bf_len = dhcp_bpf_filter_len;
p.bf_insns = dhcp_bpf_filter;
- if (ioctl(info->rfdesc, BIOCSETF, &p) < 0)
+ if (ioctl(info->rfdesc, BIOCSETF, &p) == -1)
error("Can't install packet filter program: %m");
/* Set up the bpf write filter program structure. */
p.bf_len = dhcp_bpf_wfilter_len;
p.bf_insns = dhcp_bpf_wfilter;
- if (ioctl(info->rfdesc, BIOCSETWF, &p) < 0)
+ if (ioctl(info->rfdesc, BIOCSETWF, &p) == -1)
error("Can't install write filter program: %m");
/* make sure these settings cannot be changed after dropping privs */
- if (ioctl(info->rfdesc, BIOCLOCK) < 0)
+ if (ioctl(info->rfdesc, BIOCLOCK) == -1)
error("Failed to lock bpf descriptor: %m");
}
@@ -246,7 +246,7 @@ send_packet(struct interface_info *interface, struct dhcp_packet *raw,
iov[1].iov_len = len;
result = writev(interface->wfdesc, iov, 2);
- if (result < 0)
+ if (result == -1)
warning("send_packet: %m");
return (result);
}
diff --git a/usr.sbin/dhcpd/dispatch.c b/usr.sbin/dhcpd/dispatch.c
index 35bedebdbef..b33502af8bd 100644
--- a/usr.sbin/dhcpd/dispatch.c
+++ b/usr.sbin/dhcpd/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.23 2008/05/07 12:19:20 beck Exp $ */
+/* $OpenBSD: dispatch.c,v 1.24 2008/09/15 20:38:17 claudio Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998, 1999
@@ -419,7 +419,7 @@ interface_status(struct interface_info *ifinfo)
/* get interface flags */
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
- if (ioctl(ifsock, SIOCGIFFLAGS, &ifr) < 0) {
+ if (ioctl(ifsock, SIOCGIFFLAGS, &ifr) == -1) {
syslog(LOG_ERR, "ioctl(SIOCGIFFLAGS) on %s: %m", ifname);
goto inactive;
}
@@ -435,7 +435,7 @@ interface_status(struct interface_info *ifinfo)
goto active;
memset(&ifmr, 0, sizeof(ifmr));
strlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name));
- if (ioctl(ifsock, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
+ if (ioctl(ifsock, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) {
if (errno != EINVAL) {
syslog(LOG_DEBUG, "ioctl(SIOCGIFMEDIA) on %s: %m",
ifname);
diff --git a/usr.sbin/dhcpd/icmp.c b/usr.sbin/dhcpd/icmp.c
index 6df90da95f4..d96fc6b324b 100644
--- a/usr.sbin/dhcpd/icmp.c
+++ b/usr.sbin/dhcpd/icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp.c,v 1.9 2004/09/16 18:35:43 deraadt Exp $ */
+/* $OpenBSD: icmp.c,v 1.10 2008/09/15 20:38:17 claudio Exp $ */
/*
* Copyright (c) 1997, 1998 The Internet Software Consortium.
@@ -70,7 +70,7 @@ icmp_startup(int routep, void (*handler)(struct iaddr, u_int8_t *, int))
/* Make sure it does routing... */
state = 0;
if (setsockopt(icmp_protocol_fd, SOL_SOCKET, SO_DONTROUTE,
- &state, sizeof(state)) < 0)
+ &state, sizeof(state)) == -1)
error("Unable to disable SO_DONTROUTE on ICMP socket: %m");
add_protocol("icmp", icmp_protocol_fd, icmp_echoreply, (void *)handler);
@@ -103,7 +103,7 @@ icmp_echorequest(struct iaddr *addr)
/* Send the ICMP packet... */
status = sendto(icmp_protocol_fd, &icmp, sizeof(icmp), 0,
(struct sockaddr *)&to, sizeof(to));
- if (status < 0)
+ if (status == -1)
warning("icmp_echorequest %s: %m", inet_ntoa(to.sin_addr));
if (status != sizeof icmp)
@@ -125,7 +125,7 @@ icmp_echoreply(struct protocol *protocol)
salen = sizeof from;
status = recvfrom(protocol->fd, icbuf, sizeof(icbuf), 0,
(struct sockaddr *)&from, &salen);
- if (status < 0) {
+ if (status == -1) {
warning("icmp_echoreply: %m");
return;
}
diff --git a/usr.sbin/dhcpd/sync.c b/usr.sbin/dhcpd/sync.c
index a9276813857..50c0baf42cb 100644
--- a/usr.sbin/dhcpd/sync.c
+++ b/usr.sbin/dhcpd/sync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sync.c,v 1.6 2008/05/30 05:58:20 deraadt Exp $ */
+/* $OpenBSD: sync.c,v 1.7 2008/09/15 20:38:17 claudio Exp $ */
/*
* Copyright (c) 2008 Bob Beck <beck@openbsd.org>
@@ -218,7 +218,7 @@ sync_init(const char *iface, const char *baddr, u_short port)
goto fail;
}
if (setsockopt(syncfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
- sizeof(ttl)) < 0) {
+ sizeof(ttl)) == -1) {
fprintf(stderr, "failed to set multicast ttl to "
"%u: %s\n", ttl, strerror(errno));
setsockopt(syncfd, IPPROTO_IP,