From: garsilva@embeddedor.com (Gustavo A. R. Silva)
To: cocci@systeme.lip6.fr
Subject: [Cocci] __init macro and Coccinelle
Date: Tue, 15 Aug 2017 15:45:29 -0500 [thread overview]
Message-ID: <fdfbf0a2-033f-e66d-e015-cfa296ecb8ec@embeddedor.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1708152241390.2049@hadrien>
On 08/15/2017 03:42 PM, Julia Lawall wrote:
>
>
> On Tue, 15 Aug 2017, Gustavo A. R. Silva wrote:
>
>>
>>
>> On 08/15/2017 03:24 PM, Julia Lawall wrote:
>>>
>>>
>>> On Tue, 15 Aug 2017, Gustavo A. R. Silva wrote:
>>>
>>>> Hello everybody,
>>>>
>>>> I have the following script:
>>>>
>>>> @r@
>>>> identifier f_init;
>>>> position p;
>>>> @@
>>>>
>>>>
>>>> * __init f_init at p(...)
>>>>
>>>> I want to spot __init functions, but it doesn't seem to work. I get a
>>>> parse
>>>> error around the __init macro:
>>>>
>>>> around = '__init',
>>>> whole content = * __init f_init at p(...)
>>>>
>>>> I wonder if there is a way to work around that issue?
>>>
>>> If you want to match a function, you have to put something that will match
>>> the whole function, not just the top part. So it would be
>>>
>>> __init f(...) { ... }
>>>
>>
>> That worked, thanks. :)
>>
>> But now if I combine it in the following way:
>>
>> @r1@
>> identifier s_type;
>> identifier f_init;
>> identifier s;
>> position p;
>> type T;
>> @@
>>
>> (
>> * struct s_type s = {.init = f_init at p};
>> |
>> * __init f_init at p(...) { ... }
>> )
>>
>> I get the same error parse error:
>>
>> around = '__init',
>> whole content = __init f_init at p(...) { ... }
>
> Don't do it :)
>
> There are some parsing hacks to differentiate function calls from function
> definitions. Adding the disjunction defeats them. Just make two separate
> rules.
>
Oh OK, I got it. I'll do that.
Thank you, Julia. :)
--
Gustavo A. R. Silva
prev parent reply other threads:[~2017-08-15 20:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-15 20:18 [Cocci] __init macro and Coccinelle Gustavo A. R. Silva
2017-08-15 20:24 ` Julia Lawall
2017-08-15 20:29 ` Gustavo A. R. Silva
2017-08-15 20:42 ` Julia Lawall
2017-08-15 20:45 ` Gustavo A. R. Silva [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=fdfbf0a2-033f-e66d-e015-cfa296ecb8ec@embeddedor.com \
--to=garsilva@embeddedor.com \
--cc=cocci@systeme.lip6.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