From: Lennart Poettering Date: Tue, 12 Oct 2021 13:54:54 +0000 (+0200) Subject: fd-util: always return 0 on success in close_all_fds() X-Git-Tag: v250-rc1~399^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c844f0a924f34d0fe84672c08f83eeed6d696b44;p=thirdparty%2Fsystemd.git fd-util: always return 0 on success in close_all_fds() We never make use of the return value, and in case of close_range() we don't even know how many fds got closed, hence don't pretend we knew. --- diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 658b17fed72..b9df043aa7d 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -262,7 +262,7 @@ int close_all_fds(const int except[], size_t n_except) { /* Close everything. Yay! */ if (close_range(3, -1, 0) >= 0) - return 1; + return 0; if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno)) return -errno; @@ -297,8 +297,6 @@ int close_all_fds(const int except[], size_t n_except) { sorted = newa(int, n_sorted); if (sorted) { - int c = 0; - memcpy(sorted, except, n_except * sizeof(int)); /* Let's add fd 2 to the list of fds, to simplify the loop below, as this @@ -326,18 +324,16 @@ int close_all_fds(const int except[], size_t n_except) { have_close_range = false; break; } - - c += end - start - 1; } if (have_close_range) { /* The loop succeeded. Let's now close everything beyond the end */ if (sorted[n_sorted-1] >= INT_MAX) /* Dont let the addition below overflow */ - return c; + return 0; if (close_range(sorted[n_sorted-1] + 1, -1, 0) >= 0) - return c + 1; + return 0; if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno)) return -errno;