Skip to contentSkip to conversation

x86/events: Replace snprintf() with sysfs_emit()

PATCH New Jiapeng Chong 1 participant 1 message May 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/events: Replace snprintf() with sysfs_emit()

coccicheck complains about the use of snprintf() in sysfs show functions.

Fix the coccicheck warning:

./arch/x86/events/amd/core.c:1300:8-16: WARNING: use scnprintf or sprintf.

---
 arch/x86/events/amd/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/amd/core.c +1 -1
index 262e39a85031..47ef8aee15d2 100644
@@ -1297,7 +1297,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);
Signature · 1 line
2.20.1.7.g153144c