From 3ee8dafb2797c43ec8844edded456f06da352494 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 22 Nov 2022 14:28:59 +0000 Subject: [PATCH] gspawn: Fold in safe_fdwalk_with_invalid_fds() helper function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since it’s now always called the same way after safe_fdwalk() has been called. This introduces no functional changes. Signed-off-by: Philip Withnall --- glib/gspawn.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/glib/gspawn.c b/glib/gspawn.c index be09f791b..f491c12cf 100644 --- a/glib/gspawn.c +++ b/glib/gspawn.c @@ -1412,6 +1412,8 @@ filename_to_fd (const char *p) } #endif +static int safe_fdwalk_with_invalid_fds (int (*cb)(void *data, int fd), void *data); + /* This function is called between fork() and exec() and hence must be * async-signal-safe (see signal-safety(7)). */ static int @@ -1493,8 +1495,7 @@ safe_fdwalk (int (*cb)(void *data, int fd), void *data) return res; #endif - errno = ENOSYS; - return -1; + return safe_fdwalk_with_invalid_fds (cb, data); #endif } @@ -1605,9 +1606,6 @@ safe_fdwalk_set_cloexec (int lowfd) ret = safe_fdwalk (set_cloexec, GINT_TO_POINTER (lowfd)); - if (ret < 0 && errno == ENOSYS) - ret = safe_fdwalk_with_invalid_fds (set_cloexec, GINT_TO_POINTER (lowfd)); - return ret; } @@ -1665,9 +1663,6 @@ safe_closefrom (int lowfd) #endif /* HAVE_CLOSE_RANGE */ ret = safe_fdwalk (close_func_with_invalid_fds, GINT_TO_POINTER (lowfd)); - if (ret < 0 && errno == ENOSYS) - ret = safe_fdwalk_with_invalid_fds (close_func_with_invalid_fds, GINT_TO_POINTER (lowfd)); - return ret; #endif }