All of lore.kernel.org
 help / color / mirror / Atom feed
From: eliseomarmol@gmail.com (Eliseo Martínez)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Matching functions with attributes
Date: Wed, 21 Jan 2015 18:28:38 +0100	[thread overview]
Message-ID: <F6392E9E-0D22-4398-8173-DD84FFEBAB98@gmail.com> (raw)
In-Reply-To: <54BFD099.8030002@users.sourceforge.net>


> Then, would there be any way to match functions having the
>> literal ?FUNC_ATTR_NONNULL_RET? in their declaration/definition?
> 
> Would you like to try it out how many source code places can be found
> with your macro name?

This approach
``` 
@nonnullfuncs@ identifier func; @@

* func
  (...)
  ... FUNC_ATTR_NONNULL_RET ...
  {...}
```
matches nothing.

>> @@ identifier func =~ "^(transstr|list_alloc|listitem_alloc| [...] |concat_str)$"; [...] @@
>> 
>>  var = func(...);
>>  ... when != var = E
>> (
>> * if (var == NULL) S;
>> |
>> * if (var != NULL) S;
>> )
> 
> Does this kind of SmPL disjunction make sense?

I don?t see why not. AFAIK, Disjunctions can contain a full term (identifier/expression/statement).
Regarding meaning, well, I?m looking for places where var is checked for nullness/non-nullnes.
That?s the most obvious way I?ve found to express that?

>> As you see, I have to replicate the list.
>> 
> I would also appreciate if such repetition could be avoided for
> SmPL constraints.

I?ve tried with rule inheritance, but don?t know what to put in a first rule that just ?selects? the functions. This is:

```
@r@ identifier func =~ ??list of names? ? @@

  ? What here???

@@ identifier r.func @@

(
* if (func(?) == NULL) S;
|
* if (func(?) != NULL) S;
)
```

>> Is there any better way to achieve the same effect?
> 
> How do you think about to construct the desired regular expression
> by other programming scripts automatically?
> 
> Would you like to store involved function names into specific
> data structures (like databases)?

The purpose of my question is to see if there?s a way to do this within coccinelle.
If there?s no such a way, then, well, I?ll definitely consider constructing that regexp through some external script.

Thanks.

  reply	other threads:[~2015-01-21 17:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 14:05 [Cocci] Matching functions with attributes Eliseo Martínez
2015-01-21 16:15 ` SF Markus Elfring
2015-01-21 17:28   ` Eliseo Martínez [this message]
2015-01-21 18:03     ` SF Markus Elfring
2015-01-21 21:36       ` Eliseo Martínez
2015-01-21 21:46     ` Julia Lawall
2015-01-21 22:47       ` Eliseo Martínez
2015-01-22  5:58         ` Julia Lawall
2015-01-22  8:45         ` SF Markus Elfring
2015-01-22  8:59         ` SF Markus Elfring
2015-01-22  9:23           ` Eliseo Martínez
2015-01-22  9:36             ` Eliseo Martínez
2015-01-22 10:11               ` SF Markus Elfring
2015-01-22 11:52             ` Julia Lawall
2015-01-22 12:56               ` Eliseo Martínez
2015-01-22 14:44                 ` Julia Lawall
2015-01-22 15:28                 ` SF Markus Elfring
2015-01-22  8:29       ` [Cocci] Run time differences between SmPL disjunctions and regular expressions (in constraints) SF Markus Elfring
2015-01-22  8:37         ` Julia Lawall
2015-01-22  9:50           ` SF Markus Elfring
2015-01-27 19:01 ` [Cocci] Matching functions with attributes Julia Lawall

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=F6392E9E-0D22-4398-8173-DD84FFEBAB98@gmail.com \
    --to=eliseomarmol@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.