diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2021-03-01 15:56:01 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2021-03-01 15:56:01 +0000 |
commit | 3422ee18fa72bde98d0a95a374a418b07ace6512 (patch) | |
tree | ba362cb1c113a17b1436cc3a0eb0cec4bfa42bb7 | |
parent | c1fa27d4ef60f2665f9e39c6a4d364751c1a2766 (diff) |
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.c | 7 |
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; } } |