scsi: hptiop:Convert snprintf() to sysfs_emit()
Subsystems (2)
PATCH 1/1 scsi: hptiop:Convert snprintf() to sysfs_emit()
Coccinnelle reports a warning
Warning: Use scnprintf or sprintf
Following the advice on kernel documentation
https://www.kernel.org/doc/html/latest/filesystems/sysfs.html
For show(device *...) functions we should only use sysfs_emit() or sysfs_emit_at() especially when formatting the value to be returned to user space.
Convert snprintf() to sysfs_emit()
Signed-off-by Jules Irenge <[email protected]>
--- drivers/scsi/hptiop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/hptiop.c +2 -2
@@ -1111,7 +1111,7 @@ static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev,static ssize_t hptiop_show_version (struct device *dev,struct device_attribute *attr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"%s\n" , driver_ver); +return sysfs_emit (buf,"%s\n" , driver_ver); } static ssize_t hptiop_show_fw_version(struct device *dev,
@@ -1120,7 +1120,7 @@ static ssize_t hptiop_show_fw_version(struct device *dev,struct Scsi_Host *host =class_to_shost (dev);struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; - return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", + return sysfs_emit(buf, "%d.%d.%d.%d\n", hba->firmware_version >> 24, (hba->firmware_version >> 16) & 0xff, (hba->firmware_version >> 8) & 0xff,
Signature · 1 line
2.39.2