Setting the alignment of sequences, arrays, variants and structures
makes no sense.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
unsigned int alignment)
{
int ret = 0;
+ enum ctf_type_id type_id;
/* Alignment must be bit-aligned (1) or byte aligned */
if (!type || type->frozen || (alignment != 1 && (alignment & 0x7))) {
goto end;
}
+ type_id = bt_ctf_field_type_get_type_id(type);
+ if (type_id == CTF_TYPE_UNKNOWN) {
+ ret = -1;
+ goto end;
+ }
+
if (type->declaration->id == CTF_TYPE_STRING &&
alignment != CHAR_BIT) {
ret = -1;
goto end;
}
+ if (type_id == CTF_TYPE_STRUCT || type_id == CTF_TYPE_VARIANT ||
+ type_id == CTF_TYPE_SEQUENCE || type_id == CTF_TYPE_ARRAY) {
+ /* Setting an alignment on these types makes no sense */
+ ret = -1;
+ goto end;
+ }
+
type->declaration->alignment = alignment;
ret = 0;
end: