cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Lennart Glauer <lennart.glauer@gmail.com>
To: cocci@systeme.lip6.fr
Subject: [Cocci] Question: Removing a function argument
Date: Mon, 27 May 2019 14:05:59 +0200	[thread overview]
Message-ID: <246F5E26-E77D-4283-9927-952D07BA42BF@gmail.com> (raw)


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

             reply	other threads:[~2019-05-27 12:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27 12:05 Lennart Glauer [this message]
2019-05-27 12:11 ` [Cocci] Question: Removing a function argument 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=246F5E26-E77D-4283-9927-952D07BA42BF@gmail.com \
    --to=lennart.glauer@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 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).