Skip to content

PIO_Instruction.h warning message due to always-true comparison #2607

@earlephilhower

Description

@earlephilhower

GCC 14.3 with pedantic -Wall -Wextra warnings enabled produces the following warning on a comparison that's always true because of the param being unsigned

home/runner/arduino_ide/hardware/pico/rp2040//pico-sdk/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h: In function 'uint pio_encode_sideset_opt(uint, uint)':
/home/runner/arduino_ide/hardware/pico/rp2040//pico-sdk/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h:151:57: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits]
  151 |     valid_params_if(PIO_INSTRUCTIONS, sideset_bit_count >= 0 && sideset_bit_count <= 4);
      |                                       ~~~~~~~~~~~~~~~~~~^~~~
/home/runner/arduino_ide/hardware/pico/rp2040//pico-sdk/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h:151:5: note: in expansion of macro 'valid_params_if'
  151 |     valid_params_if(PIO_INSTRUCTIONS, sideset_bit_count >= 0 && sideset_bit_count <= 4);
      |     ^~~~~~~~~~~~~~~

static inline uint pio_encode_sideset_opt(uint sideset_bit_count, uint value) {
valid_params_if(PIO_INSTRUCTIONS, sideset_bit_count >= 0 && sideset_bit_count <= 4);
valid_params_if(PIO_INSTRUCTIONS, value <= ((1u << sideset_bit_count) - 1));
return 0x1000u | value << (12u - sideset_bit_count);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions