* [Cocci] How to write SmPL patch to handle for-each macros?
@ 2019-07-03 15:46 Quentin Young
2019-07-09 6:07 ` Julia Lawall
0 siblings, 1 reply; 2+ messages in thread
From: Quentin Young @ 2019-07-03 15:46 UTC (permalink / raw)
To: cocci
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.
Quentin
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Cocci] How to write SmPL patch to handle for-each macros?
2019-07-03 15:46 [Cocci] How to write SmPL patch to handle for-each macros? Quentin Young
@ 2019-07-09 6:07 ` Julia Lawall
0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2019-07-09 6:07 UTC (permalink / raw)
To: Quentin Young; +Cc: cocci
[-- 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-09 6:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03 15:46 [Cocci] How to write SmPL patch to handle for-each macros? Quentin Young
2019-07-09 6:07 ` Julia Lawall
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 NNTP newsgroup(s).