[PATCH v2] lib/ring: do not allow zero size ring
Morten Brørup
mb at smartsharesystems.com
Tue Nov 11 01:40:29 CET 2025
> diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
> index edd63aa535..0a9fc31530 100644
> --- a/lib/ring/rte_ring.c
> +++ b/lib/ring/rte_ring.c
> @@ -47,7 +47,7 @@ EAL_REGISTER_TAILQ(rte_ring_tailq)
> RING_F_MP_HTS_ENQ | RING_F_MC_HTS_DEQ)
>
> /* true if x is a power of 2 */
> -#define POWEROF2(x) ((((x)-1) & (x)) == 0)
> +#define POWEROF2(x) ((x != 0) && (((x)-1) & (x)) == 0)
Please remove this private macro and use the RTE_IS_POWER_OF_2() macro from rte_bitops.h instead.
With such modification,
Acked-by: Morten Brørup <mb at smartsharesystems.com>
<feature creep>
app/pdump/main.c also defines a POWEROF2() macro, which could be replaced by RTE_IS_POWER_OF_2().
But changing that is unrelated to your improvement in this patch, and should be an independent patch.
Not your responsibility to fix that; just mentioning it for someone to pick it up.
</feature creep>
More information about the dev
mailing list