[PATCH] x86/hpet: Replace sprintf() with scnprintf() in hpet_select_clockevents()

From: Habil Eren Türker

Date: Tue Nov 17 2026 - 06:39:27 EST


Replace the deprecated sprintf() call with scnprintf() when formatting
the per-CPU HPET channel name into the 10-byte hc->name buffer.
Using scnprintf() ensures null-termination while avoiding
-Wformat-truncation warnings for the unsigned int channel index.

Signed-off-by: Habil Eren Türker <habilerenturker@xxxxxxxxxxx>
---
arch/x86/kernel/hpet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 8dc7b710e125..0edf0fe0ac2b 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -722,7 +722,7 @@ static void __init hpet_select_clockevents(void)
if (!(hc->boot_cfg & HPET_TN_FSB_CAP))
continue;

- sprintf(hc->name, "hpet%d", i);
+ scnprintf(hc->name, sizeof(hc->name), "hpet%u", i);

irq = hpet_assign_irq(hpet_domain, hc, hc->num);
if (irq <= 0)
--
2.47.3