lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1307989386-17666-1-git-send-email-Gregory.Dietsche@cuw.edu>
Date:	Mon, 13 Jun 2011 13:23:06 -0500
From:	Greg Dietsche <Gregory.Dietsche@....edu>
To:	julia@...u.dk
Cc:	Gilles.Muller@...6.fr, npalix.work@...il.com, cocci@...u.dk,
	linux-kernel@...r.kernel.org,
	Greg Dietsche <Gregory.Dietsche@....edu>
Subject: [PATCH v2] coccinelle: if (ret) return ret; return ret; semantic patch

Semantic patch to find code that matches this pattern:
	if (...) return ret;
	return ret;

Version 2:
	Incorporate review comments from Julia Lawall
	Add matches for a number of other similar patterns.

Signed-off-by: Greg Dietsche <Gregory.Dietsche@....edu>
---
 scripts/coccinelle/misc/doublereturn.cocci |   34 ++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 scripts/coccinelle/misc/doublereturn.cocci

diff --git a/scripts/coccinelle/misc/doublereturn.cocci b/scripts/coccinelle/misc/doublereturn.cocci
new file mode 100644
index 0000000..b41e6f2
--- /dev/null
+++ b/scripts/coccinelle/misc/doublereturn.cocci
@@ -0,0 +1,34 @@
+// Removing unecessary code that matches this core pattern:
+//	-if(...) return ret;
+//	return ret;
+//
+// Confidence: High
+// Copyright: (C) 2011 Greg Dietsche GPLv2.
+// URL: http://www.gregd.org
+// Comments:
+// Options: -no_includes
+
+virtual patch
+
+@...ends on patch@
+expression ret, operand;
+identifier is_ordinal_table ~= "IS_ORDINAL_TABLE_\(ONE\|TWO\)";
+@@
+(
+//via an isomorphism this also covers ret and unlikely(ret)
+-if (likely(ret)) return ret;
+|
+-if (IS_ZERO(ret)) return ret;
+|
+-if (is_ordinal_table(...)) return ret;
+|
+-if (!ret) return ret;
+|
+-if (ret > operand) return ret;
+|
+-if (ret < operand) return ret;
+|
+-if (ret != operand) return ret;
+)
+-return ret;
++return ret;
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ