From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4046128691207836946==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Wed, 18 Nov 2020 01:21:19 +0800 Message-ID: <20201117172119.GA13563@186f812c2ec0> In-Reply-To: <202011180141.y4gJ2gqh-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============4046128691207836946== 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: Wolfgang Grandegger CC: "Marc Kleine-Budde" CC: Jakub Kicinski CC: Nicolas Ferre CC: Alexandre Belloni CC: Ludovic Desroches CC: linux-can(a)vger.kernel.org CC: netdev(a)vger.kernel.org From: kernel test robot drivers/net/can/at91_can.c:1185: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: 9c87c9f41245baa3fc4716cf39141439cf405b01 commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 18 hours ago :::::: commit date: 4 months ago Please take the patch only if it's a positive warning. Thanks! at91_can.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/can/at91_can.c +++ b/drivers/net/can/at91_can.c @@ -1182,9 +1182,9 @@ static ssize_t at91_sysfs_show_mb0_id(st struct at91_priv *priv =3D netdev_priv(to_net_dev(dev)); = if (priv->mb0_id & CAN_EFF_FLAG) - return snprintf(buf, PAGE_SIZE, "0x%08x\n", priv->mb0_id); + return scnprintf(buf, PAGE_SIZE, "0x%08x\n", priv->mb0_id); else - return snprintf(buf, PAGE_SIZE, "0x%03x\n", priv->mb0_id); + return scnprintf(buf, PAGE_SIZE, "0x%03x\n", priv->mb0_id); } = static ssize_t at91_sysfs_set_mb0_id(struct device *dev, --===============4046128691207836946==--