From b8c2805263f7761772117cbaf93766909a8dabac Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Wed, 20 Nov 2024 15:31:54 +0100 Subject: [PATCH] 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. --- platforms/common/spi.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platforms/common/spi.cpp b/platforms/common/spi.cpp index 963372bdbe0f..bf553fbbf19b 100644 --- a/platforms/common/spi.cpp +++ b/platforms/common/spi.cpp @@ -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) {