linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: drop dead assignments in loop_init()
@ 2020-12-11 18:12 Lukas Bulwahn
  2020-12-11 18:23 ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Lukas Bulwahn @ 2020-12-11 18:12 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, linux-block
  Cc: Hannes Reinecke, linux-kernel, clang-built-linux,
	kernel-janitors, 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.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
---
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(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d2ce1ddc192d..eed4bc5ef5c5 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: drop dead assignments in loop_init()
  2020-12-11 18:12 [PATCH] block: drop dead assignments in loop_init() Lukas Bulwahn
@ 2020-12-11 18:23 ` Julia Lawall
  2020-12-11 18:40   ` Lukas Bulwahn
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2020-12-11 18:23 UTC (permalink / raw)
  To: Lukas Bulwahn
  Cc: Christoph Hellwig, Jens Axboe, linux-block, Hannes Reinecke,
	linux-kernel, clang-built-linux, kernel-janitors



On Fri, 11 Dec 2020, Lukas Bulwahn wrote:

> 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

>
> Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
> ---
> 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(-)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index d2ce1ddc192d..eed4bc5ef5c5 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -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
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: drop dead assignments in loop_init()
  2020-12-11 18:23 ` Julia Lawall
@ 2020-12-11 18:40   ` Lukas Bulwahn
  2020-12-12  4:27     ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Lukas Bulwahn @ 2020-12-11 18:40 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Christoph Hellwig, Jens Axboe, linux-block, Hannes Reinecke,
	Linux Kernel Mailing List, clang-built-linux, kernel-janitors

On Fri, Dec 11, 2020 at 7:23 PM Julia Lawall <julia.lawall@inria.fr> wrote:
>
>
>
> On Fri, 11 Dec 2020, Lukas Bulwahn wrote:
>
> > 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
>

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

> >
> > Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
> > ---
> > 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(-)
> >
> > diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> > index d2ce1ddc192d..eed4bc5ef5c5 100644
> > --- a/drivers/block/loop.c
> > +++ b/drivers/block/loop.c
> > @@ -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
> >
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: drop dead assignments in loop_init()
  2020-12-11 18:40   ` Lukas Bulwahn
@ 2020-12-12  4:27     ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2020-12-12  4:27 UTC (permalink / raw)
  To: Lukas Bulwahn, Julia Lawall
  Cc: Christoph Hellwig, Jens Axboe, linux-block, Hannes Reinecke,
	Linux Kernel Mailing List, clang-built-linux, kernel-janitors

On Fri, 2020-12-11 at 19:40 +0100, Lukas Bulwahn wrote:
> On Fri, Dec 11, 2020 at 7:23 PM Julia Lawall <julia.lawall@inria.fr> wrote:
> > On Fri, 11 Dec 2020, Lukas Bulwahn wrote:
> > > 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?

> 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;



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-12  4:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 18:12 [PATCH] block: drop dead assignments in loop_init() Lukas Bulwahn
2020-12-11 18:23 ` Julia Lawall
2020-12-11 18:40   ` Lukas Bulwahn
2020-12-12  4:27     ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).