Coccinelle archive on lore.kernel.org
 help / color / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Quentin Young <qlyoung@qlyoung.net>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] How to write SmPL patch to handle for-each macros?
Date: Tue, 9 Jul 2019 08:07:40 +0200 (CEST)
Message-ID: <alpine.DEB.2.21.1907090806090.3825@hadrien> (raw)
In-Reply-To: <D38654B4-F23E-4715-ABB2-9DB58CB5610F@qlyoung.net>

[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]



On Wed, 3 Jul 2019, Quentin Young wrote:

> Hi there, I was wondering how to handle this situation in SmPL. I have a
> codebase that defines a couple macros for use within for loops, mostly used to
> iterate lists, like this:
>
> for (LIST_ELEMENTS(…)) {
>    /* blah blah */
> }
>
> I’m having trouble figuring out how to write a rule that matches these for
> statements without resorting to doing preprocessor expansion before I run
> spatch. The semantics I’m trying to achieve are:
>
> @@
> …
> @@
>
> for (LIST_ELEMENTS(…)) {
>    /* stuff I want to match is here */
> }
>
> Could I get some help? Barring that, I’d also take a link to the appropriate
> documentation, if I’ve missed it. Thanks in advance.

Perhaps it will work to put something in standard.h

#define LIST_ELEMENTS(a,b,c) ;;

You can also make your own file of macro definitions and pass them in with
--macro-file

julia


>
> Quentin
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 15:46 Quentin Young
2019-07-09  6:07 ` Julia Lawall [this message]

Reply instructions:

You may reply publically 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.21.1907090806090.3825@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=qlyoung@qlyoung.net \
    /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

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr cocci@archiver.kernel.org
	public-inbox-index cocci


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/ public-inbox