* [PATCH] scsi: pmcraid: convert sysfs snprintf to sysfs_emit
@ 2022-04-28 7:02 Xuezhi Zhang
2022-04-28 15:22 ` Martin K. Petersen
2022-04-29 3:42 ` Bart Van Assche
0 siblings, 2 replies; 3+ messages in thread
From: Xuezhi Zhang @ 2022-04-28 7:02 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linux-scsi, linux-kernel, Xuezhi Zhang
Fix the following coccicheck warnings:
drivers/scsi/pmcraid.c:3591:8-16:
WARNING: use scnprintf or sprintf
drivers/scsi/pmcraid.c:3557:8-16:
WARNING: use scnprintf or sprintf
drivers/scsi/pmcraid.c:3496:8-16:
WARNING: use scnprintf or sprintf
Signed-off-by: Xuezhi Zhang <zhangxuezhi1@coolpad.com>
---
drivers/scsi/pmcraid.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 3d5cd337a2a6..299553ff2277 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3493,7 +3493,7 @@ static ssize_t pmcraid_show_log_level(
struct Scsi_Host *shost = class_to_shost(dev);
struct pmcraid_instance *pinstance =
(struct pmcraid_instance *)shost->hostdata;
- return snprintf(buf, PAGE_SIZE, "%d\n", pinstance->current_log_level);
+ return sysfs_emit(buf, "%d\n", pinstance->current_log_level);
}
/**
@@ -3554,8 +3554,7 @@ static ssize_t pmcraid_show_drv_version(
char *buf
)
{
- return snprintf(buf, PAGE_SIZE, "version: %s\n",
- PMCRAID_DRIVER_VERSION);
+ return sysfs_emt(buf, "version: %s\n", PMCRAID_DRIVER_VERSION);
}
static struct device_attribute pmcraid_driver_version_attr = {
@@ -3588,8 +3587,7 @@ static ssize_t pmcraid_show_adapter_id(
pinstance->pdev->devfn;
u32 aen_group = pmcraid_event_family.id;
- return snprintf(buf, PAGE_SIZE,
- "adapter id: %d\nminor: %d\naen group: %d\n",
+ return sysfs_emit(buf, "adapter id: %d\nminor: %d\naen group: %d\n",
adapter_id, MINOR(pinstance->cdev.dev), aen_group);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: pmcraid: convert sysfs snprintf to sysfs_emit
2022-04-28 7:02 [PATCH] scsi: pmcraid: convert sysfs snprintf to sysfs_emit Xuezhi Zhang
@ 2022-04-28 15:22 ` Martin K. Petersen
2022-04-29 3:42 ` Bart Van Assche
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2022-04-28 15:22 UTC (permalink / raw)
To: Xuezhi Zhang; +Cc: jejb, martin.petersen, linux-scsi, linux-kernel
Xuezhi,
> @@ -3554,8 +3554,7 @@ static ssize_t pmcraid_show_drv_version(
> char *buf
> )
> {
> - return snprintf(buf, PAGE_SIZE, "version: %s\n",
> - PMCRAID_DRIVER_VERSION);
> + return sysfs_emt(buf, "version: %s\n", PMCRAID_DRIVER_VERSION);
^^^^^^^^^
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: pmcraid: convert sysfs snprintf to sysfs_emit
2022-04-28 7:02 [PATCH] scsi: pmcraid: convert sysfs snprintf to sysfs_emit Xuezhi Zhang
2022-04-28 15:22 ` Martin K. Petersen
@ 2022-04-29 3:42 ` Bart Van Assche
1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2022-04-29 3:42 UTC (permalink / raw)
To: Xuezhi Zhang, jejb, martin.petersen; +Cc: linux-scsi, linux-kernel
On 4/28/22 00:02, Xuezhi Zhang wrote:
> Fix the following coccicheck warnings:
> drivers/scsi/pmcraid.c:3591:8-16:
> WARNING: use scnprintf or sprintf
> drivers/scsi/pmcraid.c:3557:8-16:
> WARNING: use scnprintf or sprintf
> drivers/scsi/pmcraid.c:3496:8-16:
> WARNING: use scnprintf or sprintf
I'm not sure the above is sufficient as motivation for this patch. The
current code looks fine to me. Why to change the snprintf() calls into
sysfs_emit() calls?
> @@ -3554,8 +3554,7 @@ static ssize_t pmcraid_show_drv_version(
> char *buf
> )
> {
> - return snprintf(buf, PAGE_SIZE, "version: %s\n",
> - PMCRAID_DRIVER_VERSION);
> + return sysfs_emt(buf, "version: %s\n", PMCRAID_DRIVER_VERSION);
> }
Something tells me that this patch has not been tested at all - not even
compile tested. Are you perhaps checking whether it is possible to get a
broken patch in the kernel tree?
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-29 3:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 7:02 [PATCH] scsi: pmcraid: convert sysfs snprintf to sysfs_emit Xuezhi Zhang
2022-04-28 15:22 ` Martin K. Petersen
2022-04-29 3:42 ` Bart Van Assche
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.