diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2024-08-30 19:05:16 +0100 |
|---|---|---|
| committer | Cédric Le Goater <clg@redhat.com> | 2024-09-16 17:44:07 +0200 |
| commit | 737cb2f3b21af83ab3e01d4f86e52c1c1afe3524 (patch) | |
| tree | db9fc0f0e750e6f7378cdb20934ad6ad1200e0fa /hw/gpio/aspeed_gpio.c | |
| parent | ea9cdbcf3a0b8d5497cddf87990f1b39d8f3bb0a (diff) | |
| download | focaccia-qemu-737cb2f3b21af83ab3e01d4f86e52c1c1afe3524.tar.gz focaccia-qemu-737cb2f3b21af83ab3e01d4f86e52c1c1afe3524.zip | |
hw/gpio/aspeed_gpio: Avoid shift into sign bit
In aspeed_gpio_update() we calculate "mask = 1 << gpio", where gpio can be between 0 and 31. Coverity complains about this because 1 << 31 won't fit in a signed integer. For QEMU this isn't an error because we enable -fwrapv, but we can keep Coverity happy by doing the shift on unsigned numbers. Resolves: Coverity CID 1547742 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/gpio/aspeed_gpio.c')
| -rw-r--r-- | hw/gpio/aspeed_gpio.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c index 3e7b35cf4f..71756664dd 100644 --- a/hw/gpio/aspeed_gpio.c +++ b/hw/gpio/aspeed_gpio.c @@ -281,7 +281,7 @@ static void aspeed_gpio_update(AspeedGPIOState *s, GPIOSets *regs, diff &= mode_mask; if (diff) { for (gpio = 0; gpio < ASPEED_GPIOS_PER_SET; gpio++) { - uint32_t mask = 1 << gpio; + uint32_t mask = 1U << gpio; /* If the gpio needs to be updated... */ if (!(diff & mask)) { |