return ret;
}
+BT_HIDDEN
+int bt_ctf_field_type_validate(struct bt_ctf_field_type *type)
+{
+ int ret = 0;
+
+ if (!type) {
+ ret = -1;
+ goto end;
+ }
+
+ if (type->declaration->id == CTF_TYPE_ENUM) {
+ struct bt_ctf_field_type_enumeration *enumeration =
+ container_of(type, struct bt_ctf_field_type_enumeration,
+ parent);
+
+ ret = enumeration->entries->len ? 0 : -1;
+ }
+end:
+ return ret;
+}
+
struct bt_ctf_field_type *bt_ctf_field_type_integer_create(unsigned int size)
{
struct bt_ctf_field_type_integer *integer =
if (!type || !field_type || type->frozen ||
validate_identifier(field_name) ||
- (type->declaration->id != CTF_TYPE_STRUCT)) {
+ (type->declaration->id != CTF_TYPE_STRUCT) ||
+ bt_ctf_field_type_validate(field_type)) {
goto end;
}
if (!type || !field_type || type->frozen ||
validate_identifier(field_name) ||
- (type->declaration->id != CTF_TYPE_VARIANT)) {
+ (type->declaration->id != CTF_TYPE_VARIANT) ||
+ bt_ctf_field_type_validate(field_type)) {
ret = -1;
goto end;
}
{
struct bt_ctf_field_type_array *array = NULL;
- if (!element_type || length == 0) {
+ if (!element_type || length == 0 ||
+ bt_ctf_field_type_validate(element_type)) {
goto error;
}
{
struct bt_ctf_field_type_sequence *sequence = NULL;
- if (!element_type || validate_identifier(length_field_name)) {
+ if (!element_type || validate_identifier(length_field_name) ||
+ bt_ctf_field_type_validate(element_type)) {
goto error;
}
struct metadata_context *context)
{
size_t entry;
- int ret = 0;
+ int ret;
struct bt_ctf_field_type_enumeration *enumeration = container_of(type,
struct bt_ctf_field_type_enumeration, parent);
+ ret = bt_ctf_field_type_validate(type);
+ if (ret) {
+ goto end;
+ }
+
g_string_append(context->string, "enum : ");
ret = bt_ctf_field_type_serialize(enumeration->container, context);
if (ret) {