mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Su Hui" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Su Hui <suhui@nfschina.com>, Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] alarmtimer: Remove dead return value in clock2alarm()
Date: Wed, 30 Apr 2025 07:22:20 -0000	[thread overview]
Message-ID: <174599774083.22196.5201101258841287355.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250430032734.2079290-3-suhui@nfschina.com>

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     d8ca84d48a2a2d4f6780980743c34b70c49f5844
Gitweb:        https://git.kernel.org/tip/d8ca84d48a2a2d4f6780980743c34b70c49f5844
Author:        Su Hui <suhui@nfschina.com>
AuthorDate:    Wed, 30 Apr 2025 11:27:33 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 30 Apr 2025 09:06:23 +02:00

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

---
 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 0ddccdf..621d396 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;
 }
 
 /**

  reply	other threads:[~2025-04-30  7:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30  3:27 [PATCH v3 0/3] time: some cleanup for jiffies and alarmtimer Su Hui
2025-04-30  3:27 ` [PATCH v3 1/3] time/jiffies: change register_refined_jiffies() to void __init Su Hui
2025-04-30  7:22   ` [tip: timers/core] time/jiffies: Change " tip-bot2 for Su Hui
2025-04-30  3:27 ` [PATCH v3 2/3] alarmtimer: remove dead return value in clock2alarm() Su Hui
2025-04-30  7:22   ` tip-bot2 for Su Hui [this message]
2025-04-30 22:14   ` John Stultz
2025-04-30  3:27 ` [PATCH v3 3/3] alarmtimer: switch some spin_{lock,unlock}_irqsave() to guard() Su Hui
2025-04-30  7:04   ` Thomas Gleixner
2025-04-30  7:19     ` Su Hui
2025-04-30  7:22   ` [tip: timers/core] alarmtimer: Switch spin_{lock,unlock}_irqsave() to guards tip-bot2 for Su Hui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=174599774083.22196.5201101258841287355.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=suhui@nfschina.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®