From: Roy Marples Date: Mon, 10 Oct 2016 08:46:41 +0000 (+0000) Subject: Return early to make code more readable. X-Git-Tag: v6.11.6~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9a6bea1fcb4d74fa62e212e31b9a4908d991230;p=thirdparty%2Fdhcpcd.git Return early to make code more readable. --- diff --git a/arp.c b/arp.c index 330ea092..b6c08b6a 100644 --- a/arp.c +++ b/arp.c @@ -384,28 +384,26 @@ arp_cancel(struct arp_state *astate) void arp_free(struct arp_state *astate) { + struct interface *ifp; + struct iarp_state *state; - if (astate != NULL) { - struct interface *ifp; - struct iarp_state *state; - - ifp = astate->iface; - eloop_timeout_delete(ifp->ctx->eloop, NULL, astate); - state = ARP_STATE(ifp); - TAILQ_REMOVE(&state->arp_states, astate, next); - if (astate->free_cb) - astate->free_cb(astate); - free(astate); - - /* If there are no more ARP states, close the socket. */ - if (state->fd != -1 && - TAILQ_FIRST(&state->arp_states) == NULL) - { - eloop_event_delete(ifp->ctx->eloop, state->fd); - if_closeraw(ifp, state->fd); - free(state); - ifp->if_data[IF_DATA_ARP] = NULL; - } + if (astate == NULL) + return; + + ifp = astate->iface; + eloop_timeout_delete(ifp->ctx->eloop, NULL, astate); + state = ARP_STATE(ifp); + TAILQ_REMOVE(&state->arp_states, astate, next); + if (astate->free_cb) + astate->free_cb(astate); + free(astate); + + /* If there are no more ARP states, close the socket. */ + if (state->fd != -1 && TAILQ_FIRST(&state->arp_states) == NULL) { + eloop_event_delete(ifp->ctx->eloop, state->fd); + if_closeraw(ifp, state->fd); + free(state); + ifp->if_data[IF_DATA_ARP] = NULL; } }