public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: most: replace snprintf in show functions with sysfs_emit
@ 2021-11-03  8:23 cgel.zte
  2021-11-03  8:27 ` Johan Hovold
  2021-11-03  8:28 ` [PATCH] drivers: most: " Greg KH
  0 siblings, 2 replies; 6+ messages in thread
From: cgel.zte @ 2021-11-03  8:23 UTC (permalink / raw)
  To: johan; +Cc: gregkh, linux-kernel, Jing Yao, Zeal Robot

From: Jing Yao <yao.jing2@zte.com.cn>

coccicheck complains about the use of snprintf() in sysfs show
funcitons:
WARNING use scnprintf or sprintf

Use sysfs_emit instead of scnprintf, snprintf or sprintf makes more
sense.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>
---
 drivers/most/most_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c
index acabb7715b42..dccbec16000c 100644
--- a/drivers/most/most_usb.c
+++ b/drivers/most/most_usb.c
@@ -831,7 +831,7 @@ static ssize_t value_show(struct device *dev, struct device_attribute *attr,
 	int err;
 
 	if (sysfs_streq(name, "arb_address"))
-		return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
+		return sysfs_emit(buf, "%04x\n", dci_obj->reg_addr);
 
 	if (sysfs_streq(name, "arb_value"))
 		reg_addr = dci_obj->reg_addr;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-10  2:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-03  8:23 [PATCH] drivers: most: replace snprintf in show functions with sysfs_emit cgel.zte
2021-11-03  8:27 ` Johan Hovold
2021-11-04 11:45   ` [PATCH v2] " cgel.zte
2021-11-08  9:50     ` Johan Hovold
2021-11-10  2:53       ` [PATCH v3] most: usb: " cgel.zte
2021-11-03  8:28 ` [PATCH] drivers: most: " Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox