[lttng-dev] [PATCH] FIX: Align buffers on 4 bytes for 64bit access
Rongqing Li
rongqing.li at windriver.com
Thu May 15 21:29:57 EDT 2014
On 05/16/2014 03:36 AM, Jérémie Galarneau wrote:
> On Thu, May 15, 2014 at 4:57 AM, <rongqing.li at windriver.com> wrote:
>> From: Fredrik Markström <fredrik.markstrom at gmail.com>
>>
>> Signed-off-by: Fredrik Markstr枚m <fredrik.markstrom at gmail.com>
>> ---
>> formats/ctf/metadata/objstack.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/formats/ctf/metadata/objstack.c b/formats/ctf/metadata/objstack.c
>> index 9e264a4..9643b9b 100644
>> --- a/formats/ctf/metadata/objstack.c
>> +++ b/formats/ctf/metadata/objstack.c
>> @@ -118,6 +118,8 @@ void *objstack_alloc(struct objstack *objstack, size_t len)
>> struct objstack_node *last_node;
>> void *p;
>>
>> + len = (len + 3) & ~3;
>
> Please use the "ALIGN" macro defined in include/babeltrace/align.h.
> len = ALIGN(len, sizeof(unsigned long))
>
Hi Galarneau:
I think it is more explicit to make the address,which is allocated
by objstack_alloc, to align the sizeof(void*), not sizeof(long);
though the size of void* and long are same.
do you agree?
-Roy
> Also, the "data" member in struct objstack_node should be aligned.
>
> struct objstack_node {
> struct bt_list_head node;
> size_t len;
> size_t used_len;
> char __attribute__ ((aligned (sizeof(unsigned long)))) data[];
> };
>
> Thanks for bringing the problem to our attention! I'll wait for a v2.
>
> Regards,
> Jérémie
>
>> +
>> /* Get last node */
>> last_node = bt_list_entry(objstack->head.prev,
>> struct objstack_node, node);
>> --
>> 1.7.10.4
>>
>>
>> _______________________________________________
>> lttng-dev mailing list
>> lttng-dev at lists.lttng.org
>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
>
>
--
Best Reagrds,
Roy | RongQing Li
More information about the lttng-dev
mailing list