diff options
author | Per Åstrand <per.astrand@arm.com> | 2020-09-28 11:25:36 +0200 |
---|---|---|
committer | Per Åstrand <per.astrand@arm.com> | 2020-09-28 12:45:05 +0200 |
commit | 51c18bac97dc3ae3393a786999f4602ca11c22f7 (patch) | |
tree | 9603d63c57e86612e135e82901ff50f9e1591a3e | |
parent | c801901c992ca632a0beb1eeb78b42c910e2e0aa (diff) | |
download | ethos-u-core-driver-51c18bac97dc3ae3393a786999f4602ca11c22f7.tar.gz |
Silence gcc > 7 type-limits warning
GCC > 7 warns that the selected type of the enum makes the comparisson
unneccesary. Since the selected enum fits in an integer, the input
parameter is casted to an integer to make the comparison valid and
asserts that the enum is within valid enum values (which we know are
monotonically growing).
Change-Id: Id81799e2ac43a83b998541ce7531d2039202cd62
-rw-r--r-- | src/ethosu_pmu.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ethosu_pmu.c b/src/ethosu_pmu.c index c1f5c5b..7ca35fc 100644 --- a/src/ethosu_pmu.c +++ b/src/ethosu_pmu.c @@ -78,12 +78,15 @@ enum ethosu_pmu_event_type pmu_event_type(uint32_t id) uint32_t pmu_event_value(enum ethosu_pmu_event_type event) { - if (!(event < ETHOSU_PMU_SENTINEL) || (event < 0)) + int a = event; + if ((a < ETHOSU_PMU_SENTINEL) && (a >= ETHOSU_PMU_NO_EVENT)) + { + return eventbyid[event]; + } + else { return (uint32_t)(-1); } - - return eventbyid[event]; } void ethosu_pmu_driver_init(void) |