mirror of
https://github.com/systemd/systemd.git
synced 2026-08-04 15:10:33 +00:00
Merge pull request #33074 from keszybz/bpf-fd-handling
Small cleanups in bpf code
This commit is contained in:
@@ -212,9 +212,6 @@ int fd_cloexec_many(const int fds[], size_t n_fds, bool cloexec) {
|
||||
continue;
|
||||
|
||||
RET_GATHER(r, fd_cloexec(*fd, cloexec));
|
||||
|
||||
if (r >= 0)
|
||||
r = 1; /* report if we did anything */
|
||||
}
|
||||
|
||||
return r;
|
||||
@@ -756,8 +753,7 @@ int rearrange_stdio(int original_input_fd, int original_output_fd, int original_
|
||||
}
|
||||
|
||||
/* Let's assemble fd[] with the fds to install in place of stdin/stdout/stderr */
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (fd[i] < 0)
|
||||
fd[i] = null_fd; /* A negative parameter means: connect this one to /dev/null */
|
||||
else if (fd[i] != i && fd[i] < 3) {
|
||||
@@ -770,20 +766,16 @@ int rearrange_stdio(int original_input_fd, int original_output_fd, int original_
|
||||
|
||||
fd[i] = copy_fd[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* At this point we now have the fds to use in fd[], and they are all above the stdio range, so that
|
||||
* we have freedom to move them around. If the fds already were at the right places then the specific
|
||||
* fds are -EBADF. Let's now move them to the right places. This is the point of no return. */
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (fd[i] == i) {
|
||||
|
||||
/* fd is already in place, but let's make sure O_CLOEXEC is off */
|
||||
r = fd_cloexec(i, false);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
||||
} else {
|
||||
assert(fd[i] > 2);
|
||||
|
||||
@@ -792,7 +784,6 @@ int rearrange_stdio(int original_input_fd, int original_output_fd, int original_
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
r = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user