]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
chase-symlinks: Remove unused ret_fd arguments
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 13 Mar 2023 20:55:04 +0000 (21:55 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 14 Mar 2023 12:46:58 +0000 (13:46 +0100)
src/basic/chase-symlinks.c
src/basic/chase-symlinks.h
src/basic/stat-util.c
src/boot/bootctl-install.c
src/boot/bootctl-status.c
src/core/dbus-manager.c
src/coredump/coredumpctl.c
src/nspawn/nspawn-mount.c
src/partition/repart.c
src/shared/bootspec.c
src/systemctl/systemctl-switch-root.c

index bf90ba23cc5031f135cf4b90090d21e9194f9a93..1b434950e62f204626ce55d67a1bb7d4d5aca3d0 100644 (file)
@@ -631,21 +631,19 @@ int chase_symlinks_and_stat(
                 const char *root,
                 ChaseSymlinksFlags chase_flags,
                 char **ret_path,
-                struct stat *ret_stat,
-                int *ret_fd) {
+                struct stat *ret_stat) {
 
         _cleanup_close_ int path_fd = -EBADF;
         _cleanup_free_ char *p = NULL;
         int r;
 
         assert(path);
-        assert(ret_stat);
 
         if (chase_flags & (CHASE_NONEXISTENT|CHASE_STEP))
                 return -EINVAL;
 
         if (empty_or_root(root) && !ret_path &&
-            (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0 && !ret_fd) {
+            (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0) {
                 /* Shortcut this call if none of the special features of this call are requested */
 
                 if (fstatat(AT_FDCWD, path, ret_stat, FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0) < 0)
@@ -664,8 +662,6 @@ int chase_symlinks_and_stat(
 
         if (ret_path)
                 *ret_path = TAKE_PTR(p);
-        if (ret_fd)
-                *ret_fd = TAKE_FD(path_fd);
 
         return 1;
 }
@@ -675,8 +671,7 @@ int chase_symlinks_and_access(
                 const char *root,
                 ChaseSymlinksFlags chase_flags,
                 int access_mode,
-                char **ret_path,
-                int *ret_fd) {
+                char **ret_path) {
 
         _cleanup_close_ int path_fd = -EBADF;
         _cleanup_free_ char *p = NULL;
@@ -688,7 +683,7 @@ int chase_symlinks_and_access(
                 return -EINVAL;
 
         if (empty_or_root(root) && !ret_path &&
-            (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0 && !ret_fd) {
+            (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0) {
                 /* Shortcut this call if none of the special features of this call are requested */
 
                 if (faccessat(AT_FDCWD, path, access_mode, FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0) < 0)
@@ -708,8 +703,6 @@ int chase_symlinks_and_access(
 
         if (ret_path)
                 *ret_path = TAKE_PTR(p);
-        if (ret_fd)
-                *ret_fd = TAKE_FD(path_fd);
 
         return 1;
 }
index 19acf9e4b56c9a812860d1d93042295d2c7e6118..26e8cfceca77d7c86c73a9f1ec6efe3af56aecce 100644 (file)
@@ -33,8 +33,8 @@ int chase_symlinks(const char *path_with_prefix, const char *root, ChaseSymlinks
 
 int chase_symlinks_and_open(const char *path, const char *root, ChaseSymlinksFlags chase_flags, int open_flags, char **ret_path);
 int chase_symlinks_and_opendir(const char *path, const char *root, ChaseSymlinksFlags chase_flags, char **ret_path, DIR **ret_dir);
-int chase_symlinks_and_stat(const char *path, const char *root, ChaseSymlinksFlags chase_flags, char **ret_path, struct stat *ret_stat, int *ret_fd);
-int chase_symlinks_and_access(const char *path, const char *root, ChaseSymlinksFlags chase_flags, int access_mode, char **ret_path, int *ret_fd);
+int chase_symlinks_and_stat(const char *path, const char *root, ChaseSymlinksFlags chase_flags, char **ret_path, struct stat *ret_stat);
+int chase_symlinks_and_access(const char *path, const char *root, ChaseSymlinksFlags chase_flags, int access_mode, char **ret_path);
 int chase_symlinks_and_fopen_unlocked(const char *path, const char *root, ChaseSymlinksFlags chase_flags, const char *open_flags, char **ret_path, FILE **ret_file);
 int chase_symlinks_and_unlink(const char *path, const char *root, ChaseSymlinksFlags chase_flags, int unlink_flags, char **ret_path);
 
index 700e28f2c2d30ef07aeef9b5341422ab5897d5d6..88b8346a0fd9342f0ae483d6ea53174cc93f0dcb 100644 (file)
@@ -145,7 +145,7 @@ int null_or_empty_path_with_root(const char *fn, const char *root) {
         if (path_equal_ptr(path_startswith(fn, root ?: "/"), "dev/null"))
                 return true;
 
-        r = chase_symlinks_and_stat(fn, root, CHASE_PREFIX_ROOT, NULL, &st, NULL);
+        r = chase_symlinks_and_stat(fn, root, CHASE_PREFIX_ROOT, NULL, &st);
         if (r < 0)
                 return r;
 
index 624b88abe372dd46bb9cc82078781916cec8ce55..1b86c7773e61ef2f344796a9ba48cf7d08ac9524 100644 (file)
@@ -663,7 +663,7 @@ static int install_variables(
                 return 0;
         }
 
-        r = chase_symlinks_and_access(path, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL, NULL);
+        r = chase_symlinks_and_access(path, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL);
         if (r == -ENOENT)
                 return 0;
         if (r < 0)
index e25cd963ae42fcf1a17a9bc5d7d55001bf833851..ce97b013cf5d784c6d046ee19abb252a33cd3f79 100644 (file)
@@ -560,7 +560,7 @@ static void deref_unlink_file(Hashmap *known_files, const char *fn, const char *
                 return;
 
         if (arg_dry_run) {
-                r = chase_symlinks_and_access(fn, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, &path, NULL);
+                r = chase_symlinks_and_access(fn, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, &path);
                 if (r < 0)
                         log_info_errno(r, "Unable to determine whether \"%s\" exists, ignoring: %m", fn);
                 else
index 242a662bca2f1d86f281878580cf56543847cd12..2198e73f248c6c9d8a7f4a1854f728205ff536d3 100644 (file)
@@ -1768,7 +1768,7 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
                         return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
                                                  "Path to init binary '%s' not absolute.", init);
 
-                r = chase_symlinks_and_access(init, root, CHASE_PREFIX_ROOT, X_OK, NULL, NULL);
+                r = chase_symlinks_and_access(init, root, CHASE_PREFIX_ROOT, X_OK, NULL);
                 if (r == -EACCES)
                         return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
                                                  "Init binary %s is not executable.", init);
index 4c312d0fbb964a2d6b51f598a9fef2cf8107279e..909ffc8d8b822f7901ca9b7d32e7ae30fd91a200 100644 (file)
@@ -981,7 +981,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
                         return r;
                 assert(r > 0);
 
-                r = chase_symlinks_and_access(filename, arg_root, CHASE_PREFIX_ROOT, F_OK, &resolved, NULL);
+                r = chase_symlinks_and_access(filename, arg_root, CHASE_PREFIX_ROOT, F_OK, &resolved);
                 if (r < 0)
                         return log_error_errno(r, "Cannot access \"%s%s\": %m", strempty(arg_root), filename);
 
index ea54b23e083d439a317c6e395f6b6169e9065b59..f190239cad70a2dc78489edb8765014149a50a74 100644 (file)
@@ -926,7 +926,7 @@ static int mount_inaccessible(const char *dest, CustomMount *m) {
         assert(dest);
         assert(m);
 
-        r = chase_symlinks_and_stat(m->destination, dest, CHASE_PREFIX_ROOT, &where, &st, NULL);
+        r = chase_symlinks_and_stat(m->destination, dest, CHASE_PREFIX_ROOT, &where, &st);
         if (r < 0) {
                 log_full_errno(m->graceful ? LOG_DEBUG : LOG_ERR, r, "Failed to resolve %s/%s: %m", dest, m->destination);
                 return m->graceful ? 0 : r;
index e8f3cb7fe7b0bb3f062b8d5aa1d04dd529354070..2b1fbbdae2d4fad1568365ebeb7534369df76bed 100644 (file)
@@ -4021,7 +4021,7 @@ static int add_exclude_path(const char *path, Hashmap **denylist, DenyType type)
         if (!st)
                 return log_oom();
 
-        r = chase_symlinks_and_stat(path, arg_root, CHASE_PREFIX_ROOT, NULL, st, NULL);
+        r = chase_symlinks_and_stat(path, arg_root, CHASE_PREFIX_ROOT, NULL, st);
         if (r == -ENOENT)
                 return 0;
         if (r < 0)
index 49fb34b4d644bfd6b4ebadd3e6de5997a889b41e..9dddb0e289c7955466339463e340f63a9d5e88bf 100644 (file)
@@ -1269,7 +1269,7 @@ static void boot_entry_file_list(
         assert(p);
         assert(ret_status);
 
-        int status = chase_symlinks_and_access(p, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL, NULL);
+        int status = chase_symlinks_and_access(p, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL);
 
         /* Note that this shows two '/' between the root and the file. This is intentional to highlight (in
          * the absence of color support) to the user that the boot loader is only interested in the second
index 7fa8b26f593a71193275c24cb76c10e1264ff120..5c71d3d97fc2cf5184237208861fde780a983503 100644 (file)
@@ -21,11 +21,11 @@ static int same_file_in_root(
         struct stat sta, stb;
         int r;
 
-        r = chase_symlinks_and_stat(a, root, CHASE_PREFIX_ROOT, NULL, &sta, NULL);
+        r = chase_symlinks_and_stat(a, root, CHASE_PREFIX_ROOT, NULL, &sta);
         if (r < 0)
                 return r;
 
-        r = chase_symlinks_and_stat(b, root, CHASE_PREFIX_ROOT, NULL, &stb, NULL);
+        r = chase_symlinks_and_stat(b, root, CHASE_PREFIX_ROOT, NULL, &stb);
         if (r < 0)
                 return r;