Skip to contentSkip to conversation

block: drop dead assignments in loop_init()

PATCH Superseded Lukas Bulwahn 2 participants 2 messages Dec 11, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 block: drop dead assignments in loop_init()

Commit 8410d38c2552 ("loop: use __register_blkdev to allocate devices on demand") simplified loop_init(); so computing the range of the block region is not required anymore and can be dropped.

Drop dead assignments in loop_init().

As compilers will detect these unneeded assignments and optimize this, the resulting object code is identical before and after this change.

No functional change. No change in object code.

---
v1 -> v2:
- replaced if block with ternary operator after Julia's style comment

Christoph, please ack.

Jens, please pick this minor non-urgent clean-up patch on your block -next tree on top of Christoph's commit above.

 drivers/block/loop.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/block/loop.c +1 -8
index d2ce1ddc192d..10c7c154c114 100644
@@ -2304,7 +2304,6 @@ MODULE_ALIAS("devname:loop-control");
 static int __init loop_init(void)
 {
 	int i, nr;
-	unsigned long range;
 	struct loop_device *lo;
 	int err;
 
@@ -2341,13 +2340,7 @@ static int __init loop_init(void)
 	 * /dev/loop-control interface, or be instantiated by accessing
 	 * a 'dead' device node.
 	 */
-	if (max_loop) {
-		nr = max_loop;
-		range = max_loop << part_shift;
-	} else {
-		nr = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
-		range = 1UL << MINORBITS;
-	}
+	nr = max_loop ? max_loop : CONFIG_BLK_DEV_LOOP_MIN_COUNT;
 
 	err = misc_register(&loop_misc);
 	if (err < 0)
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 38 lines · Lukas Bulwahn

Commit 8410d38c2552 ("loop: use __register_blkdev to allocate devices on demand") simplified loop_init(); so computing the range of the block region is not required anymore and can be dropped.

Drop dead assignments in loop_init().

As compilers will detect these unneeded assignments and optimize this, the resulting object code is identical before and after this change.

No functional change. No change in object code.

---
v1 -> v2:
- replaced if block with ternary operator after Julia's style comment

Christoph, please ack.

Jens, please pick this minor non-urgent clean-up patch on your block -next tree on top of Christoph's commit above.

 drivers/block/loop.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/block/loop.c +0 -1
index d2ce1ddc192d..10c7c154c114 100644
@@ -2304,7 +2304,6 @@ MODULE_ALIAS("devname:loop-control");
 static int __init loop_init(void)
 {
 	int i, nr;
-	unsigned long range;
 	struct loop_device *lo;
 	int err;
 
@@ -2341,13 +2340,7 @@ static int __init loop_init(void)
 	 * /dev/loop-control interface, or be instantiated by accessing

drivers/block/loop.c static int __init loop_init(void) · line 2343

Quoted 10 lines
drivers/block/loop.c +1 -7
 	 * a 'dead' device node.
 	 */
-	if (max_loop) {
-		nr = max_loop;
-		range = max_loop << part_shift;
-	} else {
-		nr = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
-		range = 1UL << MINORBITS;
-	}
+	nr = max_loop ? max_loop : CONFIG_BLK_DEV_LOOP_MIN_COUNT;

I greatly prefer an if/else to ternary, it's a lot easier to read imho.

Signature · 1 line
Jens Axboe