summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2021-03-01 15:56:00 +0000
committerflorian <florian@openbsd.org>2021-03-01 15:56:00 +0000
commit4b15555f05032b2b476611974f4a51507844874f (patch)
tree240225b1d9c937d1f584f84c72848d051c4898d9
parentLet send_rdns_withdraw and send_deconfigure_interface clean up after (diff)
downloadwireguard-openbsd-4b15555f05032b2b476611974f4a51507844874f.tar.xz
wireguard-openbsd-4b15555f05032b2b476611974f4a51507844874f.zip
We really must handle all possible enumeration values in
state_transition() and iface_timeout(). Let the compiler help us by emitting a warning when we missed one (-Wswitch). Reminded by jsg who pointed out that gcc is quite confused and thinks there is an out of bounds access in if_state_name[] in the default case. There is not, if_state_name[] and enum if_state have to be kept in sync. (Note that -Wswitch is not a silver bullet, it just happens to work here.)
-rw-r--r--sbin/dhcpleased/engine.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/sbin/dhcpleased/engine.c b/sbin/dhcpleased/engine.c
index 9329e9e05bf..e2dbd31c191 100644
--- a/sbin/dhcpleased/engine.c
+++ b/sbin/dhcpleased/engine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: engine.c,v 1.4 2021/03/01 15:54:49 florian Exp $ */
+/* $OpenBSD: engine.c,v 1.5 2021/03/01 15:56:00 florian Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
@@ -1134,9 +1134,6 @@ state_transition(struct dhcpleased_iface *iface, enum if_state new_state)
iface->timo.tv_sec /= 2;
request_dhcp_request(iface);
break;
- default:
- fatal("%s: unhandled state: %s", __func__,
- if_state_name[new_state]);
}
log_debug("%s %s -> %s, timo: %lld", __func__, if_state_name[old_state],
if_state_name[new_state], iface->timo.tv_sec);
@@ -1198,8 +1195,6 @@ iface_timeout(int fd, short events, void *arg)
else
state_transition(iface, IF_REBINDING);
break;
- default:
- break;
}
}