[PATCH] scsi: fcoe: convert sysfs snprintf to sysfs_emit

From: Xuezhi Zhang
Date: Thu Jun 16 2022 - 08:10:41 EST


Fix the following coccicheck warnings:

drivers/scsi/fcoe/fcoe_sysfs.c:376:8-16:
WARNING: use scnprintf or sprintf
drivers/scsi/fcoe/fcoe_sysfs.c:268:8-16:
WARNING: use scnprintf or sprintf
drivers/scsi/fcoe/fcoe_sysfs.c:253:8-16:
WARNING: use scnprintf or sprintf

Signed-off-by: Xuezhi Zhang <zhangxuezhi1@xxxxxxxxxxx>
---
drivers/scsi/fcoe/fcoe_sysfs.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
index af658aa38fed..eabab69f9861 100644
--- a/drivers/scsi/fcoe/fcoe_sysfs.c
+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
@@ -239,7 +239,6 @@ static char *fcf_state_names[] = {
[ FCOE_FCF_STATE_CONNECTED ] = "Connected",
};
fcoe_enum_name_search(fcf_state, fcf_state, fcf_state_names)
-#define FCOE_FCF_STATE_MAX_NAMELEN 50

static ssize_t show_fcf_state(struct device *dev,
struct device_attribute *attr,
@@ -250,7 +249,7 @@ static ssize_t show_fcf_state(struct device *dev,
name = get_fcoe_fcf_state_name(fcf->state);
if (!name)
return -EINVAL;
- return snprintf(buf, FCOE_FCF_STATE_MAX_NAMELEN, "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
static FCOE_DEVICE_ATTR(fcf, state, S_IRUGO, show_fcf_state, NULL);

@@ -265,8 +264,7 @@ static ssize_t show_ctlr_mode(struct device *dev,
name = get_fcoe_ctlr_mode_name(ctlr->mode);
if (!name)
return -EINVAL;
- return snprintf(buf, FCOE_MAX_MODENAME_LEN,
- "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}

static ssize_t store_ctlr_mode(struct device *dev,
@@ -361,7 +359,6 @@ static char *ctlr_enabled_state_names[] = {
};
fcoe_enum_name_search(ctlr_enabled_state, ctlr_enabled_state,
ctlr_enabled_state_names)
-#define FCOE_CTLR_ENABLED_MAX_NAMELEN 50

static ssize_t show_ctlr_enabled_state(struct device *dev,
struct device_attribute *attr,
@@ -373,8 +370,7 @@ static ssize_t show_ctlr_enabled_state(struct device *dev,
name = get_fcoe_ctlr_enabled_state_name(ctlr->enabled);
if (!name)
return -EINVAL;
- return snprintf(buf, FCOE_CTLR_ENABLED_MAX_NAMELEN,
- "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}

static FCOE_DEVICE_ATTR(ctlr, enabled, S_IRUGO | S_IWUSR,
--
2.34.1