Create copy of integer declaration before applying base-16 for pointers
[babeltrace.git] / formats / ctf / metadata / ctf-visitor-generate-io-struct.c
index de760ca019f1e863f9f26e49989fd172c4e8bc47..507233c97cdf3b4fbdf4ce8e24548be2a8fb6967 100644 (file)
@@ -313,6 +313,22 @@ struct declaration *ctf_type_declarator_visit(FILE *fd, int depth,
                                fprintf(fd, "[error] %s: cannot find typealias \"%s\".\n", __func__, g_quark_to_string(alias_q));
                                return NULL;
                        }
+                       if (nested_declaration->id == CTF_TYPE_INTEGER) {
+                               struct declaration_integer *integer_declaration =
+                                       container_of(nested_declaration, struct declaration_integer, p);
+                               /* For base to 16 for pointers (expected pretty-print) */
+                               if (!integer_declaration->base) {
+                                       /*
+                                        * We need to do a copy of the
+                                        * integer declaration to modify it. There could be other references to
+                                        * it.
+                                        */
+                                       integer_declaration = integer_declaration_new(integer_declaration->len,
+                                               integer_declaration->byte_order, integer_declaration->signedness,
+                                               integer_declaration->p.alignment, 16);
+                                       nested_declaration = &integer_declaration->p;
+                               }
+                       }
                } else {
                        nested_declaration = ctf_type_specifier_list_visit(fd, depth,
                                type_specifier_list, declaration_scope, trace);
@@ -1069,7 +1085,7 @@ struct declaration *ctf_declaration_integer_visit(FILE *fd, int depth,
        int byte_order = trace->byte_order;
        int signedness = 0;
        int has_alignment = 0, has_size = 0;
-       int base = 10;
+       int base = 0;
        struct declaration_integer *integer_declaration;
 
        cds_list_for_each_entry(expression, expressions, siblings) {
This page took 0.02417 seconds and 4 git commands to generate.