diff options
author | Daniel Boulby <daniel.boulby@arm.com> | 2018-06-22 14:16:03 +0100 |
---|---|---|
committer | Daniel Boulby <daniel.boulby@arm.com> | 2018-09-21 13:14:13 +0100 |
commit | a08a2014300a495381cdb8f6d59523bcd5d3b883 (patch) | |
tree | ab016b027c303ccbe8001764f824f8980b233f54 /plat/common | |
parent | e52ed092cde21d13533df32eb68629a980d69b4b (diff) |
Ensure the flow through switch statements is clear
Ensure case clauses:
* Terminate with an unconditional break, return or goto statement.
* Use conditional break, return or goto statements as long as the end
of the case clause is unreachable; such case clauses must terminate
with assert(0) /* Unreachable */ or an unconditional __dead2 function
call
* Only fallthough when doing otherwise would result in less
readable/maintainable code; such case clauses must terminate with a
/* Fallthrough */ comment to make it clear this is the case and
indicate that a fallthrough is intended.
This reduces the chance of bugs appearing due to unintended flow through a
switch statement
Change-Id: I70fc2d1f4fd679042397dec12fd1982976646168
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Diffstat (limited to 'plat/common')
-rw-r--r-- | plat/common/plat_gicv2.c | 4 | ||||
-rw-r--r-- | plat/common/plat_gicv3.c | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/plat/common/plat_gicv2.c b/plat/common/plat_gicv2.c index 2b61834b..4b668737 100644 --- a/plat/common/plat_gicv2.c +++ b/plat/common/plat_gicv2.c @@ -226,7 +226,7 @@ void plat_ic_set_interrupt_type(unsigned int id, unsigned int type) gicv2_type = GICV2_INTR_GROUP1; break; default: - assert(false); + assert(0); /* Unreachable */ break; } @@ -266,7 +266,7 @@ void plat_ic_set_spi_routing(unsigned int id, unsigned int routing_mode, proc_num = -1; break; default: - assert(false); + assert(0); /* Unreachable */ break; } diff --git a/plat/common/plat_gicv3.c b/plat/common/plat_gicv3.c index e43a3550..f8277fe5 100644 --- a/plat/common/plat_gicv3.c +++ b/plat/common/plat_gicv3.c @@ -157,6 +157,7 @@ uint32_t plat_interrupt_type_to_line(uint32_t type, return __builtin_ctz(SCR_IRQ_BIT); else return __builtin_ctz(SCR_FIQ_BIT); + assert(0); /* Unreachable */ case INTR_TYPE_NS: /* * The Non secure interrupts will be signaled as FIQ in S-EL0/1 @@ -166,6 +167,7 @@ uint32_t plat_interrupt_type_to_line(uint32_t type, return __builtin_ctz(SCR_FIQ_BIT); else return __builtin_ctz(SCR_IRQ_BIT); + assert(0); /* Unreachable */ case INTR_TYPE_EL3: /* * The EL3 interrupts are signaled as FIQ in both S-EL0/1 and @@ -255,7 +257,7 @@ void plat_ic_set_spi_routing(unsigned int id, unsigned int routing_mode, irm = GICV3_IRM_ANY; break; default: - assert(false); + assert(0); /* Unreachable */ break; } |