Skip to content

Commit

Permalink
spi: Suppress null pointer warning
Browse files Browse the repository at this point in the history
Depending on defines px4_spi_buses can be NULL
but often it's not and in those cases the
compiler correctly warns about it.
  • Loading branch information
MaEtUgR authored and dagar committed Nov 21, 2024
1 parent a49f034 commit b8c2805
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions platforms/common/spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b8c2805

Please sign in to comment.