[PATCH 1/4] aspeed/i2c: Clean up local variable shadowing

Cédric Le Goater posted 4 patches 2 years, 4 months ago
Maintainers: "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Andrew Jeffery <andrew@aj.id.au>, Joel Stanley <joel@jms.id.au>
[PATCH 1/4] aspeed/i2c: Clean up local variable shadowing
Posted by Cédric Le Goater 2 years, 4 months ago
Remove superfluous local 'data' variable and use the one define at the
top of the routine. This fixes :

  ../hw/i2c/aspeed_i2c.c: In function ‘aspeed_i2c_bus_recv’:
  ../hw/i2c/aspeed_i2c.c:315:17: warning: declaration of ‘data’ shadows a previous local [-Wshadow=compatible-local]
    315 |         uint8_t data;
        |                 ^~~~
  ../hw/i2c/aspeed_i2c.c:288:13: note: shadowed declaration is here
    288 |     uint8_t data;
        |             ^~~~

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/i2c/aspeed_i2c.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
index 7275d40749a9..1037c22b2f79 100644
--- a/hw/i2c/aspeed_i2c.c
+++ b/hw/i2c/aspeed_i2c.c
@@ -312,7 +312,6 @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus)
         SHARED_ARRAY_FIELD_DP32(bus->regs, reg_pool_ctrl, RX_COUNT, i & 0xff);
         SHARED_ARRAY_FIELD_DP32(bus->regs, reg_cmd, RX_BUFF_EN, 0);
     } else if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, RX_DMA_EN)) {
-        uint8_t data;
         /* In new mode, clear how many bytes we RXed */
         if (aspeed_i2c_is_new_mode(bus->controller)) {
             ARRAY_FIELD_DP32(bus->regs, I2CM_DMA_LEN_STS, RX_LEN, 0);
-- 
2.41.0


Re: [PATCH 1/4] aspeed/i2c: Clean up local variable shadowing
Posted by Joel Stanley 2 years, 4 months ago
On Fri, 22 Sept 2023 at 15:59, Cédric Le Goater <clg@kaod.org> wrote:
>
> Remove superfluous local 'data' variable and use the one define at the
> top of the routine. This fixes :
>
>   ../hw/i2c/aspeed_i2c.c: In function ‘aspeed_i2c_bus_recv’:
>   ../hw/i2c/aspeed_i2c.c:315:17: warning: declaration of ‘data’ shadows a previous local [-Wshadow=compatible-local]
>     315 |         uint8_t data;
>         |                 ^~~~
>   ../hw/i2c/aspeed_i2c.c:288:13: note: shadowed declaration is here
>     288 |     uint8_t data;
>         |             ^~~~
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Joel Stanley <joel@jms.id.au>

messy.

> ---
>  hw/i2c/aspeed_i2c.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
> index 7275d40749a9..1037c22b2f79 100644
> --- a/hw/i2c/aspeed_i2c.c
> +++ b/hw/i2c/aspeed_i2c.c
> @@ -312,7 +312,6 @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus)
>          SHARED_ARRAY_FIELD_DP32(bus->regs, reg_pool_ctrl, RX_COUNT, i & 0xff);
>          SHARED_ARRAY_FIELD_DP32(bus->regs, reg_cmd, RX_BUFF_EN, 0);
>      } else if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, RX_DMA_EN)) {
> -        uint8_t data;
>          /* In new mode, clear how many bytes we RXed */
>          if (aspeed_i2c_is_new_mode(bus->controller)) {
>              ARRAY_FIELD_DP32(bus->regs, I2CM_DMA_LEN_STS, RX_LEN, 0);
> --
> 2.41.0
>
Re: [PATCH 1/4] aspeed/i2c: Clean up local variable shadowing
Posted by Philippe Mathieu-Daudé 2 years, 4 months ago
On 22/9/23 17:59, Cédric Le Goater wrote:
> Remove superfluous local 'data' variable and use the one define at the
> top of the routine. This fixes :
> 
>    ../hw/i2c/aspeed_i2c.c: In function ‘aspeed_i2c_bus_recv’:
>    ../hw/i2c/aspeed_i2c.c:315:17: warning: declaration of ‘data’ shadows a previous local [-Wshadow=compatible-local]
>      315 |         uint8_t data;
>          |                 ^~~~
>    ../hw/i2c/aspeed_i2c.c:288:13: note: shadowed declaration is here
>      288 |     uint8_t data;
>          |             ^~~~
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>   hw/i2c/aspeed_i2c.c | 1 -
>   1 file changed, 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>