From: Paul Donald Date: Thu, 13 Nov 2025 10:37:25 +0000 (+0100) Subject: dhcpv6: dhcpv6_handle_reply switch case handling X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=1259a32d7e4d6564195f1be30e5a3aa0ff0239c3;p=project%2Fodhcp6c.git dhcpv6: dhcpv6_handle_reply switch case handling shortens jumps and reduces branching. Signed-off-by: Paul Donald Link: https://github.com/openwrt/odhcp6c/pull/118 Signed-off-by: Álvaro Fernández Rojas --- diff --git a/src/dhcpv6.c b/src/dhcpv6.c index fc77fc8..0cf67e6 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -1556,14 +1556,16 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _o_unused const int rc, break; } - if (orig == DHCPV6_MSG_REQUEST) { + switch (orig) { + case DHCPV6_MSG_REQUEST: // All server candidates can be cleared if not yet bound if (!odhcp6c_is_bound()) dhcpv6_clear_all_server_cand(); odhcp6c_clear_state(STATE_SERVER_ADDR); odhcp6c_add_state(STATE_SERVER_ADDR, &from->sin6_addr, 16); - } else if (orig == DHCPV6_MSG_RENEW) { + break; + case DHCPV6_MSG_RENEW: // Send further renews if T1 is not set and if // there're IAs which were not in the Reply message if (!t1 && state_IAs != updated_IAs) { @@ -1584,7 +1586,8 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _o_unused const int rc, */ ret = -1; } - } else if (orig == DHCPV6_MSG_REBIND) { + break; + case DHCPV6_MSG_REBIND: odhcp6c_clear_state(STATE_SERVER_ADDR); odhcp6c_add_state(STATE_SERVER_ADDR, &from->sin6_addr, 16); @@ -1608,6 +1611,10 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _o_unused const int rc, */ ret = -1; } + break; + + default: + break; } break;