Check array boundary with ARRAY_SIZE() macro.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
target/mips/cpu.h | 2 --
target/mips/tcg/exception.c | 4 ++--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 32549791a18..5d8b78a70b8 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -1347,8 +1347,6 @@ enum {
EXCP_TLBXI,
EXCP_TLBRI,
EXCP_SEMIHOST,
-
- EXCP_LAST = EXCP_SEMIHOST,
};
/*
diff --git a/target/mips/tcg/exception.c b/target/mips/tcg/exception.c
index 630b8b809fa..2f02f9be877 100644
--- a/target/mips/tcg/exception.c
+++ b/target/mips/tcg/exception.c
@@ -88,7 +88,7 @@ void mips_cpu_synchronize_from_tb(CPUState *cs, const
TranslationBlock *tb)
env->hflags |= tb->flags & MIPS_HFLAG_BMASK;
}
-static const char * const excp_names[EXCP_LAST + 1] = {
+static const char * const excp_names[] = {
[EXCP_RESET] = "reset",
[EXCP_SRESET] = "soft reset",
[EXCP_DSS] = "debug single step",
@@ -131,7 +131,7 @@ static const char * const excp_names[EXCP_LAST + 1] = {
const char *mips_exception_name(int32_t exception)
{
- if (exception < 0 || exception > EXCP_LAST) {
+ if (exception < 0 || exception >= ARRAY_SIZE(excp_names)) {
return "unknown";
}
return excp_names[exception];
--
2.55.0