* [Cocci] Variable number of macro parameters?
@ 2018-07-26 18:54 Timur Tabi
2018-07-26 18:57 ` Julia Lawall
0 siblings, 1 reply; 6+ messages in thread
From: Timur Tabi @ 2018-07-26 18:54 UTC (permalink / raw)
To: cocci
I'm new to coccinelle and having trouble understanding the syntax. I
new to replace calls to one macro with another macro. So calls that
look like this:
DBG_PRINTF((x, ...))
should be replaced with
NV_PRINTF(...)
Where ... is any number of variable-separated parameters. M1 and M2
are front-ends for printf. M1 has double parentheses and M2 has only
one pair.
I came up with this, but it doesn't work because it thinks that 'y' is
the last parameter only.
@rule1@
expression x, y;
@@
-DBG_PRINTF((x, y));
+NV_PRINTF(y);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Variable number of macro parameters?
2018-07-26 18:54 [Cocci] Variable number of macro parameters? Timur Tabi
@ 2018-07-26 18:57 ` Julia Lawall
2018-07-26 19:25 ` Timur Tabi
2018-07-26 19:34 ` Timur Tabi
0 siblings, 2 replies; 6+ messages in thread
From: Julia Lawall @ 2018-07-26 18:57 UTC (permalink / raw)
To: cocci
On Thu, 26 Jul 2018, Timur Tabi wrote:
> I'm new to coccinelle and having trouble understanding the syntax. I
> new to replace calls to one macro with another macro. So calls that
> look like this:
>
> DBG_PRINTF((x, ...))
>
> should be replaced with
>
> NV_PRINTF(...)
>
> Where ... is any number of variable-separated parameters. M1 and M2
> are front-ends for printf. M1 has double parentheses and M2 has only
> one pair.
>
> I came up with this, but it doesn't work because it thinks that 'y' is
> the last parameter only.
>
> @rule1@
> expression x, y;
> @@
> -DBG_PRINTF((x, y));
> +NV_PRINTF(y);
Try expression list y;
julia
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Variable number of macro parameters?
2018-07-26 18:57 ` Julia Lawall
@ 2018-07-26 19:25 ` Timur Tabi
2018-07-26 19:38 ` Julia Lawall
2018-07-26 19:34 ` Timur Tabi
1 sibling, 1 reply; 6+ messages in thread
From: Timur Tabi @ 2018-07-26 19:25 UTC (permalink / raw)
To: cocci
On 07/26/2018 01:57 PM, Julia Lawall wrote:
>> @rule1@
>> expression x, y;
>> @@
>> -DBG_PRINTF((x, y));
>> +NV_PRINTF(y);
> Try expression list y;
You mean like this:
@rule1@
expression x;
expression list y;
@@
-DBG_PRINTF((x, y));
+NV_PRINTF(y);
That gives me an error:
$ spatch -sp_file ~/sw/dev/gpu_drv/chips_a/nv_printf.cocci osinit.c
init_defs_builtins: /usr/lib/coccinelle/standard.h
60 61
Fatal error: exception Failure("minus: parse error: \n = File
\"/home/ttabi/sw/dev/gpu_drv/chips_a/nv_printf.cocci\", line 5, column
16, charpos = 60\n around = 'y', whole content = -DBG_PRINTF((x,
y));\n")
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Variable number of macro parameters?
2018-07-26 18:57 ` Julia Lawall
2018-07-26 19:25 ` Timur Tabi
@ 2018-07-26 19:34 ` Timur Tabi
1 sibling, 0 replies; 6+ messages in thread
From: Timur Tabi @ 2018-07-26 19:34 UTC (permalink / raw)
To: cocci
On Thu, Jul 26, 2018 at 1:57 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> @rule1@
>> expression x, y;
>> @@
>> -DBG_PRINTF((x, y));
>> +NV_PRINTF(y);
>
> Try expression list y;
You mean like this:
@rule1@
expression x;
expression list y;
@@
-DBG_PRINTF((x, y));
+NV_PRINTF(y);
That gives me an error:
$ spatch -sp_file ~/sw/dev/gpu_drv/chips_a/nv_printf.cocci osinit.c
init_defs_builtins: /usr/lib/coccinelle/standard.h
60 61
Fatal error: exception Failure("minus: parse error: \n = File
\"/home/ttabi/sw/dev/gpu_drv/chips_a/nv_printf.cocci\", line 5, column
16, charpos = 60\n around = 'y', whole content = -DBG_PRINTF((x,
y));\n")
I also tried this, but it gave me a different error:
@rule1@
expression x;
expression list y;
@@
-DBG_PRINTF(
-(x,
+NV_PRINTF(
y
-)
);
Fatal error: exception Failure("minus: parse error: \n = File
\"/home/ttabi/sw/dev/gpu_drv/chips_a/nv_printf.cocci\", line 8, column
1, charpos = 75\n around = 'y', whole content = y\n")
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Variable number of macro parameters?
2018-07-26 19:25 ` Timur Tabi
@ 2018-07-26 19:38 ` Julia Lawall
2018-07-26 19:43 ` Timur Tabi
0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2018-07-26 19:38 UTC (permalink / raw)
To: cocci
On Thu, 26 Jul 2018, Timur Tabi wrote:
> On 07/26/2018 01:57 PM, Julia Lawall wrote:
> > > @rule1@
> > > expression x, y;
> > > @@
> > > -DBG_PRINTF((x, y));
> > > +NV_PRINTF(y);
> > Try expression list y;
>
> You mean like this:
>
> @rule1@
> expression x;
> expression list y;
> @@
> -DBG_PRINTF((x, y));
> +NV_PRINTF(y);
>
> That gives me an error:
>
> $ spatch -sp_file ~/sw/dev/gpu_drv/chips_a/nv_printf.cocci osinit.c
> init_defs_builtins: /usr/lib/coccinelle/standard.h
> 60 61
> Fatal error: exception Failure("minus: parse error: \n = File
> \"/home/ttabi/sw/dev/gpu_drv/chips_a/nv_printf.cocci\", line 5, column 16,
> charpos = 60\n around = 'y', whole content = -DBG_PRINTF((x, y));\n")
OK, I don't think that the notion of double parentheses is fully
supported. It works with the following:
@@
@@
DBG_PRINTF(
-(
...
- )
);
@rule1@
expression x;
expression list y;
@@
-DBG_PRINTF(x, y);
+NV_PRINTF(y);
julia
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Variable number of macro parameters?
2018-07-26 19:38 ` Julia Lawall
@ 2018-07-26 19:43 ` Timur Tabi
0 siblings, 0 replies; 6+ messages in thread
From: Timur Tabi @ 2018-07-26 19:43 UTC (permalink / raw)
To: cocci
On Thu, Jul 26, 2018 at 2:38 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> OK, I don't think that the notion of double parentheses is fully
> supported. It works with the following:
>
> @@
> @@
> DBG_PRINTF(
> -(
> ...
> - )
> );
>
>
> @rule1@
> expression x;
> expression list y;
> @@
> -DBG_PRINTF(x, y);
> +NV_PRINTF(y);
This works, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-07-26 19:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 18:54 [Cocci] Variable number of macro parameters? Timur Tabi
2018-07-26 18:57 ` Julia Lawall
2018-07-26 19:25 ` Timur Tabi
2018-07-26 19:38 ` Julia Lawall
2018-07-26 19:43 ` Timur Tabi
2018-07-26 19:34 ` Timur Tabi
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.