Skip to content

Commit eab302e

Browse files
zhijianli88martinkpetersen
authored andcommitted
scsi: snic: Convert sprintf() family to sysfs_emit() family
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(). sprintf() and scnprintf() will be converted as well if they have. Generally, this patch is generated by make coccicheck M=<path/to/file> MODE=patch \ COCCI=scripts/coccinelle/api/device_attr_show.cocci No functional change intended CC: Karan Tilak Kumar <kartilak@cisco.com> CC: Sesidhar Baddela <sebaddel@cisco.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> Link: https://lore.kernel.org/r/20240319063132.1588443-12-lizhijian@fujitsu.com Reviewed-by: Karan Tilak Kumar <kartilak@cisco.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 9bd8e41 commit eab302e

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

drivers/scsi/snic/snic_attrs.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ snic_show_sym_name(struct device *dev,
1313
{
1414
struct snic *snic = shost_priv(class_to_shost(dev));
1515

16-
return snprintf(buf, PAGE_SIZE, "%s\n", snic->name);
16+
return sysfs_emit(buf, "%s\n", snic->name);
1717
}
1818

1919
static ssize_t
@@ -23,16 +23,15 @@ snic_show_state(struct device *dev,
2323
{
2424
struct snic *snic = shost_priv(class_to_shost(dev));
2525

26-
return snprintf(buf, PAGE_SIZE, "%s\n",
27-
snic_state_str[snic_get_state(snic)]);
26+
return sysfs_emit(buf, "%s\n", snic_state_str[snic_get_state(snic)]);
2827
}
2928

3029
static ssize_t
3130
snic_show_drv_version(struct device *dev,
3231
struct device_attribute *attr,
3332
char *buf)
3433
{
35-
return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION);
34+
return sysfs_emit(buf, "%s\n", SNIC_DRV_VERSION);
3635
}
3736

3837
static ssize_t
@@ -45,8 +44,8 @@ snic_show_link_state(struct device *dev,
4544
if (snic->config.xpt_type == SNIC_DAS)
4645
snic->link_status = svnic_dev_link_status(snic->vdev);
4746

48-
return snprintf(buf, PAGE_SIZE, "%s\n",
49-
(snic->link_status) ? "Link Up" : "Link Down");
47+
return sysfs_emit(buf, "%s\n",
48+
(snic->link_status) ? "Link Up" : "Link Down");
5049
}
5150

5251
static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);

0 commit comments

Comments
 (0)