On Thu, Dec 9, 2021 at 2:44 PM Nithin Dabilpuram
<ndabilpu...@marvell.com> wrote:
>
> From: Gowrishankar Muthukrishnan <gmuthukri...@marvell.com>
>
> In shaper profiles cleanup, KW 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 KW happy.
>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukri...@marvell.com>
> Signed-off-by: Shijith Thotton <sthot...@marvell.com>

Acked-by: Jerin Jacob <jer...@marvell.com>
Applied to dpdk-next-net-mrvl/for-next-net. Thanks

Changed the git log to:


common/cnxk: use for loop in shaper profiles cleanup

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.

> ---
>  drivers/common/cnxk/roc_nix_tm.c   | 8 ++++----
>  drivers/common/cnxk/roc_platform.h | 2 ++
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/common/cnxk/roc_nix_tm.c 
> b/drivers/common/cnxk/roc_nix_tm.c
> index b3d8ebd..fe9e83f 100644
> --- a/drivers/common/cnxk/roc_nix_tm.c
> +++ b/drivers/common/cnxk/roc_nix_tm.c
> @@ -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);
>         }
>  }
>
> diff --git a/drivers/common/cnxk/roc_platform.h 
> b/drivers/common/cnxk/roc_platform.h
> index 61d4781..3648e84 100644
> --- a/drivers/common/cnxk/roc_platform.h
> +++ b/drivers/common/cnxk/roc_platform.h
> @@ -19,6 +19,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"
> @@ -53,6 +54,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
>
>  /** Divide ceil */
>  #define PLT_DIV_CEIL(x, y)                     \
> --
> 2.8.4
>

Reply via email to