mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"bp@alien8.de" <bp@alien8.de>, "hpa@zytor.com" <hpa@zytor.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"daniel@quora.org" <daniel@quora.org>,
	"x86@kernel.org" <x86@kernel.org>,
	"habilerenturker@hotmail.com" <habilerenturker@hotmail.com>,
	"tglx@kernel.org" <tglx@kernel.org>,
	"jwiesner@suse.de" <jwiesner@suse.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/hpet: Replace sprintf() with scnprintf() in hpet_select_clockevents()
Date: Thu, 19 Nov 2026 23:04:56 +0000	[thread overview]
Message-ID: <c6105c6acd7d17162c205e51f67f29f54e077d37.camel@intel.com> (raw)
In-Reply-To: <20261117113916.57740-1-habilerenturker@hotmail.com>

On Tue, 2026-11-17 at 11:39 +0000, Habil Eren Türker wrote:
> Replace the deprecated sprintf() call with scnprintf() when formatting
> the per-CPU HPET channel name into the 10-byte hc->name buffer.

It gets read, then masked by 0x00001f00, and shifted right by 8, then add 1. So
a max value of 32. It seems it can't overflow, no matter what the HW reports.

> Using scnprintf() ensures null-termination while avoiding
> -Wformat-truncation warnings for the unsigned int channel index.

Did you see a real compiler warning for this?

> 
> Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com>
> ---
>  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)



  reply	other threads:[~2026-11-19 23:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 11:39 Habil Eren Türker
2026-11-19 23:04 ` Edgecombe, Rick P [this message]
2026-11-19 23:28   ` Habil Eren Türker
2026-11-19 23:50     ` Dave Hansen
2026-11-19 23:59       ` Habil Eren Türker

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=c6105c6acd7d17162c205e51f67f29f54e077d37.camel@intel.com \
    --to=rick.p.edgecombe@intel.com \
    --cc=bp@alien8.de \
    --cc=daniel@quora.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=habilerenturker@hotmail.com \
    --cc=hpa@zytor.com \
    --cc=jwiesner@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --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®