]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: make swap_process_new() void
authorLennart Poettering <lennart@poettering.net>
Wed, 2 Jun 2021 13:48:14 +0000 (15:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Jun 2021 13:01:05 +0000 (15:01 +0200)
This matches device_process_new(): this function should not fail, since
it just reacts to external events.

src/core/swap.c

index ecf42ad1196c7fd1b6714446804b06b4a7aef6b5..fc781a3815b7c1dd6441ed95e95970746169f157 100644 (file)
@@ -492,7 +492,7 @@ fail:
         return r;
 }
 
-static int swap_process_new(Manager *m, const char *device, int prio, bool set_flags) {
+static void swap_process_new(Manager *m, const char *device, int prio, bool set_flags) {
         _cleanup_(sd_device_unrefp) sd_device *d = NULL;
         const char *dn, *devlink;
         struct stat st, st_link;
@@ -500,25 +500,22 @@ static int swap_process_new(Manager *m, const char *device, int prio, bool set_f
 
         assert(m);
 
-        r = swap_setup_unit(m, device, device, prio, set_flags);
-        if (r < 0)
-                return r;
+        if (swap_setup_unit(m, device, device, prio, set_flags) < 0)
+                return;
 
         /* If this is a block device, then let's add duplicates for
          * all other names of this block device */
         if (stat(device, &st) < 0 || !S_ISBLK(st.st_mode))
-                return 0;
+                return;
 
         r = sd_device_new_from_stat_rdev(&d, &st);
-        if (r < 0) {
-                log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
-                               "Failed to allocate device for swap %s: %m", device);
-                return 0;
-        }
+        if (r < 0)
+                return (void) log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
+                                             "Failed to allocate device for swap %s: %m", device);
 
         /* Add the main device node */
         if (sd_device_get_devname(d, &dn) >= 0 && !streq(dn, device))
-                swap_setup_unit(m, dn, device, prio, set_flags);
+                (void) swap_setup_unit(m, dn, device, prio, set_flags);
 
         /* Add additional units for all symlinks */
         FOREACH_DEVICE_DEVLINK(d, devlink) {
@@ -535,10 +532,8 @@ static int swap_process_new(Manager *m, const char *device, int prio, bool set_f
                      st_link.st_rdev != st.st_rdev))
                         continue;
 
-                swap_setup_unit(m, devlink, device, prio, set_flags);
+                (void) swap_setup_unit(m, devlink, device, prio, set_flags);
         }
-
-        return 0;
 }
 
 static void swap_set_state(Swap *s, SwapState state) {