* [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
2020-08-26 19:38 drivers/scsi/aacraid/linit.c:1355:8-16: WARNING: use scnprintf or sprintf kernel test robot
@ 2020-08-26 19:38 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-08-26 19:38 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 3668 bytes --]
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <efremov@linux.com>
CC: Julia Lawall <Julia.Lawall@lip6.fr>
CC: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
CC: "James E.J. Bottomley" <jejb@linux.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@oracle.com>
CC: linux-scsi(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org
From: kernel test robot <lkp@intel.com>
drivers/scsi/aacraid/linit.c:1355:8-16: WARNING: use scnprintf or sprintf
drivers/scsi/aacraid/linit.c:1381:8-16: WARNING: use scnprintf or sprintf
drivers/scsi/aacraid/linit.c:1388:8-16: WARNING: use scnprintf or sprintf
drivers/scsi/aacraid/linit.c:563:9-17: WARNING: use scnprintf or sprintf
drivers/scsi/aacraid/linit.c:590: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: abfc19ff202d ("coccinelle: api: add device_attr_show script")
CC: Denis Efremov <efremov@linux.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 2ac69819ba9e3d8d550bb5d2d2df74848e556812
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
:::::: branch date: 19 hours ago
:::::: commit date: 3 weeks ago
Please take the patch only if it's a positive warning. Thanks!
linit.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -560,10 +560,10 @@ static ssize_t aac_show_raid_level(struc
struct scsi_device *sdev = to_scsi_device(dev);
struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata);
if (sdev_channel(sdev) != CONTAINER_CHANNEL)
- return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach
+ return scnprintf(buf, PAGE_SIZE, sdev->no_uld_attach
? "Hidden\n" :
((aac->jbod && (sdev->type == TYPE_DISK)) ? "JBOD\n" : ""));
- return snprintf(buf, PAGE_SIZE, "%s\n",
+ return scnprintf(buf, PAGE_SIZE, "%s\n",
get_container_type(aac->fsa_dev[sdev_id(sdev)].type));
}
@@ -587,7 +587,7 @@ static ssize_t aac_show_unique_id(struct
if (sdev_channel(sdev) == CONTAINER_CHANNEL)
memcpy(sn, aac->fsa_dev[sdev_id(sdev)].identifier, sizeof(sn));
- return snprintf(buf, 16 * 2 + 2,
+ return scnprintf(buf, 16 * 2 + 2,
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n",
sn[0], sn[1], sn[2], sn[3],
sn[4], sn[5], sn[6], sn[7],
@@ -1352,7 +1352,7 @@ static ssize_t aac_show_driver_version(s
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", aac_driver_version);
+ return scnprintf(buf, PAGE_SIZE, "%s\n", aac_driver_version);
}
static ssize_t aac_show_serial_number(struct device *device,
@@ -1378,14 +1378,14 @@ static ssize_t aac_show_serial_number(st
static ssize_t aac_show_max_channel(struct device *device,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n",
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
class_to_shost(device)->max_channel);
}
static ssize_t aac_show_max_id(struct device *device,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n",
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
class_to_shost(device)->max_id);
}
^ permalink raw reply [flat|nested] 2+ messages in thread