[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240116045151.3940401-38-lizhijian@fujitsu.com>
Date: Tue, 16 Jan 2024 12:51:49 +0800
From: Li Zhijian <lizhijian@...itsu.com>
To: linux-kernel@...r.kernel.org
Cc: Li Zhijian <lizhijian@...itsu.com>,
Karan Tilak Kumar <kartilak@...co.com>,
Sesidhar Baddela <sebaddel@...co.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
linux-scsi@...r.kernel.org
Subject: [PATCH 40/42] drivers/scsi/snic/snic_attrs: 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/snic/snic_attrs.c:16:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/snic/snic_attrs.c:26:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/snic/snic_attrs.c:35:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/snic/snic_attrs.c:48:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Karan Tilak Kumar <kartilak@...co.com>
CC: Sesidhar Baddela <sebaddel@...co.com>
CC: "James E.J. Bottomley" <jejb@...ux.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@...cle.com>
CC: linux-scsi@...r.kernel.org
Signed-off-by: Li Zhijian <lizhijian@...itsu.com>
---
drivers/scsi/snic/snic_attrs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/snic/snic_attrs.c b/drivers/scsi/snic/snic_attrs.c
index 3ddbdbc3ded1..03921618182d 100644
--- a/drivers/scsi/snic/snic_attrs.c
+++ b/drivers/scsi/snic/snic_attrs.c
@@ -13,7 +13,7 @@ snic_show_sym_name(struct device *dev,
{
struct snic *snic = shost_priv(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", snic->name);
+ return sysfs_emit(buf, "%s\n", snic->name);
}
static ssize_t
@@ -23,7 +23,7 @@ snic_show_state(struct device *dev,
{
struct snic *snic = shost_priv(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n",
+ return sysfs_emit(buf, "%s\n",
snic_state_str[snic_get_state(snic)]);
}
@@ -32,7 +32,7 @@ snic_show_drv_version(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION);
+ return sysfs_emit(buf, "%s\n", SNIC_DRV_VERSION);
}
static ssize_t
@@ -45,8 +45,8 @@ snic_show_link_state(struct device *dev,
if (snic->config.xpt_type == SNIC_DAS)
snic->link_status = svnic_dev_link_status(snic->vdev);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- (snic->link_status) ? "Link Up" : "Link Down");
+ return sysfs_emit(buf, "%s\n",
+ (snic->link_status) ? "Link Up" : "Link Down");
}
static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);
--
2.29.2
Powered by blists - more mailing lists