spi: Suppress null pointer warning

Depending on defines px4_spi_buses can be NULL
but often it's not and in those cases the
compiler correctly warns about it.
This commit is contained in:
Matthias Grob 2024-11-20 15:31:54 +01:00 committed by Daniel Agar
parent a49f034757
commit b8c2805263

View File

@ -87,7 +87,12 @@ const px4_spi_bus_t *px4_spi_buses{nullptr};
int px4_find_spi_bus(uint32_t devid)
{
// px4_spi_buses is only NULL on certain targets depending on defines
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Waddress"
for (int i = 0; ((px4_spi_bus_t *) px4_spi_buses) != nullptr && i < SPI_BUS_MAX_BUS_ITEMS; ++i) {
#pragma GCC diagnostic pop
const px4_spi_bus_t &bus_data = px4_spi_buses[i];
if (bus_data.bus == -1) {