[PATCH v2 3/4] arch/x86/events/core: use scnprintf to print sub-string

From: Li Zhijian
Date: Fri Jan 26 2024 - 01:41:48 EST


sysfs_emit is not suitable to to print a substring, convert it to scnprintf
to make coccicheck happy.

CC: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CC: Ingo Molnar <mingo@xxxxxxxxxx>
CC: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CC: Mark Rutland <mark.rutland@xxxxxxx>
CC: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
CC: Jiri Olsa <jolsa@xxxxxxxxxx>
CC: Namhyung Kim <namhyung@xxxxxxxxxx>
CC: Ian Rogers <irogers@xxxxxxxxxx>
CC: Adrian Hunter <adrian.hunter@xxxxxxxxx>
CC: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CC: Borislav Petkov <bp@xxxxxxxxx>
CC: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
CC: x86@xxxxxxxxxx
CC: "H. Peter Anvin" <hpa@xxxxxxxxx>
CC: linux-perf-users@xxxxxxxxxxxxxxx
Signed-off-by: Li Zhijian <lizhijian@xxxxxxxxxxx>
---
V2: new patch address coccinelle warning
---
arch/x86/events/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 20d963196e4c..5ed2ba16c6c0 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1892,7 +1892,7 @@ ssize_t events_hybrid_sysfs_show(struct device *dev,
if (x86_pmu.hybrid_pmu[i].pmu_type & pmu->pmu_type) {
next_str = strchr(str, ';');
if (next_str)
- return snprintf(page, next_str - str + 1, "%s", str);
+ return scnprintf(page, next_str - str + 1, "%s", str);
else
return sysfs_emit(page, "%s", str);
}
--
2.29.2