]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Move debug information gathering to inside guard
authorDonald Sharp <sharpd@nvidia.com>
Wed, 23 Sep 2020 00:47:33 +0000 (20:47 -0400)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 6 Oct 2020 12:54:25 +0000 (15:54 +0300)
Let's not make the entire `depend_finds` function pay
for the data gathering needed for the debug.  There
are numerous other places in the code that check
the NEXTHOP_FLAG_RECURSIVE and do the same output.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/zebra_nhg.c

index b8faaa43fd95ac238bae04117d11dd16061b1f41..aabbd875ecdb74eadf48cfeda59d2c8397e1f13c 100644 (file)
@@ -1366,7 +1366,6 @@ static struct nhg_hash_entry *depends_find_singleton(const struct nexthop *nh,
 static struct nhg_hash_entry *depends_find(const struct nexthop *nh, afi_t afi)
 {
        struct nhg_hash_entry *nhe = NULL;
-       char rbuf[10];
 
        if (!nh)
                goto done;
@@ -1374,18 +1373,18 @@ static struct nhg_hash_entry *depends_find(const struct nexthop *nh, afi_t afi)
        /* We are separating these functions out to increase handling speed
         * in the non-recursive case (by not alloc/freeing)
         */
-       if (CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE)) {
+       if (CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE))
                nhe = depends_find_recursive(nh, afi);
-               strlcpy(rbuf, "(R)", sizeof(rbuf));
-       } else {
+       else
                nhe = depends_find_singleton(nh, afi);
-               rbuf[0] = '\0';
-       }
 
-       if (IS_ZEBRA_DEBUG_NHG_DETAIL)
-               zlog_debug("%s: nh %pNHv %s => %p (%u)",
-                          __func__, nh, rbuf,
+
+       if (IS_ZEBRA_DEBUG_NHG_DETAIL) {
+               zlog_debug("%s: nh %pNHv %s => %p (%u)", __func__, nh,
+                          CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE) ? "(R)"
+                                                                        : "",
                           nhe, nhe ? nhe->id : 0);
+       }
 
 done:
        return nhe;