diff mbox series

[27/42] drivers/scsi/isci: Convert snprintf to sysfs_emit

Message ID 20240116045151.3940401-25-lizhijian@fujitsu.com (mailing list archive)
State Accepted
Headers show
Series Fix coccicheck warnings | expand

Commit Message

Zhijian Li (Fujitsu) Jan. 16, 2024, 4:51 a.m. UTC
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

> ./drivers/scsi/isci/init.c:140:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
CC: "James E.J. Bottomley" <jejb@linux.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@oracle.com>
CC: linux-scsi@vger.kernel.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
 drivers/scsi/isci/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Artur Paszkiewicz Jan. 16, 2024, 7:24 a.m. UTC | #1
On 1/16/24 05:51, Li Zhijian wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
> 
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
> 
>> ./drivers/scsi/isci/init.c:140:8-16: WARNING: please use sysfs_emit
> 
> No functional change intended
> 
> CC: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
> CC: "James E.J. Bottomley" <jejb@linux.ibm.com>
> CC: "Martin K. Petersen" <martin.petersen@oracle.com>
> CC: linux-scsi@vger.kernel.org
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>

Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
diff mbox series

Patch

diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index 6277162a028b..c582a3932cea 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -137,7 +137,7 @@  static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, c
 	struct 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);