babeltrace: do not use g_quark_from_static_string in unloadable code
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jérémie Galarneau
AppliedMerged, thanks!
Jérémie
Quoted 319 lines · Nathan Lynch
The GLib Quark documentation says that
g_quark_from_static_string:"... can only be used if the string will continue to exist until the
program terminates. It can be used with statically allocated strings in the main program, but not with statically allocated memory in dynamically loaded modules."https://developer.gnome.org/glib/stable/glib-Quarks.html#g-quark-from-static-string
Convert call sites of
g_quark_from_static_stringtog_quark_from_stringin code that is potentially unloadable. Call sites in the babeltrace main program remain unchanged.Signed-off-by Nathan Lynch <[email protected]>--- formats/bt-dummy/bt-dummy.c | 2 +- formats/ctf-metadata/ctf-metadata.c | 2 +- formats/ctf-text/ctf-text.c | 14 +++++++------- formats/ctf/ctf.c | 20 ++++++++++---------- .../ctf/metadata/ctf-visitor-generate-io-struct.c | 6 +++--- formats/lttng-live/lttng-live-comm.c | 2 +- formats/lttng-live/lttng-live-plugin.c | 2 +- lib/debug-info.c | 14 +++++++------- types/enum.c | 2 +- types/float.c | 12 ++++++------ 10 files changed, 38 insertions(+), 38 deletions(-)formats/bt-dummy/bt-dummy.c +1
-1@@ -79,7 +79,7 @@ void __attribute__((constructor)) bt_dummy_init(void) {int ret; - bt_dummy_format.name =g_quark_from_static_string ("dummy" ); + bt_dummy_format.name =g_quark_from_string ("dummy" ); ret =bt_register_format (&bt_dummy_format);assert (!ret); }formats/ctf-metadata/ctf-metadata.c +1
-1@@ -132,7 +132,7 @@ void __attribute__((constructor)) ctf_metadata_init(void) {int ret; - ctf_metadata_format.name =g_quark_from_static_string ("ctf-metadata" ); + ctf_metadata_format.name =g_quark_from_string ("ctf-metadata" ); ret =bt_register_format (&ctf_metadata_format);assert (!ret); }formats/ctf-text/ctf-text.c +7
-7@@ -123,12 +123,12 @@ static GQuark Q_STREAM_PACKET_CONTEXT_TIMESTAMP_BEGIN,static void __attribute__((constructor))init_quarks (void ) { -Q_STREAM_PACKET_CONTEXT_TIMESTAMP_BEGIN =g_quark_from_static_string ("stream.packet.context.timestamp_begin" ); -Q_STREAM_PACKET_CONTEXT_TIMESTAMP_END =g_quark_from_static_string ("stream.packet.context.timestamp_end" ); -Q_STREAM_PACKET_CONTEXT_EVENTS_DISCARDED =g_quark_from_static_string ("stream.packet.context.events_discarded" ); -Q_STREAM_PACKET_CONTEXT_CONTENT_SIZE =g_quark_from_static_string ("stream.packet.context.content_size" ); -Q_STREAM_PACKET_CONTEXT_PACKET_SIZE =g_quark_from_static_string ("stream.packet.context.packet_size" ); -Q_STREAM_PACKET_CONTEXT_PACKET_SEQ_NUM =g_quark_from_static_string ("stream.packet.context.packet_seq_num" ); +Q_STREAM_PACKET_CONTEXT_TIMESTAMP_BEGIN =g_quark_from_string ("stream.packet.context.timestamp_begin" ); +Q_STREAM_PACKET_CONTEXT_TIMESTAMP_END =g_quark_from_string ("stream.packet.context.timestamp_end" ); +Q_STREAM_PACKET_CONTEXT_EVENTS_DISCARDED =g_quark_from_string ("stream.packet.context.events_discarded" ); +Q_STREAM_PACKET_CONTEXT_CONTENT_SIZE =g_quark_from_string ("stream.packet.context.content_size" ); +Q_STREAM_PACKET_CONTEXT_PACKET_SIZE =g_quark_from_string ("stream.packet.context.packet_size" ); +Q_STREAM_PACKET_CONTEXT_PACKET_SEQ_NUM =g_quark_from_string ("stream.packet.context.packet_seq_num" ); } static@@ -605,7 +605,7 @@ void __attribute__((constructor)) ctf_text_init(void) {int ret; - ctf_text_format.name =g_quark_from_static_string ("text" ); + ctf_text_format.name =g_quark_from_string ("text" ); ret =bt_register_format (&ctf_text_format);assert (!ret); }formats/ctf/ctf.c +10
-10@@ -1789,7 +1789,7 @@ int create_stream_one_packet_index(struct ctf_stream_pos *pos,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 +1806,7 @@ int create_stream_one_packet_index(struct ctf_stream_pos *pos, }/* 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 +1831,7 @@ int create_stream_one_packet_index(struct ctf_stream_pos *pos, } } - 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 +1862,7 @@ int create_stream_one_packet_index(struct ctf_stream_pos *pos,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 +1874,7 @@ int create_stream_one_packet_index(struct ctf_stream_pos *pos, }/* 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 +1886,7 @@ int create_stream_one_packet_index(struct ctf_stream_pos *pos, }/* 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 +1901,7 @@ int create_stream_one_packet_index(struct ctf_stream_pos *pos, }/* 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 +1916,7 @@ int create_stream_one_packet_index(struct ctf_stream_pos *pos, }/* 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 +1928,7 @@ int create_stream_one_packet_index(struct ctf_stream_pos *pos,/* 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;@@ -2848,7 +2848,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); }formats/ctf/metadata/ctf-visitor-generate-io-struct.c +3
-3@@ -1114,7 +1114,7 @@ struct bt_declaration *ctf_declaration_enum_visit(FILE *fd, int depth, } }if (!container_type) { - declaration =bt_lookup_declaration (g_quark_from_static_string ("int" ), + declaration =bt_lookup_declaration (g_quark_from_string ("int" ), declaration_scope);if (!declaration) {fprintf (fd,"[error] %s: \"int\" type declaration missing for enumeration\n" , __func__);@@ -2075,7 +2075,7 @@ int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node,if (CTF_STREAM_FIELD_IS_SET (stream, stream_id)) {/* check that packet header has stream_id field. */ if (!trace->packet_header_decl - ||bt_struct_declaration_lookup_field_index (trace->packet_header_decl,g_quark_from_static_string ("stream_id" )) <0 ) { + ||bt_struct_declaration_lookup_field_index (trace->packet_header_decl,g_quark_from_string ("stream_id" )) <0 ) { ret = -EPERM ;fprintf (fd,"[error] %s: missing stream_id field in packet header declaration, but stream_id attribute is declared for stream.\n" , __func__); goto error;@@ -2293,7 +2293,7 @@ int ctf_trace_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_traceif (!CTF_TRACE_FIELD_IS_SET (trace, byte_order)) {/* check that the packet header contains a "magic" field */ if (!trace->packet_header_decl - ||bt_struct_declaration_lookup_field_index (trace->packet_header_decl,g_quark_from_static_string ("magic" )) <0 ) { + ||bt_struct_declaration_lookup_field_index (trace->packet_header_decl,g_quark_from_string ("magic" )) <0 ) { ret = -EPERM ;fprintf (fd,"[error] %s: missing both byte_order and packet header magic number in trace declaration\n" , __func__); goto error;formats/lttng-live/lttng-live-comm.c +1
-1@@ -1646,7 +1646,7 @@ int lttng_live_read(struct lttng_live_ctx *ctx) goto end; } - fmt_write =bt_lookup_format (g_quark_from_static_string ("text" )); + fmt_write =bt_lookup_format (g_quark_from_string ("text" ));if (!fmt_write) {fprintf (stderr,"[error] ctf-text error\n" ); goto end;formats/lttng-live/lttng-live-plugin.c +1
-1@@ -332,7 +332,7 @@ void __attribute__((constructor)) lttng_live_init(void) {int ret; - lttng_live_format.name =g_quark_from_static_string ("lttng-live" ); + lttng_live_format.name =g_quark_from_string ("lttng-live" ); ret =bt_register_format (<tng_live_format);assert (!ret); }lib/debug-info.c +7
-7@@ -66,17 +66,17 @@ struct debug_info {static int debug_info_init (struct debug_info *info) { - info->q_statedump_bin_info =g_quark_from_static_string ( + info->q_statedump_bin_info =g_quark_from_string ("lttng_ust_statedump:bin_info" ); - info->q_statedump_debug_link =g_quark_from_static_string ( + info->q_statedump_debug_link =g_quark_from_string ("lttng_ust_statedump:debug_link)" ); - info->q_statedump_build_id =g_quark_from_static_string ( + info->q_statedump_build_id =g_quark_from_string ("lttng_ust_statedump:build_id" ); - info->q_statedump_start =g_quark_from_static_string ( + info->q_statedump_start =g_quark_from_string ("lttng_ust_statedump:start" ); - info->q_dl_open =g_quark_from_static_string ("lttng_ust_dl:dlopen" ); - info->q_lib_load =g_quark_from_static_string ("lttng_ust_lib:load" ); - info->q_lib_unload =g_quark_from_static_string ("lttng_ust_lib:unload" ); + info->q_dl_open =g_quark_from_string ("lttng_ust_dl:dlopen" ); + info->q_lib_load =g_quark_from_string ("lttng_ust_lib:load" ); + info->q_lib_unload =g_quark_from_string ("lttng_ust_lib:unload" );return bin_info_init (); }types/enum.c +1
-1@@ -449,7 +449,7 @@ struct bt_definition * definition_integer_parent = enum_declaration->integer_declaration->p.definition_new (&enum_declaration->integer_declaration->p, _enum->p.scope, -g_quark_from_static_string ("container" ),0 ,NULL ); +g_quark_from_string ("container" ),0 ,NULL ); _enum->integer =container_of (definition_integer_parent, struct definition_integer, p);return &_enum->p;types/float.c +6
-7@@ -100,23 +100,23 @@ struct bt_definition * _float->p.path =bt_new_definition_path (parent_scope, field_name, root_name);if (float_declaration->byte_order ==LITTLE_ENDIAN ) { tmp = float_declaration->mantissa->p.definition_new (&float_declaration->mantissa->p, - _float->p.scope,g_quark_from_static_string ("mantissa" ),0 ,NULL ); + _float->p.scope,g_quark_from_string ("mantissa" ),0 ,NULL ); _float->mantissa = container_of(tmp, struct definition_integer, p); tmp = float_declaration->exp->p.definition_new (&float_declaration->exp->p, - _float->p.scope,g_quark_from_static_string ("exp" ),1 ,NULL ); + _float->p.scope,g_quark_from_string ("exp" ),1 ,NULL ); _float->exp = container_of(tmp, struct definition_integer, p); tmp = float_declaration->sign->p.definition_new (&float_declaration->sign->p, - _float->p.scope,g_quark_from_static_string ("sign" ),2 ,NULL ); + _float->p.scope,g_quark_from_string ("sign" ),2 ,NULL ); _float->sign = container_of(tmp, struct definition_integer, p); }else { tmp = float_declaration->sign->p.definition_new (&float_declaration->sign->p, - _float->p.scope,g_quark_from_static_string ("sign" ),0 ,NULL ); + _float->p.scope,g_quark_from_string ("sign" ),0 ,NULL ); _float->sign = container_of(tmp, struct definition_integer, p); tmp = float_declaration->exp->p.definition_new (&float_declaration->exp->p, - _float->p.scope,g_quark_from_static_string ("exp" ),1 ,NULL ); + _float->p.scope,g_quark_from_string ("exp" ),1 ,NULL ); _float->exp = container_of(tmp, struct definition_integer, p); tmp = float_declaration->mantissa->p.definition_new (&float_declaration->mantissa->p, - _float->p.scope,g_quark_from_static_string ("mantissa" ),2 ,NULL ); + _float->p.scope,g_quark_from_string ("mantissa" ),2 ,NULL ); _float->mantissa = container_of(tmp, struct definition_integer, p); } _float->p.ref =1 ; --2.5.5
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev