lib: fix switch statements to comply with MISRA rules
authorJonathan Wright <jonathan.wright@arm.com>
Tue, 13 Mar 2018 17:45:42 +0000 (17:45 +0000)
committerJonathan Wright <jonathan.wright@arm.com>
Mon, 26 Mar 2018 11:43:05 +0000 (12:43 +0100)
Ensure (where possible) that switch statements in lib comply with MISRA
rules 16.1 - 16.7.

Change-Id: I52bc896fb7094d2b7569285686ee89f39f1ddd84
Signed-off-by: Jonathan Wright <jonathan.wright@arm.com>
include/lib/pmf/pmf.h
lib/pmf/pmf_smc.c
lib/psci/psci_main.c

index a3d32263da4837613994ef7b189ffbebe497127c..2320760ea8e4783a7db3aaad5eaaaca7ad04fe2d 100644 (file)
@@ -37,8 +37,8 @@
 /*
  * Defines for PMF SMC function ids.
  */
-#define PMF_SMC_GET_TIMESTAMP_32       0x82000010
-#define PMF_SMC_GET_TIMESTAMP_64       0xC2000010
+#define PMF_SMC_GET_TIMESTAMP_32       0x82000010u
+#define PMF_SMC_GET_TIMESTAMP_64       0xC2000010u
 #define PMF_NUM_SMC_CALLS              2
 
 /*
index 5cf193e21947d6c210167ad883fff16c233d091c..e86611802b43601b7094ac6c216dc12366f17238 100644 (file)
@@ -30,8 +30,7 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid,
                x2 = (uint32_t)x2;
                x3 = (uint32_t)x3;
 
-               switch (smc_fid) {
-               case PMF_SMC_GET_TIMESTAMP_32:
+               if (smc_fid == PMF_SMC_GET_TIMESTAMP_32) {
                        /*
                         * Return error code and the captured
                         * time-stamp to the caller.
@@ -41,13 +40,9 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid,
                        rc = pmf_get_timestamp_smc(x1, x2, x3, &ts_value);
                        SMC_RET3(handle, rc, (uint32_t)ts_value,
                                        (uint32_t)(ts_value >> 32));
-
-               default:
-                       break;
                }
        } else {
-               switch (smc_fid) {
-               case PMF_SMC_GET_TIMESTAMP_64:
+               if (smc_fid == PMF_SMC_GET_TIMESTAMP_64) {
                        /*
                         * Return error code and the captured
                         * time-stamp to the caller.
@@ -56,9 +51,6 @@ uintptr_t pmf_smc_handler(unsigned int smc_fid,
                         */
                        rc = pmf_get_timestamp_smc(x1, x2, x3, &ts_value);
                        SMC_RET2(handle, rc, ts_value);
-
-               default:
-                       break;
                }
        }
 
index d25d1775ce9f9aa23badb5a9d00bd13ca029c39a..607d0cd50331332180b0e9701d4d6fc38bd0307b 100644 (file)
@@ -414,10 +414,12 @@ u_register_t psci_smc_handler(uint32_t smc_fid,
                case PSCI_SYSTEM_OFF:
                        psci_system_off();
                        /* We should never return from psci_system_off() */
+                       break;
 
                case PSCI_SYSTEM_RESET:
                        psci_system_reset();
                        /* We should never return from psci_system_reset() */
+                       break;
 
                case PSCI_FEATURES:
                        return psci_features(x1);