[PATCH] bitops: improve power of 2 alignment function documentation

Bruce Richardson bruce.richardson at intel.com
Tue Jul 22 10:40:15 CEST 2025


On Tue, Jul 22, 2025 at 09:53:21AM +0200, Mattias Rönnblom wrote:
> In the documentation, make clear
> rte_align(32|64)prevpow2(<n>) -> <n>, provided <n> is a power of 2.
> 
> The original documentation stated the "previous" power of 2 would be
> returned, potentially leaving the user to erroneously conclude that,
> for example, rte_align32prevpow2(32) -> 16.
> 
> The rte_align(32|64)pow2(<n>) documentation, suffering from a similar
> issue, is reworded in the same manner.
> 
> Fixes: 08f683174e94 ("eal: add functions for previous power of 2 alignment")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Mattias Rönnblom <mattias.ronnblom at ericsson.com>
> ---
>  lib/eal/include/rte_bitops.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h
> index b9a6af381b..2d1b9d281c 100644
> --- a/lib/eal/include/rte_bitops.h
> +++ b/lib/eal/include/rte_bitops.h
> @@ -1320,7 +1320,7 @@ rte_is_power_of_2(uint32_t n)
>   *   The integer value to align
>   *
>   * @return
> - *   Input parameter aligned to the next power of 2
> + *   The smallest power of 2 which is greater than or equal to @c x.
>   */

Much clearer, thanks.

Acked-by: Bruce Richardson <bruce.richardson at intel.com>



More information about the dev mailing list