Skip to content

Commit c29dcb3

Browse files
zfieldsnashif
authored andcommitted
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 <[email protected]>
1 parent cb0ce21 commit c29dcb3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/timer/cortex_m_systick.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#define CYC_PER_TICK (sys_clock_hw_cycles_per_sec() \
1717
/ CONFIG_SYS_CLOCK_TICKS_PER_SEC)
18-
#define MAX_TICKS ((COUNTER_MAX / CYC_PER_TICK) - 1)
18+
#define MAX_TICKS ((k_ticks_t)(COUNTER_MAX / CYC_PER_TICK) - 1)
1919
#define MAX_CYCLES (MAX_TICKS * CYC_PER_TICK)
2020

2121
/* Minimum cycles in the future to try to program. Note that this is
@@ -27,7 +27,7 @@
2727
* masked. Choosing a fraction of a tick is probably a good enough
2828
* default, with an absolute minimum of 1k cyc.
2929
*/
30-
#define MIN_DELAY MAX(1024, (CYC_PER_TICK/16))
30+
#define MIN_DELAY MAX(1024U, ((uint32_t)CYC_PER_TICK/16U))
3131

3232
#define TICKLESS (IS_ENABLED(CONFIG_TICKLESS_KERNEL))
3333

0 commit comments

Comments
 (0)