* [PATCH] bus: mhi: replace snprintf with sysfs_emit
@ 2022-04-26 12:58 Wan Jiabing
2022-04-26 21:26 ` Kees Cook
2022-04-27 10:22 ` Manivannan Sadhasivam
0 siblings, 2 replies; 3+ messages in thread
From: Wan Jiabing @ 2022-04-26 12:58 UTC (permalink / raw)
To: Manivannan Sadhasivam, Hemant Kumar, Greg Kroah-Hartman,
Jeffrey Hugo, Bhaumik Bhatt, Paul Davey, Kees Cook, mhi,
linux-arm-msm, linux-kernel
Cc: Wan Jiabing
Fix following coccicheck warning:
./drivers/bus/mhi/host/init.c:89:8-16: WARNING: use scnprintf or sprintf
Use sysfs_emit and sysfs_emit_at instead of snprintf.
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
drivers/bus/mhi/host/init.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c
index cbb86b21063e..c137d55ccfa0 100644
--- a/drivers/bus/mhi/host/init.c
+++ b/drivers/bus/mhi/host/init.c
@@ -86,7 +86,7 @@ static ssize_t serial_number_show(struct device *dev,
struct mhi_device *mhi_dev = to_mhi_device(dev);
struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
- return snprintf(buf, PAGE_SIZE, "Serial Number: %u\n",
+ return sysfs_emit(buf, "Serial Number: %u\n",
mhi_cntrl->serial_number);
}
static DEVICE_ATTR_RO(serial_number);
@@ -100,9 +100,8 @@ static ssize_t oem_pk_hash_show(struct device *dev,
int i, cnt = 0;
for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++)
- cnt += snprintf(buf + cnt, PAGE_SIZE - cnt,
- "OEMPKHASH[%d]: 0x%x\n", i,
- mhi_cntrl->oem_pk_hash[i]);
+ cnt += sysfs_emit_at(buf, cnt, "OEMPKHASH[%d]: 0x%x\n",
+ i, mhi_cntrl->oem_pk_hash[i]);
return cnt;
}
--
2.35.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bus: mhi: replace snprintf with sysfs_emit
2022-04-26 12:58 [PATCH] bus: mhi: replace snprintf with sysfs_emit Wan Jiabing
@ 2022-04-26 21:26 ` Kees Cook
2022-04-27 10:22 ` Manivannan Sadhasivam
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2022-04-26 21:26 UTC (permalink / raw)
To: Wan Jiabing
Cc: Manivannan Sadhasivam, Hemant Kumar, Greg Kroah-Hartman,
Jeffrey Hugo, Bhaumik Bhatt, Paul Davey, mhi, linux-arm-msm,
linux-kernel
On Tue, Apr 26, 2022 at 08:58:59PM +0800, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./drivers/bus/mhi/host/init.c:89:8-16: WARNING: use scnprintf or sprintf
>
> Use sysfs_emit and sysfs_emit_at instead of snprintf.
>
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bus: mhi: replace snprintf with sysfs_emit
2022-04-26 12:58 [PATCH] bus: mhi: replace snprintf with sysfs_emit Wan Jiabing
2022-04-26 21:26 ` Kees Cook
@ 2022-04-27 10:22 ` Manivannan Sadhasivam
1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2022-04-27 10:22 UTC (permalink / raw)
To: Wan Jiabing
Cc: Manivannan Sadhasivam, Hemant Kumar, Greg Kroah-Hartman,
Jeffrey Hugo, Bhaumik Bhatt, Paul Davey, Kees Cook, mhi,
linux-arm-msm, linux-kernel
On Tue, Apr 26, 2022 at 08:58:59PM +0800, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./drivers/bus/mhi/host/init.c:89:8-16: WARNING: use scnprintf or sprintf
>
> Use sysfs_emit and sysfs_emit_at instead of snprintf.
>
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Thanks,
Mani
> ---
> drivers/bus/mhi/host/init.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c
> index cbb86b21063e..c137d55ccfa0 100644
> --- a/drivers/bus/mhi/host/init.c
> +++ b/drivers/bus/mhi/host/init.c
> @@ -86,7 +86,7 @@ static ssize_t serial_number_show(struct device *dev,
> struct mhi_device *mhi_dev = to_mhi_device(dev);
> struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
>
> - return snprintf(buf, PAGE_SIZE, "Serial Number: %u\n",
> + return sysfs_emit(buf, "Serial Number: %u\n",
> mhi_cntrl->serial_number);
> }
> static DEVICE_ATTR_RO(serial_number);
> @@ -100,9 +100,8 @@ static ssize_t oem_pk_hash_show(struct device *dev,
> int i, cnt = 0;
>
> for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++)
> - cnt += snprintf(buf + cnt, PAGE_SIZE - cnt,
> - "OEMPKHASH[%d]: 0x%x\n", i,
> - mhi_cntrl->oem_pk_hash[i]);
> + cnt += sysfs_emit_at(buf, cnt, "OEMPKHASH[%d]: 0x%x\n",
> + i, mhi_cntrl->oem_pk_hash[i]);
>
> return cnt;
> }
> --
> 2.35.3
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-27 10:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 12:58 [PATCH] bus: mhi: replace snprintf with sysfs_emit Wan Jiabing
2022-04-26 21:26 ` Kees Cook
2022-04-27 10:22 ` Manivannan Sadhasivam
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.