Base gcc warns about 'rp' may be used uninitialized.
Now the code is correct and rp is not use uninitalized but it is not as
obvious as it could be. Also rp is a bit of a shitty name for the redo
queue tail pointer. So cleanup the code and with it stop the warning.

OK?
-- 
:wq Claudio

Index: rde_decide.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_decide.c,v
retrieving revision 1.83
diff -u -p -r1.83 rde_decide.c
--- rde_decide.c        8 Mar 2021 12:18:46 -0000       1.83
+++ rde_decide.c        16 Mar 2021 16:48:15 -0000
@@ -295,7 +295,7 @@ void
 prefix_insert(struct prefix *new, struct prefix *ep, struct rib_entry *re)
 {
        struct prefix_list redo = LIST_HEAD_INITIALIZER(redo);
-       struct prefix *xp, *np, *rp, *ip = ep;
+       struct prefix *xp, *np, *tailp = NULL, *ip = ep;
        int testall, selected = 0;
 
        /* start scan at the entry point (ep) or if the head if ep == NULL */
@@ -315,13 +315,13 @@ prefix_insert(struct prefix *new, struct
                                 * put it onto redo queue.
                                 */
                                LIST_REMOVE(xp, entry.list.rib);
-                               if (LIST_EMPTY(&redo))
+                               if (tailp == NULL)
                                        LIST_INSERT_HEAD(&redo, xp,
                                            entry.list.rib);
                                else
-                                       LIST_INSERT_AFTER(rp, xp,
+                                       LIST_INSERT_AFTER(tailp, xp,
                                            entry.list.rib);
-                               rp = xp;
+                               tailp = xp;
                        } else {
                                /*
                                 * lock insertion point and
@@ -371,7 +371,7 @@ void
 prefix_remove(struct prefix *old, struct rib_entry *re)
 {
        struct prefix_list redo = LIST_HEAD_INITIALIZER(redo);
-       struct prefix *xp, *np, *rp;
+       struct prefix *xp, *np, *tailp = NULL;
        int testall;
 
        xp = LIST_NEXT(old, entry.list.rib);
@@ -393,13 +393,13 @@ prefix_remove(struct prefix *old, struct
                                 * put it onto redo queue.
                                 */
                                LIST_REMOVE(xp, entry.list.rib);
-                               if (LIST_EMPTY(&redo))
+                               if (tailp == NULL)
                                        LIST_INSERT_HEAD(&redo, xp,
                                            entry.list.rib);
                                else
-                                       LIST_INSERT_AFTER(rp, xp,
+                                       LIST_INSERT_AFTER(tailp, xp,
                                            entry.list.rib);
-                               rp = xp;
+                               tailp = xp;
                        }
                }
        }

Reply via email to