From 743dcd8acf68059f78da2d89894363eef50aa33b Mon Sep 17 00:00:00 2001 From: Nathan Hartman <59230071+hartmannathan@users.noreply.github.com> Date: Sun, 12 Apr 2020 15:21:45 -0400 Subject: [PATCH] Fix suspect DEBUGASSERT() like PR765 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As pointed out by Şükrü Bahadır Arslan in PR765, function calls inside DEBUGASSERT() will not be executed if DEBUGASSERT is disabled. Following that PR, I searched for other instances of similar errors and found four. As there are many thousands of DEBUGASSERT in the code, this is *not* an exhaustive fix. arch/arm/src/tms570/tms570_boot.c: * In function arm_boot(), call tms570_memtest_complete() outside of the DEBUGASSERT(). Otherwise, if DEBUGASSERT is disabled, we will never rendezvous with completion of the test. (Two instances of this fix.) arch/arm/src/tms570/tms570_clockconfig.c: * In function tms570_clockconfig(), call tms570_efc_selftest_complete() outside of the DEBUGASSERT() for the same reason as above. boards/arm/sam34/sam4s-xplained-pro/src/sam_boot.c: * In function board_late_initialize(), call sam_watchdog_initialize() outside of the DEBUGASSERT() for the same reason as above. --- arch/arm/src/tms570/tms570_boot.c | 11 +++++++++-- arch/arm/src/tms570/tms570_clockconfig.c | 10 ++++++++-- boards/arm/sam34/sam4s-xplained-pro/src/sam_boot.c | 4 +++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/arch/arm/src/tms570/tms570_boot.c b/arch/arm/src/tms570/tms570_boot.c index 29935bb74b2..f57d7754142 100644 --- a/arch/arm/src/tms570/tms570_boot.c +++ b/arch/arm/src/tms570/tms570_boot.c @@ -297,6 +297,10 @@ static void go_nx_start(void) void arm_boot(void) { +#ifdef CONFIG_TMS570_SELFTEST + int check; +#endif /* CONFIG_TMS570_SELFTEST */ + /* Enable CPU Event Export. * * This allows the CPU to signal any single-bit or double-bit errors @@ -340,7 +344,8 @@ void arm_boot(void) /* Run the memory selftest on CPU RAM. */ tms570_memtest_start(PBIST_RINFOL_ESRAM1_RAM); - DEBUGASSERT(tms570_memtest_complete() == OK); + check = tms570_memtest_complete(); + DEBUGASSERT(check == OK); #endif /* CONFIG_TMS570_SELFTEST */ /* Initialize CPU RAM. */ @@ -379,7 +384,9 @@ void arm_boot(void) /* Wait for the memory test to complete */ - DEBUGASSERT(tms570_memtest_complete() == OK); + check = tms570_memtest_complete(); + DEBUGASSERT(check == OK); + UNUSED(check); #endif /* CONFIG_TMS570_SELFTEST */ #ifdef CONFIG_TMS570_MIBASPI1 diff --git a/arch/arm/src/tms570/tms570_clockconfig.c b/arch/arm/src/tms570/tms570_clockconfig.c index 1dd057fab36..020f40b87fe 100644 --- a/arch/arm/src/tms570/tms570_clockconfig.c +++ b/arch/arm/src/tms570/tms570_clockconfig.c @@ -816,6 +816,10 @@ static void tms570_eclk_configure(void) void tms570_clockconfig(void) { +#ifdef CONFIG_TMS570_SELFTEST + int check; +#endif /* CONFIG_TMS570_SELFTEST */ + /* Configure PLL control registers and enable PLLs. */ tms570_pll_setup(); @@ -839,8 +843,10 @@ void tms570_clockconfig(void) #ifdef CONFIG_TMS570_SELFTEST /* Wait for eFuse controller self-test to complete and check results */ - DEBUGASSERT(tms570_efc_selftest_complete() == 0); -#endif + check = tms570_efc_selftest_complete(); + DEBUGASSERT(check == 0); + UNUSED(check); +#endif /* CONFIG_TMS570_SELFTEST */ /* Set up flash address and data wait states. */ diff --git a/boards/arm/sam34/sam4s-xplained-pro/src/sam_boot.c b/boards/arm/sam34/sam4s-xplained-pro/src/sam_boot.c index b25c60a7cd8..43399b59414 100644 --- a/boards/arm/sam34/sam4s-xplained-pro/src/sam_boot.c +++ b/boards/arm/sam34/sam4s-xplained-pro/src/sam_boot.c @@ -89,7 +89,9 @@ void board_late_initialize(void) #if (defined(CONFIG_SAM34_WDT) && !defined(CONFIG_WDT_DISABLE_ON_RESET)) /* Configure watchdog timer and enable kicker kernel thread. */ - DEBUGASSERT(sam_watchdog_initialize() >= 0); + int check = sam_watchdog_initialize(); + DEBUGASSERT(check >= 0); + UNUSED(check); #endif #ifndef CONFIG_ARCH_LEDS