]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: coccinelle fixes
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 18 Mar 2021 10:59:31 +0000 (11:59 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 18 Mar 2021 10:59:31 +0000 (11:59 +0100)
Another batch of fixes (mostly) generated by Coccinelle.

src/basic/fs-util.h
src/basic/rm-rf.h
src/core/namespace.c
src/network/netdev/batadv.c
src/test/test-copy.c
src/veritysetup/veritysetup-generator.c

index f036a19eb5df7ca4b33b22a91debcef4306a86bd..45115fd3db18581fc2dbb6863ab7b7f452b91da2 100644 (file)
@@ -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);
 
index d954146a2ebdef7fc3eeaa4c7ce9e8ed1eec5c9a..87be9b34102b0dcc47080698519663b5f495a05a 100644 (file)
@@ -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);
index c5897c6c944be52fda33757abdf39c6c5663cb01..d47531408baac5f5ab8723433716e7de85d634c7 100644 (file)
@@ -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 */
index 86cd1f19b372713922451e66f0f43ed7cc49acda..1f899e90f67abff9d02873608bb2f59e206b3df4 100644 (file)
@@ -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;
 
index 43118202b85e9d7f236df503878535b0502ebe25..7b8f8fa1b2babe4c9817ebcf2deefbe34721d062 100644 (file)
@@ -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[]) {
index d16d7edebd5a3256c4e7bcc68165929cd0792676..fd95e6f304b1527286d729c41baca4980e6835ee 100644 (file)
@@ -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();