X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=597e8d25f9e97baf2852d468a2422d3ae7aa377a;hb=7e3e3582f6fc79c97b07fad7fa7019e8a80aeb0e;hp=c2e387017eb471660de7b1fa78b63e3bb4cb7098;hpb=40af9f9fb5d827c8c58e32efd6fca204da1194c8;p=babeltrace.git diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index c2e38701..597e8d25 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -159,6 +159,14 @@ struct bt_format ctf_format = { .convert_index_timestamp = ctf_convert_index_timestamp, }; +void bt_ctf_hook(void) +{ + /* + * Dummy function to prevent the linker from discarding this format as + * "unused" in static builds. + */ +} + static int ctf_timestamp_begin(struct bt_trace_descriptor *descriptor, struct bt_trace_handle *handle, enum bt_clock_type type, @@ -1789,7 +1797,7 @@ begin: fprintf(stderr, "[error] Unable to read packet header: %s\n", strerror(-ret)); return ret; } - len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("magic")); + len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_string("magic")); if (len_index >= 0) { struct bt_definition *field; uint64_t magic; @@ -1806,7 +1814,7 @@ begin: } /* check uuid */ - len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("uuid")); + len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_string("uuid")); if (len_index >= 0) { struct definition_array *defarray; struct bt_definition *field; @@ -1831,7 +1839,7 @@ begin: } } - len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("stream_id")); + len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_string("stream_id")); if (len_index >= 0) { struct bt_definition *field; @@ -1862,7 +1870,7 @@ begin: return ret; } /* read packet size from header */ - len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size")); + len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_string("packet_size")); if (len_index >= 0) { struct bt_definition *field; @@ -1874,7 +1882,7 @@ begin: } /* read content size from header */ - len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size")); + len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_string("content_size")); if (len_index >= 0) { struct bt_definition *field; @@ -1886,7 +1894,7 @@ begin: } /* read timestamp begin from header */ - len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_begin")); + len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_string("timestamp_begin")); if (len_index >= 0) { struct bt_definition *field; @@ -1901,7 +1909,7 @@ begin: } /* read timestamp end from header */ - len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_end")); + len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_string("timestamp_end")); if (len_index >= 0) { struct bt_definition *field; @@ -1916,7 +1924,7 @@ begin: } /* read events discarded from header */ - len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("events_discarded")); + len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_string("events_discarded")); if (len_index >= 0) { struct bt_definition *field; @@ -1928,7 +1936,7 @@ begin: /* read packet_seq_num from header */ len_index = bt_struct_declaration_lookup_field_index( file_stream->parent.stream_packet_context->declaration, - g_quark_from_static_string("packet_seq_num")); + g_quark_from_string("packet_seq_num")); if (len_index >= 0) { struct bt_definition *field; @@ -2491,8 +2499,10 @@ struct bt_trace_descriptor *ctf_open_trace(const char *path, int flags, return &td->parent; error: - trace_debug_info_destroy(td); - g_free(td); + if (td) { + trace_debug_info_destroy(td); + g_free(td); + } return NULL; } @@ -2846,7 +2856,7 @@ void __attribute__((constructor)) ctf_init(void) { int ret; - ctf_format.name = g_quark_from_static_string("ctf"); + ctf_format.name = g_quark_from_string("ctf"); ret = bt_register_format(&ctf_format); assert(!ret); }