]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: RB_FIND then RB_REMOVE nhg_connected
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 14 May 2019 21:31:17 +0000 (14:31 -0700)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:39 +0000 (11:13 -0400)
Can't RM_REMOVE directly with a key, you need to actually pass the
data to be removed. So, lookup with a key first to find the node,
then remove it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/zebra_nhg.c

index e5c4520c70d7f9b0adb27d45881f72eafa33df23..ebddeb3f9514dbb028c9ae04d581658a5579e7cf 100644 (file)
@@ -103,13 +103,16 @@ void nhg_connected_head_del(struct nhg_connected_head *head,
                            struct nhg_hash_entry *depend)
 {
        struct nhg_connected lookup = {};
-       struct nhg_connected *removed = NULL;
+       struct nhg_connected *remove = NULL;
 
        lookup.nhe = depend;
 
-       removed = RB_REMOVE(nhg_connected_head, head, &lookup);
+       /* Lookup to find the element, then remove it */
+       remove = RB_FIND(nhg_connected_head, head, &lookup);
+       remove = RB_REMOVE(nhg_connected_head, head, remove);
 
-       nhg_connected_free(removed);
+       if (remove)
+               nhg_connected_free(remove);
 }
 
 void nhg_connected_head_add(struct nhg_connected_head *head,