diff options
author | Alistair Francis <alistair.francis@xilinx.com> | 2017-08-23 13:55:21 -0700 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2018-05-30 20:05:34 +0200 |
commit | 07a1cc5aa0df9c91c9ea4751460275e961e8d3c8 (patch) | |
tree | aeec03a46cf23e3758b7560fc9df18f279410c62 | |
parent | 0541b9edd636bd45f80026218b65fe7644e86b47 (diff) |
psci_common: Resolve GCC static analysis false positive
Previously commit 555ebb34db8f3424c1b394df2f10ecf9c1f70901 attmpted to fix this
GCC issue:
services/std_svc/psci/psci_common.c: In function 'psci_do_state_coordination':
services/std_svc/psci/psci_common.c:220:27: error: array subscript is above
array bounds [-Werror=array-bounds]
psci_req_local_pwr_states[pwrlvl - 1][cpu_idx] = req_pwr_state;
This fix doesn't work as asserts aren't built in non-debug build flows.
Let's use GCCs #pragma option (documented here:
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html) to avoid
this false positive instead.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
(cherry picked from commit 5722b78cdb4a69d08c3c585aae2fb8dd9cbb9bfc)
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
-rw-r--r-- | services/std_svc/psci/psci_common.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/services/std_svc/psci/psci_common.c b/services/std_svc/psci/psci_common.c index 8a2b81c3..4c736f5f 100644 --- a/services/std_svc/psci/psci_common.c +++ b/services/std_svc/psci/psci_common.c @@ -216,8 +216,15 @@ static void psci_set_req_local_pwr_state(unsigned int pwrlvl, unsigned int cpu_idx, plat_local_state_t req_pwr_state) { + /* + * This should never happen, we have this here to avoid + * "array subscript is above array bounds" errors in GCC. + */ assert(pwrlvl > PSCI_CPU_PWR_LVL); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" psci_req_local_pwr_states[pwrlvl - 1][cpu_idx] = req_pwr_state; +#pragma GCC diagnostic pop } /****************************************************************************** |