From fe37651c7264f73494a1c2f711980d7aaba16813 Mon Sep 17 00:00:00 2001 From: Radoslaw Pajak Date: Wed, 18 Dec 2013 10:14:37 +0100 Subject: [PATCH 1/1] [rename] renamed kdbus related macros KDBUS_PART_HEADER_SIZE renamed to KDBUS_ITEM_HEADER_SIZE KDBUS_PART_SIZE renamed to KDBUS_ITEM_SIZE to become not confusing and to fit kdbus naming convention changes. Change-Id: I9c2b607185831f9cd317274dc3240733b1498c74 Signed-off-by: Radoslaw Pajak --- bus/kdbus-d.c | 28 ++++++++++++++-------------- dbus/dbus-transport-kdbus.c | 38 +++++++++++++++++++------------------- dbus/kdbus-common.h | 4 ++-- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/bus/kdbus-d.c b/bus/kdbus-d.c index 487110c..c926c32 100644 --- a/bus/kdbus-d.c +++ b/bus/kdbus-d.c @@ -127,7 +127,7 @@ dbus_bool_t add_match_kdbus (DBusTransport* transport, __u64 id, const char *rul /*parsing rule and calculating size of command*/ size = sizeof(struct kdbus_cmd_match); if(parse_match_key(rule, "interface='", &pInterface)) /*actual size is not important for interface because bloom size is defined by bus*/ - size += KDBUS_PART_HEADER_SIZE + bloom_size; + size += KDBUS_ITEM_HEADER_SIZE + bloom_size; name_size = parse_match_key(rule, "sender='", &pName); if(name_size) { @@ -138,7 +138,7 @@ dbus_bool_t add_match_kdbus (DBusTransport* transport, __u64 id, const char *rul pName = NULL; } else - size += KDBUS_PART_SIZE(name_size + 1); //well known name + size += KDBUS_ITEM_SIZE(name_size + 1); //well known name } pCmd_match = alloca(size); @@ -154,14 +154,14 @@ dbus_bool_t add_match_kdbus (DBusTransport* transport, __u64 id, const char *rul if(pName) { pItem->type = KDBUS_MATCH_SRC_NAME; - pItem->size = KDBUS_PART_HEADER_SIZE + name_size + 1; + pItem->size = KDBUS_ITEM_HEADER_SIZE + name_size + 1; memcpy(pItem->str, pName, strlen(pName) + 1); pItem = KDBUS_PART_NEXT(pItem); } if(pInterface) { pItem->type = KDBUS_MATCH_BLOOM; - pItem->size = KDBUS_PART_HEADER_SIZE + bloom_size; + pItem->size = KDBUS_ITEM_HEADER_SIZE + bloom_size; strncpy(pItem->data, pInterface, bloom_size); } @@ -280,7 +280,7 @@ int kdbus_NameQuery(const char* name, DBusTransport* transport, struct nameInfo* if(item->type == KDBUS_ITEM_SECLABEL) { - pInfo->sec_label_len = item->size - KDBUS_PART_HEADER_SIZE - 1; + pInfo->sec_label_len = item->size - KDBUS_ITEM_HEADER_SIZE - 1; if(pInfo->sec_label_len != 0) { pInfo->sec_label = malloc(pInfo->sec_label_len); @@ -336,7 +336,7 @@ char* make_kdbus_bus(DBusBusType type, const char* address, DBusError *error) return NULL; } - bus_make_size = sizeof(struct kdbus_cmd_make) + KDBUS_PART_SIZE(name_size) + KDBUS_PART_SIZE(sizeof(__u64)); + bus_make_size = sizeof(struct kdbus_cmd_make) + KDBUS_ITEM_SIZE(name_size) + KDBUS_ITEM_SIZE(sizeof(__u64)); bus_make = alloca(bus_make_size); if (!bus_make) { @@ -352,7 +352,7 @@ char* make_kdbus_bus(DBusBusType type, const char* address, DBusError *error) item = bus_make->items; item->type = KDBUS_ITEM_MAKE_NAME; - item->size = KDBUS_PART_HEADER_SIZE + name_size; + item->size = KDBUS_ITEM_HEADER_SIZE + name_size; if(type == DBUS_BUS_SYSTEM) sprintf(name, "%u-kdbus-%s", getuid(), "system"); else if(type == DBUS_BUS_SESSION) @@ -363,7 +363,7 @@ char* make_kdbus_bus(DBusBusType type, const char* address, DBusError *error) item = KDBUS_PART_NEXT(item); item->type = KDBUS_ITEM_BLOOM_SIZE; - item->size = KDBUS_PART_HEADER_SIZE + sizeof(__u64); + item->size = KDBUS_ITEM_HEADER_SIZE + sizeof(__u64); item->data64[0] = 64; addr_value = strchr(address, ':') + 1; @@ -432,7 +432,7 @@ static dbus_bool_t add_matches_for_kdbus_broadcasts(DBusConnection* connection) } size = sizeof(struct kdbus_cmd_match); - size += KDBUS_PART_SIZE(1)*3 + KDBUS_PART_SIZE(sizeof(__u64))*2; /*3 name related items plus 2 id related items*/ + size += KDBUS_ITEM_SIZE(1)*3 + KDBUS_ITEM_SIZE(sizeof(__u64))*2; /*3 name related items plus 2 id related items*/ pCmd_match = alloca(size); if(pCmd_match == NULL) @@ -448,20 +448,20 @@ static dbus_bool_t add_matches_for_kdbus_broadcasts(DBusConnection* connection) pItem = pCmd_match->items; pItem->type = KDBUS_MATCH_NAME_CHANGE; - pItem->size = KDBUS_PART_HEADER_SIZE + 1; + pItem->size = KDBUS_ITEM_HEADER_SIZE + 1; pItem = KDBUS_PART_NEXT(pItem); pItem->type = KDBUS_MATCH_NAME_ADD; - pItem->size = KDBUS_PART_HEADER_SIZE + 1; + pItem->size = KDBUS_ITEM_HEADER_SIZE + 1; pItem = KDBUS_PART_NEXT(pItem); pItem->type = KDBUS_MATCH_NAME_REMOVE; - pItem->size = KDBUS_PART_HEADER_SIZE + 1; + pItem->size = KDBUS_ITEM_HEADER_SIZE + 1; pItem = KDBUS_PART_NEXT(pItem); pItem->type = KDBUS_MATCH_ID_ADD; - pItem->size = KDBUS_PART_HEADER_SIZE + sizeof(__u64); + pItem->size = KDBUS_ITEM_HEADER_SIZE + sizeof(__u64); pItem->id = KDBUS_MATCH_SRC_ID_ANY; pItem = KDBUS_PART_NEXT(pItem); pItem->type = KDBUS_MATCH_ID_REMOVE; - pItem->size = KDBUS_PART_HEADER_SIZE + sizeof(__u64); + pItem->size = KDBUS_ITEM_HEADER_SIZE + sizeof(__u64); pItem->id = KDBUS_MATCH_SRC_ID_ANY; if(ioctl(fd, KDBUS_CMD_MATCH_ADD, pCmd_match)) diff --git a/dbus/dbus-transport-kdbus.c b/dbus/dbus-transport-kdbus.c index 902116d..d590a02 100644 --- a/dbus/dbus-transport-kdbus.c +++ b/dbus/dbus-transport-kdbus.c @@ -85,7 +85,7 @@ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string)) \ #define MSG_ITEM_BUILD_VEC(data, datasize) \ item->type = KDBUS_ITEM_PAYLOAD_VEC; \ - item->size = KDBUS_PART_HEADER_SIZE + sizeof(struct kdbus_vec); \ + item->size = KDBUS_ITEM_HEADER_SIZE + sizeof(struct kdbus_vec); \ item->vec.address = (unsigned long) data; \ item->vec.size = datasize; @@ -285,26 +285,26 @@ static struct kdbus_msg* kdbus_init_msg(const char* name, __u64 dst_id, uint64_t msg_size = sizeof(struct kdbus_msg); if(use_memfd == TRUE) // bulk data - memfd - msg_size += KDBUS_PART_SIZE(sizeof(struct kdbus_memfd)); + msg_size += KDBUS_ITEM_SIZE(sizeof(struct kdbus_memfd)); else { - msg_size += KDBUS_PART_SIZE(sizeof(struct kdbus_vec)); //header is a must + msg_size += KDBUS_ITEM_SIZE(sizeof(struct kdbus_vec)); //header is a must while(body_size > KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE) { - msg_size += KDBUS_PART_SIZE(sizeof(struct kdbus_vec)); + msg_size += KDBUS_ITEM_SIZE(sizeof(struct kdbus_vec)); body_size -= KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE; } if(body_size) - msg_size += KDBUS_PART_SIZE(sizeof(struct kdbus_vec)); + msg_size += KDBUS_ITEM_SIZE(sizeof(struct kdbus_vec)); } if(fds_count) - msg_size += KDBUS_PART_SIZE(sizeof(int)*fds_count); + msg_size += KDBUS_ITEM_SIZE(sizeof(int)*fds_count); if (name) - msg_size += KDBUS_PART_SIZE(strlen(name) + 1); + msg_size += KDBUS_ITEM_SIZE(strlen(name) + 1); else if (dst_id == KDBUS_DST_ID_BROADCAST) - msg_size += KDBUS_PART_HEADER_SIZE + transport->bloom_size; + msg_size += KDBUS_ITEM_HEADER_SIZE + transport->bloom_size; msg = malloc(msg_size); if (!msg) @@ -419,7 +419,7 @@ static int kdbus_write_msg(DBusTransportKdbus *transport, DBusMessage *message, } item->type = KDBUS_ITEM_PAYLOAD_MEMFD; - item->size = KDBUS_PART_HEADER_SIZE + sizeof(struct kdbus_memfd); + item->size = KDBUS_ITEM_HEADER_SIZE + sizeof(struct kdbus_memfd); item->memfd.size = ret_size; item->memfd.fd = transport->memfd; } @@ -454,7 +454,7 @@ static int kdbus_write_msg(DBusTransportKdbus *transport, DBusMessage *message, { item = KDBUS_PART_NEXT(item); item->type = KDBUS_ITEM_FDS; - item->size = KDBUS_PART_HEADER_SIZE + (sizeof(int) * fds_count); + item->size = KDBUS_ITEM_HEADER_SIZE + (sizeof(int) * fds_count); memcpy(item->fds, unix_fds, sizeof(int) * fds_count); } @@ -462,14 +462,14 @@ static int kdbus_write_msg(DBusTransportKdbus *transport, DBusMessage *message, { item = KDBUS_PART_NEXT(item); item->type = KDBUS_ITEM_DST_NAME; - item->size = KDBUS_PART_HEADER_SIZE + strlen(destination) + 1; - memcpy(item->str, destination, item->size - KDBUS_PART_HEADER_SIZE); + item->size = KDBUS_ITEM_HEADER_SIZE + strlen(destination) + 1; + memcpy(item->str, destination, item->size - KDBUS_ITEM_HEADER_SIZE); } else if (dst_id == KDBUS_DST_ID_BROADCAST) { item = KDBUS_PART_NEXT(item); item->type = KDBUS_ITEM_BLOOM; - item->size = KDBUS_PART_HEADER_SIZE + transport->bloom_size; + item->size = KDBUS_ITEM_HEADER_SIZE + transport->bloom_size; strncpy(item->data, dbus_message_get_interface(message), transport->bloom_size); } @@ -703,7 +703,7 @@ static int kdbus_message_size(const struct kdbus_msg* msg) KDBUS_PART_FOREACH(item, msg, items) { - if (item->size <= KDBUS_PART_HEADER_SIZE) + if (item->size <= KDBUS_ITEM_HEADER_SIZE) { _dbus_verbose(" +%s (%llu bytes) invalid data record\n", enum_MSG(item->type), item->size); return -1; @@ -762,7 +762,7 @@ static int kdbus_decode_msg(const struct kdbus_msg* msg, char *data, DBusTranspo KDBUS_PART_FOREACH(item, msg, items) { - if (item->size <= KDBUS_PART_HEADER_SIZE) + if (item->size <= KDBUS_ITEM_HEADER_SIZE) { _dbus_verbose(" +%s (%llu bytes) invalid data record\n", enum_MSG(item->type), item->size); break; //??? continue (because dbus will find error) or break @@ -813,7 +813,7 @@ static int kdbus_decode_msg(const struct kdbus_msg* msg, char *data, DBusTranspo { int i; - *n_fds = (item->size - KDBUS_PART_HEADER_SIZE) / sizeof(int); + *n_fds = (item->size - KDBUS_ITEM_HEADER_SIZE) / sizeof(int); memcpy(fds, item->fds, *n_fds * sizeof(int)); for (i = 0; i < *n_fds; i++) _dbus_fd_set_close_on_exec(fds[i]); @@ -841,7 +841,7 @@ static int kdbus_decode_msg(const struct kdbus_msg* msg, char *data, DBusTranspo case KDBUS_ITEM_CMDLINE: case KDBUS_ITEM_NAME: { - __u64 size = item->size - KDBUS_PART_HEADER_SIZE; + __u64 size = item->size - KDBUS_ITEM_HEADER_SIZE; const char *str = item->str; int count = 0; @@ -871,10 +871,10 @@ static int kdbus_decode_msg(const struct kdbus_msg* msg, char *data, DBusTranspo _dbus_verbose(" +%s (%llu bytes) len=%llu bytes)\n", enum_MSG(item->type), item->size, - (unsigned long long)item->size - KDBUS_PART_HEADER_SIZE); + (unsigned long long)item->size - KDBUS_ITEM_HEADER_SIZE); cap = item->data32; - n = (item->size - KDBUS_PART_HEADER_SIZE) / 4 / sizeof(uint32_t); + n = (item->size - KDBUS_ITEM_HEADER_SIZE) / 4 / sizeof(uint32_t); _dbus_verbose(" CapInh="); for (i = 0; i < n; i++) diff --git a/dbus/kdbus-common.h b/dbus/kdbus-common.h index d8572d6..14b62af 100644 --- a/dbus/kdbus-common.h +++ b/dbus/kdbus-common.h @@ -35,8 +35,8 @@ #define KDBUS_PART_NEXT(part) \ (typeof(part))(((uint8_t *)part) + KDBUS_ALIGN8((part)->size)) #define KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE 0x00800000 /* maximum size of message header and items */ -#define KDBUS_PART_HEADER_SIZE offsetof(struct kdbus_item, data) -#define KDBUS_PART_SIZE(s) KDBUS_ALIGN8((s) + KDBUS_PART_HEADER_SIZE) +#define KDBUS_ITEM_HEADER_SIZE offsetof(struct kdbus_item, data) +#define KDBUS_ITEM_SIZE(s) KDBUS_ALIGN8((s) + KDBUS_ITEM_HEADER_SIZE) //todo restore if DBus policy will be applied in kdbus somehow //#define POLICY_TO_KDBUS -- 2.7.4