Fix: Don't assert on metadata generation failure
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 24 Feb 2014 15:30:50 +0000 (10:30 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 25 Feb 2014 18:37:14 +0000 (13:37 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/writer/writer.c

index a3ca263adeca7a9eb934ea6dd74432262e7e02b9..3630b36b177abb9c253451419b5b10f8a9e90f3a 100644 (file)
@@ -357,7 +357,7 @@ const char *get_byte_order_string(int byte_order)
 }
 
 static
-void append_trace_metadata(struct bt_ctf_writer *writer,
+int append_trace_metadata(struct bt_ctf_writer *writer,
                struct metadata_context *context)
 {
        unsigned char *uuid = writer->uuid;
@@ -382,10 +382,14 @@ void append_trace_metadata(struct bt_ctf_writer *writer,
        g_string_assign(context->field_name, "");
        ret = bt_ctf_field_type_serialize(writer->trace_packet_header_type,
                context);
-       assert(!ret);
+       if (ret) {
+               goto end;
+       }
        context->current_indentation_level--;
 
        g_string_append(context->string, ";\n};\n\n");
+end:
+       return ret;
 }
 
 static
@@ -429,7 +433,9 @@ char *bt_ctf_writer_get_metadata_string(struct bt_ctf_writer *writer)
        context->field_name = g_string_sized_new(DEFAULT_IDENTIFIER_SIZE);
        context->string = g_string_sized_new(DEFAULT_METADATA_STRING_SIZE);
        g_string_append(context->string, "/* CTF 1.8 */\n\n");
-       append_trace_metadata(writer, context);
+       if (append_trace_metadata(writer, context)) {
+               goto error;
+       }
        append_env_metadata(writer, context);
        g_ptr_array_foreach(writer->clocks,
                (GFunc)bt_ctf_clock_serialize, context);
This page took 0.024253 seconds and 4 git commands to generate.