Skip to contentSkip to conversation

perf/core: convert snprintf to scnprintf

PATCH Applied Jules Irenge 2 participants 2 messages Sep 17, 2022 – Sep 19, 2022 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 perf/core: convert snprintf to scnprintf

Coccinelle reports a warning

WARNING: use scnprintf or sprintf

Adding to that,
there has also been some slow migration from snprintf to scnprintf The article explains the rationale for this change

https: //lwn.net/Articles/69419/

---
 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/events/core.c +3 -3
index 2621fd24ad26..0b03a98945eb 100644
@@ -10933,7 +10933,7 @@ static ssize_t nr_addr_filters_show(struct device *dev,
 {
 	struct pmu *pmu = dev_get_drvdata(dev);
 
-	return snprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters);
+	return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters);
 }
 DEVICE_ATTR_RO(nr_addr_filters);
 
@@ -10944,7 +10944,7 @@ type_show(struct device *dev, struct device_attribute *attr, char *page)
 {
 	struct pmu *pmu = dev_get_drvdata(dev);
 
-	return snprintf(page, PAGE_SIZE-1, "%d\n", pmu->type);
+	return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->type);
 }
 static DEVICE_ATTR_RO(type);
 
@@ -10955,7 +10955,7 @@ perf_event_mux_interval_ms_show(struct device *dev,
 {
 	struct pmu *pmu = dev_get_drvdata(dev);
 
-	return snprintf(page, PAGE_SIZE-1, "%d\n", pmu->hrtimer_interval_ms);
+	return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->hrtimer_interval_ms);
 }
 
 static DEFINE_MUTEX(mux_interval_mutex);
Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 9 lines · Jules Irenge

Coccinelle reports a warning

WARNING: use scnprintf or sprintf

Adding to that,
there has also been some slow migration from snprintf to scnprintf The article explains the rationale for this change

https: //lwn.net/Articles/69419/

Please but at least a bare minimum of justification in the Changelog itself. I can't be arsed to wade through the interweb in order to figure out if this patch has merit or is just whitespace wankery.