Skip to content

Commit d8ca84d

Browse files
Su HuiKAGA-KOKO
authored andcommitted
alarmtimer: Remove dead return value in clock2alarm()
'clockid' can only be ALARM_REALTIME and ALARM_BOOTTIME. It's impossible to return -1 and callers never check the return value. Only alarm_clock_get_timespec(), alarm_clock_get_ktime(), alarm_timer_create() and alarm_timer_nsleep() call clock2alarm(). These callers use clockid_to_kclock() to get 'struct k_clock', which ensures that clock2alarm() never returns -1. Remove the impossible -1 return value, and add a warning to notify about any future misuse of this function. Signed-off-by: Su Hui <suhui@nfschina.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250430032734.2079290-3-suhui@nfschina.com
1 parent 007c071 commit d8ca84d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/time/alarmtimer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,9 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid)
515515
{
516516
if (clockid == CLOCK_REALTIME_ALARM)
517517
return ALARM_REALTIME;
518-
if (clockid == CLOCK_BOOTTIME_ALARM)
519-
return ALARM_BOOTTIME;
520-
return -1;
518+
519+
WARN_ON_ONCE(clockid != CLOCK_BOOTTIME_ALARM);
520+
return ALARM_BOOTTIME;
521521
}
522522

523523
/**

0 commit comments

Comments
 (0)