When building on ArchLinux with current tool chain, -Werror fails due to a new (probably recently introduced) warning in platforms/common/spi.cpp:
/home/andrej/inst/PX4-Autopilot/platforms/common/spi.cpp: In function 'int px4_find_spi_bus(uint32_t)':
/home/andrej/inst/PX4-Autopilot/platforms/common/spi.cpp:90:59: error: the address of 'px4_spi_buses' will never be NULL [-Werror=address]
90 | for (int i = 0; ((px4_spi_bus_t *) px4_spi_buses) != nullptr && i < SPI_BUS_MAX_BUS_ITEMS; ++i) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
Describe your preferred solution
To make the warning non-fatal, one can add -Wno-error=address behind -Werror in cmake/px4_add_common_flags.cmake. The affected boards build just fine in that case, with a non-fatal warning.
Describe possible alternatives
The obvious quick workaround (removal of ((px4_spi_bus_t *) px4_spi_buses) != nullptr) makes it build too, but that doesn’t mean it’s working (or correct). I’m not sure if there’s (e.g.) a platform where px4_spi_buses can be a nullptr. There probably is one, or else the check wouldn’t be there… This needs to be double-checked by someone familiar with the broader context.
Describe problem solved by the proposed feature
When building on ArchLinux with current tool chain,
-Werror
fails due to a new (probably recently introduced) warning inplatforms/common/spi.cpp
:Describe your preferred solution
To make the warning non-fatal, one can add
-Wno-error=address
behind-Werror
incmake/px4_add_common_flags.cmake
. The affected boards build just fine in that case, with a non-fatal warning.Describe possible alternatives
The obvious quick workaround (removal of
((px4_spi_bus_t *) px4_spi_buses) != nullptr
) makes it build too, but that doesn’t mean it’s working (or correct). I’m not sure if there’s (e.g.) a platform wherepx4_spi_buses
can be anullptr
. There probably is one, or else the check wouldn’t be there… This needs to be double-checked by someone familiar with the broader context.Additional context
No response