diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-12-19 13:07:42 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-12-19 15:00:57 +0100 |
commit | 254d1313ae5a69c08c9b93032aaaf3d6083cfc07 (patch) | |
tree | 067102a36abe6bf597c26a42d79018a1060c9007 /src/journal-remote | |
parent | cbff793ffb280d9d11e5d7b1dc3964276491bee8 (diff) | |
download | systemd-254d1313ae5a69c08c9b93032aaaf3d6083cfc07.tar.gz |
tree-wide: use -EBADF for fd initialization
-1 was used everywhere, but -EBADF or -EBADFD started being used in various
places. Let's make things consistent in the new style.
Note that there are two candidates:
EBADF 9 Bad file descriptor
EBADFD 77 File descriptor in bad state
Since we're initializating the fd, we're just assigning a value that means
"no fd yet", so it's just a bad file descriptor, and the first errno fits
better. If instead we had a valid file descriptor that became invalid because
of some operation or state change, the other errno would fit better.
In some places, initialization is dropped if unnecessary.
Diffstat (limited to 'src/journal-remote')
-rw-r--r-- | src/journal-remote/fuzz-journal-remote.c | 2 | ||||
-rw-r--r-- | src/journal-remote/journal-gatewayd.c | 4 | ||||
-rw-r--r-- | src/journal-remote/journal-remote.c | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/journal-remote/fuzz-journal-remote.c b/src/journal-remote/fuzz-journal-remote.c index db10c2b012..da0d83ec9a 100644 --- a/src/journal-remote/fuzz-journal-remote.c +++ b/src/journal-remote/fuzz-journal-remote.c @@ -19,7 +19,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { int fdin; void *mem; _cleanup_(unlink_tempfilep) char name[] = "/tmp/fuzz-journal-remote.XXXXXX.journal"; - _cleanup_close_ int fdout = -1; + _cleanup_close_ int fdout = -EBADF; _cleanup_(sd_journal_closep) sd_journal *j = NULL; _cleanup_(journal_remote_server_destroy) RemoteServer s = {}; int r; diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index b3b44bceb8..747e0be743 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -127,7 +127,7 @@ static int request_meta_ensure_tmp(RequestMeta *m) { if (m->tmp) rewind(m->tmp); else { - _cleanup_close_ int fd = -1; + _cleanup_close_ int fd = -EBADF; fd = open_tmpfile_unlinkable("/tmp", O_RDWR|O_CLOEXEC); if (fd < 0) @@ -670,7 +670,7 @@ static int request_handler_file( const char *mime_type) { _cleanup_(MHD_destroy_responsep) struct MHD_Response *response = NULL; - _cleanup_close_ int fd = -1; + _cleanup_close_ int fd = -EBADF; struct stat st; assert(connection); diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 3d7b552e95..a670468884 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -294,7 +294,7 @@ int journal_remote_add_raw_socket(RemoteServer *s, int fd) { if (r < 0) return r; - fd_ = -1; + fd_ = -EBADF; s->active++; return 0; } @@ -483,7 +483,7 @@ static int accept_connection( SocketAddress *addr, char **hostname) { - _cleanup_close_ int fd2 = -1; + _cleanup_close_ int fd2 = -EBADF; int r; log_debug("Accepting new %s connection on fd:%d", type, fd); |