[lttng-dev] [PATCH] FIX: Align buffers on 4 bytes for 64bit access

Jérémie Galarneau jeremie.galarneau at efficios.com
Thu May 15 15:36:51 EDT 2014


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))

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



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list