* [PATCH] bitops: improve power of 2 alignment function documentation
@ 2025-07-22 7:53 Mattias Rönnblom
2025-07-22 8:40 ` Bruce Richardson
0 siblings, 1 reply; 3+ messages in thread
From: Mattias Rönnblom @ 2025-07-22 7:53 UTC (permalink / raw)
To: dev, Jack Bond-Preston
Cc: Mattias Rönnblom, Mattias Rönnblom, stable
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@dpdk.org
Signed-off-by: Mattias Rönnblom <mattias.ronnblom@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.
*/
static inline uint32_t
rte_align32pow2(uint32_t x)
@@ -1338,7 +1338,7 @@ rte_align32pow2(uint32_t x)
* The integer value to align
*
* @return
- * Input parameter aligned to the previous power of 2
+ * The greatest power of 2 which is smaller than or equal to @c x.
*/
static inline uint32_t
rte_align32prevpow2(uint32_t x)
@@ -1355,7 +1355,7 @@ rte_align32prevpow2(uint32_t x)
* The 64b 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 v.
*/
static inline uint64_t
rte_align64pow2(uint64_t v)
@@ -1373,7 +1373,7 @@ rte_align64pow2(uint64_t v)
* The 64b value to align
*
* @return
- * Input parameter aligned to the previous power of 2
+ * The greatest power of 2 which is smaller than or equal to @c v.
*/
static inline uint64_t
rte_align64prevpow2(uint64_t v)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bitops: improve power of 2 alignment function documentation
2025-07-22 7:53 [PATCH] bitops: improve power of 2 alignment function documentation Mattias Rönnblom
@ 2025-07-22 8:40 ` Bruce Richardson
2025-07-22 10:29 ` Morten Brørup
0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2025-07-22 8:40 UTC (permalink / raw)
To: Mattias Rönnblom
Cc: dev, Jack Bond-Preston, Mattias Rönnblom, stable
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@dpdk.org
>
> Signed-off-by: Mattias Rönnblom <mattias.ronnblom@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@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] bitops: improve power of 2 alignment function documentation
2025-07-22 8:40 ` Bruce Richardson
@ 2025-07-22 10:29 ` Morten Brørup
0 siblings, 0 replies; 3+ messages in thread
From: Morten Brørup @ 2025-07-22 10:29 UTC (permalink / raw)
To: Bruce Richardson, Mattias Rönnblom
Cc: dev, Jack Bond-Preston, Mattias Rönnblom, stable
> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Tuesday, 22 July 2025 10.40
>
> 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@dpdk.org
> >
> > Signed-off-by: Mattias Rönnblom <mattias.ronnblom@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@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-22 10:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-22 7:53 [PATCH] bitops: improve power of 2 alignment function documentation Mattias Rönnblom
2025-07-22 8:40 ` Bruce Richardson
2025-07-22 10:29 ` Morten Brørup
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).