Skip to contentSkip to conversation

block: cleanup various NULL pointer comparisons

PATCH In review Alone Dangal 2 participants 2 messages Feb 27 – Mar 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: cleanup various NULL pointer comparisons

Remove open-coded NULL comparisons to follow kernel coding style guidelines. While at it, remove a trailing whitespace in blk-core.c.

---
 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(-)
block/badblocks.c +1 -1
index ece64e76f..d409e6b6e 100644
@@ -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);
block/bio.c +1 -1
index d80d5d268..e15f30a5c 100644
@@ -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);
block/blk-core.c +2 -2
index 474700ffa..ae075a95b 100644
@@ -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
block/blk-iolatency.c +1 -1
index 53e8dd2df..dbd951e8c 100644
@@ -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;
 		}
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 2 lines · Alone Dangal

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.

Signature · 1 line
Jens Axboe