Fix asserts appearing in release builds
authorJames Morrissey <james.morrissey@arm.com>
Mon, 10 Feb 2014 14:24:36 +0000 (14:24 +0000)
committerDan Handley <dan.handley@arm.com>
Mon, 17 Feb 2014 18:51:43 +0000 (18:51 +0000)
Also fix warnings generated in release builds when assert code
is absent.

Change-Id: I45b9173d3888f9e93e98eb5b4fdc06727ba5cbf4

Makefile
bl1/bl1_main.c
common/bl_common.c
common/psci/psci_common.c
common/psci/psci_setup.c
plat/fvp/aarch64/plat_common.c

index 7938318de85e7c8b2516a2d6a21a2bb299ed93cb..f64a700c3a30590d2bf14b9bc0ff31f3282be12a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -154,6 +154,8 @@ ifneq (${DEBUG}, 0)
 CFLAGS                 +=      -g
 # -save-temps -fverbose-asm
 ASFLAGS                        +=      -g -Wa,--gdwarf-2
+else
+CFLAGS                 +=      -DNDEBUG=1
 endif
 
 
index df92374353b0f4c09353a7e5dd05a7b0e7d5e11b..06ab4e59ee4b8b87c15df3f6908fa6f4ce8064ee 100644 (file)
@@ -47,7 +47,9 @@ void bl1_arch_next_el_setup(void);
   ******************************************************************************/
 void bl1_main(void)
 {
+#if DEBUG
        unsigned long sctlr_el3 = read_sctlr();
+#endif
        unsigned long bl2_base;
        unsigned int load_type = TOP_LOAD, spsr;
        meminfo *bl1_tzram_layout;
index 0a0c5cd803db8ea8870b8f488a41db94a25d3d1f..d401f8cc2b6b2e1147c1e83ad3a931c813fb33a4 100644 (file)
@@ -272,8 +272,9 @@ unsigned long load_image(meminfo *mem_layout,
                         unsigned int load_type,
                         unsigned long fixed_addr)
 {
-       unsigned long temp_image_base, image_base;
-       long offset;
+       unsigned long temp_image_base = 0;
+       unsigned long image_base = 0;
+       long offset = 0;
        int image_flen;
 
        /* Find the size of the image */
index e6be2f86ea259c28def863af1f6f38df8053c794..193655ddc834860a446bacaa6b6ec6015edb3f5e 100644 (file)
@@ -37,6 +37,7 @@
 #include <psci.h>
 #include <psci_private.h>
 #include <runtime_svc.h>
+#include "debug.h"
 
 /*******************************************************************************
  * Arrays that contains information needs to resume a cpu's execution when woken
@@ -511,7 +512,8 @@ void psci_afflvl_power_on_finish(unsigned long mpidr,
                                    start_afflvl,
                                    end_afflvl,
                                    mpidr_nodes);
-       assert (rc == PSCI_E_SUCCESS);
+       if (rc != PSCI_E_SUCCESS)
+               panic();
 
        /*
         * This function acquires the lock corresponding to each affinity
@@ -529,7 +531,8 @@ void psci_afflvl_power_on_finish(unsigned long mpidr,
                                         end_afflvl,
                                         pon_handlers,
                                         mpidr);
-       assert (rc == PSCI_E_SUCCESS);
+       if (rc != PSCI_E_SUCCESS)
+               panic();
 
        /*
         * This loop releases the lock corresponding to each affinity level
index c0d29f242e76918b125eb29d2dc56ac0f2fa274e..4c32b411aea46c16aacc7237dc537ed1c9c3f79a 100644 (file)
@@ -255,7 +255,7 @@ static unsigned int psci_init_aff_map(unsigned long mpidr,
  ******************************************************************************/
 void psci_setup(unsigned long mpidr)
 {
-       int afflvl, affmap_idx, rc, max_afflvl;
+       int afflvl, affmap_idx, max_afflvl;
        aff_map_node *node;
 
        /* Initialize psci's internal state */
@@ -314,8 +314,7 @@ void psci_setup(unsigned long mpidr)
                        psci_set_state(node, PSCI_STATE_ON);
        }
 
-       rc = platform_setup_pm(&psci_plat_pm_ops);
-       assert(rc == 0);
+       platform_setup_pm(&psci_plat_pm_ops);
        assert(psci_plat_pm_ops);
 
        return;
index 8568bfe2891217413e4fc5f29185eee76602287a..5b53aafb8b99d98925954e88853affbd3a54912b 100644 (file)
@@ -35,6 +35,7 @@
 #include <bl_common.h>
 /* Included only for error codes */
 #include <psci.h>
+#include "debug.h"
 
 unsigned char platform_normal_stacks[PLATFORM_STACK_SIZE][PLATFORM_CORE_COUNT]
 __attribute__ ((aligned(PLATFORM_CACHE_LINE_SIZE),
@@ -534,8 +535,8 @@ int platform_config_setup(void)
        bld = (sys_id >> SYS_ID_BLD_SHIFT) & SYS_ID_BLD_MASK;
        arch = (sys_id >> SYS_ID_ARCH_SHIFT) & SYS_ID_ARCH_MASK;
 
-       assert(rev == REV_FVP);
-       assert(arch == ARCH_MODEL);
+       if ((rev != REV_FVP) || (arch != ARCH_MODEL))
+               panic();
 
        /*
         * The build field in the SYS_ID tells which variant of the GIC