Skip to content

Commit dca6344

Browse files
irengeIngo Molnar
authored andcommitted
perf/core: Convert snprintf() to scnprintf()
Coccinelle reports a warning: WARNING: use scnprintf or sprintf 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. Adding to that, there has also been some slow migration from snprintf to scnprintf, here's the shift in usage in the past 3.5 years, in all fs/ files: v5.0 v6.0-rc6 -------------------------------------- snprintf() uses: 63 213 scnprintf() uses: 374 186 No intended change in behavior. [ mingo: Improved the changelog & reviewed the usage sites. ] Signed-off-by: Jules Irenge <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent b4e12b2 commit dca6344

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/events/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10952,7 +10952,7 @@ static ssize_t nr_addr_filters_show(struct device *dev,
1095210952
{
1095310953
struct pmu *pmu = dev_get_drvdata(dev);
1095410954

10955-
return snprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters);
10955+
return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters);
1095610956
}
1095710957
DEVICE_ATTR_RO(nr_addr_filters);
1095810958

@@ -10963,7 +10963,7 @@ type_show(struct device *dev, struct device_attribute *attr, char *page)
1096310963
{
1096410964
struct pmu *pmu = dev_get_drvdata(dev);
1096510965

10966-
return snprintf(page, PAGE_SIZE-1, "%d\n", pmu->type);
10966+
return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->type);
1096710967
}
1096810968
static DEVICE_ATTR_RO(type);
1096910969

@@ -10974,7 +10974,7 @@ perf_event_mux_interval_ms_show(struct device *dev,
1097410974
{
1097510975
struct pmu *pmu = dev_get_drvdata(dev);
1097610976

10977-
return snprintf(page, PAGE_SIZE-1, "%d\n", pmu->hrtimer_interval_ms);
10977+
return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->hrtimer_interval_ms);
1097810978
}
1097910979

1098010980
static DEFINE_MUTEX(mux_interval_mutex);

0 commit comments

Comments
 (0)