linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] perf/x86/amd: replace snprintf with sysfs_emit helper function
@ 2024-10-19  2:55 Paulo Miguel Almeida
  0 siblings, 0 replies; only message in thread
From: Paulo Miguel Almeida @ 2024-10-19  2:55 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, kan.liang, tglx, bp, dave.hansen,
	x86, hpa, linux-perf-users, linux-kernel
  Cc: paulo.miguel.almeida.rodenas, linux-hardening

sysfs_emit() helper function should be used when formatting the value to
be returned to user space as per the documentation. No need to replicate
logic in sysfs .show() callbacks.

This patch replaces open-coded sysfs_emit() logic sysfs .show()
callbacks.

Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
---
 arch/x86/events/amd/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index b4a1a2576510..bbada8e3e491 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -1346,7 +1346,7 @@ static ssize_t branches_show(struct device *cdev,
 			      struct device_attribute *attr,
 			      char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu.lbr_nr);
+	return sysfs_emit(buf, "%d\n", x86_pmu.lbr_nr);
 }
 
 static DEVICE_ATTR_RO(branches);
-- 
2.47.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-10-19  2:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-19  2:55 [PATCH][next] perf/x86/amd: replace snprintf with sysfs_emit helper function Paulo Miguel Almeida

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).