]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: various code-formatting improvements
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 21 Sep 2019 14:01:14 +0000 (16:01 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 22 Sep 2019 05:17:27 +0000 (07:17 +0200)
Reported/found by Coccinelle

src/basic/alloc-util.c
src/basic/cgroup-util.c
src/network/generator/network-generator.c
src/network/networkd-link.c
src/nspawn/nspawn-mount.c
src/shared/mount-util.c
src/test/test-exit-status.c

index a16db6824fe84f2299e290f0b8d961aee165d234..5951e8c3d590c91f325364454d44aa08087889bd 100644 (file)
@@ -78,7 +78,7 @@ void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size) {
                          * take possession of the extra space. This should be cheap, since libc doesn't have to move
                          * the memory for this. */
 
-                        qq = realloc(q, bn * size);
+                        qq = reallocarray(q, bn, size);
                         if (_likely_(qq)) {
                                 *p = qq;
                                 *allocated = bn;
index 7b5839ccd6088ec12dab399ae99527f5b00d96dc..d5c33014d77d3c4eb4ccfba5d9f5bf8d43f5a424 100644 (file)
@@ -345,10 +345,8 @@ int cg_kill(
            a workaround for kernel bug. It was fixed in 5.2-rc5 (c03cd7738a83), backported to 4.19.66
            (4340d175b898) and 4.14.138 (feb6b123b7dd). */
         r = cg_unified_controller(controller);
-        if (r < 0)
+        if (r <= 0)
                 return r;
-        if (r == 0) /* doesn't apply to legacy hierarchy */
-                return 0;
 
         return cg_kill_items(controller, path, sig, flags, s, log_kill, userdata, "cgroup.threads");
 }
index 0b5af33566de787cfac3066a95f881960e602869..81afa9530762421bf0cc160ee909e689635e8fdc 100644 (file)
@@ -837,9 +837,7 @@ static int parse_cmdline_bridge(Context *context, const char *key, const char *v
                 _cleanup_free_ char *word = NULL;
 
                 r = extract_first_word(&p, &word, ",", 0);
-                if (r == 0)
-                        return 0;
-                if (r < 0)
+                if (r <= 0)
                         return r;
 
                 r = network_set_bridge(context, word, name);
index 50648b29a10e1ab1745c73fa84d117b70a7317b8..54cbc678b44137712e2bcf05f2da2f14464e244e 100644 (file)
@@ -1915,10 +1915,8 @@ static int link_append_to_master(Link *link, NetDev *netdev) {
                 return r;
 
         r = set_put(master->slaves, link);
-        if (r < 0)
+        if (r <= 0)
                 return r;
-        if (r == 0)
-                return 0;
 
         link_ref(link);
         return 0;
index 140df4e16b68077c68044edf2b9a2cbed81ae96f..2f842754a4f4ba66597ede4309bd7fd42653670f 100644 (file)
@@ -703,8 +703,9 @@ static int parse_mount_bind_options(const char *options, unsigned long *mount_fl
                 else if (streq(word, "norbind"))
                         flags &= ~MS_REC;
                 else {
-                        log_error("Invalid bind mount option: %s", word);
-                        return -EINVAL;
+                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                               "Invalid bind mount option: %s",
+                                               word);
                 }
         }
 
index b6ff8d8c84aeb1d936d31565f0343907f8ffb318..e55d3c231568261131814d9572a432092ec35530 100644 (file)
@@ -85,7 +85,7 @@ static int get_mount_flags(const char *path, unsigned long *flags, struct libmnt
         int r = 0;
 
         fs = mnt_table_find_target(table, path, MNT_ITER_FORWARD);
-        if (fs == NULL) {
+        if (!fs) {
                 log_warning("Could not find '%s' in mount table", path);
                 goto fallback;
         }
index a007bda5c414ea8f965881e41633a585131cb7b4..e90375f6bd864873fecda8c4989effca2b143c9e 100644 (file)
@@ -14,7 +14,7 @@ static void test_exit_status_to_string(void) {
                 class = exit_status_class(i);
                 log_info("%d: %s%s%s%s",
                          i, s ?: "-",
-                         class ? " (" : "", class ?: "", class ? ")" : "");
+                         class ? " (" : "", strempty(class), class ? ")" : "");
 
                 if (s)
                         assert_se(exit_status_from_string(s) == i);