]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coccinelle: further restrict certain transformations 12420/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 29 Apr 2019 14:12:41 +0000 (16:12 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 30 Apr 2019 07:39:13 +0000 (09:39 +0200)
Some transformations generate results we don't want to keep, so
let's disable such transformations for specific files.

Also, disable const-strlen.cocci everywhere, as the STRLEN macro has a
pretty limited scope, so the transformation generates false positives in
most cases.

coccinelle/const-strlen.disabled [moved from coccinelle/const-strlen.cocci with 100% similarity]
coccinelle/dup-fcntl.cocci
coccinelle/flags-set.cocci
coccinelle/isempty.cocci
coccinelle/synthetic-errno.cocci

index ef1356428223aaf2d8378cd86f0dc2305613214b..8b133b3a24f6547062dd1c0d803dace33c94cd6a 100644 (file)
@@ -1,5 +1,7 @@
 @@
+/* We want to stick with dup() in test-fd-util.c */
+position p : script:python() { p[0].file != "src/test/test-fd-util.c" };
 expression fd;
 @@
-- dup(fd)
+- dup@p(fd)
 + fcntl(fd, F_DUPFD, 3)
index 1a70717e76cb855ba75db28be584496c53e6f627..73966b02e5d27861900299f0a5adecd4f1fa0db2 100644 (file)
@@ -1,15 +1,16 @@
 @@
+/* Disable this transformation for the securebits-util.h, as it makes
+ * the expression there confusing. */
+position p : script:python() { p[0].file != "src/shared/securebits-util.h" };
 expression x, y;
 @@
-- ((x) & (y)) == (y)
+(
+- ((x@p) & (y)) == (y)
 + FLAGS_SET(x, y)
-@@
-expression x, y;
-@@
-- (x & (y)) == (y)
+|
+- (x@p & (y)) == (y)
 + FLAGS_SET(x, y)
-@@
-expression x, y;
-@@
-- ((x) & y) == y
+|
+- ((x@p) & y) == y
 + FLAGS_SET(x, y)
+)
index d8d52758892e8e0735d256bc3ae30ccec906b6e3..e0a9f07ca6d0107524d41afb445d3c5f4f82bb9d 100644 (file)
@@ -1,60 +1,42 @@
 @@
+/* Disable this transformation for the test-string-util.c */
+position p : script:python() { p[0].file != "src/test/test-string-util.c" };
 expression s;
 @@
-- strv_length(s) == 0
+(
+- strv_length@p(s) == 0
 + strv_isempty(s)
-@@
-expression s;
-@@
-- strv_length(s) <= 0
+|
+- strv_length@p(s) <= 0
 + strv_isempty(s)
-@@
-expression s;
-@@
-- strv_length(s) > 0
+|
+- strv_length@p(s) > 0
 + !strv_isempty(s)
-@@
-expression s;
-@@
-- strv_length(s) != 0
+|
+- strv_length@p(s) != 0
 + !strv_isempty(s)
-@@
-expression s;
-@@
-- strlen(s) == 0
+|
+- strlen@p(s) == 0
 + isempty(s)
-@@
-expression s;
-@@
-- strlen(s) <= 0
+|
+- strlen@p(s) <= 0
 + isempty(s)
-@@
-expression s;
-@@
-- strlen(s) > 0
+|
+- strlen@p(s) > 0
 + !isempty(s)
-@@
-expression s;
-@@
-- strlen(s) != 0
+|
+- strlen@p(s) != 0
 + !isempty(s)
-@@
-expression s;
-@@
-- strlen_ptr(s) == 0
+|
+- strlen_ptr@p(s) == 0
 + isempty(s)
-@@
-expression s;
-@@
-- strlen_ptr(s) <= 0
+|
+- strlen_ptr@p(s) <= 0
 + isempty(s)
-@@
-expression s;
-@@
-- strlen_ptr(s) > 0
+|
+- strlen_ptr@p(s) > 0
 + !isempty(s)
-@@
-expression s;
-@@
-- strlen_ptr(s) != 0
+|
+- strlen_ptr@p(s) != 0
 + !isempty(s)
+)
index 645bfc945f4b4b0e426ec72b72aca8529fb0a347..3ddb69cb4cff498ab310f6ffd9eba2504eef6192 100644 (file)
@@ -2,9 +2,15 @@
 expression e;
 expression list args;
 @@
+(
+/* Ignore one specific case in src/shared/bootspec.c where we want to stick
+ * with the log_debug() + return pattern */
+log_debug("Found no default boot entry :(");
+|
 - log_debug(args);
 - return -e;
 + return log_debug_errno(SYNTHETIC_ERRNO(e), args);
+)
 @@
 expression e;
 expression list args;