diff options
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r-- | src/libsystemd-bus/bus-kernel.c | 5 | ||||
-rw-r--r-- | src/libsystemd-bus/bus-message.c | 8 | ||||
-rw-r--r-- | src/libsystemd-bus/bus-message.h | 3 | ||||
-rw-r--r-- | src/libsystemd-bus/bus-socket.c | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c index 5b1769c0e1..3aa408414e 100644 --- a/src/libsystemd-bus/bus-kernel.c +++ b/src/libsystemd-bus/bus-kernel.c @@ -184,12 +184,13 @@ static int bus_message_setup_bloom(sd_bus_message *m, void *bloom) { } static int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) { + struct bus_body_part *part; struct kdbus_item *d; bool well_known; uint64_t unique; size_t sz, dl; + unsigned i; int r; - struct bus_body_part *part; assert(b); assert(m); @@ -253,7 +254,7 @@ static int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) { if (m->fields) append_payload_vec(&d, m->fields, ALIGN8(m->header->fields_size)); - for (part = &m->body; part && part->size > 0; part = part->next) + MESSAGE_FOREACH_PART(part, i, m) append_payload_vec(&d, part->data, part->size); if (m->kdbus->dst_id == KDBUS_DST_ID_BROADCAST) { diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c index 721dafe38b..3790102a75 100644 --- a/src/libsystemd-bus/bus-message.c +++ b/src/libsystemd-bus/bus-message.c @@ -3600,9 +3600,11 @@ int bus_message_seal(sd_bus_message *m, uint64_t serial) { m->header->fields_size -= a; } - for (i = 0, part = &m->body; i < m->n_body_parts; i++, part = part->next) - if (part->memfd >= 0 && part->sealed) + MESSAGE_FOREACH_PART(part, i, m) + if (part->memfd >= 0 && !part->sealed) { ioctl(part->memfd, KDBUS_CMD_MEMFD_SEAL_SET, 1); + part->sealed = true; + } m->header->serial = serial; m->sealed = true; @@ -3906,7 +3908,7 @@ int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz) { e = mempset(e, 0, 8 - (m->header->fields_size % 8)); } - for (i = 0, part = &m->body; i < m->n_body_parts; i++, part = part->next) + MESSAGE_FOREACH_PART(part, i, m) e = mempcpy(e, part->data, part->size); assert(total == (size_t) ((uint8_t*) e - (uint8_t*) p)); diff --git a/src/libsystemd-bus/bus-message.h b/src/libsystemd-bus/bus-message.h index 1c50c7357a..01a1e01230 100644 --- a/src/libsystemd-bus/bus-message.h +++ b/src/libsystemd-bus/bus-message.h @@ -217,3 +217,6 @@ int bus_message_parse_fields(sd_bus_message *m); int bus_header_size(struct bus_header *h, size_t *sum); struct bus_body_part *message_append_part(sd_bus_message *m); + +#define MESSAGE_FOREACH_PART(part, i, m) \ + for ((i) = 0, (part) = &(m)->body; (i) < (m)->n_body_parts; (i)++, (part) = (part)->next) diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c index 4a07869157..f43b7da05c 100644 --- a/src/libsystemd-bus/bus-socket.c +++ b/src/libsystemd-bus/bus-socket.c @@ -102,7 +102,7 @@ static int bus_message_setup_iovec(sd_bus_message *m) { return r; } - for (i = 0, part = &m->body; i < m->n_body_parts; i++, part = part->next) { + MESSAGE_FOREACH_PART(part, i, m) { r = append_iovec(m, part->data, part->size); if (r < 0) return r; |