[PATCH 07/42] drivers/edac: Convert snprintf to sysfs_emit

From: Li Zhijian
Date: Tue Jan 16 2024 - 00:04:42 EST


Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

> ./drivers/edac/edac_mc_sysfs.c:210:8-16: WARNING: please use sysfs_emit
> ./drivers/edac/edac_mc_sysfs.c:518:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: Borislav Petkov <bp@xxxxxxxxx>
CC: Tony Luck <tony.luck@xxxxxxxxx>
CC: James Morse <james.morse@xxxxxxx>
CC: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
CC: Robert Richter <rric@xxxxxxxxxx>
CC: linux-edac@xxxxxxxxxxxxxxx
Signed-off-by: Li Zhijian <lizhijian@xxxxxxxxxxx>
---
drivers/edac/edac_mc_sysfs.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 5116873c3330..6ee5030c7207 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -207,8 +207,7 @@ static ssize_t channel_dimm_label_show(struct device *dev,
if (!rank->dimm->label[0])
return 0;

- return snprintf(data, sizeof(rank->dimm->label) + 1, "%s\n",
- rank->dimm->label);
+ return sysfs_emit(data, "%s\n", rank->dimm->label);
}

static ssize_t channel_dimm_label_store(struct device *dev,
@@ -515,7 +514,7 @@ static ssize_t dimmdev_label_show(struct device *dev,
if (!dimm->label[0])
return 0;

- return snprintf(data, sizeof(dimm->label) + 1, "%s\n", dimm->label);
+ return sysfs_emit(data, "%s\n", dimm->label);
}

static ssize_t dimmdev_label_store(struct device *dev,
--
2.29.2