[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250430032734.2079290-3-suhui@nfschina.com>
Date: Wed, 30 Apr 2025 11:27:33 +0800
From: Su Hui <suhui@...china.com>
To: jstultz@...gle.com,
tglx@...utronix.de,
sboyd@...nel.org
Cc: Su Hui <suhui@...china.com>,
linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [PATCH v3 2/3] alarmtimer: remove dead return value in clock2alarm()
'clockid' only can be ALARM_REALTIME and ALARM_BOOTTIME. It's impossible
to return -1 and callers never check the value of -1.
Only alarm_clock_get_timespec(), alarm_clock_get_ktime(),
alarm_timer_create() and alarm_timer_nsleep() call clock2alarm(). These
callers using clockid_to_kclock() to get 'struct k_clock', this ensures
clock2alarm() never returns -1.
Remove the impossible -1 return value, and add a warn to be aware of any
misuse of this function.
Signed-off-by: Su Hui <suhui@...china.com>
---
v3:
- Add WARN_ON_ONCE to notice any misuse of this function.
v2:
- No Change.
kernel/time/alarmtimer.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 0ddccdff119a..621d39666e29 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;
}
/**
--
2.30.2
Powered by blists - more mailing lists