summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2021-03-18 15:26:04 +0100
committerGitHub <noreply@github.com>2021-03-18 15:26:04 +0100
commit12854a6ed591ea5120e62583c6d30818fec6cf4f (patch)
tree76cb424e20e5371e1cb691dfcfb0f3bacb8ca0de
parentshutdown: fix typo (diff)
parentcoccinelle: filter out a couple of 'false-positive' transformations (diff)
downloadsystemd-12854a6ed591ea5120e62583c6d30818fec6cf4f.tar.xz
systemd-12854a6ed591ea5120e62583c6d30818fec6cf4f.zip
Merge pull request #19036 from mrc0mmand/cocci-fixes
tree-wide: coccinelle fixes
-rw-r--r--coccinelle/flags-set.cocci3
-rwxr-xr-xcoccinelle/run-coccinelle.sh1
-rw-r--r--coccinelle/strjoina.cocci3
-rw-r--r--src/basic/fs-util.h7
-rw-r--r--src/basic/rm-rf.h7
-rw-r--r--src/core/namespace.c6
-rw-r--r--src/network/netdev/batadv.c3
-rw-r--r--src/test/test-copy.c2
-rw-r--r--src/veritysetup/veritysetup-generator.c2
9 files changed, 16 insertions, 18 deletions
diff --git a/coccinelle/flags-set.cocci b/coccinelle/flags-set.cocci
index f6cc8ba68a..22620f1849 100644
--- a/coccinelle/flags-set.cocci
+++ b/coccinelle/flags-set.cocci
@@ -8,7 +8,8 @@ position p : script:python() {
p[0].current_element == "log_set_max_level_realm" or
p[0].current_element == "unichar_is_valid")
};
-expression x, y;
+expression x;
+constant y;
@@
(
- ((x@p) & (y)) == (y)
diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh
index 871547a881..d1af412acc 100755
--- a/coccinelle/run-coccinelle.sh
+++ b/coccinelle/run-coccinelle.sh
@@ -7,6 +7,7 @@ EXCLUDED_PATHS=(
"src/basic/linux/*"
# Symlinked to test-bus-vtable-cc.cc, which causes issues with the IN_SET macro
"src/libsystemd/sd-bus/test-bus-vtable.c"
+ "src/libsystemd/sd-journal/lookup3.c"
)
top="$(git rev-parse --show-toplevel)"
diff --git a/coccinelle/strjoina.cocci b/coccinelle/strjoina.cocci
index a6236eb0f9..b209633480 100644
--- a/coccinelle/strjoina.cocci
+++ b/coccinelle/strjoina.cocci
@@ -1,6 +1,7 @@
@@
+position p : script:python() { p[0].current_element != "test_strjoina" };
expression n, m;
expression list s;
@@
-- n = strjoina(m, s, NULL);
+- n = strjoina@p(m, s, NULL);
+ n = strjoina(m, s);
diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h
index f036a19eb5..45115fd3db 100644
--- a/src/basic/fs-util.h
+++ b/src/basic/fs-util.h
@@ -11,6 +11,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include "alloc-util.h"
#include "errno-util.h"
#include "time-util.h"
@@ -107,8 +108,7 @@ static inline char *rmdir_and_free(char *p) {
return NULL;
(void) rmdir(p);
- free(p);
- return NULL;
+ return mfree(p);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rmdir_and_free);
@@ -117,8 +117,7 @@ static inline char* unlink_and_free(char *p) {
return NULL;
(void) unlink_noerrno(p);
- free(p);
- return NULL;
+ return mfree(p);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, unlink_and_free);
diff --git a/src/basic/rm-rf.h b/src/basic/rm-rf.h
index d954146a2e..87be9b3410 100644
--- a/src/basic/rm-rf.h
+++ b/src/basic/rm-rf.h
@@ -3,6 +3,7 @@
#include <sys/stat.h>
+#include "alloc-util.h"
#include "errno-util.h"
typedef enum RemoveFlags {
@@ -25,8 +26,7 @@ static inline char *rm_rf_physical_and_free(char *p) {
return NULL;
(void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_MISSING_OK|REMOVE_CHMOD);
- free(p);
- return NULL;
+ return mfree(p);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_physical_and_free);
@@ -38,7 +38,6 @@ static inline char *rm_rf_subvolume_and_free(char *p) {
return NULL;
(void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME|REMOVE_MISSING_OK|REMOVE_CHMOD);
- free(p);
- return NULL;
+ return mfree(p);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_subvolume_and_free);
diff --git a/src/core/namespace.c b/src/core/namespace.c
index c5897c6c94..d47531408b 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -2051,13 +2051,12 @@ int setup_namespace(
};
}
- if (ns_info->private_ipc) {
+ if (ns_info->private_ipc)
*(m++) = (MountEntry) {
.path_const = "/dev/mqueue",
.mode = MQUEUEFS,
.flags = MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME,
};
- }
if (creds_path) {
/* If our service has a credentials store configured, then bind that one in, but hide
@@ -2150,11 +2149,10 @@ int setup_namespace(
if (setup_propagate)
(void) mkdir_p(propagate_dir, 0600);
- if (n_extension_images > 0) {
+ if (n_extension_images > 0)
/* ExtensionImages mountpoint directories will be created
* while parsing the mounts to create, so have the parent ready */
(void) mkdir_p(extension_dir, 0600);
- }
/* Remount / as SLAVE so that nothing now mounted in the namespace
* shows up in the parent */
diff --git a/src/network/netdev/batadv.c b/src/network/netdev/batadv.c
index 86cd1f19b3..1f899e90f6 100644
--- a/src/network/netdev/batadv.c
+++ b/src/network/netdev/batadv.c
@@ -84,11 +84,10 @@ int config_parse_badadv_bandwidth (
return 0;
}
- if (k/1000/100 > UINT32_MAX) {
+ if (k/1000/100 > UINT32_MAX)
log_syntax(unit, LOG_WARNING, filename, line, 0,
"The value of '%s=', is outside of 0...429496729500000 range: %s",
lvalue, rvalue);
- }
*bandwidth = k/1000/100;
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
index 43118202b8..7b8f8fa1b2 100644
--- a/src/test/test-copy.c
+++ b/src/test/test-copy.c
@@ -317,7 +317,7 @@ static void test_copy_proc(void) {
assert_se(read_one_line_file("/proc/version", &a) >= 0);
assert_se(read_one_line_file(f, &b) >= 0);
assert_se(streq(a, b));
- assert_se(strlen(a) > 0);
+ assert_se(!isempty(a));
}
int main(int argc, char *argv[]) {
diff --git a/src/veritysetup/veritysetup-generator.c b/src/veritysetup/veritysetup-generator.c
index d16d7edebd..fd95e6f304 100644
--- a/src/veritysetup/veritysetup-generator.c
+++ b/src/veritysetup/veritysetup-generator.c
@@ -86,7 +86,7 @@ static int create_device(void) {
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
- options_escaped = specifier_escape(arg_options ?: "");
+ options_escaped = specifier_escape(strempty(arg_options));
if (!options_escaped)
return log_oom();