Messages in this thread Patch in this message | | | From | Qing Wang <> | Subject | [PATCH] tty: vt: replace snprintf in show functions with sysfs_emit | Date | Thu, 14 Oct 2021 23:51:36 -0700 |
| |
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
| |