From: Su Hui Date: Wed, 30 Apr 2025 03:27:33 +0000 (+0800) Subject: alarmtimer: Remove dead return value in clock2alarm() X-Git-Tag: v6.16-rc1~183^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d8ca84d48a2a2d4f6780980743c34b70c49f5844;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/all/20250430032734.2079290-3-suhui@nfschina.com --- diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 0ddccdff119a0..621d39666e29f 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -515,9 +515,9 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid) { if (clockid == CLOCK_REALTIME_ALARM) return ALARM_REALTIME; - if (clockid == CLOCK_BOOTTIME_ALARM) - return ALARM_BOOTTIME; - return -1; + + WARN_ON_ONCE(clockid != CLOCK_BOOTTIME_ALARM); + return ALARM_BOOTTIME; } /**