From 51c18bac97dc3ae3393a786999f4602ca11c22f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85strand?= Date: Mon, 28 Sep 2020 11:25:36 +0200 Subject: 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 --- src/ethosu_pmu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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) -- cgit v1.2.1