]> git.droids-corp.org - dpdk.git/commitdiff
common/cnxk: use for loop in shaper profiles cleanup
authorGowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Fri, 21 Jan 2022 12:04:16 +0000 (17:34 +0530)
committerJerin Jacob <jerinj@marvell.com>
Sun, 23 Jan 2022 07:19:18 +0000 (08:19 +0100)
In shaper profiles cleanup, Klockwork static analyzer tool reports
infinite loop although existing loop condition is alright.
False positive may be due to tqh_first not checked in loop,
hence switching to FOREACH_SAFE to make Klockwork happy.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
drivers/common/cnxk/roc_nix_tm.c
drivers/common/cnxk/roc_platform.h

index b3d8ebd3c2fedaf661aca11a9394ca9e7b517626..fe9e83fe1e2d3e234ab4768b17dabcc3ac4f7501 100644 (file)
@@ -17,16 +17,16 @@ bitmap_ctzll(uint64_t slab)
 void
 nix_tm_clear_shaper_profiles(struct nix *nix)
 {
-       struct nix_tm_shaper_profile *shaper_profile;
+       struct nix_tm_shaper_profile *shaper_profile, *tmp;
+       struct nix_tm_shaper_profile_list *list;
 
-       shaper_profile = TAILQ_FIRST(&nix->shaper_profile_list);
-       while (shaper_profile != NULL) {
+       list = &nix->shaper_profile_list;
+       PLT_TAILQ_FOREACH_SAFE(shaper_profile, list, shaper, tmp) {
                if (shaper_profile->ref_cnt)
                        plt_warn("Shaper profile %u has non zero references",
                                 shaper_profile->id);
                TAILQ_REMOVE(&nix->shaper_profile_list, shaper_profile, shaper);
                nix_tm_shaper_profile_free(shaper_profile);
-               shaper_profile = TAILQ_FIRST(&nix->shaper_profile_list);
        }
 }
 
index 63be311f4db2c4ad05ca345e004a1f396e03ad54..68f29fe48e8da8109f3623c3a9966d5a56e9e239 100644 (file)
@@ -20,6 +20,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_tailq.h>
 #include <rte_telemetry.h>
 
 #include "roc_bits.h"
@@ -55,6 +56,7 @@
 #define BITMASK_ULL             GENMASK_ULL
 #define PLT_ALIGN_CEIL          RTE_ALIGN_CEIL
 #define PLT_INIT                RTE_INIT
+#define PLT_TAILQ_FOREACH_SAFE  RTE_TAILQ_FOREACH_SAFE
 
 #ifndef PLT_ETHER_ADDR_LEN
 #define PLT_ETHER_ADDR_LEN RTE_ETHER_ADDR_LEN