summaryrefslogtreecommitdiffstats
path: root/src/basic/fd-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-10-12 15:54:54 +0200
committerLennart Poettering <lennart@poettering.net>2021-10-27 17:56:36 +0200
commitc844f0a924f34d0fe84672c08f83eeed6d696b44 (patch)
tree8a467a509f9dcbd62db1f56186ed0e8333a74c30 /src/basic/fd-util.c
parentfd-util: special case invocation of close_all_fds() with single exception fd (diff)
downloadsystemd-c844f0a924f34d0fe84672c08f83eeed6d696b44.tar.xz
systemd-c844f0a924f34d0fe84672c08f83eeed6d696b44.zip
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.
Diffstat (limited to '')
-rw-r--r--src/basic/fd-util.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
index 658b17fed7..b9df043aa7 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;