Add empty plug-in hooks to prevent their elimination by the linker
[babeltrace.git] / formats / ctf / ctf.c
index c2e387017eb471660de7b1fa78b63e3bb4cb7098..597e8d25f9e97baf2852d468a2422d3ae7aa377a 100644 (file)
@@ -36,7 +36,7 @@
 #include <babeltrace/context-internal.h>
 #include <babeltrace/compat/uuid.h>
 #include <babeltrace/endian.h>
-#include <babeltrace/trace-debuginfo.h>
+#include <babeltrace/trace-debug-info.h>
 #include <babeltrace/ctf/ctf-index.h>
 #include <inttypes.h>
 #include <stdio.h>
@@ -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);
 }
This page took 0.026057 seconds and 4 git commands to generate.