2021-11-19 01:54:39

by 赵军奎

[permalink] [raw]
Subject: [PATCH] net/core: remove useless type conversion to bool

(ret == 0) is bool value, the type conversion to true/false value
is not needed.

Signed-off-by: Bernard Zhao <[email protected]>
---
net/core/page_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 9b60e4301a44..d660d46f6ad6 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -398,7 +398,7 @@ static bool page_pool_recycle_in_ring(struct page_pool *pool, struct page *page)
else
ret = ptr_ring_produce_bh(&pool->ring, page);

- return (ret == 0) ? true : false;
+ return (ret == 0);
}

/* Only allow direct recycling in special circumstances, into the
--
2.33.1



2021-11-19 07:08:24

by Ilias Apalodimas

[permalink] [raw]
Subject: Re: [PATCH] net/core: remove useless type conversion to bool

On Thu, Nov 18, 2021 at 05:54:21PM -0800, Bernard Zhao wrote:
> (ret == 0) is bool value, the type conversion to true/false value
> is not needed.
>
> Signed-off-by: Bernard Zhao <[email protected]>
> ---
> net/core/page_pool.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index 9b60e4301a44..d660d46f6ad6 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -398,7 +398,7 @@ static bool page_pool_recycle_in_ring(struct page_pool *pool, struct page *page)
> else
> ret = ptr_ring_produce_bh(&pool->ring, page);
>
> - return (ret == 0) ? true : false;
> + return (ret == 0);
> }
>
> /* Only allow direct recycling in special circumstances, into the
> --
> 2.33.1
>
Reviewed-by: Ilias Apalodimas <[email protected]>

2021-11-19 09:59:43

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] net/core: remove useless type conversion to bool

On Thu, 2021-11-18 at 17:54 -0800, Bernard Zhao wrote:
> (ret == 0) is bool value, the type conversion to true/false value
> is not needed.
[]
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
[]
> @@ -398,7 +398,7 @@ static bool page_pool_recycle_in_ring(struct page_pool *pool, struct page *page)
> else
> ret = ptr_ring_produce_bh(&pool->ring, page);
>
> - return (ret == 0) ? true : false;
> + return (ret == 0);

This doesn't need the parentheses either.

Maybe:
return !ret;
or
return ret == 0;
?