summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2014-11-26 17:34:36 +0000
committerkrw <krw@openbsd.org>2014-11-26 17:34:36 +0000
commitbbf7feffa2a95ae416db8de80aa7ce2b077433b2 (patch)
treed8e4d75e81a8281cff4b59d2706a272611423127
parentMake option string/struct const (since it is...). I've had this (diff)
downloadwireguard-openbsd-bbf7feffa2a95ae416db8de80aa7ce2b077433b2.tar.xz
wireguard-openbsd-bbf7feffa2a95ae416db8de80aa7ce2b077433b2.zip
'ifi' is successfully calloc'd during initialization or dhclient
exits, so there is no need to constantly check if 'ifi' is NULL. Similarly 'ifi->bfdesc' is successfully opened during initialization or dhclient exits, so there is no point in constantly checking if it has regressed to -1. Finally, no need to check 'ifi->linkstat' before trying to read a packet. If there is a packet it should just as well be read immediately rather than waiting for the link to reappear and confuse things. No intentional functional change.
-rw-r--r--sbin/dhclient/dispatch.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 3396c9e9d4c..b4cb665ea0b 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.95 2014/11/26 00:15:36 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.96 2014/11/26 17:34:36 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -105,21 +105,11 @@ dispatch(void)
void (*func)(void);
while (quit == 0) {
- if (!ifi) {
- warning("No interface!");
- quit = INTERNALSIG;
- continue;
- }
if (ifi->rdomain != get_rdomain(ifi->name)) {
warning("%s rdomain changed; exiting", ifi->name);
quit = INTERNALSIG;
continue;
}
- if (ifi->bfdesc == -1) {
- warning("%s bpf socket gone; exiting", ifi->name);
- quit = INTERNALSIG;
- continue;
- }
if (timeout.func) {
time(&cur_time);
@@ -168,17 +158,12 @@ dispatch(void)
}
}
- if ((fds[0].revents & (POLLIN | POLLHUP))) {
- if (ifi && ifi->linkstat && ifi->bfdesc != -1)
- packethandler();
- }
- if ((fds[1].revents & (POLLIN | POLLHUP))) {
- if (ifi)
- routehandler();
- }
- if (fds[2].revents & POLLOUT) {
+ if ((fds[0].revents & (POLLIN | POLLHUP)))
+ packethandler();
+ if ((fds[1].revents & (POLLIN | POLLHUP)))
+ routehandler();
+ if (fds[2].revents & POLLOUT)
flush_unpriv_ibuf("dispatch");
- }
if ((fds[2].revents & (POLLIN | POLLHUP))) {
/* Pipe to [priv] closed. Assume it emitted error. */
quit = INTERNALSIG;