- case CTF_TYPE_SEQUENCE:
- {
- struct bt_ctf_field_type_sequence *sequence =
- container_of(type, struct bt_ctf_field_type_sequence,
+
+ element_type = bt_ctf_field_type_sequence_get_element_type(type);
+ if (!element_type) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_ctf_field_type_validate(element_type);
+
+end:
+ BT_PUT(element_type);
+
+ return ret;
+}
+
+static
+int bt_ctf_field_type_array_validate(struct bt_ctf_field_type *type)
+{
+ int ret = 0;
+ struct bt_ctf_field_type *element_type = NULL;
+
+ element_type = bt_ctf_field_type_array_get_element_type(type);
+ if (!element_type) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_ctf_field_type_validate(element_type);
+
+end:
+ BT_PUT(element_type);
+
+ return ret;
+}
+
+static
+int bt_ctf_field_type_structure_validate(struct bt_ctf_field_type *type)
+{
+ int ret = 0;
+ struct bt_ctf_field_type *child_type = NULL;
+ int field_count = bt_ctf_field_type_structure_get_field_count(type);
+ int i;
+
+ if (field_count < 0) {
+ ret = -1;
+ goto end;
+ }
+
+ for (i = 0; i < field_count; ++i) {
+ ret = bt_ctf_field_type_structure_get_field(type,
+ NULL, &child_type, i);
+ if (ret) {
+ goto end;
+ }
+
+ ret = bt_ctf_field_type_validate(child_type);
+ if (ret) {
+ goto end;
+ }
+
+ BT_PUT(child_type);
+ }
+
+end:
+ BT_PUT(child_type);
+
+ return ret;
+}
+
+static
+int bt_ctf_field_type_variant_validate(struct bt_ctf_field_type *type)
+{
+ int ret = 0;
+ int field_count;
+ struct bt_ctf_field_type *child_type = NULL;
+ struct bt_ctf_field_type_variant *variant =
+ container_of(type, struct bt_ctf_field_type_variant,