linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel: events: Use scnprintf() in show_pmu_*() instead of snprintf()
@ 2020-09-01 23:49 Shuah Khan
  2020-09-01 23:49 ` [PATCH] kernel: Use scnprintf() in show_smt_*() " Shuah Khan
  2020-09-09  6:45 ` [PATCH] kernel: events: Use scnprintf() in show_pmu_*() " Alexander Shishkin
  0 siblings, 2 replies; 6+ messages in thread
From: Shuah Khan @ 2020-09-01 23:49 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: Shuah Khan, linux-kernel

Since snprintf() returns would-be-output size instead of the actual
output size, replace it with scnprintf(), so the nr_addr_filters_show(),
type_show(), and perf_event_mux_interval_ms_show() routines return the
actual size.

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 7ed5248f0445..5f4236c84940 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10571,7 +10571,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);
 
@@ -10582,7 +10582,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);
 
@@ -10593,7 +10593,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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-09-10 11:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 23:49 [PATCH] kernel: events: Use scnprintf() in show_pmu_*() instead of snprintf() Shuah Khan
2020-09-01 23:49 ` [PATCH] kernel: Use scnprintf() in show_smt_*() " Shuah Khan
2020-09-10 11:15   ` Qais Yousef
2020-09-09  6:45 ` [PATCH] kernel: events: Use scnprintf() in show_pmu_*() " Alexander Shishkin
2020-09-09 16:19   ` Shuah Khan
2020-09-09 17:27     ` Joe Perches

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).