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] [day] [month] [year] [list]
Message-ID: <23823c18-9f22-e107-81dc-a03dbaf0e0b0@web.de>
Date:   Sat, 7 Sep 2019 18:40:44 +0200
From:   Markus Elfring <Markus.Elfring@....de>
To:     Julia Lawall <julia.lawall@...6.fr>,
        Coccinelle <cocci@...teme.lip6.fr>,
        kernel-janitors@...r.kernel.org,
        Gilles Muller <Gilles.Muller@...6.fr>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Michal Marek <michal.lkml@...kovi.net>,
        Nicolas Palix <nicolas.palix@...g.fr>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Allison Randal <allison@...utok.net>,
        Enrico Weigelt <lkml@...ux.net>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Kate Stewart <kstewart@...uxfoundation.org>,
        Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH] Coccinelle: Reduce rules in SmPL script “ptr_ret.cocci”

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sat, 7 Sep 2019 18:30:32 +0200

This SmPL script contains duplicate code.
Thus reduce it to the required source code search functionality
by the means of the semantic patch language.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 scripts/coccinelle/api/ptr_ret.cocci | 61 +++++-----------------------
 1 file changed, 10 insertions(+), 51 deletions(-)

diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci
index e76cd5d90a8a..f4b1ce4a06d0 100644
--- a/scripts/coccinelle/api/ptr_ret.cocci
+++ b/scripts/coccinelle/api/ptr_ret.cocci
@@ -20,44 +20,28 @@ virtual report
 @depends on patch@
 expression ptr;
 @@
-
+(
 - if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0;
 + return PTR_ERR_OR_ZERO(ptr);
-
-@...ends on patch@
-expression ptr;
-@@
-
+|
 - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
 + return PTR_ERR_OR_ZERO(ptr);
-
-@...ends on patch@
-expression ptr;
-@@
-
+|
 - (IS_ERR(ptr) ? PTR_ERR(ptr) : 0)
 + PTR_ERR_OR_ZERO(ptr)
+)

 @r1 depends on !patch@
 expression ptr;
 position p1;
 @@
-
+(
 * if@p1 (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0;
-
-@r2 depends on !patch@
-expression ptr;
-position p2;
-@@
-
-* if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
-
-@r3 depends on !patch@
-expression ptr;
-position p3;
-@@
-
-* IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0
+|
+* if@p1 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
+|
+* IS_ERR@p1(ptr) ? PTR_ERR(ptr) : 0
+)

 @script:python depends on org@
 p << r1.p1;
@@ -65,33 +49,8 @@ p << r1.p1;

 coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")

-
-@...ipt:python depends on org@
-p << r2.p2;
-@@
-
-coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
-
-@...ipt:python depends on org@
-p << r3.p3;
-@@
-
-coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
-
 @script:python depends on report@
 p << r1.p1;
 @@

 coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
-
-@...ipt:python depends on report@
-p << r2.p2;
-@@
-
-coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
-
-@...ipt:python depends on report@
-p << r3.p3;
-@@
-
-coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
--
2.23.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ