public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vt: convert sysfs sprintf/snprintf family to sysfs_emit
@ 2021-02-22  8:48 Jiapeng Chong
  2021-02-22  8:53 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2021-02-22  8:48 UTC (permalink / raw)
  To: gregkh; +Cc: jirislaby, linux-kernel, Jiapeng Chong

Fix the following coccicheck warning:

./drivers/tty/vt/vt.c:3909:8-16: WARNING: use scnprintf or sprintf.
./drivers/tty/vt/vt.c:3917:8-16: WARNING: use scnprintf or sprintf

Reported-by: Abaci Robot<abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/tty/vt/vt.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 284b072..cdf8132 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3906,7 +3906,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,
@@ -3914,9 +3914,8 @@ 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",
-			(con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
-			 con->desc);
+	return sysfs_emit(buf, "%s %s\n", (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
+			  con->desc);
 
 }
 
-- 
1.8.3.1


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

* Re: [PATCH] vt: convert sysfs sprintf/snprintf family to sysfs_emit
  2021-02-22  8:48 [PATCH] vt: convert sysfs sprintf/snprintf family to sysfs_emit Jiapeng Chong
@ 2021-02-22  8:53 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-02-22  8:53 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: jirislaby, linux-kernel

On Mon, Feb 22, 2021 at 04:48:49PM +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warning:
> 
> ./drivers/tty/vt/vt.c:3909:8-16: WARNING: use scnprintf or sprintf.
> ./drivers/tty/vt/vt.c:3917:8-16: WARNING: use scnprintf or sprintf

Why?

You say what you did, but there is no justification for why this is
required in the tree.

> 
> Reported-by: Abaci Robot<abaci@linux.alibaba.com>

You forgot a ' '.

> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  drivers/tty/vt/vt.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 284b072..cdf8132 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -3906,7 +3906,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,
> @@ -3914,9 +3914,8 @@ 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",
> -			(con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
> -			 con->desc);
> +	return sysfs_emit(buf, "%s %s\n", (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
> +			  con->desc);

Why make the line longer now?  Can't this be a 1 line change here?

And why is this needed?

thanks,

greg k-h

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

end of thread, other threads:[~2021-02-22  8:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-22  8:48 [PATCH] vt: convert sysfs sprintf/snprintf family to sysfs_emit Jiapeng Chong
2021-02-22  8:53 ` Greg KH

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