diff mbox series

[4/4] aspeed/timer: Clean up local variable shadowing

Message ID 20230922155924.1172019-5-clg@kaod.org (mailing list archive)
State New, archived
Headers show
Series aspeed: Clean up local variable shadowing | expand

Commit Message

Cédric Le Goater Sept. 22, 2023, 3:59 p.m. UTC
commit 8137355e850f ("aspeed/timer: Fix behaviour running Linux")
introduced a MAX() expression to calculate the next timer deadline :

    return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0));

The second MAX() is not necessary since the compared values are an
unsigned and 0. Simply remove it and fix warning :

  ../hw/timer/aspeed_timer.c: In function ‘calculate_next’:
  ../include/qemu/osdep.h:396:31: warning: declaration of ‘_a’ shadows a previous local [-Wshadow=compatible-local]
    396 |         typeof(1 ? (a) : (b)) _a = (a), _b = (b);       \
        |                               ^~
  ../hw/timer/aspeed_timer.c:170:12: note: in expansion of macro ‘MAX’
    170 |     next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
        |            ^~~
  ../hw/timer/aspeed_timer.c:170:16: note: in expansion of macro ‘MAX’
    170 |     next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
        |                ^~~
  /home/legoater/work/qemu/qemu-aspeed.git/include/qemu/osdep.h:396:31: note: shadowed declaration is here
    396 |         typeof(1 ? (a) : (b)) _a = (a), _b = (b);       \
        |                               ^~
  ../hw/timer/aspeed_timer.c:170:12: note: in expansion of macro ‘MAX’
    170 |     next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
        |            ^~~

Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/timer/aspeed_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Sept. 22, 2023, 6:32 p.m. UTC | #1
On 22/9/23 17:59, Cédric Le Goater wrote:
> commit 8137355e850f ("aspeed/timer: Fix behaviour running Linux")
> introduced a MAX() expression to calculate the next timer deadline :
> 
>      return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0));
> 
> The second MAX() is not necessary since the compared values are an
> unsigned and 0. Simply remove it and fix warning :
> 
>    ../hw/timer/aspeed_timer.c: In function ‘calculate_next’:
>    ../include/qemu/osdep.h:396:31: warning: declaration of ‘_a’ shadows a previous local [-Wshadow=compatible-local]
>      396 |         typeof(1 ? (a) : (b)) _a = (a), _b = (b);       \
>          |                               ^~
>    ../hw/timer/aspeed_timer.c:170:12: note: in expansion of macro ‘MAX’
>      170 |     next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
>          |            ^~~
>    ../hw/timer/aspeed_timer.c:170:16: note: in expansion of macro ‘MAX’
>      170 |     next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
>          |                ^~~
>    /home/legoater/work/qemu/qemu-aspeed.git/include/qemu/osdep.h:396:31: note: shadowed declaration is here
>      396 |         typeof(1 ? (a) : (b)) _a = (a), _b = (b);       \
>          |                               ^~
>    ../hw/timer/aspeed_timer.c:170:12: note: in expansion of macro ‘MAX’
>      170 |     next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
>          |            ^~~
> 
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>   hw/timer/aspeed_timer.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

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

Patch

diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
index 9c20b3d6ad8a..72161f07bbee 100644
--- a/hw/timer/aspeed_timer.c
+++ b/hw/timer/aspeed_timer.c
@@ -167,7 +167,7 @@  static uint64_t calculate_next(struct AspeedTimer *t)
         qemu_set_irq(t->irq, t->level);
     }
 
-    next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
+    next = MAX(calculate_match(t, 0), calculate_match(t, 1));
     t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
 
     return calculate_time(t, next);