From 46caf2cb05e3c88e0c42a8507aeb524b8d2fc6df Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 22 May 2015 16:31:59 -0400 Subject: [PATCH] Fix: Return a variant's alignment as 0 (undefined). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/event-types.c | 2 ++ include/babeltrace/ctf-ir/event-types.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/formats/ctf/ir/event-types.c b/formats/ctf/ir/event-types.c index b336889b..91ab78c8 100644 --- a/formats/ctf/ir/event-types.c +++ b/formats/ctf/ir/event-types.c @@ -1286,6 +1286,8 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_create( } bt_ctf_field_type_init(&variant->parent); + /* A variant's alignment is undefined */ + variant->parent.declaration->alignment = 0; return &variant->parent; error: return NULL; diff --git a/include/babeltrace/ctf-ir/event-types.h b/include/babeltrace/ctf-ir/event-types.h index 20069435..fdec2e07 100644 --- a/include/babeltrace/ctf-ir/event-types.h +++ b/include/babeltrace/ctf-ir/event-types.h @@ -697,7 +697,8 @@ extern int bt_ctf_field_type_string_set_encoding( * * @param type Field type. * - * Returns the field type's alignment on success, a negative value on error. + * Returns the field type's alignment on success, a negative value on error and + * 0 if the alignment is undefined (as in the case of a variant). */ extern int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type); -- 2.34.1