Skip to contentSkip to conversation

mm/swapfile: Remove needless request_queue NULL pointer check

PATCH Applied Xu Wang 2 participants 2 messages Sep 17, 2021 – Sep 22, 2021

Subsystems (2)
lore
Share & tools
lore

Xu Wang

author
#0 lore raw

PATCH 1/1 mm/swapfile: Remove needless request_queue NULL pointer check

The request_queue pointer returned from bdev_get_queue() shall never be NULL, so the null check is unnecessary, just remove it.

---
 mm/swapfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/swapfile.c +1 -1
index 22d10f713848..42027d213fd2 100644
@@ -3118,7 +3118,7 @@ static bool swap_discardable(struct swap_info_struct *si)
 {
 	struct request_queue *q = bdev_get_queue(si->bdev);
 
-	if (!q || !blk_queue_discard(q))
+	if (!blk_queue_discard(q))
 		return false;
 
 	return true;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Xu Wang

The request_queue pointer returned from bdev_get_queue() shall never be NULL, so the null check is unnecessary, just remove it.

---
  mm/swapfile.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/swapfile.c +0 -0
index 22d10f713848..42027d213fd2 100644

mm/swapfile.c static bool swap_discardable(struct swap_info_struct *si) · line 3124

Quoted 8 lines
mm/swapfile.c +1 -1
@@ -3118,7 +3118,7 @@ static bool swap_discardable(struct swap_info_struct *si)
  {
  	struct request_queue *q = bdev_get_queue(si->bdev);
 
-	if (!q || !blk_queue_discard(q))
+	if (!blk_queue_discard(q))
  		return false;
 
  	return true;

Right, there is even a comment in bdev_get_queue "this is never NULL".

Signature · 3 lines
Thanks,

David / dhildenb