]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: Convert connected_free to a double pointer
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 30 Oct 2019 00:16:28 +0000 (20:16 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 2 Nov 2019 20:13:44 +0000 (16:13 -0400)
Set the connected pointer to set the pointer to NULL.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
17 files changed:
bgpd/bgp_zebra.c
eigrpd/eigrp_zebra.c
isisd/isis_zebra.c
ldpd/ldp_zebra.c
lib/if.c
lib/if.h
nhrpd/nhrp_interface.c
ospf6d/ospf6_zebra.c
ospfd/ospf_zebra.c
pbrd/pbr_zebra.c
pimd/pim_zebra.c
ripd/rip_interface.c
ripngd/ripng_interface.c
sharpd/sharp_zebra.c
staticd/static_zebra.c
zebra/connected.c
zebra/interface.c

index 7923f076c11906fa689192bf98bf424cd30e0c11..d0a732b153df0212eefc410e6c493ec9ce17d351 100644 (file)
@@ -357,7 +357,7 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
                bgp_connected_delete(bgp, ifc);
        }
 
-       connected_free(ifc);
+       connected_free(&ifc);
 
        return 0;
 }
index 9a0fdda0f927cc203051d0642db64f0914007f10..3205f13922a85e6305c8d253be932c007bd0ac17 100644 (file)
@@ -189,7 +189,7 @@ static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
        if (prefix_cmp(&ei->address, c->address) == 0)
                eigrp_if_free(ei, INTERFACE_DOWN_BY_ZEBRA);
 
-       connected_free(c);
+       connected_free(&c);
 
        return 0;
 }
index bdf6869f5cc5ccdb51bce334d689e50519c48446..b4c699ccbb5a05533caaa67af78b1d7c84cb200b 100644 (file)
@@ -128,7 +128,7 @@ static int isis_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
 
        if (if_is_operative(ifp))
                isis_circuit_del_addr(circuit_scan_by_ifp(ifp), c);
-       connected_free(c);
+       connected_free(&c);
 
        return 0;
 }
index 4df1fc0304b922dfe45dcc95f4b9a931f72037a5..946b51e4eea1a250b941cfb5f471acb5b1f42253 100644 (file)
@@ -368,7 +368,7 @@ ldp_interface_address_delete(ZAPI_CALLBACK_ARGS)
 
        ifp = ifc->ifp;
        ifc2kaddr(ifp, ifc, &ka);
-       connected_free(ifc);
+       connected_free(&ifc);
 
        /* Filter invalid addresses.  */
        if (bad_addr(ka.af, &ka.addr))
index a185d53ef78f661214fcf73893c4e9b27ce07e39..e61bf00283b59871a76b943239defec331e97e1e 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -140,6 +140,13 @@ static int if_cmp_index_func(const struct interface *ifp1,
        return ifp1->ifindex - ifp2->ifindex;
 }
 
+static void ifp_connected_free(void *arg)
+{
+       struct connected *c = arg;
+
+       connected_free(&c);
+}
+
 /* Create new interface structure. */
 static struct interface *if_new(vrf_id_t vrf_id)
 {
@@ -153,7 +160,7 @@ static struct interface *if_new(vrf_id_t vrf_id)
        ifp->vrf_id = vrf_id;
 
        ifp->connected = list_new();
-       ifp->connected->del = (void (*)(void *))connected_free;
+       ifp->connected->del = ifp_connected_free;
 
        ifp->nbr_connected = list_new();
        ifp->nbr_connected->del = (void (*)(void *))nbr_connected_free;
@@ -866,17 +873,20 @@ struct nbr_connected *nbr_connected_new(void)
 }
 
 /* Free connected structure. */
-void connected_free(struct connected *connected)
+void connected_free(struct connected **connected)
 {
-       if (connected->address)
-               prefix_free(&connected->address);
+       struct connected *ptr = *connected;
+
+       if (ptr->address)
+               prefix_free(&ptr->address);
 
-       if (connected->destination)
-               prefix_free(&connected->destination);
+       if (ptr->destination)
+               prefix_free(&ptr->destination);
 
-       XFREE(MTYPE_CONNECTED_LABEL, connected->label);
+       XFREE(MTYPE_CONNECTED_LABEL, ptr->label);
 
-       XFREE(MTYPE_CONNECTED, connected);
+       XFREE(MTYPE_CONNECTED, ptr);
+       *connected = NULL;
 }
 
 /* Free nbr connected structure. */
index 632229093735478db83605bfe2a93f3ed3d3e5db..6d966a25564afe61bb3f1427ed8340d134170ce7 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -543,7 +543,7 @@ extern ifindex_t ifname2ifindex(const char *ifname, vrf_id_t vrf_id);
 
 /* Connected address functions. */
 extern struct connected *connected_new(void);
-extern void connected_free(struct connected *);
+extern void connected_free(struct connected **connected);
 extern void connected_add(struct interface *, struct connected *);
 extern struct connected *
 connected_add_by_prefix(struct interface *, struct prefix *, struct prefix *);
index e4f614c7c4f2690bba29b71a62e7e7b913c71b66..9f828a1c7d832a3f58760fc154ee35f57324b3b7 100644 (file)
@@ -364,7 +364,7 @@ int nhrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
 
        nhrp_interface_update_address(
                ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);
-       connected_free(ifc);
+       connected_free(&ifc);
 
        return 0;
 }
index d8a6a39e1e9fd7de3faabc175580ed32c8cee0e0..6832737ada17be6f5ddf833fc6849c684554fab7 100644 (file)
@@ -143,7 +143,7 @@ static int ospf6_zebra_if_address_update_delete(ZAPI_CALLBACK_ARGS)
                ospf6_interface_state_update(c->ifp);
        }
 
-       connected_free(c);
+       connected_free(&c);
 
        return 0;
 }
index 5678d545ba354bc2056cc8cd26b9fcf674a292b3..68d9d3bf8319bd1553be65714d5a85f26706f1db 100644 (file)
@@ -150,7 +150,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
 
        rn = route_node_lookup(IF_OIFS(ifp), &p);
        if (!rn) {
-               connected_free(c);
+               connected_free(&c);
                return 0;
        }
 
@@ -163,7 +163,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
 
        ospf_if_interface(c->ifp);
 
-       connected_free(c);
+       connected_free(&c);
 
        return 0;
 }
index 39e92467ab66296459ccdc94825f38256117573d..719374e3b9e0c20e86f6c43d5188174a8c9e0373 100644 (file)
@@ -109,7 +109,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
               "%s: %s deleted %s", __PRETTY_FUNCTION__, c->ifp->name,
               prefix2str(c->address, buf, sizeof(buf)));
 
-       connected_free(c);
+       connected_free(&c);
        return 0;
 }
 
index dadcbbe65dbad0656cc2469c19bf721c7f90da67..dfddee99d044ead2681e2f827532193f26c8e7ec 100644 (file)
@@ -233,7 +233,7 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
                pim_i_am_rp_re_evaluate(pim);
        }
 
-       connected_free(c);
+       connected_free(&c);
        return 0;
 }
 
index 3173277ba7553fd449a90b91ea24fa6db090a781..4d4874060675a117a6370ef97f23d747f96e4719 100644 (file)
@@ -648,7 +648,7 @@ int rip_interface_address_delete(ZAPI_CALLBACK_ARGS)
                        rip_apply_address_del(ifc);
                }
 
-               connected_free(ifc);
+               connected_free(&ifc);
        }
 
        return 0;
index 9209a76460fbe4d3573d9e411ac50923dc23ec5e..97113a180f22b010fed718d1eaf70852a9e45068 100644 (file)
@@ -430,7 +430,7 @@ int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS)
                        /* Check wether this prefix needs to be removed. */
                        ripng_apply_address_del(ifc);
                }
-               connected_free(ifc);
+               connected_free(&ifc);
        }
 
        return 0;
index da2aa2f53949c8fde1677ad5c90a40b9fee50851..cd577e9051e851ad9ef54c77825bc21d5e52cc86 100644 (file)
@@ -73,7 +73,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
        if (!c)
                return 0;
 
-       connected_free(c);
+       connected_free(&c);
        return 0;
 }
 
index 049cb4b4fa698e63762a84f074ab8216ba990f6f..a474613b4da311a6bb7442b1fdd808464de6d56d 100644 (file)
@@ -79,7 +79,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
        if (!c)
                return 0;
 
-       connected_free(c);
+       connected_free(&c);
        return 0;
 }
 
index 75f4f53bc66ecb723473ecad22f0b2d482294299..0ff474d7873bf9912302fed34e9cb207af41b0af 100644 (file)
@@ -65,7 +65,7 @@ static void connected_withdraw(struct connected *ifc)
 
        if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED)) {
                listnode_delete(ifc->ifp->connected, ifc);
-               connected_free(ifc);
+               connected_free(&ifc);
        }
 }
 
@@ -177,7 +177,7 @@ static void connected_update(struct interface *ifp, struct connected *ifc)
                 */
                if (connected_same(current, ifc)) {
                        /* nothing to do */
-                       connected_free(ifc);
+                       connected_free(&ifc);
                        return;
                }
 
index daa93e36d1c4cbc612506170b77f6fa167e20408..5871b8746f1eef6eca6a1038cac07b3b11908de5 100644 (file)
@@ -738,7 +738,7 @@ static void if_delete_connected(struct interface *ifp)
                                                        ZEBRA_IFC_CONFIGURED)) {
                                                listnode_delete(ifp->connected,
                                                                ifc);
-                                               connected_free(ifc);
+                                               connected_free(&ifc);
                                        } else
                                                last = node;
                                }
@@ -759,7 +759,7 @@ static void if_delete_connected(struct interface *ifp)
                                last = node;
                        else {
                                listnode_delete(ifp->connected, ifc);
-                               connected_free(ifc);
+                               connected_free(&ifc);
                        }
                } else {
                        last = node;
@@ -2878,7 +2878,7 @@ static int ip_address_uninstall(struct vty *vty, struct interface *ifp,
        if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_QUEUED)
            || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
                listnode_delete(ifp->connected, ifc);
-               connected_free(ifc);
+               connected_free(&ifc);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
@@ -3103,7 +3103,7 @@ static int ipv6_address_uninstall(struct vty *vty, struct interface *ifp,
        if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_QUEUED)
            || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
                listnode_delete(ifp->connected, ifc);
-               connected_free(ifc);
+               connected_free(&ifc);
                return CMD_WARNING_CONFIG_FAILED;
        }