Skip to contentSkip to conversation

block: drop dead assignments in loop_init()

PATCH Superseded Lukas Bulwahn 3 participants 4 messages Dec 11, 2020 – Dec 12, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
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 | 3 ---
 1 file changed, 3 deletions(-)
drivers/block/loop.c +0 -3
index d2ce1ddc192d..eed4bc5ef5c5 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;
 
@@ -2343,10 +2342,8 @@ static int __init loop_init(void)
 	 */
 	if (max_loop) {
 		nr = max_loop;
-		range = max_loop << part_shift;
 	} else {
 		nr = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
-		range = 1UL << MINORBITS;
 	}
 
 	err = misc_register(&loop_misc);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 10 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.

It looks like some braces should be dropped too?

julia

Quoted 38 lines

---
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 | 3 ---
 1 file changed, 3 deletions(-)
drivers/block/loop.c +0 -4
index d2ce1ddc192d..eed4bc5ef5c5 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;
 
@@ -2343,10 +2342,8 @@ static int __init loop_init(void)
 	 */
 	if (max_loop) {
 		nr = max_loop;
-		range = max_loop << part_shift;
 	} else {
 		nr = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
-		range = 1UL << MINORBITS;
 	}
 
 	err = misc_register(&loop_misc);
--

2.17.1

#2 lore raw
Quoted 11 lines · Julia Lawall
Quoted 6 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().

Quoted 9 lines
Quoted 4 lines

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.

It looks like some braces should be dropped too?

julia

Julia, you are right; I just rewrote it to:

nr = max_loop ? max_loop : CONFIG_BLK_DEV_LOOP_MIN_COUNT;

v2 will follow in a moment.

Lukas

Quoted 38 lines
Quoted 38 lines

---
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 | 3 ---
 1 file changed, 3 deletions(-)
drivers/block/loop.c +0 -4
index d2ce1ddc192d..eed4bc5ef5c5 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;
 
@@ -2343,10 +2342,8 @@ static int __init loop_init(void)
       */
      if (max_loop) {
              nr = max_loop;
-             range = max_loop << part_shift;
      } else {
              nr = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
-             range = 1UL << MINORBITS;
      }
 
      err = misc_register(&loop_misc);
--

2.17.1

#3 lore raw
Quoted 11 lines · Lukas Bulwahn
Quoted 10 lines · Julia Lawall
Quoted 9 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.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

No functional change. No change in object code.

It looks like some braces should be dropped too?

I just rewrote it to:

nr = max_loop ? max_loop : CONFIG_BLK_DEV_LOOP_MIN_COUNT;

A relatively common gcc extension would use ?: like:

	nr = max_loop ?: CONFIG_BLK_DEV_LOOP_MIN_COUNT;