From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============1086307673952027279==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Fri, 03 Jul 2020 19:35:58 +0800 Message-ID: <20200703113558.GA18944@bf425ecdd42c> In-Reply-To: <202007031941.um9p1FRJ%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============1086307673952027279== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org TO: Denis Efremov CC: Julia Lawall CC: Stefan Richter CC: linux1394-devel(a)lists.sourceforge.net CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/firewire/core-device.c:375:8-16: 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: 988676da8375 ("coccinelle: api: add device_attr_show script") CC: Denis Efremov Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git f= or-5.9 head: 5502a4eb3af819792a6c43b418c401f613a39d02 commit: 988676da837516bbfafda5478472fd4265f0de4e [1/3] coccinelle: api: add= device_attr_show script :::::: branch date: 8 days ago :::::: commit date: 9 days ago Please take the patch only if it's a positive warning. Thanks! core-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -372,7 +372,7 @@ static ssize_t rom_index_show(struct dev struct fw_device *device =3D fw_device(dev->parent); struct fw_unit *unit =3D fw_unit(dev); = - return snprintf(buf, PAGE_SIZE, "%d\n", + return scnprintf(buf, PAGE_SIZE, "%d\n", (int)(unit->directory - device->config_rom)); } =20 --===============1086307673952027279==--