diff mbox series

[1/4] libnvdimm: remove redundant list_empty() check in badrange.c

Message ID 20200820143027.3241-2-thunder.leizhen@huawei.com (mailing list archive)
State New, archived
Headers show
Series clean up some functions in nvdimm/badrange.c and namespace_devs.c | expand

Commit Message

Zhen Lei Aug. 20, 2020, 2:30 p.m. UTC
In add_badrange() or badblocks_populate(), the list_empty() branch does
the same things as the code after list_for_each_entry(). And the
list_for_each_entry() will do noting when list_empty().

So the list_empty() branch can be removed without functional change, let
the code after list_for_each_entry() to do it.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/nvdimm/badrange.c | 10 ----------
 1 file changed, 10 deletions(-)
diff mbox series

Patch

diff --git a/drivers/nvdimm/badrange.c b/drivers/nvdimm/badrange.c
index b9eeefa27e3a507..9fdba8c43e8605e 100644
--- a/drivers/nvdimm/badrange.c
+++ b/drivers/nvdimm/badrange.c
@@ -53,13 +53,6 @@  static int add_badrange(struct badrange *badrange, u64 addr, u64 length)
 	bre_new = kzalloc(sizeof(*bre_new), GFP_KERNEL);
 	spin_lock(&badrange->lock);
 
-	if (list_empty(&badrange->list)) {
-		if (!bre_new)
-			return -ENOMEM;
-		append_badrange_entry(badrange, bre_new, addr, length);
-		return 0;
-	}
-
 	/*
 	 * There is a chance this is a duplicate, check for those first.
 	 * This will be the common case as ARS_STATUS returns all known
@@ -215,9 +208,6 @@  static void badblocks_populate(struct badrange *badrange,
 {
 	struct badrange_entry *bre;
 
-	if (list_empty(&badrange->list))
-		return;
-
 	list_for_each_entry(bre, &badrange->list, list) {
 		u64 bre_end = bre->start + bre->length - 1;