Skip to content

Commit

Permalink
nrfx_clock: Disable array bounds warning for nrf_clock_is_running
Browse files Browse the repository at this point in the history
This commit disables the array bounds warning (`-Warray-bounds`) for
the `nrf_clock_is_running` function because GCC 12 and above may report
a false positive due to the size of the write access to the memory
address pointed by the `p_clk_src` argument being variable depending on
the value of the `domain` argument.

Signed-off-by: Stephanos Ioannidis <[email protected]>
  • Loading branch information
stephanosio authored and nika-nordic committed Aug 30, 2022
1 parent 16756ca commit f5a9b04
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hal/nrf_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,17 @@ NRF_STATIC_INLINE bool nrf_clock_start_task_check(NRF_CLOCK_Type const * p_reg,
}
}

/*
* `-Warray-bounds` warning is disabled for the `nrf_clock_is_running`
* function because GCC 12 and above may report a false positive due to the
* size of the write access to the memory address pointed by the `p_clk_src`
* argument being variable depending on the value of the `domain` argument.
*/
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif

NRF_STATIC_INLINE bool nrf_clock_is_running(NRF_CLOCK_Type const * p_reg,
nrf_clock_domain_t domain,
void * p_clk_src)
Expand Down Expand Up @@ -831,6 +842,10 @@ NRF_STATIC_INLINE bool nrf_clock_is_running(NRF_CLOCK_Type const * p_reg,
return false;
}

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

NRF_STATIC_INLINE void nrf_clock_lf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_lfclk_t source)
{
p_reg->LFCLKSRC = (uint32_t)(source);
Expand Down

0 comments on commit f5a9b04

Please sign in to comment.