+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
#define log_debug_bus_message(m) \
do { \
sd_bus_message *_mm = (m); \
- log_debug("Got message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error=%s", \
+ log_debug("Got message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error-name=%s error-message=%s", \
bus_message_type_to_string(_mm->header->type), \
strna(sd_bus_message_get_sender(_mm)), \
strna(sd_bus_message_get_destination(_mm)), \
strna(sd_bus_message_get_member(_mm)), \
BUS_MESSAGE_COOKIE(_mm), \
_mm->reply_cookie, \
+ strna(_mm->error.name), \
strna(_mm->error.message)); \
} while (false)
assert(reply);
bus = reply->bus;
assert(bus);
- assert(bus->state == BUS_HELLO || bus->state == BUS_CLOSING);
+ assert(IN_SET(bus->state, BUS_HELLO, BUS_CLOSING));
r = sd_bus_message_get_errno(reply);
if (r > 0)
} else
a = *p;
- while (*a != ';' && *a != ',' && *a != 0) {
+ while (!IN_SET(*a, ';', ',', 0)) {
char c;
if (*a == '%') {
assert(*p);
assert(guid);
- while (**p != 0 && **p != ';') {
+ while (!IN_SET(**p, 0, ';')) {
r = parse_address_key(p, "guid", guid);
if (r < 0)
return r;
assert(*p);
assert(guid);
- while (**p != 0 && **p != ';') {
+ while (!IN_SET(**p, 0, ';')) {
r = parse_address_key(p, "guid", guid);
if (r < 0)
return r;
assert(*p);
assert(guid);
- while (**p != 0 && **p != ';') {
+ while (!IN_SET(**p, 0, ';')) {
r = parse_address_key(p, "guid", guid);
if (r < 0)
goto fail;
assert(*p);
assert(guid);
- while (**p != 0 && **p != ';') {
+ while (!IN_SET(**p, 0, ';')) {
r = parse_address_key(p, "guid", guid);
if (r < 0)
return r;
static void bus_enter_closing(sd_bus *bus) {
assert(bus);
- if (bus->state != BUS_OPENING &&
- bus->state != BUS_AUTHENTICATING &&
- bus->state != BUS_HELLO &&
- bus->state != BUS_RUNNING)
+ if (!IN_SET(bus->state, BUS_OPENING, BUS_AUTHENTICATING, BUS_HELLO, BUS_RUNNING))
return;
bus->state = BUS_CLOSING;
if (timeout == 0)
timeout = BUS_DEFAULT_TIMEOUT;
- return bus_message_seal(m, ++b->cookie, timeout);
+ return sd_bus_message_seal(m, ++b->cookie, timeout);
}
static int bus_remarshal_message(sd_bus *b, sd_bus_message **m) {
* pick a fixed, artificial one. We use (uint32_t) -1 rather
* than (uint64_t) -1 since dbus1 only had 32bit identifiers,
* even though kdbus can do 64bit. */
- return bus_message_seal(m, 0xFFFFFFFFULL, 0);
+ return sd_bus_message_seal(m, 0xFFFFFFFFULL, 0);
}
static int bus_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call, size_t *idx) {
return r;
if (*idx >= BUS_MESSAGE_SIZE(m))
- log_debug("Sent message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error=%s",
+ log_debug("Sent message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error-name=%s error-message=%s",
bus_message_type_to_string(m->header->type),
strna(sd_bus_message_get_sender(m)),
strna(sd_bus_message_get_destination(m)),
strna(sd_bus_message_get_member(m)),
BUS_MESSAGE_COOKIE(m),
m->reply_cookie,
+ strna(m->error.name),
strna(m->error.message));
return r;
int r, ret = 0;
assert(bus);
- assert(bus->state == BUS_RUNNING || bus->state == BUS_HELLO);
+ assert(IN_SET(bus->state, BUS_RUNNING, BUS_HELLO));
while (bus->wqueue_size > 0) {
assert(bus);
assert(m);
- assert(bus->state == BUS_RUNNING || bus->state == BUS_HELLO);
+ assert(IN_SET(bus->state, BUS_RUNNING, BUS_HELLO));
/* Note that the priority logic is only available on kdbus,
* where the rqueue is unused. We check the rqueue here
if (m->dont_send)
goto finish;
- if ((bus->state == BUS_RUNNING || bus->state == BUS_HELLO) && bus->wqueue_size <= 0) {
+ if (IN_SET(bus->state, BUS_RUNNING, BUS_HELLO) && bus->wqueue_size <= 0) {
size_t idx = 0;
r = bus_write_message(bus, m, hint_sync_call, &idx);
assert(bus);
- if (bus->state == BUS_UNSET || bus->state == BUS_CLOSED || bus->state == BUS_CLOSING)
+ if (IN_SET(bus->state, BUS_UNSET, BUS_CLOSED, BUS_CLOSING))
return -ENOTCONN;
if (bus->state == BUS_RUNNING)
return 1;
flags |= POLLIN;
- } else if (bus->state == BUS_RUNNING || bus->state == BUS_HELLO) {
+ } else if (IN_SET(bus->state, BUS_RUNNING, BUS_HELLO)) {
if (bus->rqueue_size <= 0)
flags |= POLLIN;
if (bus->wqueue_size > 0)
return 1;
}
- if (bus->state != BUS_RUNNING && bus->state != BUS_HELLO) {
+ if (!IN_SET(bus->state, BUS_RUNNING, BUS_HELLO)) {
*timeout_usec = (uint64_t) -1;
return 0;
}
* here (we leave that to the usual handling), we just verify
* we don't let any earlier msg through. */
- if (m->header->type != SD_BUS_MESSAGE_METHOD_RETURN &&
- m->header->type != SD_BUS_MESSAGE_METHOD_ERROR)
+ if (!IN_SET(m->header->type, SD_BUS_MESSAGE_METHOD_RETURN, SD_BUS_MESSAGE_METHOD_ERROR))
return -EIO;
if (m->reply_cookie != 1)
assert(bus);
assert(m);
- if (m->header->type != SD_BUS_MESSAGE_METHOD_RETURN &&
- m->header->type != SD_BUS_MESSAGE_METHOD_ERROR)
+ if (!IN_SET(m->header->type, SD_BUS_MESSAGE_METHOD_RETURN, SD_BUS_MESSAGE_METHOD_ERROR))
return 0;
if (m->destination && bus->unique_name && !streq_ptr(m->destination, bus->unique_name))
int r;
assert(bus);
- assert(bus->state == BUS_RUNNING || bus->state == BUS_HELLO);
+ assert(IN_SET(bus->state, BUS_RUNNING, BUS_HELLO));
r = process_timeout(bus);
if (r != 0)
}
s->match_callback.callback = callback;
- s->match_callback.cookie = ++bus->match_cookie;
if (bus->bus_client) {
enum bus_match_scope scope;
goto finish;
}
- r = bus_add_match_internal(bus, s->match_callback.match_string, components, n_components, s->match_callback.cookie);
+ r = bus_add_match_internal(bus, s->match_callback.match_string, components, n_components);
if (r < 0)
goto finish;