[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211104115100.31547-1-yao.jing2@zte.com.cn>
Date: Thu, 4 Nov 2021 11:51:00 +0000
From: cgel.zte@...il.com
To: peterz@...radead.org
Cc: mingo@...hat.com, acme@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
namhyung@...nel.org, tglx@...utronix.de, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
Jing Yao <yao.jing2@....com.cn>, Zeal Robot <zealci@....com.cn>
Subject: [PATCH] x86/events/intel: replace snprintf in show functions with sysfs_emit
From: Jing Yao <yao.jing2@....com.cn>
coccicheck complains about the use of snprintf() in sysfs show
functions:
WARNING use scnprintf or sprintf
Use sysfs_emit instead of scnprintf, snprintf or sprintf makes more
sense.
Reported-by: Zeal Robot <zealci@....com.cn>
Signed-off-by: Jing Yao <yao.jing2@....com.cn>
---
arch/x86/events/intel/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 603964408d2d..687e15473feb 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -5116,7 +5116,7 @@ static ssize_t show_sysctl_tfa(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, 40, "%d\n", allow_tsx_force_abort);
+ return sysfs_emit(buf, "%d\n", allow_tsx_force_abort);
}
static ssize_t set_sysctl_tfa(struct device *cdev,
@@ -5150,7 +5150,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);
@@ -5166,7 +5166,7 @@ static ssize_t pmu_name_show(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", pmu_name_str);
+ return sysfs_emit(buf, "%s\n", pmu_name_str);
}
static DEVICE_ATTR_RO(pmu_name);
--
2.25.1
Powered by blists - more mailing lists