summaryrefslogtreecommitdiff
path: root/contrib/coccinelle
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2016-09-29 15:29:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-29 22:42:18 (GMT)
commit76dd98c13947bd811c1d11d0c63ccdc9a4fb3142 (patch)
tree71fe0bb6d2dafa7df4986c3cdd742d8f081324ad /contrib/coccinelle
parent9ed0d8d6e6de7737fe9a658446318b86e57c6fad (diff)
downloadgit-76dd98c13947bd811c1d11d0c63ccdc9a4fb3142.zip
git-76dd98c13947bd811c1d11d0c63ccdc9a4fb3142.tar.gz
git-76dd98c13947bd811c1d11d0c63ccdc9a4fb3142.tar.bz2
remove unnecessary check before QSORT
Add a semantic patch for removing checks similar to the one that QSORT already does internally and apply it to the code base. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/coccinelle')
-rw-r--r--contrib/coccinelle/qsort.cocci18
1 files changed, 18 insertions, 0 deletions
diff --git a/contrib/coccinelle/qsort.cocci b/contrib/coccinelle/qsort.cocci
index a094e7c..22b93a9 100644
--- a/contrib/coccinelle/qsort.cocci
+++ b/contrib/coccinelle/qsort.cocci
@@ -17,3 +17,21 @@ expression nmemb, compar;
@@
- qsort(base, nmemb, sizeof(T), compar);
+ QSORT(base, 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)
+ QSORT(base, nmemb, compar);