All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3] media: i2c: ccs: replace snprintf in show functions with sysfs_emit
@ 2021-10-20  2:14 Qing Wang
  2021-10-20  9:47 ` Kieran Bingham
  0 siblings, 1 reply; 3+ messages in thread
From: Qing Wang @ 2021-10-20  2:14 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab, linux-media, linux-kernel; +Cc: Qing Wang

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

Fix the following coccicheck warning:
drivers/media/i2c/ccs/ccs-core.c:3761: WARNING: use scnprintf or sprintf.

V3:
- Fix some formatting problems.

Signed-off-by: Qing Wang <wangqing@vivo.com>
---
 drivers/media/i2c/ccs/ccs-core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 5363f3b..9158d3c
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -2758,13 +2758,13 @@ ident_show(struct device *dev, struct device_attribute *attr, char *buf)
 	struct ccs_module_info *minfo = &sensor->minfo;
 
 	if (minfo->mipi_manufacturer_id)
-		return snprintf(buf, PAGE_SIZE, "%4.4x%4.4x%2.2x\n",
-				minfo->mipi_manufacturer_id, minfo->model_id,
-				minfo->revision_number) + 1;
+		return sysfs_emit(buf, "%4.4x%4.4x%2.2x\n",
+				  minfo->mipi_manufacturer_id, minfo->model_id,
+				  minfo->revision_number) + 1;
 	else
-		return snprintf(buf, PAGE_SIZE, "%2.2x%4.4x%2.2x\n",
-				minfo->smia_manufacturer_id, minfo->model_id,
-				minfo->revision_number) + 1;
+		return sysfs_emit(buf, "%2.2x%4.4x%2.2x\n",
+				  minfo->smia_manufacturer_id, minfo->model_id,
+				  minfo->revision_number) + 1;
 }
 static DEVICE_ATTR_RO(ident);
 
-- 
2.7.4


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

* Re: [PATCH V3] media: i2c: ccs: replace snprintf in show functions with sysfs_emit
  2021-10-20  2:14 [PATCH V3] media: i2c: ccs: replace snprintf in show functions with sysfs_emit Qing Wang
@ 2021-10-20  9:47 ` Kieran Bingham
  2021-10-20 11:18   ` Sakari Ailus
  0 siblings, 1 reply; 3+ messages in thread
From: Kieran Bingham @ 2021-10-20  9:47 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Qing Wang, Sakari Ailus, linux-kernel,
	linux-media
  Cc: Qing Wang

Hi Qing,

Quoting Qing Wang (2021-10-20 03:14:15)
> show() should not use snprintf() when formatting the value to be
> returned to user space.
> 
> Fix the following coccicheck warning:
> drivers/media/i2c/ccs/ccs-core.c:3761: WARNING: use scnprintf or sprintf.
> 
> V3:
> - Fix some formatting problems.

This could go below the --- so that it doesn't get entered into the
commit itself, but I suspect that can be handled while applying. Not
sure what the preferences are for that.

Anyway, thank you for updating with my suggestions.

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> 
> Signed-off-by: Qing Wang <wangqing@vivo.com>
> ---
>  drivers/media/i2c/ccs/ccs-core.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
> index 5363f3b..9158d3c
> --- a/drivers/media/i2c/ccs/ccs-core.c
> +++ b/drivers/media/i2c/ccs/ccs-core.c
> @@ -2758,13 +2758,13 @@ ident_show(struct device *dev, struct device_attribute *attr, char *buf)
>         struct ccs_module_info *minfo = &sensor->minfo;
>  
>         if (minfo->mipi_manufacturer_id)
> -               return snprintf(buf, PAGE_SIZE, "%4.4x%4.4x%2.2x\n",
> -                               minfo->mipi_manufacturer_id, minfo->model_id,
> -                               minfo->revision_number) + 1;
> +               return sysfs_emit(buf, "%4.4x%4.4x%2.2x\n",
> +                                 minfo->mipi_manufacturer_id, minfo->model_id,
> +                                 minfo->revision_number) + 1;
>         else
> -               return snprintf(buf, PAGE_SIZE, "%2.2x%4.4x%2.2x\n",
> -                               minfo->smia_manufacturer_id, minfo->model_id,
> -                               minfo->revision_number) + 1;
> +               return sysfs_emit(buf, "%2.2x%4.4x%2.2x\n",
> +                                 minfo->smia_manufacturer_id, minfo->model_id,
> +                                 minfo->revision_number) + 1;
>  }
>  static DEVICE_ATTR_RO(ident);
>  
> -- 
> 2.7.4
>

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

* Re: [PATCH V3] media: i2c: ccs: replace snprintf in show functions with sysfs_emit
  2021-10-20  9:47 ` Kieran Bingham
@ 2021-10-20 11:18   ` Sakari Ailus
  0 siblings, 0 replies; 3+ messages in thread
From: Sakari Ailus @ 2021-10-20 11:18 UTC (permalink / raw)
  To: Kieran Bingham
  Cc: Mauro Carvalho Chehab, Qing Wang, linux-kernel, linux-media

On Wed, Oct 20, 2021 at 10:47:36AM +0100, Kieran Bingham wrote:
> Hi Qing,
> 
> Quoting Qing Wang (2021-10-20 03:14:15)
> > show() should not use snprintf() when formatting the value to be
> > returned to user space.
> > 
> > Fix the following coccicheck warning:
> > drivers/media/i2c/ccs/ccs-core.c:3761: WARNING: use scnprintf or sprintf.
> > 
> > V3:
> > - Fix some formatting problems.
> 
> This could go below the --- so that it doesn't get entered into the
> commit itself, but I suspect that can be handled while applying. Not
> sure what the preferences are for that.

You're right in saying it needs to be after '---' line. But no need to
resend for that.

> 
> Anyway, thank you for updating with my suggestions.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> > 
> > Signed-off-by: Qing Wang <wangqing@vivo.com>
> > ---
> >  drivers/media/i2c/ccs/ccs-core.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
> > index 5363f3b..9158d3c
> > --- a/drivers/media/i2c/ccs/ccs-core.c
> > +++ b/drivers/media/i2c/ccs/ccs-core.c
> > @@ -2758,13 +2758,13 @@ ident_show(struct device *dev, struct device_attribute *attr, char *buf)
> >         struct ccs_module_info *minfo = &sensor->minfo;
> >  
> >         if (minfo->mipi_manufacturer_id)
> > -               return snprintf(buf, PAGE_SIZE, "%4.4x%4.4x%2.2x\n",
> > -                               minfo->mipi_manufacturer_id, minfo->model_id,
> > -                               minfo->revision_number) + 1;
> > +               return sysfs_emit(buf, "%4.4x%4.4x%2.2x\n",
> > +                                 minfo->mipi_manufacturer_id, minfo->model_id,
> > +                                 minfo->revision_number) + 1;
> >         else
> > -               return snprintf(buf, PAGE_SIZE, "%2.2x%4.4x%2.2x\n",
> > -                               minfo->smia_manufacturer_id, minfo->model_id,
> > -                               minfo->revision_number) + 1;
> > +               return sysfs_emit(buf, "%2.2x%4.4x%2.2x\n",
> > +                                 minfo->smia_manufacturer_id, minfo->model_id,
> > +                                 minfo->revision_number) + 1;
> >  }
> >  static DEVICE_ATTR_RO(ident);
> >  
> > -- 
> > 2.7.4
> >

-- 
Sakari Ailus

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20  2:14 [PATCH V3] media: i2c: ccs: replace snprintf in show functions with sysfs_emit Qing Wang
2021-10-20  9:47 ` Kieran Bingham
2021-10-20 11:18   ` Sakari Ailus

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.