[PATCH] coccinelle: merge three rules from qsort.cocci

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Nov 2019 19:30:28 +0100

This script contained three transformation rules for the semantic patch language
where a condition check should be removed before QSORT() calls.
Combine these rules by using a SmPL disjunction.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
 contrib/coccinelle/qsort.cocci | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/contrib/coccinelle/qsort.cocci b/contrib/coccinelle/qsort.cocci
index 22b93a9966..b2130a5e51 100644
--- a/contrib/coccinelle/qsort.cocci
+++ b/contrib/coccinelle/qsort.cocci
@@ -21,17 +21,5 @@ expression nmemb, compar;
 @@
 expression base, nmemb, compar;
 @@
-- if (nmemb)
-    QSORT(base, nmemb, compar);
-
-@@
-expression base, nmemb, compar;
-@@
-- if (nmemb > 0)
-    QSORT(base, nmemb, compar);
-
-@@
-expression base, nmemb, compar;
-@@
-- if (nmemb > 1)
+- if ( \( nmemb \| nmemb > \( 0 \| 1 \) \) )
     QSORT(base, nmemb, compar);
--
2.24.0





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux