Easy search for elements besides binary operators with SmPL
Hello,
I would like to check also the application of elements which are used together with binary operators like the following.
@find@
expression target;
identifier action;
@@
target = action(...,
...
* | __GFP_NOFAIL
| ...,
...);elfring at Sonne:~/Projekte/Linux/next-patched> spatch.opt drivers/md/dm-region-hash.c ~/Projekte/Coccinelle/janitor/show_use_of_nofail1.cocci ?
minus: parse error:
File "/home/elfring/Projekte/Coccinelle/janitor/show_use_of_nofail1.cocci", line 6, column 17, charpos = 87
around = '...',
whole content = ...
How should I improve my search pattern?
A metavariable can already be used for the search of a function parameter at an undetermined position within a bigger list. Can similar functionality work also for binary operators?
Regards,
Markus
A message that is not in the archive (sent off-list or not yet received): alpine.DEB.2.20.1705122137090.3416@hadrien
Quoted 2 lines
Maybe put parentheses around the second argument. An isomorphism will drop them and you will avoid whatever parsing issue is being encountered.
I do not observe a desired improvement after such a SmPL code adjustment.
@find@
expression target;
identifier action;
@@
target = action(...,
...
* | __GFP_NOFAIL
| (...),
...);The Coccinelle software does also not like a reduced script variant so far.
@find@
expression target;
identifier action;
@@
target = action(...,
...
* | __GFP_NOFAIL
);elfring at Sonne:~/Projekte/Linux/next-patched> spatch.opt drivers/md/dm-region-hash.c ~/Projekte/Coccinelle/janitor/show_use_of_nofail_as_last_option1.cocci ?
minus: parse error:
File "/home/elfring/Projekte/Coccinelle/janitor/show_use_of_nofail_as_last_option1.cocci", line 6, column 17, charpos = 87
around = '...',
whole content = ...
Do you get further ideas?
Regards,
Markus
Quoted 4 lines · SF Markus Elfring
Quoted 2 lines
Maybe put parentheses around the second argument. An isomorphism will drop them and you will avoid whatever parsing issue is being encountered.
I do not observe a desired improvement after such a SmPL code adjustment.
Your change is not what I suggested either. The second argument starts to the right of one comma and ends to the left of the next one.
julia
Quoted 37 lines
@find@
expression target;
identifier action;
@@
target = action(...,... * | __GFP_NOFAIL | (...), ...);The Coccinelle software does also not like a reduced script variant so far.
@find@
expression target;
identifier action;
@@
target = action(...,... * | __GFP_NOFAIL );elfring at Sonne:~/Projekte/Linux/next-patched> spatch.opt
drivers/md/dm-region-hash.c~/Projekte/Coccinelle/janitor/show_use_of_nofail_as_last_option1.cocci?
minus: parse error:
File "/home/elfring/Projekte/Coccinelle/janitor/show_use_of_nofail_as_last_option1.cocci", line 6, column 17, charpos = 87
around = '...',
whole content = ...Do you get further ideas?
Regards,
Markus
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Maybe put parentheses around the second argument. An isomorphism will drop them and you will avoid whatever parsing issue is being encountered.
I do not observe a desired improvement after such a SmPL code adjustment.
Your change is not what I suggested either. The second argument starts to the right of one comma and ends to the left of the next one.
I interpreted the ?second one? as belonging to the ellipsis in the binary operator specification (for a moment).
Now I observe that the following SmPL script variants work as desired in principle.
@find_last_option@
expression target;
identifier action;
@@
target = action(...,
( ...
* | __GFP_NOFAIL
)
);@find_flag@
expression target;
identifier action;
@@
target = action(...,
( ...
* | __GFP_NOFAIL
| ...
),
...);I find it just strange that extra parentheses are needed in such an use case at the moment.
Regards,
Markus
Quoted 37 lines · SF Markus Elfring
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Maybe put parentheses around the second argument. An isomorphism will drop them and you will avoid whatever parsing issue is being encountered.
I do not observe a desired improvement after such a SmPL code adjustment.
Your change is not what I suggested either. The second argument starts to the right of one comma and ends to the left of the next one.
I interpreted the ?second one? as belonging to the ellipsis in the binary operator specification (for a moment).
Now I observe that the following SmPL script variants work as desired in principle.
@find_last_option@
expression target;
identifier action;
@@
target = action(...,( ... * | __GFP_NOFAIL ) );@find_flag@
expression target;
identifier action;
@@
target = action(...,( ... * | __GFP_NOFAIL | ... ), ...);
Quoted 2 lines
I find it just strange that extra parentheses are needed in such an use case at the moment.
... is used in a number of contexts in SmPL, and sometimes its use has to be restricted to avoid parsing ambiguities. I'm a bit surprised also that it is a problem in this case.
julia
Quoted 5 lines
Quoted 2 lines
I find it just strange that extra parentheses are needed in such an use case at the moment.
... is used in a number of contexts in SmPL, and sometimes its use has to be restricted to avoid parsing ambiguities.
I tried to use extra parentheses for other source code search patterns. I left them ?accidentally? out with undesired consequences this time.
Quoted 1 line
I'm a bit surprised also that it is a problem in this case.
I find such a feedback interesting then if it will influence corresponding software evolution.
Regards,
Markus