Add enum {} default mapping to "int" type
[babeltrace.git] / formats / ctf / metadata / ctf-visitor-generate-io-struct.c
index a2919ee2c7ce036b353e1002c1c05aba2d11bc05..a399066afc65b5e72f4368546b3319517f25aec4 100644 (file)
@@ -845,24 +845,28 @@ struct declaration *ctf_declaration_enum_visit(FILE *fd, int depth,
                        }
                }
                if (!container_type) {
-                               fprintf(fd, "[error] %s: missing container type for enumeration\n", __func__);
+                       declaration = lookup_declaration(g_quark_from_static_string("int"),
+                                                        declaration_scope);
+                       if (!declaration) {
+                               fprintf(fd, "[error] %s: \"int\" type declaration missing for enumeration\n", __func__);
                                return NULL;
-                       
-               }
-               switch (container_type->type) {
-               case NODE_INTEGER:
-               case NODE_TYPE_SPECIFIER:
+                       }
+               } else {
                        declaration = ctf_type_declarator_visit(fd, depth,
                                                container_type,
                                                &dummy_id, NULL,
                                                declaration_scope,
                                                NULL, trace);
-                       assert(declaration->id == CTF_TYPE_INTEGER);
-                       integer_declaration = container_of(declaration, struct declaration_integer, p);
-                       break;
-               default:
-                       assert(0);
                }
+               if (!declaration) {
+                       fprintf(fd, "[error] %s: unable to create container type for enumeration\n", __func__);
+                       return NULL;
+               }
+               if (declaration->id != CTF_TYPE_INTEGER) {
+                       fprintf(fd, "[error] %s: container type for enumeration is not integer\n", __func__);
+                       return NULL;
+               }
+               integer_declaration = container_of(declaration, struct declaration_integer, p);
                enum_declaration = enum_declaration_new(integer_declaration);
                declaration_unref(&integer_declaration->p);     /* leave ref to enum */
                cds_list_for_each_entry(iter, enumerator_list, siblings) {
@@ -1177,7 +1181,7 @@ struct declaration *ctf_type_specifier_list_visit(FILE *fd,
                        &node->u.integer.expressions, trace);
        case TYPESPEC_STRING:
                return ctf_declaration_string_visit(fd, depth,
-                       &first->u.string.expressions, trace);
+                       &node->u.string.expressions, trace);
        case TYPESPEC_STRUCT:
                return ctf_declaration_struct_visit(fd, depth,
                        node->u._struct.name,
@@ -1788,6 +1792,10 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node,
                                return ret;
                        }
                }
+               if (!trace->streams) {
+                       fprintf(fd, "[error] %s: missing trace declaration\n", __func__);
+                       return -EINVAL;
+               }
                cds_list_for_each_entry(iter, &node->u.root.stream, siblings) {
                        ret = ctf_stream_visit(fd, depth + 1, iter,
                                               trace->root_declaration_scope, trace);
This page took 0.025095 seconds and 4 git commands to generate.