Fix ctf_clock_declaration_visit returning an error when reading a boolean
[babeltrace.git] / formats / ctf / metadata / ctf-visitor-generate-io-struct.c
index 0b93b7234cb443631b261c38cf43a7736ff41d03..559e97ecdf65b778034dbf28914036f79003b90d 100644 (file)
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
  */
 
 #include <stdio.h>
@@ -823,7 +831,6 @@ struct declaration *ctf_declaration_struct_visit(FILE *fd,
 {
        struct declaration_struct *struct_declaration;
        struct ctf_node *iter;
-       int ret;
 
        /*
         * For named struct (without body), lookup in
@@ -851,6 +858,8 @@ struct declaration *ctf_declaration_struct_visit(FILE *fd,
                        }
                }
                if (!bt_list_empty(min_align)) {
+                       int ret;
+
                        ret = get_unary_unsigned(min_align, &min_align_value);
                        if (ret) {
                                fprintf(fd, "[error] %s: unexpected unary expression for structure \"align\" attribute\n", __func__);
@@ -861,12 +870,16 @@ struct declaration *ctf_declaration_struct_visit(FILE *fd,
                struct_declaration = struct_declaration_new(declaration_scope,
                                                            min_align_value);
                bt_list_for_each_entry(iter, declaration_list, siblings) {
+                       int ret;
+
                        ret = ctf_struct_declaration_list_visit(fd, depth + 1, iter,
                                struct_declaration, trace);
                        if (ret)
                                goto error_free_declaration;
                }
                if (name) {
+                       int ret;
+
                        ret = register_struct_declaration(g_quark_from_string(name),
                                        struct_declaration,
                                        declaration_scope);
@@ -890,7 +903,6 @@ struct declaration *ctf_declaration_variant_visit(FILE *fd,
        struct declaration_untagged_variant *untagged_variant_declaration;
        struct declaration_variant *variant_declaration;
        struct ctf_node *iter;
-       int ret;
 
        /*
         * For named variant (without body), lookup in
@@ -916,12 +928,16 @@ struct declaration *ctf_declaration_variant_visit(FILE *fd,
                }
                untagged_variant_declaration = untagged_variant_declaration_new(declaration_scope);
                bt_list_for_each_entry(iter, declaration_list, siblings) {
+                       int ret;
+
                        ret = ctf_variant_declaration_list_visit(fd, depth + 1, iter,
                                untagged_variant_declaration, trace);
                        if (ret)
                                goto error;
                }
                if (name) {
+                       int ret;
+
                        ret = register_variant_declaration(g_quark_from_string(name),
                                        untagged_variant_declaration,
                                        declaration_scope);
@@ -1051,7 +1067,6 @@ struct declaration *ctf_declaration_enum_visit(FILE *fd, int depth,
        struct last_enum_value last_value;
        struct ctf_node *iter;
        GQuark dummy_id;
-       int ret;
 
        /*
         * For named enum (without body), lookup in
@@ -1107,12 +1122,16 @@ struct declaration *ctf_declaration_enum_visit(FILE *fd, int depth,
                        last_value.u.u = 0;
                }
                bt_list_for_each_entry(iter, enumerator_list, siblings) {
+                       int ret;
+
                        ret = ctf_enumerator_list_visit(fd, depth + 1, iter, enum_declaration,
                                        &last_value);
                        if (ret)
                                goto error;
                }
                if (name) {
+                       int ret;
+
                        ret = register_enum_declaration(g_quark_from_string(name),
                                        enum_declaration,
                                        declaration_scope);
@@ -2345,6 +2364,7 @@ int ctf_clock_declaration_visit(FILE *fd, int depth, struct ctf_node *node,
                                goto error;
                        }
                        clock->absolute = ret;
+                       ret = 0;
                } else {
                        fprintf(fd, "[warning] %s: attribute \"%s\" is unknown in clock declaration.\n", __func__, left);
                }
@@ -2612,6 +2632,7 @@ void callsite_free(gpointer data)
                g_free(callsite->file);
                g_free(callsite);
        }
+       g_free(cs_dups);
 }
 
 static
@@ -2959,18 +2980,20 @@ error:
 
 int ctf_destroy_metadata(struct ctf_trace *trace)
 {
-       int i, j, k;
+       int i;
        struct ctf_file_stream *metadata_stream;
 
        if (trace->streams) {
                for (i = 0; i < trace->streams->len; i++) {
                        struct ctf_stream_declaration *stream;
+                       int j;
 
                        stream = g_ptr_array_index(trace->streams, i);
                        if (!stream)
                                continue;
                        for (j = 0; j < stream->streams->len; j++) {
                                struct ctf_stream_definition *stream_def;
+                               int k;
 
                                stream_def = g_ptr_array_index(stream->streams, j);
                                if (!stream_def)
This page took 0.024439 seconds and 4 git commands to generate.