chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-bus: use IN_SET
[elogind.git]
/
src
/
libelogind
/
sd-bus
/
sd-bus.c
diff --git
a/src/libelogind/sd-bus/sd-bus.c
b/src/libelogind/sd-bus/sd-bus.c
index 5b679c056906a7727987bb9e6ab83552258a2afd..6d304719e61f55d82467123aac2e5805d8b14693 100644
(file)
--- a/
src/libelogind/sd-bus/sd-bus.c
+++ b/
src/libelogind/sd-bus/sd-bus.c
@@
-1,5
+1,3
@@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-318,10
+316,7
@@
_public_ int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t mask) {
assert_return(!IN_SET(bus->state, BUS_CLOSING, BUS_CLOSED), -EPERM);
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(!IN_SET(bus->state, BUS_CLOSING, BUS_CLOSED), -EPERM);
assert_return(!bus_pid_changed(bus), -ECHILD);
- if (b)
- bus->creds_mask |= mask;
- else
- bus->creds_mask &= ~mask;
+ SET_FLAG(bus->creds_mask, mask, b);
/* The well knowns we need unconditionally, so that matches can work */
bus->creds_mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES|SD_BUS_CREDS_UNIQUE_NAME;
/* The well knowns we need unconditionally, so that matches can work */
bus->creds_mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES|SD_BUS_CREDS_UNIQUE_NAME;
@@
-425,7
+420,7
@@
static int hello_callback(sd_bus_message *reply, void *userdata, sd_bus_error *e
}
static int bus_send_hello(sd_bus *bus) {
}
static int bus_send_hello(sd_bus *bus) {
- _cleanup_
bus_message_unref_
sd_bus_message *m = NULL;
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message *m = NULL;
int r;
assert(bus);
int r;
assert(bus);
@@
-538,7
+533,7
@@
static void skip_address_key(const char **p) {
*p += strcspn(*p, ",");
if (**p == ',')
*p += strcspn(*p, ",");
if (**p == ',')
- (*p)
++;
+ (*p)++;
}
static int parse_unix_address(sd_bus *b, const char **p, char **guid) {
}
static int parse_unix_address(sd_bus *b, const char **p, char **guid) {
@@
-703,7
+698,7
@@
static int parse_exec_address(sd_bus *b, const char **p, char **guid) {
goto fail;
}
goto fail;
}
- (*p)
++;
+ (*p)++;
if (ul >= n_argv) {
if (!GREEDY_REALLOC0(argv, allocated, ul + 2)) {
if (ul >= n_argv) {
if (!GREEDY_REALLOC0(argv, allocated, ul + 2)) {
@@
-1496,7
+1491,9
@@
static void bus_enter_closing(sd_bus *bus) {
}
_public_ sd_bus *sd_bus_ref(sd_bus *bus) {
}
_public_ sd_bus *sd_bus_ref(sd_bus *bus) {
- assert_return(bus, NULL);
+
+ if (!bus)
+ return NULL;
assert_se(REFCNT_INC(bus->n_ref) >= 2);
assert_se(REFCNT_INC(bus->n_ref) >= 2);
@@
-1688,7
+1685,7
@@
static int dispatch_wqueue(sd_bus *bus) {
* it got full, then all bets are off
* anyway. */
* it got full, then all bets are off
* anyway. */
- bus->wqueue_size
--;
+ bus->wqueue_size--;
sd_bus_message_unref(bus->wqueue[0]);
memmove(bus->wqueue, bus->wqueue + 1, sizeof(sd_bus_message*) * bus->wqueue_size);
bus->windex = 0;
sd_bus_message_unref(bus->wqueue[0]);
memmove(bus->wqueue, bus->wqueue + 1, sizeof(sd_bus_message*) * bus->wqueue_size);
bus->windex = 0;
@@
-1737,7
+1734,7
@@
static int dispatch_rqueue(sd_bus *bus, bool hint_priority, int64_t priority, sd
/* Dispatch a queued message */
*m = bus->rqueue[0];
/* Dispatch a queued message */
*m = bus->rqueue[0];
- bus->rqueue_size
--;
+ bus->rqueue_size--;
memmove(bus->rqueue, bus->rqueue + 1, sizeof(sd_bus_message*) * bus->rqueue_size);
return 1;
}
memmove(bus->rqueue, bus->rqueue + 1, sizeof(sd_bus_message*) * bus->rqueue_size);
return 1;
}
@@
-1754,7
+1751,7
@@
static int dispatch_rqueue(sd_bus *bus, bool hint_priority, int64_t priority, sd
}
static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie, bool hint_sync_call) {
}
static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie, bool hint_sync_call) {
- _cleanup_
bus_message_unref_
sd_bus_message *m = sd_bus_message_ref(_m);
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message *m = sd_bus_message_ref(_m);
int r;
assert_return(m, -EINVAL);
int r;
assert_return(m, -EINVAL);
@@
-1801,7
+1798,7
@@
static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie,
r = bus_write_message(bus, m, hint_sync_call, &idx);
if (r < 0) {
r = bus_write_message(bus, m, hint_sync_call, &idx);
if (r < 0) {
- if (
r == -ENOTCONN || r == -ECONNRESET || r == -EPIPE || r == -ESHUTDOWN
) {
+ if (
IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)
) {
bus_enter_closing(bus);
return -ECONNRESET;
}
bus_enter_closing(bus);
return -ECONNRESET;
}
@@
-1829,7
+1826,7
@@
static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie,
if (!GREEDY_REALLOC(bus->wqueue, bus->wqueue_allocated, bus->wqueue_size + 1))
return -ENOMEM;
if (!GREEDY_REALLOC(bus->wqueue, bus->wqueue_allocated, bus->wqueue_size + 1))
return -ENOMEM;
- bus->wqueue[bus->wqueue_size
++] = sd_bus_message_ref(m);
+ bus->wqueue[bus->wqueue_size++] = sd_bus_message_ref(m);
}
finish:
}
finish:
@@
-1904,8
+1901,8
@@
_public_ int sd_bus_call_async(
void *userdata,
uint64_t usec) {
void *userdata,
uint64_t usec) {
- _cleanup_
bus_message_unref_
sd_bus_message *m = sd_bus_message_ref(_m);
- _cleanup_
bus_slot_unref_
sd_bus_slot *s = NULL;
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message *m = sd_bus_message_ref(_m);
+ _cleanup_
(sd_bus_slot_unrefp)
sd_bus_slot *s = NULL;
int r;
assert_return(m, -EINVAL);
int r;
assert_return(m, -EINVAL);
@@
-2003,7
+2000,7
@@
_public_ int sd_bus_call(
sd_bus_error *error,
sd_bus_message **reply) {
sd_bus_error *error,
sd_bus_message **reply) {
- _cleanup_
bus_message_unref_
sd_bus_message *m = sd_bus_message_ref(_m);
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message *m = sd_bus_message_ref(_m);
usec_t timeout;
uint64_t cookie;
unsigned i;
usec_t timeout;
uint64_t cookie;
unsigned i;
@@
-2108,7
+2105,7
@@
_public_ int sd_bus_call(
r = bus_read_message(bus, false, 0);
if (r < 0) {
r = bus_read_message(bus, false, 0);
if (r < 0) {
- if (
r == -ENOTCONN || r == -ECONNRESET || r == -EPIPE || r == -ESHUTDOWN
) {
+ if (
IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)
) {
bus_enter_closing(bus);
r = -ECONNRESET;
}
bus_enter_closing(bus);
r = -ECONNRESET;
}
@@
-2141,7
+2138,7
@@
_public_ int sd_bus_call(
r = dispatch_wqueue(bus);
if (r < 0) {
r = dispatch_wqueue(bus);
if (r < 0) {
- if (
r == -ENOTCONN || r == -ECONNRESET || r == -EPIPE || r == -ESHUTDOWN
) {
+ if (
IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)
) {
bus_enter_closing(bus);
r = -ECONNRESET;
}
bus_enter_closing(bus);
r = -ECONNRESET;
}
@@
-2244,8
+2241,8
@@
_public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
}
static int process_timeout(sd_bus *bus) {
}
static int process_timeout(sd_bus *bus) {
- _cleanup_
bus_error_free_
sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
- _cleanup_
bus_message_unref_
sd_bus_message* m = NULL;
+ _cleanup_
(sd_bus_error_free)
sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message* m = NULL;
struct reply_callback *c;
sd_bus_slot *slot;
usec_t n;
struct reply_callback *c;
sd_bus_slot *slot;
usec_t n;
@@
-2281,7
+2278,7
@@
static int process_timeout(sd_bus *bus) {
slot = container_of(c, sd_bus_slot, reply_callback);
slot = container_of(c, sd_bus_slot, reply_callback);
- bus->iteration_counter
++;
+ bus->iteration_counter++;
bus->current_message = m;
bus->current_slot = sd_bus_slot_ref(slot);
bus->current_message = m;
bus->current_slot = sd_bus_slot_ref(slot);
@@
-2326,8
+2323,8
@@
static int process_hello(sd_bus *bus, sd_bus_message *m) {
}
static int process_reply(sd_bus *bus, sd_bus_message *m) {
}
static int process_reply(sd_bus *bus, sd_bus_message *m) {
- _cleanup_
bus_message_unref_
sd_bus_message *synthetic_reply = NULL;
- _cleanup_
bus_error_free_
sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message *synthetic_reply = NULL;
+ _cleanup_
(sd_bus_error_free)
sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
struct reply_callback *c;
sd_bus_slot *slot;
int r;
struct reply_callback *c;
sd_bus_slot *slot;
int r;
@@
-2406,7
+2403,7
@@
static int process_reply(sd_bus *bus, sd_bus_message *m) {
}
static int process_filter(sd_bus *bus, sd_bus_message *m) {
}
static int process_filter(sd_bus *bus, sd_bus_message *m) {
- _cleanup_
bus_error_free_
sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
+ _cleanup_
(sd_bus_error_free)
sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
struct filter_callback *l;
int r;
struct filter_callback *l;
int r;
@@
-2472,7
+2469,7
@@
static int process_match(sd_bus *bus, sd_bus_message *m) {
}
static int process_builtin(sd_bus *bus, sd_bus_message *m) {
}
static int process_builtin(sd_bus *bus, sd_bus_message *m) {
- _cleanup_
bus_message_unref_
sd_bus_message *reply = NULL;
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message *reply = NULL;
int r;
assert(bus);
int r;
assert(bus);
@@
-2604,7
+2601,7
@@
static int dispatch_track(sd_bus *bus) {
}
static int process_running(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **ret) {
}
static int process_running(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **ret) {
- _cleanup_
bus_message_unref_
sd_bus_message *m = NULL;
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message *m = NULL;
int r;
assert(bus);
int r;
assert(bus);
@@
-2668,7
+2665,7
@@
null_message:
}
static int process_closing(sd_bus *bus, sd_bus_message **ret) {
}
static int process_closing(sd_bus *bus, sd_bus_message **ret) {
- _cleanup_
bus_message_unref_
sd_bus_message *m = NULL;
+ _cleanup_
(sd_bus_message_unrefp)
sd_bus_message *m = NULL;
struct reply_callback *c;
int r;
struct reply_callback *c;
int r;
@@
-2677,7
+2674,7
@@
static int process_closing(sd_bus *bus, sd_bus_message **ret) {
c = ordered_hashmap_first(bus->reply_callbacks);
if (c) {
c = ordered_hashmap_first(bus->reply_callbacks);
if (c) {
- _cleanup_
bus_error_free_
sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
+ _cleanup_
(sd_bus_error_free)
sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
sd_bus_slot *slot;
/* First, fail all outstanding method calls */
sd_bus_slot *slot;
/* First, fail all outstanding method calls */
@@
-2793,7
+2790,7
@@
static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priorit
case BUS_OPENING:
r = bus_socket_process_opening(bus);
case BUS_OPENING:
r = bus_socket_process_opening(bus);
- if (
r == -ENOTCONN || r == -ECONNRESET || r == -EPIPE || r == -ESHUTDOWN
) {
+ if (
IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)
) {
bus_enter_closing(bus);
r = 1;
} else if (r < 0)
bus_enter_closing(bus);
r = 1;
} else if (r < 0)
@@
-2804,7
+2801,7
@@
static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priorit
case BUS_AUTHENTICATING:
r = bus_socket_process_authenticating(bus);
case BUS_AUTHENTICATING:
r = bus_socket_process_authenticating(bus);
- if (
r == -ENOTCONN || r == -ECONNRESET || r == -EPIPE || r == -ESHUTDOWN
) {
+ if (
IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)
) {
bus_enter_closing(bus);
r = 1;
} else if (r < 0)
bus_enter_closing(bus);
r = 1;
} else if (r < 0)
@@
-2818,7
+2815,7
@@
static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priorit
case BUS_RUNNING:
case BUS_HELLO:
r = process_running(bus, hint_priority, priority, ret);
case BUS_RUNNING:
case BUS_HELLO:
r = process_running(bus, hint_priority, priority, ret);
- if (
r == -ENOTCONN || r == -ECONNRESET || r == -EPIPE || r == -ESHUTDOWN
) {
+ if (
IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)
) {
bus_enter_closing(bus);
r = 1;
bus_enter_closing(bus);
r = 1;
@@
-2943,7
+2940,7
@@
_public_ int sd_bus_flush(sd_bus *bus) {
for (;;) {
r = dispatch_wqueue(bus);
if (r < 0) {
for (;;) {
r = dispatch_wqueue(bus);
if (r < 0) {
- if (
r == -ENOTCONN || r == -ECONNRESET || r == -EPIPE || r == -ESHUTDOWN
) {
+ if (
IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)
) {
bus_enter_closing(bus);
return -ECONNRESET;
}
bus_enter_closing(bus);
return -ECONNRESET;
}