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.
This commit is contained in:
+4
-4
@@ -48,9 +48,9 @@ static int log_max_level = LOG_INFO;
|
||||
static int log_facility = LOG_DAEMON;
|
||||
|
||||
static int console_fd = STDERR_FILENO;
|
||||
static int syslog_fd = -1;
|
||||
static int kmsg_fd = -1;
|
||||
static int journal_fd = -1;
|
||||
static int syslog_fd = -EBADF;
|
||||
static int kmsg_fd = -EBADF;
|
||||
static int journal_fd = -EBADF;
|
||||
|
||||
static bool syslog_is_stream = false;
|
||||
|
||||
@@ -345,7 +345,7 @@ void log_close(void) {
|
||||
void log_forget_fds(void) {
|
||||
/* Do not call from library code. */
|
||||
|
||||
console_fd = kmsg_fd = syslog_fd = journal_fd = -1;
|
||||
console_fd = kmsg_fd = syslog_fd = journal_fd = -EBADF;
|
||||
}
|
||||
|
||||
void log_set_max_level(int level) {
|
||||
|
||||
Reference in New Issue
Block a user