cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Detecting functions with dummy return value
@ 2019-11-01 14:52 Ondřej Surý
  2019-11-01 19:09 ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Ondřej Surý @ 2019-11-01 14:52 UTC (permalink / raw)
  To: cocci

Hi,

we changed our allocator (wrapper) function to assert() instead of returning ISC_R_MEMORY.

As you can imagine there’s a lot of checks down the road that needs to be cleaned up,
so I am looking for a way to detect function that only does:

isc_result_t
foo(…) {

…
return (ISC_R_SUCCESS);
}

it could possibly be:

isc_result_t
foo(…) {
…
return (ISC_R_SUCCESS);
…
return (ISC_R_SUCCESS);
}

Looking at badcheck.cocci, it looks like I just need a block that would „match“ such functions,
but I can’t find a solid example on how to write a patch that would express:

Mark functions that just return ISC_R_SUCCESS and nothing else:

Something like this:

@match_rule@
expression E;
@@

<+... when != E != ISC_R_SUCCESS;
return (E);
...+>

@depends on match_rule@
@@

- return(...);
+ return;

But that doesn’t work for me, it matches all return()s.

Thanks,
Ondrej
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-02  6:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01 14:52 [Cocci] Detecting functions with dummy return value Ondřej Surý
2019-11-01 19:09 ` Julia Lawall
2019-11-01 19:22   ` Ondřej Surý
2019-11-02  6:40     ` Julia Lawall

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).