[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 08/13] hw/gpio/nrf51_gpio: Add nRF51 GPIO per
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v3 08/13] hw/gpio/nrf51_gpio: Add nRF51 GPIO peripheral |
Date: |
Thu, 1 Nov 2018 12:32:02 +0000 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Tue, Oct 30, 2018 at 08:25:22PM -0400, Steffen Görtz wrote:
> +/*
> + * Check if the output driver is connected to the direction switch
> + * given the current configuration and logic level.
> + * It is not differentiated between standard and "high"(-power) drive modes.
> + */
> +static bool is_connected(uint32_t config, uint32_t level)
> +{
> + bool state;
> + uint32_t drive_config = extract32(config, 8, 3);
> +
> + switch (drive_config) {
> + case 0 ... 3:
> + state = true;
> + break;
> + case 4 ... 5:
> + state = level != 0;
> + break;
> + case 6 ... 7:
> + state = level == 0;
> + break;
> + }
> +
> + return state;
> +}
gcc (GCC) 8.2.1 20181011 doesn't know that extract32(..., 3) can only
result in values [0, 7] so it warns that state can be uninitialized.
It might be simplest to include a default case that returns false (with
a comment).
signature.asc
Description: PGP signature
- Re: [Qemu-devel] [PATCH v3 08/13] hw/gpio/nrf51_gpio: Add nRF51 GPIO peripheral,
Stefan Hajnoczi <=