[systemd-commits] 6 commits - Makefile.am shell-completion/bash src/core src/fsck src/fstab-generator src/random-seed

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Fri Nov 15 20:12:16 PST 2013


 Makefile.am                           |    2 
 shell-completion/bash/journalctl      |    6 ++
 src/core/load-fragment.c              |   53 +++++++----------------
 src/core/unit.c                       |   38 +++++++++-------
 src/fsck/fsck.c                       |   77 ++++++++++++++++++++--------------
 src/fstab-generator/fstab-generator.c |   77 ++++++++++++++++++++++------------
 src/random-seed/random-seed.c         |    8 +--
 7 files changed, 148 insertions(+), 113 deletions(-)

New commits:
commit 7524c3cf4485bb9afd4ef0bf005a89f0319c19cd
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Nov 15 19:00:01 2013 -0500

    bash-completion: journalctl --file

diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl
index 942a253..e4b2f4a 100644
--- a/shell-completion/bash/journalctl
+++ b/shell-completion/bash/journalctl
@@ -43,7 +43,7 @@ _journalctl() {
                               -h --help -l --local --new-id128 -m --merge --no-pager
                               --no-tail -q --quiet --setup-keys --this-boot --verify
                               --version --list-catalog --update-catalog --list-boots'
-                       [ARG]='-b --boot --this-boot -D --directory -F --field
+                       [ARG]='-b --boot --this-boot -D --directory --file -F --field
                               -o --output -u --unit --user-unit'
                 [ARGUNKNOWN]='-c --cursor --interval -n --lines -p --priority --since --until
                               --verify-key'
@@ -58,6 +58,10 @@ _journalctl() {
                                 comps=$(compgen -d -- "$cur")
                                 compopt -o filenames
                         ;;
+                        --file)
+                                comps=$(compgen -f -- "$cur")
+                                compopt -o filenames
+                        ;;
                         --output|-o)
                                 comps='short short-monotonic verbose export json cat'
                         ;;

commit 952d97ed2b44f58b973a78c87d09b20c36f61460
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Nov 12 22:05:16 2013 -0500

    random-seed: improve debugging messages a bit

diff --git a/Makefile.am b/Makefile.am
index 04e8e32..246bf45 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -163,6 +163,7 @@ AM_CPPFLAGS = \
 	-DSYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH=\"$(rootbindir)/systemd-tty-ask-password-agent\" \
 	-DSYSTEMD_STDIO_BRIDGE_BINARY_PATH=\"$(bindir)/systemd-stdio-bridge\" \
 	-DROOTPREFIX=\"$(rootprefix)\" \
+	-DRANDOM_SEED_DIR=\"$(localstatedir)/lib/systemd/\" \
 	-DRANDOM_SEED=\"$(localstatedir)/lib/systemd/random-seed\" \
 	-DSYSTEMD_CRYPTSETUP_PATH=\"$(rootlibexecdir)/systemd-cryptsetup\" \
 	-DSYSTEM_GENERATOR_PATH=\"$(systemgeneratordir)\" \
@@ -4339,6 +4340,7 @@ substitutions = \
        '|PACKAGE_VERSION=$(PACKAGE_VERSION)|' \
        '|PACKAGE_NAME=$(PACKAGE_NAME)|' \
        '|PACKAGE_URL=$(PACKAGE_URL)|' \
+       '|RANDOM_SEED_DIR=$(localstatedir)/lib/systemd/|' \
        '|RANDOM_SEED=$(localstatedir)/lib/systemd/random-seed|' \
        '|prefix=$(prefix)|' \
        '|exec_prefix=$(exec_prefix)|' \
diff --git a/src/random-seed/random-seed.c b/src/random-seed/random-seed.c
index afbd500..af79ecf 100644
--- a/src/random-seed/random-seed.c
+++ b/src/random-seed/random-seed.c
@@ -72,7 +72,7 @@ int main(int argc, char *argv[]) {
 
         r = mkdir_parents_label(RANDOM_SEED, 0755);
         if (r < 0) {
-                log_error("Failed to create parent directory of " RANDOM_SEED ": %s", strerror(-r));
+                log_error("Failed to create directory " RANDOM_SEED_DIR ": %s", strerror(-r));
                 goto finish;
         }
 
@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
                 if (seed_fd < 0) {
                         seed_fd = open(RANDOM_SEED, O_RDONLY|O_CLOEXEC|O_NOCTTY);
                         if (seed_fd < 0) {
-                                log_error("Failed to open random seed: %m");
+                                log_error("Failed to open " RANDOM_SEED ": %m");
                                 r = -errno;
                                 goto finish;
                         }
@@ -106,7 +106,7 @@ int main(int argc, char *argv[]) {
                 if (k <= 0) {
 
                         if (r != 0)
-                                log_error("Failed to read seed file: %m");
+                                log_error("Failed to read seed from " RANDOM_SEED ": %m");
 
                         r = k == 0 ? -EIO : (int) k;
 
@@ -125,7 +125,7 @@ int main(int argc, char *argv[]) {
 
                 seed_fd = open(RANDOM_SEED, O_WRONLY|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
                 if (seed_fd < 0) {
-                        log_error("Failed to open random seed: %m");
+                        log_error("Failed to open " RANDOM_SEED ": %m");
                         r = -errno;
                         goto finish;
                 }

commit 4e8da529592b01fee27f48962fe953b777de9b30
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Nov 12 22:01:10 2013 -0500

    fstab-generator: use RequiresOverridable for fsck units
    
    This allows the user to disable fsck's by masking.
    
    If fsck fails, emergency target is started, the user might mount the
    unit using mount and disable fsck by masking the unit. In this case,
    .mount will be active because the mount is detect through
    /proc/self/mountinfo, but systemd-fsck at .service will still be in
    failed mode. This results in a funny situation where
    
    $ systemctl show -p ActiveState local-fs.target yyy.mount
    ActiveState=active
    ActiveState=active
    
    $ sudo systemctl start local-fs.target
    [sudo] password for test:
    Failed to start local-fs.target: Unit systemd-fsck at xxx.service is masked.

diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index fa0d3f7..1227f08 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -183,7 +183,7 @@ static int add_fsck(FILE *f, const char *what, const char *where, const char *ty
                         return log_oom();
 
                 fprintf(f,
-                        "Requires=%s\n"
+                        "RequiresOverridable=%s\n"
                         "After=%s\n",
                         fsck,
                         fsck);

commit e48614c4b268d9e7ecbd478d1d2410f9e92095e0
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Oct 21 19:54:10 2013 -0400

    core: some more _cleanup_free_

diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index b7e848c..72c4637 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2403,9 +2403,10 @@ static int merge_by_names(Unit **u, Set *names, const char *id) {
 
 static int load_from_path(Unit *u, const char *path) {
         int r;
-        Set *symlink_names;
-        FILE *f = NULL;
-        char *filename = NULL, *id = NULL;
+        _cleanup_set_free_free_ Set *symlink_names = NULL;
+        _cleanup_fclose_ FILE *f = NULL;
+        _cleanup_free_ char *filename = NULL;
+        char *id = NULL;
         Unit *merged;
         struct stat st;
 
@@ -2419,10 +2420,8 @@ static int load_from_path(Unit *u, const char *path) {
         if (path_is_absolute(path)) {
 
                 filename = strdup(path);
-                if (!filename) {
-                        r = -ENOMEM;
-                        goto finish;
-                }
+                if (!filename)
+                        return -ENOMEM;
 
                 r = open_follow(&filename, &f, symlink_names, &id);
                 if (r < 0) {
@@ -2430,7 +2429,7 @@ static int load_from_path(Unit *u, const char *path) {
                         filename = NULL;
 
                         if (r != -ENOENT)
-                                goto finish;
+                                return r;
                 }
 
         } else  {
@@ -2442,10 +2441,8 @@ static int load_from_path(Unit *u, const char *path) {
                          * follow all symlinks and add their name to our unit
                          * name set while doing so */
                         filename = path_make_absolute(path, *p);
-                        if (!filename) {
-                                r = -ENOMEM;
-                                goto finish;
-                        }
+                        if (!filename)
+                                return -ENOMEM;
 
                         if (u->manager->unit_path_cache &&
                             !set_get(u->manager->unit_path_cache, filename))
@@ -2458,7 +2455,7 @@ static int load_from_path(Unit *u, const char *path) {
                                 filename = NULL;
 
                                 if (r != -ENOENT)
-                                        goto finish;
+                                        return r;
 
                                 /* Empty the symlink names for the next run */
                                 set_clear_free(symlink_names);
@@ -2469,27 +2466,22 @@ static int load_from_path(Unit *u, const char *path) {
                 }
         }
 
-        if (!filename) {
+        if (!filename)
                 /* Hmm, no suitable file found? */
-                r = 0;
-                goto finish;
-        }
+                return 0;
 
         merged = u;
         r = merge_by_names(&merged, symlink_names, id);
         if (r < 0)
-                goto finish;
+                return r;
 
         if (merged != u) {
                 u->load_state = UNIT_MERGED;
-                r = 0;
-                goto finish;
+                return 0;
         }
 
-        if (fstat(fileno(f), &st) < 0) {
-                r = -errno;
-                goto finish;
-        }
+        if (fstat(fileno(f), &st) < 0)
+                return -errno;
 
         if (null_or_empty(&st))
                 u->load_state = UNIT_MASKED;
@@ -2501,7 +2493,7 @@ static int load_from_path(Unit *u, const char *path) {
                                  config_item_perf_lookup,
                                  (void*) load_fragment_gperf_lookup, false, true, u);
                 if (r < 0)
-                        goto finish;
+                        return r;
         }
 
         free(u->fragment_path);
@@ -2517,16 +2509,7 @@ static int load_from_path(Unit *u, const char *path) {
                         u->source_mtime = 0;
         }
 
-        r = 0;
-
-finish:
-        set_free_free(symlink_names);
-        free(filename);
-
-        if (f)
-                fclose(f);
-
-        return r;
+        return 0;
 }
 
 int unit_load_fragment(Unit *u) {
diff --git a/src/core/unit.c b/src/core/unit.c
index 15e0a82..84c43f7 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -127,7 +127,8 @@ int unit_add_name(Unit *u, const char *text) {
                 goto fail;
         }
 
-        if ((r = unit_name_to_instance(s, &i)) < 0)
+        r = unit_name_to_instance(s, &i);
+        if (r < 0)
                 goto fail;
 
         if (i && unit_vtable[t]->no_instances) {
@@ -154,13 +155,15 @@ int unit_add_name(Unit *u, const char *text) {
                 goto fail;
         }
 
-        if ((r = set_put(u->names, s)) < 0) {
+        r = set_put(u->names, s);
+        if (r < 0) {
                 if (r == -EEXIST)
                         r = 0;
                 goto fail;
         }
 
-        if ((r = hashmap_put(u->manager->units, s, u)) < 0) {
+        r = hashmap_put(u->manager->units, s, u);
+        if (r < 0) {
                 set_remove(u->names, s);
                 goto fail;
         }
@@ -201,7 +204,8 @@ int unit_choose_id(Unit *u, const char *name) {
                 if (!u->instance)
                         return -EINVAL;
 
-                if (!(t = unit_name_replace_instance(name, u->instance)))
+                t = unit_name_replace_instance(name, u->instance);
+                if (!t)
                         return -ENOMEM;
 
                 name = t;
@@ -213,7 +217,8 @@ int unit_choose_id(Unit *u, const char *name) {
         if (!s)
                 return -ENOENT;
 
-        if ((r = unit_name_to_instance(s, &i)) < 0)
+        r = unit_name_to_instance(s, &i);
+        if (r < 0)
                 return r;
 
         u->id = s;
@@ -546,14 +551,13 @@ static void merge_dependencies(Unit *u, Unit *other, UnitDependency d) {
         SET_FOREACH(back, other->dependencies[d], i) {
                 UnitDependency k;
 
-                for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++)
-                        if ((r = set_remove_and_put(back->dependencies[k], other, u)) < 0) {
-
-                                if (r == -EEXIST)
-                                        set_remove(back->dependencies[k], other);
-                                else
-                                        assert(r == -ENOENT);
-                        }
+                for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++) {
+                        r = set_remove_and_put(back->dependencies[k], other, u);
+                        if (r == -EEXIST)
+                                set_remove(back->dependencies[k], other);
+                        else
+                                assert(r >= 0 || r == -ENOENT);
+                }
         }
 
         complete_move(&u->dependencies[d], &other->dependencies[d]);
@@ -632,7 +636,8 @@ int unit_merge_by_name(Unit *u, const char *name) {
                 if (!u->instance)
                         return -EINVAL;
 
-                if (!(s = unit_name_replace_instance(name, u->instance)))
+                s = unit_name_replace_instance(name, u->instance);
+                if (!s)
                         return -ENOMEM;
 
                 name = s;
@@ -843,7 +848,7 @@ int unit_load_fragment_and_dropin(Unit *u) {
 
         assert(u);
 
-        /* Load a .service file */
+        /* Load a .{service,socket,...} file */
         r = unit_load_fragment(u);
         if (r < 0)
                 return r;
@@ -1280,7 +1285,8 @@ int unit_reload(Unit *u) {
         if (state != UNIT_ACTIVE)
                 return -ENOEXEC;
 
-        if ((following = unit_following(u))) {
+        following = unit_following(u);
+        if (following) {
                 log_debug_unit(u->id, "Redirecting reload request from %s to %s.",
                                u->id, following->id);
                 return unit_reload(following);

commit 94192cdaf652c9717f15274504ed315126c07a93
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Nov 12 00:53:59 2013 -0500

    fsck,fstab-generator: be lenient about missing fsck.<type>
    
    If fstab contains 1 for passno, treat this as an error, but only warn
    briefly. If fstab doesn't contain this information, don't complain at
    all.
    
    Patch is complicated a bit by the fact that we might have the fstype specified
    in fstab or on /proc/cmdline, in which case we can check if we have the appropriate
    fsck tool, or not specified, or specified as auto, in which case we have to look
    and check the type of the filesystem ourselves. It cannot be done before the
    device appears, so it is too early in the generator phase, and it must be done
    directly in fsck service.

diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index c2e1c74..4f1aa22 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -212,10 +212,11 @@ int main(int argc, char *argv[]) {
         siginfo_t status;
         _cleanup_udev_unref_ struct udev *udev = NULL;
         _cleanup_udev_device_unref_ struct udev_device *udev_device = NULL;
-        const char *device;
+        const char *device, *type;
         bool root_directory;
         int progress_pipe[2] = { -1, -1 };
         char dash_c[2+10+1];
+        struct stat st;
 
         if (argc > 2) {
                 log_error("This program expects one or no arguments.");
@@ -234,11 +235,27 @@ int main(int argc, char *argv[]) {
         if (!arg_force && arg_skip)
                 return 0;
 
+        udev = udev_new();
+        if (!udev) {
+                log_oom();
+                return EXIT_FAILURE;
+        }
+
         if (argc > 1) {
                 device = argv[1];
                 root_directory = false;
+
+                if (stat(device, &st) < 0) {
+                        log_error("Failed to stat '%s': %m", device);
+                        return EXIT_FAILURE;
+                }
+
+                udev_device = udev_device_new_from_devnum(udev, 'b', st.st_rdev);
+                if (!udev_device) {
+                        log_error("Failed to detect device %s", device);
+                        return EXIT_FAILURE;
+                }
         } else {
-                struct stat st;
                 struct timespec times[2];
 
                 /* Find root device */
@@ -260,12 +277,6 @@ int main(int argc, char *argv[]) {
                         return EXIT_SUCCESS;
                 }
 
-                udev = udev_new();
-                if (!udev) {
-                        log_oom();
-                        return EXIT_FAILURE;
-                }
-
                 udev_device = udev_device_new_from_devnum(udev, 'b', st.st_dev);
                 if (!udev_device) {
                         log_error("Failed to detect root device.");
@@ -281,6 +292,19 @@ int main(int argc, char *argv[]) {
                 root_directory = true;
         }
 
+        type = udev_device_get_property_value(udev_device, "ID_FS_TYPE");
+        if (type) {
+                const char *checker = strappenda("/sbin/fsck.", type);
+                r = access(checker, X_OK);
+                if (r < 0) {
+                        if (errno == ENOENT) {
+                                log_info("%s doesn't exist, not checking file system.", checker);
+                                return EXIT_SUCCESS;
+                        } else
+                                log_warning("%s cannot be used: %m", checker);
+                }
+        }
+
         if (arg_show_progress)
                 if (pipe(progress_pipe) < 0) {
                         log_error("pipe(): %m");
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 96b0906..fa0d3f7 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -146,6 +146,52 @@ static bool mount_in_initrd(struct mntent *me) {
                 streq(me->mnt_dir, "/usr");
 }
 
+static int add_fsck(FILE *f, const char *what, const char *where, const char *type, int passno) {
+        assert(f);
+
+        if (passno == 0)
+                return 0;
+
+        if (type && !streq(type, "auto")) {
+                int r;
+                const char *checker;
+
+                checker = strappenda("/sbin/fsck.", type);
+                r = access(checker, X_OK);
+                if (r < 0) {
+                        log_warning("Checking was requested for %s, but %s cannot be used: %m", what, checker);
+
+                        /* treat missing check as essentially OK */
+                        return errno == ENOENT ? 0 : -errno;
+                }
+        }
+
+        if (streq(where, "/")) {
+                char *lnk;
+
+                lnk = strappenda(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/systemd-fsck-root.service");
+                mkdir_parents_label(lnk, 0755);
+                if (symlink("systemd-fsck-root.service", lnk) < 0) {
+                        log_error("Failed to create symlink %s: %m", lnk);
+                        return -errno;
+                }
+        } else {
+                _cleanup_free_ char *fsck = NULL;
+
+                fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
+                if (!fsck)
+                        return log_oom();
+
+                fprintf(f,
+                        "Requires=%s\n"
+                        "After=%s\n",
+                        fsck,
+                        fsck);
+        }
+
+        return 0;
+}
+
 static int add_mount(
                 const char *what,
                 const char *where,
@@ -161,6 +207,7 @@ static int add_mount(
                 *name = NULL, *unit = NULL, *lnk = NULL,
                 *automount_name = NULL, *automount_unit = NULL;
         _cleanup_fclose_ FILE *f = NULL;
+        int r;
 
         assert(what);
         assert(where);
@@ -208,32 +255,9 @@ static int add_mount(
                         "Before=%s\n",
                         post);
 
-        if (passno > 0) {
-                if (streq(where, "/")) {
-                        lnk = strjoin(arg_dest, "/", SPECIAL_LOCAL_FS_TARGET, ".wants/", "systemd-fsck-root.service", NULL);
-                        if (!lnk)
-                                return log_oom();
-
-                        mkdir_parents_label(lnk, 0755);
-                        if (symlink("systemd-fsck-root.service", lnk) < 0) {
-                                log_error("Failed to create symlink %s: %m", lnk);
-                                return -errno;
-                        }
-                } else {
-                        _cleanup_free_ char *fsck = NULL;
-
-                        fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
-                        if (!fsck)
-                                return log_oom();
-
-                        fprintf(f,
-                                "Requires=%s\n"
-                                "After=%s\n",
-                                fsck,
-                                fsck);
-                }
-        }
-
+        r = add_fsck(f, what, where, type, passno);
+        if (r < 0)
+                return r;
 
         fprintf(f,
                 "\n"
@@ -259,7 +283,6 @@ static int add_mount(
 
         if (!noauto) {
                 if (post) {
-                        free(lnk);
                         lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
                         if (!lnk)
                                 return log_oom();

commit e375825da0cbdbf3be755c277f9c0dec35b41a09
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Nov 11 23:32:31 2013 -0500

    fsck: modernization

diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 9b67ccf..c2e1c74 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -144,7 +144,7 @@ static double percent(int pass, unsigned long cur, unsigned long max) {
 }
 
 static int process_progress(int fd) {
-        FILE *f, *console;
+        _cleanup_fclose_ FILE *console = NULL, *f = NULL;
         usec_t last = 0;
         bool locked = false;
         int clear = 0;
@@ -156,15 +156,13 @@ static int process_progress(int fd) {
         }
 
         console = fopen("/dev/console", "w");
-        if (!console) {
-                fclose(f);
+        if (!console)
                 return -ENOMEM;
-        }
 
         while (!feof(f)) {
                 int pass, m;
                 unsigned long cur, max;
-                char *device;
+                _cleanup_free_ char *device = NULL;
                 double p;
                 usec_t t;
 
@@ -173,20 +171,16 @@ static int process_progress(int fd) {
 
                 /* Only show one progress counter at max */
                 if (!locked) {
-                        if (flock(fileno(console), LOCK_EX|LOCK_NB) < 0) {
-                                free(device);
+                        if (flock(fileno(console), LOCK_EX|LOCK_NB) < 0)
                                 continue;
-                        }
 
                         locked = true;
                 }
 
                 /* Only update once every 50ms */
                 t = now(CLOCK_MONOTONIC);
-                if (last + 50 * USEC_PER_MSEC > t)  {
-                        free(device);
+                if (last + 50 * USEC_PER_MSEC > t)
                         continue;
-                }
 
                 last = t;
 
@@ -194,8 +188,6 @@ static int process_progress(int fd) {
                 fprintf(console, "\r%s: fsck %3.1f%% complete...\r%n", device, p, &m);
                 fflush(console);
 
-                free(device);
-
                 if (m > clear)
                         clear = m;
         }
@@ -210,8 +202,6 @@ static int process_progress(int fd) {
                 fflush(console);
         }
 
-        fclose(f);
-        fclose(console);
         return 0;
 }
 
@@ -255,34 +245,37 @@ int main(int argc, char *argv[]) {
 
                 if (stat("/", &st) < 0) {
                         log_error("Failed to stat() the root directory: %m");
-                        goto finish;
+                        return EXIT_FAILURE;
                 }
 
                 /* Virtual root devices don't need an fsck */
                 if (major(st.st_dev) == 0)
-                        return 0;
+                        return EXIT_SUCCESS;
 
                 /* check if we are already writable */
                 times[0] = st.st_atim;
                 times[1] = st.st_mtim;
                 if (utimensat(AT_FDCWD, "/", times, 0) == 0) {
                         log_info("Root directory is writable, skipping check.");
-                        return 0;
+                        return EXIT_SUCCESS;
                 }
 
-                if (!(udev = udev_new())) {
+                udev = udev_new();
+                if (!udev) {
                         log_oom();
-                        goto finish;
+                        return EXIT_FAILURE;
                 }
 
-                if (!(udev_device = udev_device_new_from_devnum(udev, 'b', st.st_dev))) {
+                udev_device = udev_device_new_from_devnum(udev, 'b', st.st_dev);
+                if (!udev_device) {
                         log_error("Failed to detect root device.");
-                        goto finish;
+                        return EXIT_FAILURE;
                 }
 
-                if (!(device = udev_device_get_devnode(udev_device))) {
+                device = udev_device_get_devnode(udev_device);
+                if (!device) {
                         log_error("Failed to detect device node of root directory.");
-                        goto finish;
+                        return EXIT_FAILURE;
                 }
 
                 root_directory = true;
@@ -291,7 +284,7 @@ int main(int argc, char *argv[]) {
         if (arg_show_progress)
                 if (pipe(progress_pipe) < 0) {
                         log_error("pipe(): %m");
-                        goto finish;
+                        return EXIT_FAILURE;
                 }
 
         cmdline[i++] = "/sbin/fsck";



More information about the systemd-commits mailing list