[systemd-devel] [PATCH 1/7] libsystemd-bus: bring definitions in sync with kdbus

Daniel Mack daniel at zonque.org
Tue Dec 3 23:49:25 PST 2013


On 12/04/2013 03:31 AM, Yin Kangkai wrote:
> On 2013-11-15, 19:32 +0100, Daniel Mack wrote:

>> diff --git a/src/libsystemd-bus/bus-kernel.h b/src/libsystemd-bus/bus-kernel.h
>> index c4573c9..69df4f4 100644
>> --- a/src/libsystemd-bus/bus-kernel.h
>> +++ b/src/libsystemd-bus/bus-kernel.h
>> @@ -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)
> 
> We missed this one? KDBUS_ITEM_SIZE/KDBUS_PART_SIZE
> 
> Actually, I have a stupid question, do we have any particular reason
> to use "part/PART"? giving the fact that we already have term "item"
> everywhere in the code...
> 
> struct kdbus_item, items, kdbus_msg.items...
> 
> My opinion, on the contrary, we should replace all the KDBUS_PART_xxx
> into KDBUS_ITEM_xxx, that seems more reasonable to me :)

Nope. A 'part' is more generic: anything that has size header and a
dynamic length is a 'part' and can be iterated over with
KDBUS_PART_FOREACH. Hence,  an 'item' is a 'part', but not vice versa.
See struct kdbus_name_list for example.


HTH,
Daniel



More information about the systemd-devel mailing list