Skip to contentSkip to conversation

ufs: remove an unneed NULL check on list iterator

PATCH Superseded Xiaomeng Tong 2 participants 3 messages Mar 19, 2022 – Mar 20, 2022 SCSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ufs: remove an unneed NULL check on list iterator

The list iterator is always non-NULL so it doesn't need to be checked. Thus just remove the unnecessary NULL check.

---
 drivers/scsi/ufs/ufshpb.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/scsi/ufs/ufshpb.c +0 -6
index 2d36a0715..a3db0ad60 100644
@@ -869,12 +869,6 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)
 	struct ufshpb_region *rgn, *victim_rgn = NULL;
 
 	list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) {
-		if (!rgn) {
-			dev_err(&hpb->sdev_ufs_lu->sdev_dev,
-				"%s: no region allocated\n",
-				__func__);
-			return NULL;
-		}
 		if (ufshpb_check_srgns_issue_state(hpb, rgn))
 			continue;
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 16 lines · Xiaomeng Tong

The list iterator is always non-NULL so it doesn't need to be checked. Thus just remove the unnecessary NULL check.

---
drivers/scsi/ufs/ufshpb.c | 6 ------

1 file changed, 6 deletions(-)
drivers/scsi/ufs/ufshpb.c +0 -0
index 2d36a0715..a3db0ad60 100644

drivers/scsi/ufs/ufshpb.c static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb) · line 877

Quoted 9 lines
drivers/scsi/ufs/ufshpb.c +0 -6
@@ -869,12 +869,6 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)
 	struct ufshpb_region *rgn, *victim_rgn = NULL;
 
 	list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) {
-		if (!rgn) {
-			dev_err(&hpb->sdev_ufs_lu->sdev_dev,
-				"%s: no region allocated\n",
-				__func__);
-			return NULL;
-		}

Maybe it make more sense to move that check after the loop body instead of removing it completely? This code obviously does nothing in it's current state but it's clear what the original intention was, so restoring that would perhaps be better.

But probably someone with more experience about this code can make the call

Quoted 6 lines
drivers/scsi/ufs/ufshpb.c +0 -0
 		if (ufshpb_check_srgns_issue_state(hpb, rgn))
 			continue;
 
Signature · 1 line
2.17.1

Jakob

#2 lore raw
Quoted 7 lines · Jakob Koschel

Maybe it make more sense to move that check after the loop body instead of removing it completely? This code obviously does nothing in it's current state but it's clear what the original intention was, so restoring that would perhaps be better.

But probably someone with more experience about this code can make the call

This seems like a better choice, if it doesn't go against the author's original intention. I will fix it in PATCH v2, thanks.

--
Xiaomeng Tong