From 273ff863cfae89bf953f819cb4d5dc05b1fb2793 Mon Sep 17 00:00:00 2001 From: Krzysztof Taborowski Date: Fri, 5 Apr 2024 13:06:16 +0200 Subject: [PATCH] pal: remove unncessary timer object casting Possible fix for sporadic test failures. Casting away a const can cause undefined behavior. We are not modifying timer object anyway, so we can use const pointer further. Signed-off-by: Krzysztof Taborowski --- subsys/sal/sid_pal/src/sid_timer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/subsys/sal/sid_pal/src/sid_timer.c b/subsys/sal/sid_pal/src/sid_timer.c index d5a6eb78f1..cb1d4803b9 100644 --- a/subsys/sal/sid_pal/src/sid_timer.c +++ b/subsys/sal/sid_pal/src/sid_timer.c @@ -60,7 +60,7 @@ static const struct sid_timespec *sid_pal_timer_get_tolerance(sid_pal_timer_prio return tolerance; } -static bool sid_pal_timer_list_in_list(sid_pal_timer_t *timer) +static bool sid_pal_timer_list_in_list(const sid_pal_timer_t *timer) { SID_PAL_ASSERT(timer); bool result = true; @@ -214,9 +214,8 @@ bool sid_pal_timer_is_armed(const sid_pal_timer_t *timer_storage) if (!timer_storage) { return false; } - sid_pal_timer_t *timer = (sid_pal_timer_t *)timer_storage; - return sid_pal_timer_list_in_list(timer); + return sid_pal_timer_list_in_list(timer_storage); } void sid_pal_timer_event_callback(void *arg, const struct sid_timespec *now)