eal: fix return type of bsf safe functions

Message ID 20221005154036.4187143-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series eal: fix return type of bsf safe functions |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-testing warning apply patch failure

Commit Message

Thomas Monjalon Oct. 5, 2022, 3:40 p.m. UTC
  In a recent commit, changing return type from int to uint32_t,
I did a last minute change to functions rte_bsf32_safe and rte_bsf64_safe,
because thought they were forgotten.
Actually these functions are returning 0 or 1, so it should be int.
The return type is reverted to the original type for these 2 functions.

Fixes: 4b81c145ae37 ("eal: change return type of bsf/fls functions")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/eal/include/rte_common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

David Marchand Oct. 5, 2022, 7:41 p.m. UTC | #1
On Wed, Oct 5, 2022 at 5:41 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> In a recent commit, changing return type from int to uint32_t,
> I did a last minute change to functions rte_bsf32_safe and rte_bsf64_safe,
> because thought they were forgotten.
> Actually these functions are returning 0 or 1, so it should be int.
> The return type is reverted to the original type for these 2 functions.
>
> Fixes: 4b81c145ae37 ("eal: change return type of bsf/fls functions")
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Reviewed-by: David Marchand <david.marchand@redhat.com>
  
Tyler Retzlaff Oct. 5, 2022, 10:20 p.m. UTC | #2
On Wed, Oct 05, 2022 at 09:41:26PM +0200, David Marchand wrote:
> On Wed, Oct 5, 2022 at 5:41 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > In a recent commit, changing return type from int to uint32_t,
> > I did a last minute change to functions rte_bsf32_safe and rte_bsf64_safe,
> > because thought they were forgotten.
> > Actually these functions are returning 0 or 1, so it should be int.
> > The return type is reverted to the original type for these 2 functions.
> >
> > Fixes: 4b81c145ae37 ("eal: change return type of bsf/fls functions")
> >
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> 
> Reviewed-by: David Marchand <david.marchand@redhat.com>

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  
Thomas Monjalon Oct. 6, 2022, 12:27 a.m. UTC | #3
06/10/2022 00:20, Tyler Retzlaff:
> On Wed, Oct 05, 2022 at 09:41:26PM +0200, David Marchand wrote:
> > On Wed, Oct 5, 2022 at 5:41 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> > >
> > > In a recent commit, changing return type from int to uint32_t,
> > > I did a last minute change to functions rte_bsf32_safe and rte_bsf64_safe,
> > > because thought they were forgotten.
> > > Actually these functions are returning 0 or 1, so it should be int.
> > > The return type is reverted to the original type for these 2 functions.
> > >
> > > Fixes: 4b81c145ae37 ("eal: change return type of bsf/fls functions")
> > >
> > > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > 
> > Reviewed-by: David Marchand <david.marchand@redhat.com>
> 
> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

Applied, sorry for the noise.
  
Mattias Rönnblom Oct. 6, 2022, 6:20 p.m. UTC | #4
On 2022-10-05 17:40, Thomas Monjalon wrote:
> In a recent commit, changing return type from int to uint32_t,
> I did a last minute change to functions rte_bsf32_safe and rte_bsf64_safe,
> because thought they were forgotten.
> Actually these functions are returning 0 or 1, so it should be int.

Wouldn't bool be a better choice?

> The return type is reverted to the original type for these 2 functions.
> 
> Fixes: 4b81c145ae37 ("eal: change return type of bsf/fls functions")
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>   lib/eal/include/rte_common.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
> index 23d9e05cbb..15765b408d 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -660,7 +660,7 @@ rte_bsf32(uint32_t v)
>    * @return
>    *     Returns 0 if ``v`` was 0, otherwise returns 1.
>    */
> -static inline uint32_t
> +static inline int
>   rte_bsf32_safe(uint32_t v, uint32_t *pos)
>   {
>   	if (v == 0)
> @@ -739,7 +739,7 @@ rte_bsf64(uint64_t v)
>    * @return
>    *     Returns 0 if ``v`` was 0, otherwise returns 1.
>    */
> -static inline uint32_t
> +static inline int
>   rte_bsf64_safe(uint64_t v, uint32_t *pos)
>   {
>   	if (v == 0)
  

Patch

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 23d9e05cbb..15765b408d 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -660,7 +660,7 @@  rte_bsf32(uint32_t v)
  * @return
  *     Returns 0 if ``v`` was 0, otherwise returns 1.
  */
-static inline uint32_t
+static inline int
 rte_bsf32_safe(uint32_t v, uint32_t *pos)
 {
 	if (v == 0)
@@ -739,7 +739,7 @@  rte_bsf64(uint64_t v)
  * @return
  *     Returns 0 if ``v`` was 0, otherwise returns 1.
  */
-static inline uint32_t
+static inline int
 rte_bsf64_safe(uint64_t v, uint32_t *pos)
 {
 	if (v == 0)