linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: panel: replace snprintf in show functions with sysfs_emit
@ 2021-10-15  6:48 Qing Wang
  2021-10-15 11:11 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Qing Wang @ 2021-10-15  6:48 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	dri-devel, 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/gpu/drm/panel/panel-dsi-cm.c:251: WARNING: use scnprintf or sprintf.
drivers/gpu/drm/panel/panel-dsi-cm.c:271: WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

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

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
index 5fbfb71..a8efb06 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -248,7 +248,7 @@ static ssize_t num_dsi_errors_show(struct device *dev,
 	if (r)
 		return r;
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", errors);
+	return sysfs_emit(buf, "%d\n", errors);
 }
 
 static ssize_t hw_revision_show(struct device *dev,
@@ -268,7 +268,7 @@ static ssize_t hw_revision_show(struct device *dev,
 	if (r)
 		return r;
 
-	return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x\n", id1, id2, id3);
+	return sysfs_emit(buf, "%02x.%02x.%02x\n", id1, id2, id3);
 }
 
 static DEVICE_ATTR_RO(num_dsi_errors);
-- 
2.7.4


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

* Re: [PATCH] drm: panel: replace snprintf in show functions with sysfs_emit
  2021-10-15  6:48 [PATCH] drm: panel: replace snprintf in show functions with sysfs_emit Qing Wang
@ 2021-10-15 11:11 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2021-10-15 11:11 UTC (permalink / raw)
  To: Qing Wang
  Cc: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1595 bytes --]

Hi,

On Thu, Oct 14, 2021 at 11:48:10PM -0700, Qing Wang wrote:
> show() must not use snprintf() when formatting the value to be
> returned to user space.
> 
> Fix the following coccicheck warning:
> drivers/gpu/drm/panel/panel-dsi-cm.c:251: WARNING: use scnprintf or sprintf.
> drivers/gpu/drm/panel/panel-dsi-cm.c:271: WARNING: use scnprintf or sprintf.
> 
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
> 
> Signed-off-by: Qing Wang <wangqing@vivo.com>
> ---

The patch subject could be more specific (this updates just one panel driver).
Otherwise:

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/panel/panel-dsi-cm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index 5fbfb71..a8efb06 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -248,7 +248,7 @@ static ssize_t num_dsi_errors_show(struct device *dev,
>  	if (r)
>  		return r;
>  
> -	return snprintf(buf, PAGE_SIZE, "%d\n", errors);
> +	return sysfs_emit(buf, "%d\n", errors);
>  }
>  
>  static ssize_t hw_revision_show(struct device *dev,
> @@ -268,7 +268,7 @@ static ssize_t hw_revision_show(struct device *dev,
>  	if (r)
>  		return r;
>  
> -	return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x\n", id1, id2, id3);
> +	return sysfs_emit(buf, "%02x.%02x.%02x\n", id1, id2, id3);
>  }
>  
>  static DEVICE_ATTR_RO(num_dsi_errors);
> -- 
> 2.7.4
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15  6:48 [PATCH] drm: panel: replace snprintf in show functions with sysfs_emit Qing Wang
2021-10-15 11:11 ` Sebastian Reichel

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).