Skip to content

Commit

Permalink
hw/mcu: Fix compilation with ARM GCC 13
Browse files Browse the repository at this point in the history
multiple hal_timer_stop() implementations follow same pattern which
seems to trigger false-positive (ie entry cannot be used uninitialized
here) with ARM GCC 13.2

Compiling repos/apache-mynewt-core/kernel/os/src/os_error.c
Error: repos/apache-mynewt-core/hw/mcu/nordic/nrf5340/src/hal_timer.c:
     In function 'hal_timer_stop':
repos/apache-mynewt-core/hw/mcu/nordic/nrf5340/src/hal_timer.c:885:17:
     error: 'entry' may be used uninitialized [-Werror=maybe-uninitialized]
  885 |                 nrf_timer_set_ocmp((struct nrf5340_hal_timer *)
                                            entry->bsp_timer,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  886 |                                    entry->expiry);
      |                                    ~~~~~~~~~~~~~~
repos/apache-mynewt-core/hw/mcu/nordic/nrf5340/src/hal_timer.c:863:23:
    note: 'entry' was declared here
  863 |     struct hal_timer *entry;
  • Loading branch information
sjanc committed Oct 6, 2023
1 parent b78d14a commit 25cd4af
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hw/mcu/native/src/hal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ int
hal_timer_stop(struct hal_timer *timer)
{
struct native_timer *nt;
struct hal_timer *ht;
struct hal_timer *ht = NULL;
int reset_ocmp;
os_sr_t sr;

Expand Down
2 changes: 1 addition & 1 deletion hw/mcu/nordic/nrf51xxx/src/hal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ hal_timer_stop(struct hal_timer *timer)
{
uint32_t ctx;
int reset_ocmp;
struct hal_timer *entry;
struct hal_timer *entry = NULL;
struct nrf51_hal_timer *bsptimer;

if (timer == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion hw/mcu/nordic/nrf52xxx/src/hal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ hal_timer_stop(struct hal_timer *timer)
{
uint32_t ctx;
int reset_ocmp;
struct hal_timer *entry;
struct hal_timer *entry = NULL;
struct nrf52_hal_timer *bsptimer;

if (timer == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion hw/mcu/nordic/nrf5340/src/hal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ hal_timer_stop(struct hal_timer *timer)
{
uint32_t ctx;
int reset_ocmp;
struct hal_timer *entry;
struct hal_timer *entry = NULL;
struct nrf5340_hal_timer *bsptimer;

if (timer == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion hw/mcu/nordic/nrf5340_net/src/hal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ hal_timer_stop(struct hal_timer *timer)
{
uint32_t ctx;
int reset_ocmp;
struct hal_timer *entry;
struct hal_timer *entry = NULL;
struct nrf5340_hal_timer *bsptimer;

if (timer == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion hw/mcu/nordic/nrf91xx/src/hal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ hal_timer_stop(struct hal_timer *timer)
{
uint32_t ctx;
int reset_ocmp;
struct hal_timer *entry;
struct hal_timer *entry = NULL;
struct nrf91_hal_timer *bsptimer;

if (timer == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion hw/mcu/nxp/kinetis/src/hal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ int
hal_timer_stop(struct hal_timer *timer)
{
struct kinetis_hal_tmr *tmr;
struct hal_timer *entry;
struct hal_timer *entry = NULL;
bool reset_period;
os_sr_t sr;

Expand Down
2 changes: 1 addition & 1 deletion hw/mcu/stm/stm32_common/src/hal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ int
hal_timer_stop(struct hal_timer *timer)
{
struct stm32_hal_tmr *tmr;
struct hal_timer *ht;
struct hal_timer *ht = NULL;
int sr;
int reset_ocmp;

Expand Down

0 comments on commit 25cd4af

Please sign in to comment.