mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
coccinelle: further restrict certain transformations
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.
This commit is contained in:
parent
1f72479037
commit
ccd52940d0
@ -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)
|
||||
|
@ -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)
|
||||
)
|
||||
|
@ -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)
|
||||
)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user