mirror of
https://github.com/systemd/systemd.git
synced 2026-08-07 08:30:57 +00:00
libsystemd-bus: bring definitions in sync with kdbus
In particular, KDBUS_ITEM_NEXT is now called KDBUS_PART_NEXT, and KDBUS_ITEM_FOREACH was renamed to KDBUS_PART_FOREACH and takes one more argument to make it more flexible.
This commit is contained in:
@@ -507,7 +507,7 @@ int bus_add_match_internal(
|
||||
item->type = KDBUS_MATCH_BLOOM;
|
||||
memcpy(item->data64, bloom, BLOOM_SIZE);
|
||||
|
||||
item = KDBUS_ITEM_NEXT(item);
|
||||
item = KDBUS_PART_NEXT(item);
|
||||
}
|
||||
|
||||
if (sender) {
|
||||
|
||||
@@ -409,7 +409,7 @@ static void close_kdbus_msg(sd_bus *bus, struct kdbus_msg *k) {
|
||||
off = (uint8_t *)k - (uint8_t *)bus->kdbus_buffer;
|
||||
ioctl(bus->input_fd, KDBUS_CMD_MSG_RELEASE, &off);
|
||||
|
||||
KDBUS_ITEM_FOREACH(d, k) {
|
||||
KDBUS_PART_FOREACH(d, k, items) {
|
||||
|
||||
if (d->type == KDBUS_MSG_FDS)
|
||||
close_many(d->fds, (d->size - offsetof(struct kdbus_item, fds)) / sizeof(int));
|
||||
@@ -435,7 +435,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
|
||||
if (k->payload_type != KDBUS_PAYLOAD_DBUS1)
|
||||
return 0;
|
||||
|
||||
KDBUS_ITEM_FOREACH(d, k) {
|
||||
KDBUS_PART_FOREACH(d, k, items) {
|
||||
size_t l;
|
||||
|
||||
l = d->size - offsetof(struct kdbus_item, data);
|
||||
@@ -489,7 +489,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
KDBUS_ITEM_FOREACH(d, k) {
|
||||
KDBUS_PART_FOREACH(d, k, items) {
|
||||
size_t l;
|
||||
|
||||
l = d->size - offsetof(struct kdbus_item, data);
|
||||
@@ -685,13 +685,13 @@ int bus_kernel_create(const char *name, char **s) {
|
||||
|
||||
l = strlen(name);
|
||||
make = alloca0(offsetof(struct kdbus_cmd_bus_make, items) +
|
||||
KDBUS_ITEM_HEADER_SIZE + sizeof(uint64_t) +
|
||||
KDBUS_ITEM_HEADER_SIZE + DECIMAL_STR_MAX(uid_t) + 1 + l + 1);
|
||||
KDBUS_PART_HEADER_SIZE + sizeof(uint64_t) +
|
||||
KDBUS_PART_HEADER_SIZE + DECIMAL_STR_MAX(uid_t) + 1 + l + 1);
|
||||
|
||||
n = make->items;
|
||||
n->type = KDBUS_MAKE_NAME;
|
||||
sprintf(n->str, "%lu-%s", (unsigned long) getuid(), name);
|
||||
n->size = KDBUS_ITEM_HEADER_SIZE + strlen(n->str) + 1;
|
||||
n->size = KDBUS_PART_HEADER_SIZE + strlen(n->str) + 1;
|
||||
|
||||
make->size = offsetof(struct kdbus_cmd_bus_make, items) + n->size;
|
||||
make->flags = KDBUS_MAKE_POLICY_OPEN;
|
||||
|
||||
@@ -23,16 +23,16 @@
|
||||
|
||||
#include "sd-bus.h"
|
||||
|
||||
#define KDBUS_ITEM_NEXT(item) \
|
||||
#define KDBUS_PART_NEXT(item) \
|
||||
(typeof(item))(((uint8_t *)item) + ALIGN8((item)->size))
|
||||
|
||||
#define KDBUS_ITEM_FOREACH(item, head) \
|
||||
for (item = (head)->items; \
|
||||
(uint8_t *)(item) < (uint8_t *)(head) + (head)->size; \
|
||||
item = KDBUS_ITEM_NEXT(item))
|
||||
#define KDBUS_PART_FOREACH(part, head, first) \
|
||||
for (part = (head)->first; \
|
||||
(uint8_t *)(part) < (uint8_t *)(head) + (head)->size; \
|
||||
part = KDBUS_PART_NEXT(part))
|
||||
|
||||
#define KDBUS_ITEM_HEADER_SIZE offsetof(struct kdbus_item, data)
|
||||
#define KDBUS_ITEM_SIZE(s) ALIGN8((s) + KDBUS_ITEM_HEADER_SIZE)
|
||||
#define KDBUS_PART_HEADER_SIZE offsetof(struct kdbus_item, data)
|
||||
#define KDBUS_ITEM_SIZE(s) ALIGN8((s) + KDBUS_PART_HEADER_SIZE)
|
||||
|
||||
#define MEMFD_CACHE_MAX 32
|
||||
|
||||
|
||||
Reference in New Issue
Block a user