2022-01-27 07:18:16

by David Yang

[permalink] [raw]
Subject: [PATCH] scsi: mvsas: replace snprintf with sysfs_emit

From: Yang Guang <[email protected]>

coccinelle report:
./drivers/scsi/mvsas/mv_init.c:699:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/mvsas/mv_init.c:747:8-16:
WARNING: use scnprintf or sprintf

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Yang Guang <[email protected]>
Signed-off-by: David Yang <[email protected]>
---
drivers/scsi/mvsas/mv_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index dcae2d4464f9..44df7c03aab8 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -696,7 +696,7 @@ static struct pci_driver mvs_pci_driver = {
static ssize_t driver_version_show(struct device *cdev,
struct device_attribute *attr, char *buffer)
{
- return snprintf(buffer, PAGE_SIZE, "%s\n", DRV_VERSION);
+ return sysfs_emit(buffer, "%s\n", DRV_VERSION);
}

static DEVICE_ATTR_RO(driver_version);
@@ -744,7 +744,7 @@ static ssize_t interrupt_coalescing_store(struct device *cdev,
static ssize_t interrupt_coalescing_show(struct device *cdev,
struct device_attribute *attr, char *buffer)
{
- return snprintf(buffer, PAGE_SIZE, "%d\n", interrupt_coalescing);
+ return sysfs_emit(buffer, "%d\n", interrupt_coalescing);
}

static DEVICE_ATTR_RW(interrupt_coalescing);
--
2.30.2


2022-02-09 11:32:38

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH] scsi: mvsas: replace snprintf with sysfs_emit

On Thu, 27 Jan 2022 08:00:59 +0800, [email protected] wrote:

> From: Yang Guang <[email protected]>
>
> coccinelle report:
> ./drivers/scsi/mvsas/mv_init.c:699:8-16:
> WARNING: use scnprintf or sprintf
> ./drivers/scsi/mvsas/mv_init.c:747:8-16:
> WARNING: use scnprintf or sprintf
>
> [...]

Applied to 5.18/scsi-queue, thanks!

[1/1] scsi: mvsas: replace snprintf with sysfs_emit
https://git.kernel.org/mkp/scsi/c/0ad3867b0f13

--
Martin K. Petersen Oracle Linux Engineering