linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: vt: replace snprintf in show functions with sysfs_emit
@ 2021-10-15  6:51 Qing Wang
  2021-10-15  6:59 ` Greg Kroah-Hartman
       [not found] ` <APcArgDIEqvUlprBO4*Tk4rA.9.1634281148594.Hmail.wangqing@vivo.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Qing Wang @ 2021-10-15  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-kernel; +Cc: Qing Wang

show() must not use snprintf() when formatting the value to be
returned to user space.

Fix the following coccicheck warning:
drivers/tty/vt/vt.c:3902: WARNING: use scnprintf or sprintf.
drivers/tty/vt/vt.c:3910: WARNING: use scnprintf or sprintf.

Signed-off-by: Qing Wang <wangqing@vivo.com>
---
 drivers/tty/vt/vt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index ef981d3..ea44ea1 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3899,7 +3899,7 @@ static ssize_t show_bind(struct device *dev, struct device_attribute *attr,
 	bind = con_is_bound(con->con);
 	console_unlock();
 
-	return snprintf(buf, PAGE_SIZE, "%i\n", bind);
+	return sysfs_emit(buf, "%i\n", bind);
 }
 
 static ssize_t show_name(struct device *dev, struct device_attribute *attr,
@@ -3907,7 +3907,7 @@ static ssize_t show_name(struct device *dev, struct device_attribute *attr,
 {
 	struct con_driver *con = dev_get_drvdata(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%s %s\n",
+	return sysfs_emit(buf, "%s %s\n",
 			(con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
 			 con->desc);
 
-- 
2.7.4


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

end of thread, other threads:[~2021-10-15  7:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15  6:51 [PATCH] tty: vt: replace snprintf in show functions with sysfs_emit Qing Wang
2021-10-15  6:59 ` Greg Kroah-Hartman
     [not found] ` <APcArgDIEqvUlprBO4*Tk4rA.9.1634281148594.Hmail.wangqing@vivo.com>
2021-10-15  7:10   ` 回复: " 王擎
2021-10-15  7:29     ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).