* [Cocci] Finding non-zero returning functions with SmPL
@ 2015-07-27 15:18 SF Markus Elfring
2015-07-27 15:34 ` Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: SF Markus Elfring @ 2015-07-27 15:18 UTC (permalink / raw)
To: cocci
Hello,
I have tried the following small SmPL script out
@non_zero_returning_functions@
identifier work;
type return_type;
@@
*return_type work(...)
{
<+...
return ... when != 0
when != NULL
;
...+>
}
on this bit of source code.
#include <API-test1.h>
int my_status(void)
{
return 1;
}
int main(void)
{
return my_status();
}
elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file show_non-zero_returning_functions1.cocci ../Probe/API-test1.c
init_defs_builtins: /usr/local/lib/coccinelle/standard.h
116 120
Fatal error: exception Failure("minus: parse error: \n = File \"show_non-zero_returning_functions1.cocci\", line 8, column 13, charpos = 116\n around = 'when', whole content = return ... when != 0;\n")
Do I use the SmPL construct "when" in an inappropriate way here?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cocci] Finding non-zero returning functions with SmPL
2015-07-27 15:18 [Cocci] Finding non-zero returning functions with SmPL SF Markus Elfring
@ 2015-07-27 15:34 ` Julia Lawall
2015-07-27 16:02 ` SF Markus Elfring
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2015-07-27 15:34 UTC (permalink / raw)
To: cocci
> *return_type work(...)
> {
> <+...
> return ... when != 0
> when != NULL
You can't put when on a ... that represents a single expression.
The simplest thing would be to put return e; and then when you declare e,
put
expression e != {0,NULL};
julia
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cocci] Finding non-zero returning functions with SmPL
2015-07-27 15:34 ` Julia Lawall
@ 2015-07-27 16:02 ` SF Markus Elfring
0 siblings, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2015-07-27 16:02 UTC (permalink / raw)
To: cocci
>> *return_type work(...)
>> {
>> <+...
>> return ... when != 0
>> when != NULL
>
> You can't put when on a ... that represents a single expression.
Thanks for your quick clarification.
Would it make sense that the Coccinelle software will also support
this construct at such a script place directly?
> expression e != {0,NULL};
The use of this SmPL metavariable seems to work to some degree.
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-27 16:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-27 15:18 [Cocci] Finding non-zero returning functions with SmPL SF Markus Elfring
2015-07-27 15:34 ` Julia Lawall
2015-07-27 16:02 ` SF Markus Elfring
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.