[lttng-dev] [PATCH v2] Fix: Align buffers from objstack_alloc on sizeof(void *)
Jérémie Galarneau
jeremie.galarneau at efficios.com
Fri May 16 11:52:46 EDT 2014
#include <babeltrace/align.h> is missing. I've added it and merged.
Also, note that you should use git format-patch's
--subject-prefix="PATCH project_name" option. It makes it easier to
keep track of patches since this mailing list is shared between
multiple projects.
Thanks!
Jérémie
On Thu, May 15, 2014 at 10:10 PM, <rongqing.li at windriver.com> wrote:
> From: Fredrik Markström <fredrik.markstrom at gmail.com>
>
> The buffers from objstack_alloc will store the pointer, so it must
> be aligned on pointer, or else it will cause issue on the cpu
> which does not support unaligned addresses access
>
> Signed-off-by: Fredrik Markstrom <fredrik.markstrom at gmail.com>
> Signed-off-by: Roy Li <rongqing.li at windriver.com>
> ---
> formats/ctf/metadata/objstack.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/formats/ctf/metadata/objstack.c b/formats/ctf/metadata/objstack.c
> index 9e264a4..0e7d04e 100644
> --- a/formats/ctf/metadata/objstack.c
> +++ b/formats/ctf/metadata/objstack.c
> @@ -39,7 +39,7 @@ struct objstack_node {
> struct bt_list_head node;
> size_t len;
> size_t used_len;
> - char data[];
> + char __attribute__ ((aligned (sizeof(void *)))) data[];
> };
>
> BT_HIDDEN
> @@ -118,6 +118,8 @@ void *objstack_alloc(struct objstack *objstack, size_t len)
> struct objstack_node *last_node;
> void *p;
>
> + len = ALIGN(len, sizeof(void *));
> +
> /* Get last node */
> last_node = bt_list_entry(objstack->head.prev,
> struct objstack_node, node);
> --
> 1.7.10.4
>
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list