Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Julia Lawall <Julia.Lawall@inria.fr>,
	 Nicolas Palix <nicolas.palix@imag.fr>,
	Rob Herring <robh@kernel.org>,
	 Saravana Kannan <saravanak@google.com>,
	 Wolfram Sang <wsa+renesas@sang-engineering.com>,
	cocci@inria.fr,  devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [cocci] [PATCH/RFC v2] coccinelle: of_table: Do not add commas after sentinels
Date: Wed, 5 Feb 2025 15:36:36 +0100 (CET)	[thread overview]
Message-ID: <6abd97ee-b9fe-d2eb-4486-b1c43efc0e5@inria.fr> (raw)
In-Reply-To: <f4d11c2e43697681678cf3fe0b2781bcd3bf3884.1738765482.git.geert+renesas@glider.be>



On Wed, 5 Feb 2025, Geert Uytterhoeven wrote:

> It does not make sense to have a comma after a sentinel, as any new
> elements must be added before the sentinel.  Hence do not add the comma
> when adding the sentinel.
>
> Include the comma after the previous entry, else it will appear after the
> sentinel.
>
> Add a comment to clarify the purpose of the empty element.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2:
>   - Add devicetree people.
>
> This is a patch I wrote last year.
> My original intention was to create a Coccinelle script to remove
> commas after sentinels, and annotate them, to automate the creation of
> patches like commit 0256b6aeee11d705 ("pinctrl: renesas: Annotate
> sentinels in tables").  Unfortunately I could not get that work (blame
> it on this being my first experiment with Coccinelle).  Hence I gave up,
> and instead settled for adapting the existing script to not add these
> commas in the first place...
>
> Known issues:
>
>   1. This generates patches like:
>
> 	+	{/* sentinel */}
>
>      while I would prefer to see:
>
> 	+	{ /* sentinel */ }
>
>      Is there a way to do that, or should I just post-process the
>      generated patches?

Try running with --smpl-spacing.

julia

>
>   2. If the array contains a "{ NULL }" element, this is still flagged
>      as a missing sentinel:
>
> 	-	{ NULL }
> 	+	{ NULL },
> 	+	{},
>
>      Note that this is a pre-existing issue.
> ---
>  scripts/coccinelle/misc/of_table.cocci | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/coccinelle/misc/of_table.cocci b/scripts/coccinelle/misc/of_table.cocci
> index 4693ea7447534144..7ade9766dee89c70 100644
> --- a/scripts/coccinelle/misc/of_table.cocci
> +++ b/scripts/coccinelle/misc/of_table.cocci
> @@ -37,15 +37,14 @@ struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
>  	...,
>  	{
>  	.var = E,
> --	}
> -+	},
> -+	{ }
> +	},
> ++	{ /* sentinel */ }
>  };
>  |
>  struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
>  	...,
>  	{ ..., E, ... },
> -+	{ },
> ++	{ /* sentinel */ }
>  };
>  )
>
> --
> 2.43.0
>
>

      reply	other threads:[~2025-02-05 14:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 14:28 [cocci] [PATCH/RFC v2] coccinelle: of_table: Do not add commas after sentinels Geert Uytterhoeven
2025-02-05 14:36 ` Julia Lawall [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=6abd97ee-b9fe-d2eb-4486-b1c43efc0e5@inria.fr \
    --to=julia.lawall@inria.fr \
    --cc=cocci@inria.fr \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.palix@imag.fr \
    --cc=robh@kernel.org \
    --cc=saravanak@google.com \
    --cc=wsa+renesas@sang-engineering.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).