You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/04/12 21:49:44 UTC

[incubator-nuttx] 01/02: Fix suspect DEBUGASSERT() like PR765

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 743dcd8acf68059f78da2d89894363eef50aa33b
Author: Nathan Hartman <59...@users.noreply.github.com>
AuthorDate: Sun Apr 12 15:21:45 2020 -0400

    Fix suspect DEBUGASSERT() like PR765
    
    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 29935bb..f57d775 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 1dd057f..020f40b 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 b25c60a..43399b5 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