scsi: isci: convert sysfs sprintf/snprintf family to sysfs_emit
Subsystems (2)
PATCH 1/1 scsi: isci: convert sysfs sprintf/snprintf family to sysfs_emit
Fix the following coccicheck warning:
./drivers/scsi/isci/init.c:140:8-16: WARNING: use scnprintf or sprintf.
--- drivers/scsi/isci/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/isci/init.c +1 -1
@@ -137,7 +137,7 @@ static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, cstruct sas_ha_struct *sas_ha =SHOST_TO_SAS_HA (shost);struct isci_host *ihost =container_of (sas_ha,typeof (*ihost), sas_ha); -return snprintf (buf,PAGE_SIZE ,"%d\n" , ihost->id); +return sysfs_emit (buf,"%d\n" , ihost->id); } static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL);
Signature · 1 line
1.8.3.1
Quoted 21 lines · Jiapeng Chong
Fix the following coccicheck warning:
./drivers/scsi/isci/init.c:140:8-16: WARNING: use scnprintf or
sprintf.Reported-by Abaci Robot<[email protected]>Signed-off-by Jiapeng Chong <[email protected]>--- drivers/scsi/isci/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/isci/init.c +0
-0@@ -137,7 +137,7 @@ static ssize_t isci_show_id(struct device *dev,struct
device_attribute*attr, cdrivers/scsi/isci/init.c +0
-0struct sas_ha_struct *sas_ha =SHOST_TO_SAS_HA (shost); struct isci_host *ihost = container_of(sas_ha, typeof(*ihost),
sas_ha);
drivers/scsi/isci/init.c static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, c · line 140
Quoted 2 lines
drivers/scsi/isci/init.c +1
-1-return snprintf (buf,PAGE_SIZE ,"%d\n" , ihost->id); +return sysfs_emit (buf,"%d\n" , ihost->id);
What's the point of doing this change? We'd have to have 13,600 bit integer types before this could ever possibly overflow and the difference between snprintf and scnprintf actually matter from a practical point of view. Perhaps the coccinelle check should be updated to account for these common impossible to overflow situations.
James