linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] brd: remove a redundant check
@ 2020-04-22  1:28 Zhen Lei
  2020-04-24  2:08 ` Leizhen (ThunderTown)
  0 siblings, 1 reply; 2+ messages in thread
From: Zhen Lei @ 2020-04-22  1:28 UTC (permalink / raw)
  To: Jens Axboe, linux-block, linux-kernel; +Cc: Zhen Lei

Because pages[i] can't be NULL, otherwise "pos = pages[i]->index;" will
panic. So when "ret" is NULL, it can't be equal to pages[i].

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/block/brd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 2fb25c348d53..59fec4a8ac93 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -147,7 +147,7 @@ static void brd_free_pages(struct brd_device *brd)
 			BUG_ON(pages[i]->index < pos);
 			pos = pages[i]->index;
 			ret = radix_tree_delete(&brd->brd_pages, pos);
-			BUG_ON(!ret || ret != pages[i]);
+			BUG_ON(ret != pages[i]);
 			__free_page(pages[i]);
 		}
 
-- 
2.26.0.106.g9fadedd



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] brd: remove a redundant check
  2020-04-22  1:28 [PATCH 1/1] brd: remove a redundant check Zhen Lei
@ 2020-04-24  2:08 ` Leizhen (ThunderTown)
  0 siblings, 0 replies; 2+ messages in thread
From: Leizhen (ThunderTown) @ 2020-04-24  2:08 UTC (permalink / raw)
  To: Jens Axboe, linux-block, linux-kernel



On 2020/4/22 9:28, Zhen Lei wrote:
> Because pages[i] can't be NULL, otherwise "pos = pages[i]->index;" will
> panic. So when "ret" is NULL, it can't be equal to pages[i].

In fact, "ret != pages[i]" is clear enough.

> 
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
>  drivers/block/brd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/brd.c b/drivers/block/brd.c
> index 2fb25c348d53..59fec4a8ac93 100644
> --- a/drivers/block/brd.c
> +++ b/drivers/block/brd.c
> @@ -147,7 +147,7 @@ static void brd_free_pages(struct brd_device *brd)
>  			BUG_ON(pages[i]->index < pos);
>  			pos = pages[i]->index;
>  			ret = radix_tree_delete(&brd->brd_pages, pos);
> -			BUG_ON(!ret || ret != pages[i]);
> +			BUG_ON(ret != pages[i]);
>  			__free_page(pages[i]);
>  		}
>  
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-24  2:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22  1:28 [PATCH 1/1] brd: remove a redundant check Zhen Lei
2020-04-24  2:08 ` Leizhen (ThunderTown)

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).