kdbus-test: fix kdbus item alignment in kdbus_hello_registrar()
authorDjalal Harouni <tixxdz@opendz.org>
Wed, 11 Jun 2014 16:27:59 +0000 (17:27 +0100)
committerKay Sievers <kay@vrfy.org>
Thu, 12 Jun 2014 13:12:54 +0000 (15:12 +0200)
Currently running the test-kdbus-activator test will fail with -EINVAL

To fix this, remove the redundant offsetof() macros since it is already
handled. The KDBUS_ITEM_SIZE() will expand into KDBUS_ITEM_HEADER_SIZE()
which expands into an offsetof() one.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test/kdbus-util.c

index 531626323b4d2763f733594a71cb31bad9b9d511..7a6f27297e9c949ba747cd04075dfc453488ee94 100644 (file)
@@ -117,20 +117,19 @@ kdbus_hello_registrar(const char *path, const char *name,
        struct kdbus_item *item, *items;
        size_t i, size;
 
-       size = KDBUS_ITEM_SIZE(offsetof(struct kdbus_item, str) + strlen(name) + 1)
-               + num_access * KDBUS_ITEM_SIZE(offsetof(struct kdbus_item, policy_access) +
-                                              sizeof(struct kdbus_policy_access));
+       size = KDBUS_ITEM_SIZE(strlen(name) + 1)
+               + num_access * KDBUS_ITEM_SIZE(sizeof(struct kdbus_policy_access));
 
        items = alloca(size);
 
        item = items;
-       item->size = offsetof(struct kdbus_item, str) + strlen(name) + 1;
+       item->size = KDBUS_ITEM_HEADER_SIZE + strlen(name) + 1;
        item->type = KDBUS_ITEM_NAME;
        strcpy(item->str, name);
        item = KDBUS_ITEM_NEXT(item);
 
        for (i = 0; i < num_access; i++) {
-               item->size = offsetof(struct kdbus_item, policy_access) +
+               item->size = KDBUS_ITEM_HEADER_SIZE +
                             sizeof(struct kdbus_policy_access);
                item->type = KDBUS_ITEM_POLICY_ACCESS;