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_string to
g_quark_from_string in code that is potentially unloadable. Call
sites in the babeltrace main program remain unchanged.
Signed-off-by: Nathan Lynch <nathan_lynch@mentor.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- 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);
}
ret = bt_register_format(&bt_dummy_format);
assert(!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);
}
ret = bt_register_format(&ctf_metadata_format);
assert(!ret);
}
static
void __attribute__((constructor)) init_quarks(void)
{
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");
- 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);
}
ret = bt_register_format(&ctf_text_format);
assert(!ret);
}
fprintf(stderr, "[error] Unable to read packet header: %s\n", strerror(-ret));
return ret;
}
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;
if (len_index >= 0) {
struct bt_definition *field;
uint64_t magic;
- 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;
if (len_index >= 0) {
struct definition_array *defarray;
struct bt_definition *field;
- 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;
if (len_index >= 0) {
struct bt_definition *field;
return ret;
}
/* read packet size from header */
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;
if (len_index >= 0) {
struct bt_definition *field;
}
/* read content size from header */
}
/* 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;
if (len_index >= 0) {
struct bt_definition *field;
}
/* read timestamp begin from header */
}
/* 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;
if (len_index >= 0) {
struct bt_definition *field;
}
/* read timestamp end from header */
}
/* 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;
if (len_index >= 0) {
struct bt_definition *field;
}
/* read events discarded from header */
}
/* 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;
if (len_index >= 0) {
struct bt_definition *field;
/* read packet_seq_num from header */
len_index = bt_struct_declaration_lookup_field_index(
file_stream->parent.stream_packet_context->declaration,
/* 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;
if (len_index >= 0) {
struct bt_definition *field;
- 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);
}
ret = bt_register_format(&ctf_format);
assert(!ret);
}
}
}
if (!container_type) {
}
}
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__);
declaration_scope);
if (!declaration) {
fprintf(fd, "[error] %s: \"int\" type declaration missing for enumeration\n", __func__);
if (CTF_STREAM_FIELD_IS_SET(stream, stream_id)) {
/* check that packet header has stream_id field. */
if (!trace->packet_header_decl
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;
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;
if (!CTF_TRACE_FIELD_IS_SET(trace, byte_order)) {
/* check that the packet header contains a "magic" field */
if (!trace->packet_header_decl
if (!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;
ret = -EPERM;
fprintf(fd, "[error] %s: missing both byte_order and packet header magic number in trace declaration\n", __func__);
goto error;
- 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;
if (!fmt_write) {
fprintf(stderr, "[error] ctf-text error\n");
goto end;
- 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);
}
ret = bt_register_format(<tng_live_format);
assert(!ret);
}
static
int debug_info_init(struct debug_info *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");
"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)");
"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");
"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");
"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();
}
return bin_info_init();
}
definition_integer_parent =
enum_declaration->integer_declaration->p.definition_new(&enum_declaration->integer_declaration->p,
_enum->p.scope,
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;
_enum->integer = container_of(definition_integer_parent,
struct definition_integer, p);
return &_enum->p;
_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.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->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->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->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->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->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;
_float->mantissa = container_of(tmp, struct definition_integer, p);
}
_float->p.ref = 1;