* [PATCH v2] scsi/qla4xxx: convert sysfs sprintf/snprintf family to sysfs_emit/sysfs_emit_at
@ 2021-01-21 3:57 Jiapeng Zhong
2021-01-21 4:55 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Jiapeng Zhong @ 2021-01-21 3:57 UTC (permalink / raw)
To: njavali
Cc: mrangankar, GR-QLogic-Storage-Upstream, jejb, martin.petersen,
linux-scsi, linux-kernel, Jiapeng Zhong
Fix the following coccicheck warning:
./drivers/scsi/qla4xxx/ql4_attr.c: WARNING: use scnprintf or
sprintf.
Reported-by: Abaci Robot<abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com>
---
Changes in v2:
- convert snprintf family to sysfs_emit_at.
drivers/scsi/qla4xxx/ql4_attr.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/scsi/qla4xxx/ql4_attr.c b/drivers/scsi/qla4xxx/ql4_attr.c
index ec43528..ad9b021 100644
--- a/drivers/scsi/qla4xxx/ql4_attr.c
+++ b/drivers/scsi/qla4xxx/ql4_attr.c
@@ -156,11 +156,11 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
if (is_qla80XX(ha))
- return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
+ return sysfs_emit_at(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
ha->fw_info.fw_major, ha->fw_info.fw_minor,
ha->fw_info.fw_patch, ha->fw_info.fw_build);
else
- return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
+ return sysfs_emit_at(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
ha->fw_info.fw_major, ha->fw_info.fw_minor,
ha->fw_info.fw_patch, ha->fw_info.fw_build);
}
@@ -170,7 +170,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number);
+ return sysfs_emit_at(buf, PAGE_SIZE, "%s\n", ha->serial_number);
}
static ssize_t
@@ -178,7 +178,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fw_info.iscsi_major,
+ return sysfs_emit_at(buf, PAGE_SIZE, "%d.%02d\n", ha->fw_info.iscsi_major,
ha->fw_info.iscsi_minor);
}
@@ -187,7 +187,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
+ return sysfs_emit_at(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
ha->fw_info.bootload_major, ha->fw_info.bootload_minor,
ha->fw_info.bootload_patch, ha->fw_info.bootload_build);
}
@@ -197,7 +197,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "0x%08X\n", ha->board_id);
+ return sysfs_emit_at(buf, PAGE_SIZE, "0x%08X\n", ha->board_id);
}
static ssize_t
@@ -207,7 +207,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
qla4xxx_get_firmware_state(ha);
- return snprintf(buf, PAGE_SIZE, "0x%08X%8X\n", ha->firmware_state,
+ return sysfs_emit_at(buf, PAGE_SIZE, "0x%08X%8X\n", ha->firmware_state,
ha->addl_fw_state);
}
@@ -220,7 +220,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
if (is_qla40XX(ha))
return -ENOSYS;
- return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_cnt);
+ return sysfs_emit_at(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_cnt);
}
static ssize_t
@@ -232,7 +232,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
if (is_qla40XX(ha))
return -ENOSYS;
- return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_num);
+ return sysfs_emit_at(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_num);
}
static ssize_t
@@ -244,7 +244,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
if (is_qla40XX(ha))
return -ENOSYS;
- return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->iscsi_pci_func_cnt);
+ return sysfs_emit_at(buf, PAGE_SIZE, "0x%04X\n", ha->iscsi_pci_func_cnt);
}
static ssize_t
@@ -253,7 +253,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_name);
+ return sysfs_emit_at(buf, PAGE_SIZE, "%s\n", ha->model_name);
}
static ssize_t
@@ -261,7 +261,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s %s\n", ha->fw_info.fw_build_date,
+ return sysfs_emit_at(buf, PAGE_SIZE, "%s %s\n", ha->fw_info.fw_build_date,
ha->fw_info.fw_build_time);
}
@@ -309,7 +309,7 @@ void qla4_8xxx_free_sysfs_attr(struct scsi_qla_host *ha)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
qla4xxx_about_firmware(ha);
- return snprintf(buf, PAGE_SIZE, "%u.%u secs\n", ha->fw_uptime_secs,
+ return sysfs_emit_at(buf, PAGE_SIZE, "%u.%u secs\n", ha->fw_uptime_secs,
ha->fw_uptime_msecs);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] scsi/qla4xxx: convert sysfs sprintf/snprintf family to sysfs_emit/sysfs_emit_at
2021-01-21 3:57 [PATCH v2] scsi/qla4xxx: convert sysfs sprintf/snprintf family to sysfs_emit/sysfs_emit_at Jiapeng Zhong
@ 2021-01-21 4:55 ` Bart Van Assche
2021-01-21 5:15 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2021-01-21 4:55 UTC (permalink / raw)
To: Jiapeng Zhong, njavali
Cc: mrangankar, GR-QLogic-Storage-Upstream, jejb, martin.petersen,
linux-scsi, linux-kernel
On 1/20/21 7:57 PM, Jiapeng Zhong wrote:
> - return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
> + return sysfs_emit_at(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
> ha->fw_info.fw_major, ha->fw_info.fw_minor,
> ha->fw_info.fw_patch, ha->fw_info.fw_build);
From the sysfs_emit_at() source code:
WARN(... || at >= PAGE_SIZE, "invalid sysfs_emit_at: buf:%p at:%d\n",
buf, at)
In other words, this patch is wrong. sysfs_emit() should have been used
instead of sysfs_emit_at().
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] scsi/qla4xxx: convert sysfs sprintf/snprintf family to sysfs_emit/sysfs_emit_at
2021-01-21 4:55 ` Bart Van Assche
@ 2021-01-21 5:15 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2021-01-21 5:15 UTC (permalink / raw)
To: Bart Van Assche, Jiapeng Zhong, njavali
Cc: mrangankar, GR-QLogic-Storage-Upstream, jejb, martin.petersen,
linux-scsi, linux-kernel
On Wed, 2021-01-20 at 20:55 -0800, Bart Van Assche wrote:
> On 1/20/21 7:57 PM, Jiapeng Zhong wrote:
> > - return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
> > + return sysfs_emit_at(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
> > ha->fw_info.fw_major, ha->fw_info.fw_minor,
> > ha->fw_info.fw_patch, ha->fw_info.fw_build);
>
> From the sysfs_emit_at() source code:
>
> WARN(... || at >= PAGE_SIZE, "invalid sysfs_emit_at: buf:%p at:%d\n",
> buf, at)
>
> In other words, this patch is wrong. sysfs_emit() should have been used
> instead of sysfs_emit_at().
Instead, use the cocci script from
commit aa838896d87a ("drivers core: Use sysfs_emit and sysfs_emit_at for
show(device *...) functions")
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-21 5:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 3:57 [PATCH v2] scsi/qla4xxx: convert sysfs sprintf/snprintf family to sysfs_emit/sysfs_emit_at Jiapeng Zhong
2021-01-21 4:55 ` Bart Van Assche
2021-01-21 5:15 ` Joe Perches
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.