From: lars@metafoo.de (Lars-Peter Clausen)
To: cocci@systeme.lip6.fr
Subject: [Cocci] cocci: char* indexing style for linux
Date: Mon, 18 Aug 2014 10:37:41 +0200 [thread overview]
Message-ID: <53F1BB55.8080008@metafoo.de> (raw)
In-Reply-To: <alpine.DEB.2.10.1408171241450.2520@hadrien>
On 08/17/2014 07:42 PM, Julia Lawall wrote:
>
>
> On Sun, 17 Aug 2014, Joe Perches wrote:
>
>> On Sun, 2014-08-17 at 18:09 +0200, SF Markus Elfring wrote:
>>>> I would prefer to be able to convert
>>>> *(skb->data + frame_size / 2 + 10)
>>>> not to
>>>> (skb->data + frame_size / 2)[10]
>>>> but to
>>>> skb->data[frame_size / 2 + 10]
>>>>
>>>> but I don't know how.
>>>
>>> How do you think about a bit more fine-tuning for the desired semantic
>>> patch?
>>
>> Not sure I understand what you are requesting.
>>
>>> Can it be that the pattern "*(foo + e)" is too generic for any source
>>> code place?
>>
>> I don't think so as any type or combination of
>> arithmetic operations would then need to be specified
>> by the spatch input script.
>>
>>> Would you like to try out the specification of a few more elements
>>> instead of a single expression here?
>>
>> Not really.
>>
>> I think a precedence specification capability like first
>> pointer match followed by longest arithmetic match would
>> perhaps be a better generic facility.
>
> Isn't the problem already solved? If not, I will look into it.
I think for these kinds of problems it would be helpful to have a
metavariable type that is somewhere in the middle of idexpression and
expression. Something that matches an identifier or accessing a field in an
identifier, or a field of a field of an identifier and so on.
In the past I had cocci scripts where I ended up doing
(
id->fld1
|
id->fld1.fld2
|
id->fld1.fld2.fld3
...
)
to kind of make this work.
- Lars
next prev parent reply other threads:[~2014-08-18 8:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-16 20:06 [Cocci] cocci: char* indexing style for linux Joe Perches
2014-08-16 20:59 ` Joe Perches
2014-08-17 10:11 ` Julia Lawall
2014-08-17 13:01 ` Joe Perches
2014-08-17 16:09 ` SF Markus Elfring
2014-08-17 16:22 ` Joe Perches
2014-08-17 17:39 ` [Cocci] Conversion of some pointer arithmetic to array indexing style SF Markus Elfring
2014-08-17 17:48 ` Julia Lawall
2014-08-17 17:42 ` [Cocci] cocci: char* indexing style for linux Julia Lawall
2014-08-18 8:37 ` Lars-Peter Clausen [this message]
2014-08-18 9:40 ` Julia Lawall
2014-08-18 11:31 ` SF Markus Elfring
2014-08-18 11:55 ` Julia Lawall
2014-08-18 9:49 ` Julia Lawall
2014-08-18 9:57 ` Lars-Peter Clausen
2014-08-18 10:33 ` Julia Lawall
2014-08-18 10:55 ` [Cocci] Clarification for array indexing style SF Markus Elfring
2014-08-18 10:59 ` Julia Lawall
2014-08-18 10:34 ` [Cocci] cocci: char* indexing style for linux Lars-Peter Clausen
2014-08-18 2:56 ` Julia Lawall
2014-08-18 8:08 ` [Cocci] Conversion of some pointer arithmetic to array indexing style SF Markus Elfring
2014-08-18 9:39 ` Julia Lawall
2014-08-18 10:35 ` SF Markus Elfring
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=53F1BB55.8080008@metafoo.de \
--to=lars@metafoo.de \
--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