From: Ondřej Surý Date: Fri, 6 Dec 2019 12:29:04 +0000 (+0100) Subject: Add semantic patch to find void f() { ... return ((void)g())); ... } X-Git-Tag: v9.15.7~32^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dfa33050b00cf4d5103181ebddc517a2a99d9e8;p=thirdparty%2Fbind9.git Add semantic patch to find void f() { ... return ((void)g())); ... } When a function returns void, it can be used as an argument to return in function returning also void, e.g.: void in(void) { return; } void out(void) { return (in()); } while this is legal, it should be rewritten as: void out(void) { in(); return; } The semantic patch just find the occurrences, and they need to be fixed by hand. --- diff --git a/cocci/return-void-from-void.spatch b/cocci/return-void-from-void.spatch new file mode 100644 index 00000000000..fcc639f6ea0 --- /dev/null +++ b/cocci/return-void-from-void.spatch @@ -0,0 +1,19 @@ +@ rule1 @ +identifier f1; +@@ + +void f1(...) +{ +... +} + +@ rule2 @ +identifier rule1.f1; +identifier f2; +@@ + +void f2(...) { +... +* return(f1(...)); +... +}