Re: [PATCH] kernel: events: Use scnprintf() in show_pmu_*() instead of snprintf()

From: Shuah Khan
Date: Wed Sep 09 2020 - 12:22:26 EST


On 9/9/20 12:45 AM, Alexander Shishkin wrote:
Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx> writes:

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.

Well, firstly they should just be sprintf()s, and secondly, I wouldn't
worry about it, because [0].

scnprintf() or sprinf() could be used.


[0] https://marc.info/?l=linux-kernel&m=159874491103969&w=2

Awesome. Thanks for the pointer. I wasn't aware of this work and
it takes care of the problem kernel wide. A better way to solve
the problem.

thanks,
-- Shuah