* [PATCH 4/7] x86: events: Convert snprintf() to scnprintf()
@ 2022-09-26 18:45 Jules Irenge
0 siblings, 0 replies; only message in thread
From: Jules Irenge @ 2022-09-26 18:45 UTC (permalink / raw)
To: mark.rutland
Cc: alexander.shishkin, tglx, bp, dave.hansen, x86, hpa,
linux-perf-users, linux-kernel, elana.copperman
Coccinnelle reports a warning
Warning: Use scnprintf or sprintf
Adding to that, there has been a slow migration from snprintf to scnprintf.
This LWN article explains the rationale for this change
https: //lwn.net/Articles/69419/
Ie. snprintf() returns what *would* be the resulting length,
while scnprintf() returns the actual length.
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
arch/x86/events/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index f969410d0c90..71695d21ffd1 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1905,7 +1905,7 @@ ssize_t events_hybrid_sysfs_show(struct device *dev,
if (x86_pmu.hybrid_pmu[i].cpu_type & pmu->cpu_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 sprintf(page, "%s", str);
}
@@ -2566,7 +2566,7 @@ static ssize_t get_attr_rdpmc(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, 40, "%d\n", x86_pmu.attr_rdpmc);
+ return scnprintf(buf, 40, "%d\n", x86_pmu.attr_rdpmc);
}
static ssize_t set_attr_rdpmc(struct device *cdev,
@@ -2624,7 +2624,7 @@ static ssize_t max_precise_show(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu_max_precise());
+ return scnprintf(buf, PAGE_SIZE, "%d\n", x86_pmu_max_precise());
}
static DEVICE_ATTR_RO(max_precise);
--
2.37.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-26 18:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-26 18:45 [PATCH 4/7] x86: events: Convert snprintf() to scnprintf() Jules Irenge
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.