]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
system-update-generator: drop pointless goto
authorDavid Tardon <dtardon@redhat.com>
Tue, 16 May 2023 05:39:32 +0000 (07:39 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 24 May 2023 19:01:31 +0000 (04:01 +0900)
src/system-update-generator/system-update-generator.c

index ee5f8ec12ecf261cdfcc319429ec58603444149d..83b06902ab3046046d381474c4bb6c4ecfbacb1f 100644 (file)
 static const char *arg_dest = NULL;
 
 static int generate_symlink(void) {
-        _cleanup_free_ char *j = NULL;
-
         FOREACH_STRING(p, "/system-update", "/etc/system-update") {
-                if (laccess(p, F_OK) >= 0)
-                        goto link_found;
+                if (laccess(p, F_OK) >= 0) {
+                        _cleanup_free_ char *j = NULL;
+
+                        j = path_join(arg_dest, SPECIAL_DEFAULT_TARGET);
+                        if (!j)
+                                return log_oom();
+
+                        if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", j) < 0)
+                                return log_error_errno(errno, "Failed to create symlink %s: %m", j);
+
+                        return 1;
+                }
 
                 if (errno != ENOENT)
                         log_warning_errno(errno, "Failed to check if %s symlink exists, ignoring: %m", p);
         }
 
         return 0;
-
-link_found:
-        j = path_join(arg_dest, SPECIAL_DEFAULT_TARGET);
-        if (!j)
-                return log_oom();
-
-        if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", j) < 0)
-                return log_error_errno(errno, "Failed to create symlink %s: %m", j);
-
-        return 1;
 }
 
 static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {