[PATCH] block: cleanup various NULL pointer comparisons

Alone Dangal posted 1 patch 1 month, 1 week ago
block/badblocks.c     | 2 +-
block/bio.c           | 2 +-
block/blk-core.c      | 4 ++--
block/blk-iolatency.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
[PATCH] block: cleanup various NULL pointer comparisons
Posted by Alone Dangal 1 month, 1 week ago
Remove open-coded NULL comparisons to follow kernel coding style
guidelines. While at it, remove a trailing whitespace in blk-core.c.

Signed-off-by: Alone Dangal <yogeshdangal66@gmail.com>
---
 block/badblocks.c     | 2 +-
 block/bio.c           | 2 +-
 block/blk-core.c      | 4 ++--
 block/blk-iolatency.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/badblocks.c b/block/badblocks.c
index ece64e76f..d409e6b6e 100644
--- a/block/badblocks.c
+++ b/block/badblocks.c
@@ -1374,7 +1374,7 @@ EXPORT_SYMBOL_GPL(badblocks_clear);
  */
 void ack_all_badblocks(struct badblocks *bb)
 {
-	if (bb->page == NULL || bb->changed)
+	if (!bb->page || bb->changed)
 		/* no point even trying */
 		return;
 	write_seqlock_irq(&bb->lock);
diff --git a/block/bio.c b/block/bio.c
index d80d5d268..e15f30a5c 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -762,7 +762,7 @@ static int __bio_alloc_cache_prune(struct bio_alloc_cache *cache,
 	unsigned int i = 0;
 	struct bio *bio;
 
-	while ((bio = cache->free_list) != NULL) {
+	while ((bio = cache->free_list)) {
 		cache->free_list = bio->bi_next;
 		cache->nr--;
 		bio_free(bio);
diff --git a/block/blk-core.c b/block/blk-core.c
index 474700ffa..ae075a95b 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -635,7 +635,7 @@ static void __submit_bio(struct bio *bio)
 		blk_mq_submit_bio(bio);
 	} else if (likely(bio_queue_enter(bio) == 0)) {
 		struct gendisk *disk = bio->bi_bdev->bd_disk;
-	
+
 		if ((bio->bi_opf & REQ_POLLED) &&
 		    !(disk->queue->limits.features & BLK_FEAT_POLL)) {
 			bio->bi_status = BLK_STS_NOTSUPP;
@@ -695,7 +695,7 @@ static void __submit_bio_noacct(struct bio *bio)
 		 */
 		bio_list_init(&lower);
 		bio_list_init(&same);
-		while ((bio = bio_list_pop(&bio_list_on_stack[0])) != NULL)
+		while ((bio = bio_list_pop(&bio_list_on_stack[0])))
 			if (q == bdev_get_queue(bio->bi_bdev))
 				bio_list_add(&same, bio);
 			else
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index 53e8dd2df..dbd951e8c 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -689,7 +689,7 @@ static void blkiolatency_timer_fn(struct timer_list *t)
 		 * We scaled down but don't have a scale_grp, scale up and carry
 		 * on.
 		 */
-		if (lat_info->scale_grp == NULL) {
+		if (!lat_info->scale_grp) {
 			scale_cookie_change(iolat->blkiolat, lat_info, true);
 			goto next_lock;
 		}
-- 
2.53.0
Re: [PATCH] block: cleanup various NULL pointer comparisons
Posted by Jens Axboe 2 weeks, 6 days ago
On 2/27/26 8:06 AM, Alone Dangal wrote:
> Remove open-coded NULL comparisons to follow kernel coding style
> guidelines. While at it, remove a trailing whitespace in blk-core.c.

This is just unnecessary churn.

-- 
Jens Axboe