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).

Attachment: signature.asc
Description: PGP signature

Reply via email to