From 25cd4af362b87433486b834d71beb11247016276 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 6 Oct 2023 08:42:10 +0200 Subject: [PATCH] hw/mcu: Fix compilation with ARM GCC 13 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; --- hw/mcu/native/src/hal_timer.c | 2 +- hw/mcu/nordic/nrf51xxx/src/hal_timer.c | 2 +- hw/mcu/nordic/nrf52xxx/src/hal_timer.c | 2 +- hw/mcu/nordic/nrf5340/src/hal_timer.c | 2 +- hw/mcu/nordic/nrf5340_net/src/hal_timer.c | 2 +- hw/mcu/nordic/nrf91xx/src/hal_timer.c | 2 +- hw/mcu/nxp/kinetis/src/hal_timer.c | 2 +- hw/mcu/stm/stm32_common/src/hal_timer.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/mcu/native/src/hal_timer.c b/hw/mcu/native/src/hal_timer.c index 098ab8ddd5..77d3d0efea 100644 --- a/hw/mcu/native/src/hal_timer.c +++ b/hw/mcu/native/src/hal_timer.c @@ -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; diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_timer.c b/hw/mcu/nordic/nrf51xxx/src/hal_timer.c index a99be65cb1..abcd7a9a47 100644 --- a/hw/mcu/nordic/nrf51xxx/src/hal_timer.c +++ b/hw/mcu/nordic/nrf51xxx/src/hal_timer.c @@ -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) { diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_timer.c b/hw/mcu/nordic/nrf52xxx/src/hal_timer.c index fc6fe834d1..75dec3c382 100644 --- a/hw/mcu/nordic/nrf52xxx/src/hal_timer.c +++ b/hw/mcu/nordic/nrf52xxx/src/hal_timer.c @@ -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) { diff --git a/hw/mcu/nordic/nrf5340/src/hal_timer.c b/hw/mcu/nordic/nrf5340/src/hal_timer.c index cdc6c1ed0e..082567b9c4 100644 --- a/hw/mcu/nordic/nrf5340/src/hal_timer.c +++ b/hw/mcu/nordic/nrf5340/src/hal_timer.c @@ -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) { diff --git a/hw/mcu/nordic/nrf5340_net/src/hal_timer.c b/hw/mcu/nordic/nrf5340_net/src/hal_timer.c index 06884c61b3..9f6701520e 100644 --- a/hw/mcu/nordic/nrf5340_net/src/hal_timer.c +++ b/hw/mcu/nordic/nrf5340_net/src/hal_timer.c @@ -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) { diff --git a/hw/mcu/nordic/nrf91xx/src/hal_timer.c b/hw/mcu/nordic/nrf91xx/src/hal_timer.c index 61f87a10ed..5547a32818 100644 --- a/hw/mcu/nordic/nrf91xx/src/hal_timer.c +++ b/hw/mcu/nordic/nrf91xx/src/hal_timer.c @@ -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) { diff --git a/hw/mcu/nxp/kinetis/src/hal_timer.c b/hw/mcu/nxp/kinetis/src/hal_timer.c index 4fadd01a2c..58cc02e3ee 100644 --- a/hw/mcu/nxp/kinetis/src/hal_timer.c +++ b/hw/mcu/nxp/kinetis/src/hal_timer.c @@ -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; diff --git a/hw/mcu/stm/stm32_common/src/hal_timer.c b/hw/mcu/stm/stm32_common/src/hal_timer.c index e5f4ed7ac9..b7c2206746 100644 --- a/hw/mcu/stm/stm32_common/src/hal_timer.c +++ b/hw/mcu/stm/stm32_common/src/hal_timer.c @@ -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;