Skip to content

Commit 1ad717c

Browse files
zhijianli88martinkpetersen
authored andcommitted
scsi: fnic: Convert snprintf() to sysfs_emit()
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/fnic/fnic_attrs.c:17:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/fnic/fnic_attrs.c:23:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/fnic/fnic_attrs.c:31:8-16: WARNING: please use sysfs_emit No functional change intended CC: Satish Kharat <[email protected]> CC: Sesidhar Baddela <[email protected]> CC: Karan Tilak Kumar <[email protected]> CC: James E.J. Bottomley <[email protected]> CC: Martin K. Petersen <[email protected]> CC: [email protected] Signed-off-by: Li Zhijian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Karan Tilak Kumar <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent bc978cc commit 1ad717c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/scsi/fnic/fnic_attrs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@ static ssize_t fnic_show_state(struct device *dev,
1414
struct fc_lport *lp = shost_priv(class_to_shost(dev));
1515
struct fnic *fnic = lport_priv(lp);
1616

17-
return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]);
17+
return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]);
1818
}
1919

2020
static ssize_t fnic_show_drv_version(struct device *dev,
2121
struct device_attribute *attr, char *buf)
2222
{
23-
return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION);
23+
return sysfs_emit(buf, "%s\n", DRV_VERSION);
2424
}
2525

2626
static ssize_t fnic_show_link_state(struct device *dev,
2727
struct device_attribute *attr, char *buf)
2828
{
2929
struct fc_lport *lp = shost_priv(class_to_shost(dev));
3030

31-
return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up)
32-
? "Link Up" : "Link Down");
31+
return sysfs_emit(buf, "%s\n", (lp->link_up) ? "Link Up" : "Link Down");
3332
}
3433

3534
static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);

0 commit comments

Comments
 (0)