]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coccinelle: beef up isempty() checks (#7729)
authorLennart Poettering <lennart@poettering.net>
Sat, 23 Dec 2017 07:47:55 +0000 (08:47 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 23 Dec 2017 07:47:55 +0000 (08:47 +0100)
With these additions, coccinelle finds everything fixed by the first
commit in PR #7695. In order not to needlessly conflict with that PR
this PR won't include those fixes, but only the coccinelle changes to
detect them automatically in the future.

coccinelle/isempty.cocci

index 1374ee40d75f5f953183bf02f5e7b3304f300d72..d8d52758892e8e0735d256bc3ae30ccec906b6e3 100644 (file)
@@ -6,10 +6,55 @@ expression s;
 @@
 expression s;
 @@
+- strv_length(s) <= 0
++ strv_isempty(s)
+@@
+expression s;
+@@
+- strv_length(s) > 0
++ !strv_isempty(s)
+@@
+expression s;
+@@
+- strv_length(s) != 0
++ !strv_isempty(s)
+@@
+expression s;
+@@
 - strlen(s) == 0
 + isempty(s)
 @@
 expression s;
 @@
+- strlen(s) <= 0
++ isempty(s)
+@@
+expression s;
+@@
+- strlen(s) > 0
++ !isempty(s)
+@@
+expression s;
+@@
+- strlen(s) != 0
++ !isempty(s)
+@@
+expression s;
+@@
 - strlen_ptr(s) == 0
 + isempty(s)
+@@
+expression s;
+@@
+- strlen_ptr(s) <= 0
++ isempty(s)
+@@
+expression s;
+@@
+- strlen_ptr(s) > 0
++ !isempty(s)
+@@
+expression s;
+@@
+- strlen_ptr(s) != 0
++ !isempty(s)