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

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).