From 185a23ffa3b6fc007021ac9bbab2213c63911c0a Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Wed, 14 Mar 2018 15:56:21 +0000 Subject: [PATCH] services: fix switch statements to comply with MISRA rules Ensure (where possible) that switch statements in services comply with MISRA rules 16.1 - 16.7. Change-Id: I47bf6ed4a026201e6fe125ce51842482e99e8bb0 Signed-off-by: Jonathan Wright --- services/spd/opteed/opteed_main.c | 2 ++ services/spd/tlkd/tlkd_common.c | 1 + services/spd/tlkd/tlkd_main.c | 2 ++ services/spd/tspd/tspd_main.c | 3 ++- services/std_svc/sdei/sdei_main.c | 21 ++------------------- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/services/spd/opteed/opteed_main.c b/services/spd/opteed/opteed_main.c index 13a307a2..3d679806 100644 --- a/services/spd/opteed/opteed_main.c +++ b/services/spd/opteed/opteed_main.c @@ -311,6 +311,7 @@ uint64_t opteed_smc_handler(uint32_t smc_fid, * OPTEE. Jump back to the original C runtime context. */ opteed_synchronous_sp_exit(optee_ctx, x1); + break; /* @@ -345,6 +346,7 @@ uint64_t opteed_smc_handler(uint32_t smc_fid, * return value to the caller */ opteed_synchronous_sp_exit(optee_ctx, x1); + break; /* * OPTEE is returning from a call or being preempted from a call, in diff --git a/services/spd/tlkd/tlkd_common.c b/services/spd/tlkd/tlkd_common.c index 483d45b6..d846269b 100644 --- a/services/spd/tlkd/tlkd_common.c +++ b/services/spd/tlkd/tlkd_common.c @@ -49,6 +49,7 @@ uint64_t tlkd_va_translate(uintptr_t va, int type) break; default: assert(0); + break; } /* get the (NS/S) physical address */ diff --git a/services/spd/tlkd/tlkd_main.c b/services/spd/tlkd/tlkd_main.c index cb68bff7..da3b732e 100644 --- a/services/spd/tlkd/tlkd_main.c +++ b/services/spd/tlkd/tlkd_main.c @@ -350,6 +350,7 @@ uint64_t tlkd_smc_handler(uint32_t smc_fid, * context. */ tlkd_synchronous_sp_exit(&tlk_ctx, x1); + break; /* * These function IDs are used only by TLK to indicate it has @@ -375,6 +376,7 @@ uint64_t tlkd_smc_handler(uint32_t smc_fid, * return value to the caller */ tlkd_synchronous_sp_exit(&tlk_ctx, x1); + break; /* * Return the number of service function IDs implemented to diff --git a/services/spd/tspd/tspd_main.c b/services/spd/tspd/tspd_main.c index 3d06e0b8..2312205c 100644 --- a/services/spd/tspd/tspd_main.c +++ b/services/spd/tspd/tspd_main.c @@ -435,6 +435,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid, * context. */ tspd_synchronous_sp_exit(tsp_ctx, x1); + break; #endif /* * This function ID is used only by the SP to indicate it has finished @@ -475,6 +476,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid, * return value to the caller */ tspd_synchronous_sp_exit(tsp_ctx, x1); + break; /* * Request from non-secure client to perform an @@ -591,7 +593,6 @@ uint64_t tspd_smc_handler(uint32_t smc_fid, SMC_RET3(ns_cpu_context, x1, x2, x3); } - break; /* * Request from the non-secure world to abort a preempted Yielding SMC * Call. diff --git a/services/std_svc/sdei/sdei_main.c b/services/std_svc/sdei/sdei_main.c index 1969307f..9589a252 100644 --- a/services/std_svc/sdei/sdei_main.c +++ b/services/std_svc/sdei/sdei_main.c @@ -916,7 +916,6 @@ uint64_t sdei_smc_handler(uint32_t smc_fid, ret = sdei_version(); SDEI_LOG("< VER:%lx\n", ret); SMC_RET1(handle, ret); - break; case SDEI_EVENT_REGISTER: x5 = SMC_GET_GP(handle, CTX_GPREG_X5); @@ -925,32 +924,27 @@ uint64_t sdei_smc_handler(uint32_t smc_fid, ret = sdei_event_register(x1, x2, x3, x4, x5); SDEI_LOG("< REG:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_EVENT_ENABLE: SDEI_LOG("> ENABLE(n:%d)\n", (int) x1); ret = sdei_event_enable(x1); SDEI_LOG("< ENABLE:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_EVENT_DISABLE: SDEI_LOG("> DISABLE(n:%d)\n", (int) x1); ret = sdei_event_disable(x1); SDEI_LOG("< DISABLE:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_EVENT_CONTEXT: SDEI_LOG("> CTX(p:%d):%lx\n", (int) x1, read_mpidr_el1()); ret = sdei_event_context(handle, x1); SDEI_LOG("< CTX:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_EVENT_COMPLETE_AND_RESUME: resume = 1; - /* Fall through */ case SDEI_EVENT_COMPLETE: SDEI_LOG("> COMPLETE(r:%d sta/ep:%lx):%lx\n", resume, x1, @@ -969,92 +963,81 @@ uint64_t sdei_smc_handler(uint32_t smc_fid, SMC_RET1(handle, ret); SMC_RET0(handle); - break; case SDEI_EVENT_STATUS: SDEI_LOG("> STAT(n:%d)\n", (int) x1); ret = sdei_event_status(x1); SDEI_LOG("< STAT:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_EVENT_GET_INFO: SDEI_LOG("> INFO(n:%d, %d)\n", (int) x1, (int) x2); ret = sdei_event_get_info(x1, x2); SDEI_LOG("< INFO:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_EVENT_UNREGISTER: SDEI_LOG("> UNREG(n:%d)\n", (int) x1); ret = sdei_event_unregister(x1); SDEI_LOG("< UNREG:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_PE_UNMASK: SDEI_LOG("> UNMASK:%lx\n", read_mpidr_el1()); sdei_pe_unmask(); SDEI_LOG("< UNMASK:%d\n", 0); SMC_RET1(handle, 0); - break; case SDEI_PE_MASK: SDEI_LOG("> MASK:%lx\n", read_mpidr_el1()); ret = sdei_pe_mask(); SDEI_LOG("< MASK:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_INTERRUPT_BIND: SDEI_LOG("> BIND(%d)\n", (int) x1); ret = sdei_interrupt_bind(x1); SDEI_LOG("< BIND:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_INTERRUPT_RELEASE: SDEI_LOG("> REL(%d)\n", (int) x1); ret = sdei_interrupt_release(x1); SDEI_LOG("< REL:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_SHARED_RESET: SDEI_LOG("> S_RESET():%lx\n", read_mpidr_el1()); ret = sdei_shared_reset(); SDEI_LOG("< S_RESET:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_PRIVATE_RESET: SDEI_LOG("> P_RESET():%lx\n", read_mpidr_el1()); ret = sdei_private_reset(); SDEI_LOG("< P_RESET:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_EVENT_ROUTING_SET: SDEI_LOG("> ROUTE_SET(n:%d f:%lx aff:%lx)\n", (int) x1, x2, x3); ret = sdei_event_routing_set(x1, x2, x3); SDEI_LOG("< ROUTE_SET:%ld\n", ret); SMC_RET1(handle, ret); - break; case SDEI_FEATURES: SDEI_LOG("> FTRS(f:%lx)\n", x1); ret = sdei_features(x1); SDEI_LOG("< FTRS:%lx\n", ret); SMC_RET1(handle, ret); - break; case SDEI_EVENT_SIGNAL: SDEI_LOG("> SIGNAL(e:%lx t:%lx)\n", x1, x2); ret = sdei_signal(x1, x2); SDEI_LOG("< SIGNAL:%ld\n", ret); SMC_RET1(handle, ret); - break; + default: + /* Do nothing in default case */ break; } -- 2.30.2