All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: qemu-arm@nongnu.org,  qemu-devel@nongnu.org,
	 Joel Stanley <joel@jms.id.au>,  Andrew Jeffery <andrew@aj.id.au>
Subject: Re: [PATCH 2/4] aspeed: Clean up local variable shadowing
Date: Sat, 23 Sep 2023 08:34:43 +0200	[thread overview]
Message-ID: <87pm29mm7w.fsf@pond.sub.org> (raw)
In-Reply-To: <20230922155924.1172019-3-clg@kaod.org> ("Cédric Le Goater"'s message of "Fri, 22 Sep 2023 17:59:22 +0200")

Cédric Le Goater <clg@kaod.org> writes:

> Remove superfluous local 'irq' variables and use the one define at the
> top of the routine. This fixes warnings in aspeed_soc_ast2600_realize()
> such as :
>
>   ../hw/arm/aspeed_ast2600.c: In function ‘aspeed_soc_ast2600_realize’:
>   ../hw/arm/aspeed_ast2600.c:420:18: warning: declaration of ‘irq’ shadows a previous local [-Wshadow=compatible-local]
>     420 |         qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i);
>         |                  ^~~
>   ../hw/arm/aspeed_ast2600.c:312:14: note: shadowed declaration is here
>     312 |     qemu_irq irq;
>         |              ^~~
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/arm/aspeed_ast2600.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
> index a8b3a8065a11..e122e1c32d42 100644
> --- a/hw/arm/aspeed_ast2600.c
> +++ b/hw/arm/aspeed_ast2600.c
> @@ -388,7 +388,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
>      aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0,
>                      sc->memmap[ASPEED_DEV_TIMER1]);
>      for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
> -        qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i);
> +        irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i);
>          sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq);
>      }
>  
> @@ -413,8 +413,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
>      }
>      aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]);
>      for (i = 0; i < ASPEED_I2C_GET_CLASS(&s->i2c)->num_busses; i++) {
> -        qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
> -                                        sc->irqmap[ASPEED_DEV_I2C] + i);
> +        irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
> +                               sc->irqmap[ASPEED_DEV_I2C] + i);
>          /* The AST2600 I2C controller has one IRQ per bus. */
>          sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c.busses[i]), 0, irq);
>      }
> @@ -611,8 +611,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
>      }
>      aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]);
>      for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) {
> -        qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
> -                                        sc->irqmap[ASPEED_DEV_I3C] + i);
> +        irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
> +                               sc->irqmap[ASPEED_DEV_I3C] + i);
>          /* The AST2600 I3C controller has one IRQ per bus. */
>          sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq);
>      }

Clashes with Philippe's

    [PATCH v2 10/22] hw/arm/aspeed: Clean up local variable shadowing
    Message-ID: <20230904161235.84651-11-philmd@linaro.org>

The difference is a matter of taste: one @irq in function scope vs. four
in nested scopes.  I'd prefer the former, i.e. this patch, but
maintainers' preference matter more than mine.  If you want me to merge
together with other shadowing patches, tell me your preference, if any.


  parent reply	other threads:[~2023-09-23  6:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22 15:59 [PATCH 0/4] aspeed: Clean up local variable shadowing Cédric Le Goater
2023-09-22 15:59 ` [PATCH 1/4] aspeed/i2c: " Cédric Le Goater
2023-09-22 18:22   ` Philippe Mathieu-Daudé
2023-09-27  2:38   ` Joel Stanley
2023-09-22 15:59 ` [PATCH 2/4] aspeed: " Cédric Le Goater
2023-09-22 18:23   ` Philippe Mathieu-Daudé
2023-09-23  6:34   ` Markus Armbruster [this message]
2023-09-23  7:10     ` Cédric Le Goater
2023-09-22 15:59 ` [PATCH 3/4] aspeed/i3c: Rename variable shadowing a local Cédric Le Goater
2023-09-22 18:28   ` Philippe Mathieu-Daudé
2023-09-25  6:29     ` Andrew Jeffery
2023-09-22 15:59 ` [PATCH 4/4] aspeed/timer: Clean up local variable shadowing Cédric Le Goater
2023-09-22 18:32   ` Philippe Mathieu-Daudé
2023-09-22 18:20 ` [PATCH 0/4] aspeed: " Philippe Mathieu-Daudé
2023-09-22 19:00   ` Cédric Le Goater
2023-09-23  7:13     ` Markus Armbruster
2023-09-25 16:28       ` Cédric Le Goater
2023-09-26  6:44         ` Markus Armbruster
2023-09-29  6:46 ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pm29mm7w.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.