Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Li Zhijian <lizhijian@fujitsu.com>
Cc: linux-kernel@vger.kernel.org,
	Nicolas Palix <nicolas.palix@imag.fr>,
	 cocci@inria.fr
Subject: Re: [cocci] [PATCH 01/42] coccinelle: device_attr_show.cocci: update description and warning message
Date: Thu, 18 Jan 2024 21:26:59 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2401182125480.3296@hadrien> (raw)
In-Reply-To: <20240116041129.3937800-2-lizhijian@fujitsu.com>



On Tue, 16 Jan 2024, Li Zhijian wrote:

> Update them according to latest Documentation/filesystems/sysfs.rst.
>
> CC: Julia Lawall <Julia.Lawall@inria.fr>
> CC: Nicolas Palix <nicolas.palix@imag.fr>
> CC: cocci@inria.fr
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
>  scripts/coccinelle/api/device_attr_show.cocci | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/coccinelle/api/device_attr_show.cocci b/scripts/coccinelle/api/device_attr_show.cocci
> index a28dc061653a..a621e9610479 100644
> --- a/scripts/coccinelle/api/device_attr_show.cocci
> +++ b/scripts/coccinelle/api/device_attr_show.cocci
> @@ -1,10 +1,8 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  ///
>  /// From Documentation/filesystems/sysfs.rst:
> -///  show() must not use snprintf() when formatting the value to be
> -///  returned to user space. If you can guarantee that an overflow
> -///  will never happen you can use sprintf() otherwise you must use
> -///  scnprintf().
> +/// show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> +/// the value to be returned to user space.
>  ///
>  // Confidence: High
>  // Copyright: (C) 2020 Denis Efremov ISPRAS
> @@ -46,10 +44,10 @@ ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
>  p << r.p;
>  @@
>
> -coccilib.report.print_report(p[0], "WARNING: use scnprintf or sprintf")
> +coccilib.report.print_report(p[0], "WARNING: please use sysfs_emit")
>
>  @script: python depends on org@
>  p << r.p;
>  @@
>
> -coccilib.org.print_todo(p[0], "WARNING: use scnprintf or sprintf")
> +coccilib.org.print_todo(p[0], "WARNING: please use sysfs_emit")

Thanks for the suggestion, but it's not really consistent, because the
patch rule still generates a call to scnprintf.  Would it be possible to
fix that up?  Or should it be removed?

thanks,
julia

  reply	other threads:[~2024-01-18 20:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16  4:10 [cocci] [PATCH 00/42] Fix coccicheck warnings Li Zhijian
2024-01-16  4:10 ` [cocci] [PATCH 01/42] coccinelle: device_attr_show.cocci: update description and warning message Li Zhijian
2024-01-18 20:26   ` Julia Lawall [this message]
2024-01-19  2:53     ` Zhijian Li (Fujitsu)
2024-01-19  6:25       ` Zhijian Li (Fujitsu)
2024-02-06  2:07 ` [cocci] (subset) [PATCH 00/42] Fix coccicheck warnings Martin K. Petersen

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=alpine.DEB.2.22.394.2401182125480.3296@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=cocci@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    --cc=nicolas.palix@imag.fr \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).