cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Question: Removing a function argument
@ 2019-05-27 12:05 Lennart Glauer
  2019-05-27 12:11 ` Julia Lawall
  0 siblings, 1 reply; 2+ messages in thread
From: Lennart Glauer @ 2019-05-27 12:05 UTC (permalink / raw)
  To: cocci


[-- Attachment #1.1: Type: text/plain, Size: 594 bytes --]

Hello all,

I’m interested in using Coccinelle.
Currently I’m playing with the example „Removing a function argument":
http://coccinelle.lip6.fr/docs/main_grammar016.html#sec24 <http://coccinelle.lip6.fr/docs/main_grammar016.html#sec24>

It works well with drivers/atm/firestream.c,
but if the definition of the function and the call are in two different files it doesn’t work anymore.
It seems that the reference „rule1.fn“ doesn’t work across files?
I created a minimal testcase (see attachment).
Is there any way to make this work?

best regards
Lennart Glauer


[-- Attachment #1.2.1: Type: text/html, Size: 1140 bytes --]

[-- Attachment #1.2.2: patch.cocci --]
[-- Type: application/octet-stream, Size: 201 bytes --]


@ rule1 @
identifier fn;
identifier irq, dev_id;
typedef irqreturn_t;
@@

irqreturn_t fn (int irq, void *dev_id)
{
    ...
}

@@
identifier rule1.fn;
expression E1, E2, E3;
@@

 fn(E1, E2
-  ,E3
   )

[-- Attachment #1.2.3: Type: text/html, Size: 208 bytes --]

[-- Attachment #1.2.4: testA.c --]
[-- Type: application/octet-stream, Size: 77 bytes --]

#include "testA.h"

irqreturn_t foo(int irq, void *dev_id)
{
    return 0;
}

[-- Attachment #1.2.5: Type: text/html, Size: 208 bytes --]

[-- Attachment #1.2.6: testA.h --]
[-- Type: application/octet-stream, Size: 107 bytes --]

#ifndef TESTA_H
#define TESTA_H

typedef int irqreturn_t;

irqreturn_t foo(int irq, void *dev_id);

#endif

[-- Attachment #1.2.7: Type: text/html, Size: 208 bytes --]

[-- Attachment #1.2.8: testB.c --]
[-- Type: application/octet-stream, Size: 91 bytes --]

#include <stdlib.h>

#include "testA.h"

int main(void)
{
    return foo(0, NULL, NULL);
}

[-- Attachment #1.2.9: Type: text/html, Size: 226 bytes --]

[-- 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

* Re: [Cocci] Question: Removing a function argument
  2019-05-27 12:05 [Cocci] Question: Removing a function argument Lennart Glauer
@ 2019-05-27 12:11 ` Julia Lawall
  0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2019-05-27 12:11 UTC (permalink / raw)
  To: Lennart Glauer; +Cc: cocci

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



On Mon, 27 May 2019, Lennart Glauer wrote:

> Hello all,
>
> I’m interested in using Coccinelle.
> Currently I’m playing with the example „Removing a function argument":
> http://coccinelle.lip6.fr/docs/main_grammar016.html#sec24 <http://coccinelle.lip6.fr/docs/main_grammar016.html#sec24>
>
> It works well with drivers/atm/firestream.c,
> but if the definition of the function and the call are in two different files it doesn’t work anymore.
> It seems that the reference „rule1.fn“ doesn’t work across files?
> I created a minimal testcase (see attachment).
> Is there any way to make this work?

Coccinelle normally works on one file at a time.  If you put more file
names on the command line they will all be precessed at once, so both the
definition and use will be seen.  However, it is not advisable to put the
names of all of the files of the Linux kernel on the command line.  You
will run out fo memory having the representations of all of the files in
memory at the same time.

Afterwards, the choices are to use iteration (demos/iteration.cocci) to
find the definition and then find the calls.

Alternatively, if you know of some groups of files that should be treated
at once, you can put then in a file with one file per line, with the
groups separated by newlines, eg

file1
file2

file3
file4
file5

and then pass the name of this file to Coccinelle with the name
--file-groups.

julia

[-- 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-05-27 12:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27 12:05 [Cocci] Question: Removing a function argument Lennart Glauer
2019-05-27 12:11 ` 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).