From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============5221981997189981786==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Mon, 28 Dec 2020 04:05:06 +0800 Message-ID: <20201227200505.GA43178@8887daa46785> In-Reply-To: <202012280427.S5ZgodfV-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============5221981997189981786== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov CC: Julia Lawall CC: Pablo Neira Ayuso CC: Jozsef Kadlecsik CC: Florian Westphal CC: Jakub Kicinski CC: netfilter-devel(a)vger.kernel.org CC: coreteam(a)netfilter.org CC: netdev(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot net/netfilter/xt_IDLETIMER.c:88:9-17: WARNING: use scnprintf or sprintf From Documentation/filesystems/sysfs.txt: show() must not use snprintf() when formatting the value to be returned to user space. If you can guarantee that an overflow will never happen you can use sprintf() otherwise you must use scnprintf(). Generated by: scripts/coccinelle/api/device_attr_show.cocci Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script") CC: Denis Efremov Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = master head: 52cd5f9c22eeef26d05f9d9338ba4eb38f14dd3a commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 3 hours ago :::::: commit date: 5 months ago Please take the patch only if it's a positive warning. Thanks! xt_IDLETIMER.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/netfilter/xt_IDLETIMER.c +++ b/net/netfilter/xt_IDLETIMER.c @@ -85,9 +85,9 @@ static ssize_t idletimer_tg_show(struct mutex_unlock(&list_mutex); = if (time_after(expires, jiffies) || ktimespec.tv_sec > 0) - return snprintf(buf, PAGE_SIZE, "%ld\n", time_diff); + return scnprintf(buf, PAGE_SIZE, "%ld\n", time_diff); = - return snprintf(buf, PAGE_SIZE, "0\n"); + return scnprintf(buf, PAGE_SIZE, "0\n"); } = static void idletimer_tg_work(struct work_struct *work) --===============5221981997189981786==--