block: Reduce the scope of a variable in __blk_mq_update_nr_hw_queues()
PATCH 1/1 block: Reduce the scope of a variable in __blk_mq_update_nr_hw_queues()
Improve code readability by reducing the scope of the variable 'i'.
This patch fixes the following W=2 compiler warning:
block/blk-mq.c:5037:8: error: declaration shadows a local variable [-Werror,-Wshadow]
5037 | int i = prev_nr_hw_queues;
| ^block/blk-mq.c:4999:6: note: previous declaration is here
4999 | int i;
| ^
--- block/blk-mq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-mq.c +1 -2
@@ -4972,7 +4972,6 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,struct request_queue *q;int prev_nr_hw_queues = set->nr_hw_queues;unsigned int memflags; -int i;lockdep_assert_held (&set->tag_list_lock);
@@ -5032,7 +5031,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,memalloc_noio_restore (memflags);/* Free the excess tags when nr_hw_queues shrink. */ -for (i = set->nr_hw_queues; i < prev_nr_hw_queues; i++) +for (int i = set->nr_hw_queues; i < prev_nr_hw_queues; i++)__blk_mq_free_map_and_rqs (set, i); }
Quoted 9 lines · Bart Van Assche
Improve code readability by reducing the scope of the variable 'i'.
This patch fixes the following W=2 compiler warning:
block/blk-mq.c:5037:8: error: declaration shadows a local variable [-Werror,-Wshadow]
5037 | int i =prev_nr_hw_queues;
| ^block/blk-mq.c:4999:6: note: previous declaration is here
4999 | int i;
If we want to fix this renaming one variable is much better.
But Nilay is currently active with major changes to this area, let's delay cosmetic fixes until that has landed.