Coccinelle archive on
 help / color / Atom feed
From: "Ondřej Surý" <>
Subject: [Cocci] Detecting functions with dummy return value
Date: Fri, 1 Nov 2019 09:52:11 -0500
Message-ID: <> (raw)


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:

foo(…) {

return (ISC_R_SUCCESS);

it could possibly be:

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:

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.

Cocci mailing list

             reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 14:52 Ondřej Surý [this message]
2019-11-01 19:09 ` Julia Lawall
2019-11-01 19:22   ` Ondřej Surý
2019-11-02  6:40     ` Julia Lawall

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Coccinelle archive on

Archives are clonable:
	git clone --mirror cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ \
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone