mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kieran Bingham <kieran.bingham@ideasonboard.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Qing Wang <wangqing@vivo.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Cc: Qing Wang <wangqing@vivo.com>
Subject: Re: [PATCH] media: ccs: replace snprintf in show functions with sysfs_emit
Date: Fri, 15 Oct 2021 23:36:33 +0100	[thread overview]
Message-ID: <163433739388.456562.9392744334237641054@Monstersaurus> (raw)
In-Reply-To: <1634280562-4629-1-git-send-email-wangqing@vivo.com>

Hello,

Quoting Qing Wang (2021-10-15 07:49:22)
> show() must 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:2717: 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/media/i2c/ccs/ccs-core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
> index a9403a2..21a156d 100644
> --- a/drivers/media/i2c/ccs/ccs-core.c
> +++ b/drivers/media/i2c/ccs/ccs-core.c
> @@ -2715,11 +2715,11 @@ ccs_sysfs_ident_read(struct device *dev, struct device_attribute *attr,

What version of the kernel is this patch against?

I can't find the direct line mapping for this in either the linux-media
tree or torvalds master branch (closest match at
https://git.linuxtv.org/media_tree.git/tree/drivers/media/i2c/ccs/ccs-core.c#n2754)

Ah: https://lore.kernel.org/all/20210603071750.11594-1-thunder.leizhen@huawei.com/
updated this, so I suspect this patch has been submitted against perhaps
a v5.14 kernel? It would be best to rebase and repost against the latest
branch of https://git.linuxtv.org/media_tree.git


>         struct ccs_module_info *minfo = &sensor->minfo;
>  
>         if (minfo->mipi_manufacturer_id)
> -               return snprintf(buf, PAGE_SIZE, "%4.4x%4.4x%2.2x\n",
> +               return sysfs_emit(buf, "%4.4x%4.4x%2.2x\n",
>                                 minfo->mipi_manufacturer_id, minfo->model_id,
>                                 minfo->revision_number) + 1;

This change looks good, but I think it might be better to re-indent the
minfo lines to match as well...

>         else
> -               return snprintf(buf, PAGE_SIZE, "%2.2x%4.4x%2.2x\n",
> +               return sysfs_emit(buf, "%2.2x%4.4x%2.2x\n",
>                                 minfo->smia_manufacturer_id, minfo->model_id,
>                                 minfo->revision_number) + 1;

here as well of course.

--
Kieran


>  }
> -- 
> 2.7.4
>

      reply	other threads:[~2021-10-15 22:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15  6:49 Qing Wang
2021-10-15 22:36 ` Kieran Bingham [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=163433739388.456562.9392744334237641054@Monstersaurus \
    --to=kieran.bingham@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=wangqing@vivo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®