Re: [PATCH RESEND v2] perf/x86/intel/uncore: Use sysfs_emit() in uncore_event_show()

"Mi, Dapeng" <[email protected]>
Newsgroups org.kernel.vger.linux-perf-users,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Reviewed-by: Dapeng Mi <[email protected]>

On 7/26/2026 5:41 PM, Thorsten Blum wrote:
> Replace sprintf() with sysfs_emit() in uncore_event_show(). sysfs_emit()
> is preferred for formatting sysfs output because it provides safer
> bounds checking.
>
> Add a terminating newline as suggested by checkpatch.
>
> Acked-by: Namhyung Kim <[email protected]>
> Signed-off-by: Thorsten Blum <[email protected]>
> ---
> Changes in v2:
> - Add a terminating newline as suggested by checkpatch
> - Link to v1: https://lore.kernel.org/r/[email protected]/
> ---
>  arch/x86/events/intel/uncore.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
> index 7857959c6e82..1ef4b4a5f545 100644
> --- a/arch/x86/events/intel/uncore.c
> +++ b/arch/x86/events/intel/uncore.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  #include <linux/module.h>
> +#include <linux/sysfs.h>
>  
>  #include <asm/cpu_device_id.h>
>  #include <asm/intel-family.h>
> @@ -153,7 +154,7 @@ ssize_t uncore_event_show(struct device *dev,
>  {
>  	struct uncore_event_desc *event =
>  		container_of(attr, struct uncore_event_desc, attr);
> -	return sprintf(buf, "%s", event->config);
> +	return sysfs_emit(buf, "%s\n", event->config);
>  }
>  
>  struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu)
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.