tree-wide: use -EBADF more

This commit is contained in:
Yu Watanabe
2022-12-21 01:50:33 +09:00
parent 19ee48a6c2
commit 5bb1d7fbab
41 changed files with 65 additions and 65 deletions
+1 -1
View File
@@ -103,5 +103,5 @@ int asynchronous_close(int fd) {
assert_se(close_nointr(fd) != -EBADF);
}
return -1;
return -EBADF;
}
+1 -1
View File
@@ -206,7 +206,7 @@ int chase_symlinks_at(
for (todo = buffer;;) {
_cleanup_free_ char *first = NULL;
_cleanup_close_ int child = -1;
_cleanup_close_ int child = -EBADF;
struct stat st;
const char *e;
+1 -1
View File
@@ -246,7 +246,7 @@ static int close_all_fds_frugal(const int except[], size_t n_except) {
"Refusing to loop over %d potential fds.",
max_fd);
for (int fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) {
for (int fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -EBADF) {
int q;
if (fd_in_set(fd, except, n_except))
+3 -3
View File
@@ -22,8 +22,8 @@ int safe_close(int fd);
void safe_close_pair(int p[static 2]);
static inline int safe_close_above_stdio(int fd) {
if (fd < 3) /* Don't close stdin/stdout/stderr, but still invalidate the fd by returning -1 */
return -1;
if (fd < 3) /* Don't close stdin/stdout/stderr, but still invalidate the fd by returning -EBADF. */
return -EBADF;
return safe_close(fd);
}
@@ -87,7 +87,7 @@ int fd_move_above_stdio(int fd);
int rearrange_stdio(int original_input_fd, int original_output_fd, int original_error_fd);
static inline int make_null_stdio(void) {
return rearrange_stdio(-1, -1, -1);
return rearrange_stdio(-EBADF, -EBADF, -EBADF);
}
/* Like TAKE_PTR() but for file descriptors, resetting them to -1 */
+1 -1
View File
@@ -767,7 +767,7 @@ int read_full_file_full(
r = xfopenat(dir_fd, filename, "re", 0, &f);
if (r < 0) {
_cleanup_close_ int sk = -1;
_cleanup_close_ int sk = -EBADF;
/* ENXIO is what Linux returns if we open a node that is an AF_UNIX socket */
if (r != -ENXIO)