mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 10:51:20 +03:00
bus: add macro for iterating through body parts of a message
This commit is contained in:
parent
13c299d3a8
commit
9b29bb6853
@ -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) {
|
||||
|
@ -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));
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user