]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Return early to make code more readable.
authorRoy Marples <roy@marples.name>
Mon, 10 Oct 2016 08:46:41 +0000 (08:46 +0000)
committerRoy Marples <roy@marples.name>
Mon, 10 Oct 2016 08:46:41 +0000 (08:46 +0000)
arp.c

diff --git a/arp.c b/arp.c
index 330ea092684f967f796fce0196cd95d04ec69eb8..b6c08b6ad378f7f7264814a696ff49f70d359ec5 100644 (file)
--- 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;
        }
 }