libsystemd: use _NEG_ macros, adjust some comments
No functional change.
This commit is contained in:
@@ -579,11 +579,10 @@ static int bus_socket_read_auth(sd_bus *b) {
|
||||
} else
|
||||
handle_cmsg = true;
|
||||
}
|
||||
if (k < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(k))
|
||||
return 0;
|
||||
if (ERRNO_IS_NEG_TRANSIENT(k))
|
||||
return 0;
|
||||
if (k < 0)
|
||||
return (int) k;
|
||||
}
|
||||
if (k == 0) {
|
||||
if (handle_cmsg)
|
||||
cmsg_close_all(&mh); /* paranoia, we shouldn't have gotten any fds on EOF */
|
||||
@@ -1298,11 +1297,10 @@ int bus_socket_read_message(sd_bus *bus) {
|
||||
} else
|
||||
handle_cmsg = true;
|
||||
}
|
||||
if (k < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(k))
|
||||
return 0;
|
||||
if (ERRNO_IS_NEG_TRANSIENT(k))
|
||||
return 0;
|
||||
if (k < 0)
|
||||
return (int) k;
|
||||
}
|
||||
if (k == 0) {
|
||||
if (handle_cmsg)
|
||||
cmsg_close_all(&mh); /* On EOF we shouldn't have gotten an fd, but let's make sure */
|
||||
@@ -1361,11 +1359,10 @@ int bus_socket_process_opening(sd_bus *b) {
|
||||
assert(b->state == BUS_OPENING);
|
||||
|
||||
events = fd_wait_for_event(b->output_fd, POLLOUT, 0);
|
||||
if (events < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(events))
|
||||
return 0;
|
||||
if (ERRNO_IS_NEG_TRANSIENT(events))
|
||||
return 0;
|
||||
if (events < 0)
|
||||
return events;
|
||||
}
|
||||
if (!(events & (POLLOUT|POLLERR|POLLHUP)))
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -2178,14 +2178,11 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie) {
|
||||
size_t idx = 0;
|
||||
|
||||
r = bus_write_message(bus, m, &idx);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_DISCONNECT(r)) {
|
||||
bus_enter_closing(bus);
|
||||
return -ECONNRESET;
|
||||
}
|
||||
|
||||
if (ERRNO_IS_NEG_DISCONNECT(r)) {
|
||||
bus_enter_closing(bus);
|
||||
return -ECONNRESET;
|
||||
} else if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (idx < BUS_MESSAGE_SIZE(m)) {
|
||||
/* Wasn't fully written. So let's remember how
|
||||
@@ -2506,11 +2503,10 @@ _public_ int sd_bus_call(
|
||||
left = UINT64_MAX;
|
||||
|
||||
r = bus_poll(bus, true, left);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(r))
|
||||
continue;
|
||||
if (ERRNO_IS_NEG_TRANSIENT(r))
|
||||
continue;
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
}
|
||||
if (r == 0) {
|
||||
r = -ETIMEDOUT;
|
||||
goto fail;
|
||||
@@ -3284,13 +3280,11 @@ static int bus_process_internal(sd_bus *bus, sd_bus_message **ret) {
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_DISCONNECT(r)) {
|
||||
bus_enter_closing(bus);
|
||||
r = 1;
|
||||
} else
|
||||
return r;
|
||||
}
|
||||
if (ERRNO_IS_NEG_DISCONNECT(r)) {
|
||||
bus_enter_closing(bus);
|
||||
r = 1;
|
||||
} else if (r < 0)
|
||||
return r;
|
||||
|
||||
if (ret)
|
||||
*ret = NULL;
|
||||
@@ -3388,7 +3382,7 @@ _public_ int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec) {
|
||||
return 0;
|
||||
|
||||
r = bus_poll(bus, false, timeout_usec);
|
||||
if (r < 0 && ERRNO_IS_TRANSIENT(r))
|
||||
if (ERRNO_IS_NEG_TRANSIENT(r))
|
||||
return 1; /* treat EINTR as success, but let's exit, so that the caller will call back into us soon. */
|
||||
|
||||
return r;
|
||||
@@ -3420,25 +3414,20 @@ _public_ int sd_bus_flush(sd_bus *bus) {
|
||||
|
||||
for (;;) {
|
||||
r = dispatch_wqueue(bus);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_DISCONNECT(r)) {
|
||||
bus_enter_closing(bus);
|
||||
return -ECONNRESET;
|
||||
}
|
||||
|
||||
if (ERRNO_IS_NEG_DISCONNECT(r)) {
|
||||
bus_enter_closing(bus);
|
||||
return -ECONNRESET;
|
||||
} else if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (bus->wqueue_size <= 0)
|
||||
return 0;
|
||||
|
||||
r = bus_poll(bus, false, UINT64_MAX);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(r))
|
||||
continue;
|
||||
|
||||
if (ERRNO_IS_NEG_TRANSIENT(r))
|
||||
continue;
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -758,14 +758,12 @@ int device_read_uevent_file(sd_device *device) {
|
||||
path = strjoina(syspath, "/uevent");
|
||||
|
||||
r = read_full_virtual_file(path, &uevent, &uevent_len);
|
||||
if (r < 0) {
|
||||
if (r == -EACCES || ERRNO_IS_NEG_DEVICE_ABSENT(r))
|
||||
/* The uevent files may be write-only, the device may be already removed, or the device
|
||||
* may not have the uevent file. */
|
||||
if (r == -EACCES || ERRNO_IS_DEVICE_ABSENT(r))
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return log_device_debug_errno(device, r, "sd-device: Failed to read uevent file '%s': %m", path);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < uevent_len; i++)
|
||||
switch (state) {
|
||||
|
||||
@@ -658,12 +658,10 @@ static int journal_file_verify_header(JournalFile *f) {
|
||||
int r;
|
||||
|
||||
r = sd_id128_get_machine(&machine_id);
|
||||
if (r < 0) {
|
||||
if (!ERRNO_IS_MACHINE_ID_UNSET(r)) /* handle graceful if machine ID is not initialized yet */
|
||||
return r;
|
||||
|
||||
if (ERRNO_IS_NEG_MACHINE_ID_UNSET(r)) /* Gracefully handle the machine ID not being initialized yet */
|
||||
machine_id = SD_ID128_NULL;
|
||||
}
|
||||
else if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!sd_id128_equal(machine_id, f->header->machine_id))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EHOSTDOWN),
|
||||
@@ -2508,13 +2506,12 @@ int journal_file_append_entry(
|
||||
}
|
||||
|
||||
r = sd_id128_get_machine(&_machine_id);
|
||||
if (r < 0) {
|
||||
if (!ERRNO_IS_MACHINE_ID_UNSET(r))
|
||||
return r;
|
||||
|
||||
/* If the machine ID is not initialized yet, handle gracefully */
|
||||
if (ERRNO_IS_NEG_MACHINE_ID_UNSET(r))
|
||||
/* Gracefully handle the machine ID not being initialized yet */
|
||||
machine_id = NULL;
|
||||
} else
|
||||
else if (r < 0)
|
||||
return r;
|
||||
else
|
||||
machine_id = &_machine_id;
|
||||
|
||||
#if HAVE_GCRYPT
|
||||
|
||||
@@ -198,16 +198,14 @@ static int socket_recv_message(int fd, void *buf, size_t buf_size, uint32_t *ret
|
||||
assert(peek || (buf && buf_size > 0));
|
||||
|
||||
n = recvmsg_safe(fd, &msg, MSG_TRUNC | (peek ? MSG_PEEK : 0));
|
||||
if (n < 0) {
|
||||
if (n == -ENOBUFS)
|
||||
return log_debug_errno(n, "sd-netlink: kernel receive buffer overrun");
|
||||
if (ERRNO_IS_TRANSIENT(n)) {
|
||||
if (ret_mcast_group)
|
||||
*ret_mcast_group = 0;
|
||||
return 0;
|
||||
}
|
||||
if (n == -ENOBUFS)
|
||||
return log_debug_errno(n, "sd-netlink: kernel receive buffer overrun");
|
||||
else if (ERRNO_IS_NEG_TRANSIENT(n)) {
|
||||
if (ret_mcast_group)
|
||||
*ret_mcast_group = 0;
|
||||
return 0;
|
||||
} else if (n < 0)
|
||||
return (int) n;
|
||||
}
|
||||
|
||||
if (sender.nl.nl_pid != 0) {
|
||||
/* not from the kernel, ignore */
|
||||
|
||||
Reference in New Issue
Block a user