__init macro and Coccinelle
Hello everybody,
I have the following script:
@r@
identifier f_init;
position p;
@@
* __init f_init at p(...)
I want to spot __init functions, but it doesn't seem to work. I get a parse error around the __init macro:
around = '__init',
whole content = * __init f_init at p(...)
I wonder if there is a way to work around that issue?
Thank you
Signature · 1 line
Gustavo A. R. Silva
Quoted 12 lines · Gustavo A. R. Silva
Hello everybody,
I have the following script:
@r@
identifierf_init;
position p;
@@*
__initf_initat p(...)
Quoted 7 lines
I want to spot
__initfunctions, but it doesn't seem to work. I get a parse error around the__initmacro:around = '
__init',
whole content = *__initf_initat p(...)I wonder if there is a way to work around that issue?
If you want to match a function, you have to put something that will match the whole function, not just the top part. So it would be
__init f(...) { ... }
julia
Quoted 22 lines · Julia Lawall
Quoted 18 lines · Gustavo A. R. Silva
Hello everybody,
I have the following script:
@r@
identifierf_init;
position p;
@@*
__initf_initat p(...)I want to spot
__initfunctions, but it doesn't seem to work. I get a parse error around the__initmacro:around = '
__init',
whole content = *__initf_initat p(...)
Quoted 7 lines
Quoted 1 line
I wonder if there is a way to work around that issue?
If you want to match a function, you have to put something that will match the whole function, not just the top part. So it would be
__initf(...) { ... }
That worked, thanks. :)
But now if I combine it in the following way:
@r1@
identifier s_type;
identifier f_init;
identifier s;
position p;
type T;
@@
(
* struct s_type s = {.init = f_init at p};
|
* __init f_init at p(...) { ... }
)
I get the same error parse error:
around = '__init',
whole content = __init f_init at p(...) { ... }
Signature · 1 line
Gustavo A. R. Silva
Quoted 52 lines · Gustavo A. R. Silva
Quoted 23 lines · Julia Lawall
Quoted 19 lines · Gustavo A. R. Silva
Hello everybody,
I have the following script:
@r@
identifierf_init;
position p;
@@*
__initf_initat p(...)I want to spot
__initfunctions, but it doesn't seem to work. I get a parse
error around the__initmacro:around = '
__init',
whole content = *__initf_initat p(...)Quoted 7 lines
Quoted 1 line
I wonder if there is a way to work around that issue?
If you want to match a function, you have to put something that will match the whole function, not just the top part. So it would be
__initf(...) { ... }That worked, thanks. :)
But now if I combine it in the following way:
@r1@
identifiers_type;
identifierf_init;
identifier s;
position p;
type T;
@@(
* structs_types = {.init =f_initat p};
|
*__initf_initat p(...) { ... }
)
Quoted 4 lines
I get the same error parse error:
around = '
__init',
whole content =__initf_initat p(...) { ... }
Don't do it :)
There are some parsing hacks to differentiate function calls from function definitions. Adding the disjunction defeats them. Just make two separate rules.
julia
Quoted 58 lines · Julia Lawall
Quoted 54 lines · Gustavo A. R. Silva
Quoted 23 lines · Julia Lawall
Quoted 19 lines · Gustavo A. R. Silva
Hello everybody,
I have the following script:
@r@
identifierf_init;
position p;
@@*
__initf_initat p(...)I want to spot
__initfunctions, but it doesn't seem to work. I get a parse
error around the__initmacro:around = '
__init',
whole content = *__initf_initat p(...)Quoted 7 lines
Quoted 1 line
I wonder if there is a way to work around that issue?
If you want to match a function, you have to put something that will match the whole function, not just the top part. So it would be
__initf(...) { ... }That worked, thanks. :)
But now if I combine it in the following way:
@r1@
identifiers_type;
identifierf_init;
identifier s;
position p;
type T;
@@(
* structs_types = {.init =f_initat p};
|
*__initf_initat p(...) { ... }
)I get the same error parse error:
Quoted 9 lines
Quoted 2 lines
around = '
__init',
whole content =__initf_initat p(...) { ... }Don't do it :)
There are some parsing hacks to differentiate function calls from function definitions. Adding the disjunction defeats them. Just make two separate rules.
Oh OK, I got it. I'll do that.
Thank you, Julia. :)
Signature · 1 line
Gustavo A. R. Silva