From c29dcb3a98d035b316a2d2f03f4c114e74399998 Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Tue, 7 Feb 2023 16:54:33 +0000 Subject: [PATCH] cortex-m: warnings: Address -Wextra warnings `#defines` do NOT sepecify a type. They will either adopt a native system type or type of the value that was passed into the expression. This can lead to warnings such as, "warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Wsign-compare]". By casting expressions, such as `MAX_TICKS` to `k_ticks_t`, we can force the appropriate types and resolve these warnings. Signed-off-by: Zachary J. Fields --- drivers/timer/cortex_m_systick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/timer/cortex_m_systick.c b/drivers/timer/cortex_m_systick.c index ebe6a728f4c..cb95845cd6b 100644 --- a/drivers/timer/cortex_m_systick.c +++ b/drivers/timer/cortex_m_systick.c @@ -15,7 +15,7 @@ #define CYC_PER_TICK (sys_clock_hw_cycles_per_sec() \ / CONFIG_SYS_CLOCK_TICKS_PER_SEC) -#define MAX_TICKS ((COUNTER_MAX / CYC_PER_TICK) - 1) +#define MAX_TICKS ((k_ticks_t)(COUNTER_MAX / CYC_PER_TICK) - 1) #define MAX_CYCLES (MAX_TICKS * CYC_PER_TICK) /* Minimum cycles in the future to try to program. Note that this is @@ -27,7 +27,7 @@ * masked. Choosing a fraction of a tick is probably a good enough * default, with an absolute minimum of 1k cyc. */ -#define MIN_DELAY MAX(1024, (CYC_PER_TICK/16)) +#define MIN_DELAY MAX(1024U, ((uint32_t)CYC_PER_TICK/16U)) #define TICKLESS (IS_ENABLED(CONFIG_TICKLESS_KERNEL))