All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] video: fbdev: replace snprintf in show functions with sysfs_emit
@ 2021-10-13  3:28 Qing Wang
  2021-10-15 20:49 ` Sam Ravnborg
  0 siblings, 1 reply; 2+ messages in thread
From: Qing Wang @ 2021-10-13  3:28 UTC (permalink / raw)
  To: dri-devel, linux-fbdev, linux-kernel; +Cc: Qing Wang

coccicheck complains about the use of snprintf() in sysfs show functions.

Fix the coccicheck warning:
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/video/fbdev/core/fbsysfs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c
index 65dae05..2689294 100644
--- a/drivers/video/fbdev/core/fbsysfs.c
+++ b/drivers/video/fbdev/core/fbsysfs.c
@@ -230,7 +230,7 @@ static ssize_t show_bpp(struct device *device, struct device_attribute *attr,
 			char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel);
+	return sysfs_emit(buf, "%d\n", fb_info->var.bits_per_pixel);
 }
 
 static ssize_t store_rotate(struct device *device,
@@ -257,7 +257,7 @@ static ssize_t show_rotate(struct device *device,
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate);
+	return sysfs_emit(buf, "%d\n", fb_info->var.rotate);
 }
 
 static ssize_t store_virtual(struct device *device,
@@ -285,7 +285,7 @@ static ssize_t show_virtual(struct device *device,
 			    struct device_attribute *attr, char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual,
+	return sysfs_emit(buf, "%d,%d\n", fb_info->var.xres_virtual,
 			fb_info->var.yres_virtual);
 }
 
@@ -293,7 +293,7 @@ static ssize_t show_stride(struct device *device,
 			   struct device_attribute *attr, char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length);
+	return sysfs_emit(buf, "%d\n", fb_info->fix.line_length);
 }
 
 static ssize_t store_blank(struct device *device,
@@ -381,7 +381,7 @@ static ssize_t show_pan(struct device *device,
 			struct device_attribute *attr, char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset,
+	return sysfs_emit(buf, "%d,%d\n", fb_info->var.xoffset,
 			fb_info->var.yoffset);
 }
 
@@ -390,7 +390,7 @@ static ssize_t show_name(struct device *device,
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
 
-	return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id);
+	return sysfs_emit(buf, "%s\n", fb_info->fix.id);
 }
 
 static ssize_t store_fbstate(struct device *device,
@@ -418,7 +418,7 @@ static ssize_t show_fbstate(struct device *device,
 			    struct device_attribute *attr, char *buf)
 {
 	struct fb_info *fb_info = dev_get_drvdata(device);
-	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state);
+	return sysfs_emit(buf, "%d\n", fb_info->state);
 }
 
 #if IS_ENABLED(CONFIG_FB_BACKLIGHT)
-- 
2.7.4


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

* Re: [PATCH] video: fbdev: replace snprintf in show functions with sysfs_emit
  2021-10-13  3:28 [PATCH] video: fbdev: replace snprintf in show functions with sysfs_emit Qing Wang
@ 2021-10-15 20:49 ` Sam Ravnborg
  0 siblings, 0 replies; 2+ messages in thread
From: Sam Ravnborg @ 2021-10-15 20:49 UTC (permalink / raw)
  To: Qing Wang; +Cc: dri-devel, linux-fbdev, linux-kernel

Hi Qing,
On Tue, Oct 12, 2021 at 08:28:00PM -0700, Qing Wang wrote:
> coccicheck complains about the use of snprintf() in sysfs show functions.
> 
> Fix the coccicheck warning:
> WARNING: use scnprintf or sprintf.
> 
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
> 
> Signed-off-by: Qing Wang <wangqing@vivo.com>

Thanks, applied to drm-misc-next.

As fbdev is in maintenance only I was about to skip them.
But the changes was trivial so I took them anyway.

	Sam

> ---
>  drivers/video/fbdev/core/fbsysfs.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c
> index 65dae05..2689294 100644
> --- a/drivers/video/fbdev/core/fbsysfs.c
> +++ b/drivers/video/fbdev/core/fbsysfs.c
> @@ -230,7 +230,7 @@ static ssize_t show_bpp(struct device *device, struct device_attribute *attr,
>  			char *buf)
>  {
>  	struct fb_info *fb_info = dev_get_drvdata(device);
> -	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel);
> +	return sysfs_emit(buf, "%d\n", fb_info->var.bits_per_pixel);
>  }
>  
>  static ssize_t store_rotate(struct device *device,
> @@ -257,7 +257,7 @@ static ssize_t show_rotate(struct device *device,
>  {
>  	struct fb_info *fb_info = dev_get_drvdata(device);
>  
> -	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate);
> +	return sysfs_emit(buf, "%d\n", fb_info->var.rotate);
>  }
>  
>  static ssize_t store_virtual(struct device *device,
> @@ -285,7 +285,7 @@ static ssize_t show_virtual(struct device *device,
>  			    struct device_attribute *attr, char *buf)
>  {
>  	struct fb_info *fb_info = dev_get_drvdata(device);
> -	return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual,
> +	return sysfs_emit(buf, "%d,%d\n", fb_info->var.xres_virtual,
>  			fb_info->var.yres_virtual);
>  }
>  
> @@ -293,7 +293,7 @@ static ssize_t show_stride(struct device *device,
>  			   struct device_attribute *attr, char *buf)
>  {
>  	struct fb_info *fb_info = dev_get_drvdata(device);
> -	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length);
> +	return sysfs_emit(buf, "%d\n", fb_info->fix.line_length);
>  }
>  
>  static ssize_t store_blank(struct device *device,
> @@ -381,7 +381,7 @@ static ssize_t show_pan(struct device *device,
>  			struct device_attribute *attr, char *buf)
>  {
>  	struct fb_info *fb_info = dev_get_drvdata(device);
> -	return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset,
> +	return sysfs_emit(buf, "%d,%d\n", fb_info->var.xoffset,
>  			fb_info->var.yoffset);
>  }
>  
> @@ -390,7 +390,7 @@ static ssize_t show_name(struct device *device,
>  {
>  	struct fb_info *fb_info = dev_get_drvdata(device);
>  
> -	return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id);
> +	return sysfs_emit(buf, "%s\n", fb_info->fix.id);
>  }
>  
>  static ssize_t store_fbstate(struct device *device,
> @@ -418,7 +418,7 @@ static ssize_t show_fbstate(struct device *device,
>  			    struct device_attribute *attr, char *buf)
>  {
>  	struct fb_info *fb_info = dev_get_drvdata(device);
> -	return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state);
> +	return sysfs_emit(buf, "%d\n", fb_info->state);
>  }
>  
>  #if IS_ENABLED(CONFIG_FB_BACKLIGHT)
> -- 
> 2.7.4

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13  3:28 [PATCH] video: fbdev: replace snprintf in show functions with sysfs_emit Qing Wang
2021-10-15 20:49 ` Sam Ravnborg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.