common: introduce bt_g_array_index
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 17 Oct 2023 18:52:38 +0000 (14:52 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 20 Oct 2023 23:29:14 +0000 (19:29 -0400)
Introduce bt_g_array_index, a wrapper to g_array_index, that adds a
check that the specified index does not go past the end of the array.

Use BT_ASSERT_DBG, so that it's enabled only in builds with debug mode
enabled.

The difficulty is that g_array_index is expected to yield an lvalue,
since some call sites take the address of what it yields, or assign to
it.  The way I found to make it work is to add a statement expression
that has no effect, and put the BT_ASSERT_DBG in it.

Change-Id: I280c0657ec6f1cadd01328eec79da5cefada5c31
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10905
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
24 files changed:
src/common/macros.h
src/ctf-writer/field-path.c
src/ctf-writer/field-types.c
src/ctf-writer/field-types.h
src/ctf-writer/fields.c
src/ctf-writer/resolve.c
src/lib/graph/component-class.c
src/lib/graph/component.c
src/lib/graph/graph.c
src/lib/integer-range-set.h
src/lib/plugin/plugin-so.c
src/lib/trace-ir/field-class.h
src/lib/trace-ir/field-path.h
src/lib/trace-ir/field.c
src/lib/trace-ir/trace-class.c
src/lib/trace-ir/trace.c
src/plugins/common/param-validation/param-validation.c
src/plugins/ctf/common/bfcr/bfcr.cpp
src/plugins/ctf/common/metadata/ctf-meta.hpp
src/plugins/ctf/common/msg-iter/msg-iter.cpp
src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp
src/plugins/text/details/write.c
tests/lib/test_graph_topo.c

index 533cb9fb56eab9127540004c533b38d86d8c74c1..ad4218c445f98caf104223b1499783f70ceb209d 100644 (file)
@@ -52,6 +52,10 @@ extern "C" {
                _ref;                   \
        })
 
+/* Wrapper for g_array_index that adds bound checking.  */
+#define bt_g_array_index(a, t, i)              \
+       g_array_index((a), t, ({ BT_ASSERT_DBG((i) < (a)->len); (i); }))
+
 /*
  * Copied from:
  * <https://stackoverflow.com/questions/37411809/how-to-elegantly-fix-this-unused-variable-warning/37412551#37412551>:
index 2d71d79f46b50752456da8d7f8ad832b05b2f37f..7689a6d8f842a9f7a9e51e808989a5e40dd3919d 100644 (file)
@@ -147,7 +147,7 @@ int bt_ctf_field_path_get_index(const struct bt_ctf_field_path *field_path,
                goto end;
        }
 
-       ret = g_array_index(field_path->indexes, int, index);
+       ret = bt_g_array_index(field_path->indexes, int, index);
 
 end:
        return ret;
index 50f943c351bba2b9cda84072e81a12ac5646ff07..a2986abf9c30545197bdd7030c7727814cc7758e 100644 (file)
@@ -516,7 +516,7 @@ int add_structure_variant_member(GArray *members,
 
        if (is_variant) {
                struct bt_ctf_field_type_common_variant_choice *choice =
-                       &g_array_index(members,
+                       &bt_g_array_index(members,
                                struct bt_ctf_field_type_common_variant_choice,
                                members->len - 1);
 
@@ -528,7 +528,7 @@ int add_structure_variant_member(GArray *members,
                BT_ASSERT_DBG(choice->ranges);
        } else {
                struct bt_ctf_field_type_common_structure_field *field =
-                       &g_array_index(members,
+                       &bt_g_array_index(members,
                                struct bt_ctf_field_type_common_structure_field,
                                members->len - 1);
 
@@ -2190,7 +2190,7 @@ int64_t bt_ctf_field_type_common_variant_find_choice_index(
 
                for (range_i = 0; range_i < choice->ranges->len; range_i++) {
                        struct bt_ctf_field_type_common_variant_choice_range *range =
-                               &g_array_index(
+                               &bt_g_array_index(
                                        choice->ranges,
                                        struct bt_ctf_field_type_common_variant_choice_range,
                                        range_i);
index fa6b96a4913bade3a7e4e075cf7b0cdad1b63ab4..064108cea58c8b9e30e0121402cb24bf79bad6a1 100644 (file)
        BT_CTF_ASSERT_PRE_HOT((_ft), (_name), ": ft-addr=%p", (_ft))
 
 #define BT_CTF_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(_ft, _index) \
-       (&g_array_index(((struct bt_ctf_field_type_common_structure *) (_ft))->fields, \
+       (&bt_g_array_index(((struct bt_ctf_field_type_common_structure *) (_ft))->fields, \
                struct bt_ctf_field_type_common_structure_field, (_index)))
 
 #define BT_CTF_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(_ft, _index)  \
-       (&g_array_index(((struct bt_ctf_field_type_common_variant *) (_ft))->choices, \
+       (&bt_g_array_index(((struct bt_ctf_field_type_common_variant *) (_ft))->choices, \
                struct bt_ctf_field_type_common_variant_choice, (_index)))
 
 struct bt_ctf_field_common;
index 3d6e35236ac61cde337b145524058e4690c4f9f8..e05bcbcba9bd28f4a485ccab39a2a96cc05150df 100644 (file)
@@ -163,7 +163,7 @@ int bt_ctf_field_common_string_initialize(struct bt_ctf_field_common *field,
        }
 
        g_array_set_size(string->buf, 1);
-       g_array_index(string->buf, char, 0) = '\0';
+       bt_g_array_index(string->buf, char, 0) = '\0';
        BT_LOGD("Initialized common string field object: addr=%p, ft-addr=%p",
                field, type);
 
index 33896051c5500f34008510029163efdecd0fcbb8..2ceaba3390ed9eb26652a73eafa51a89bb5d3d50 100644 (file)
@@ -541,7 +541,7 @@ int relative_ptokens_to_field_path(GList *ptokens,
                        }
 
                        for (i = 0; i < tail_field_path_len; i++) {
-                               int index = g_array_index(
+                               int index = bt_g_array_index(
                                        tail_field_path->indexes,
                                        int, i);
 
@@ -709,7 +709,7 @@ struct bt_ctf_field_type_common *field_path_to_field_type(
        for (i = 0; i < field_path->indexes->len; i++) {
                struct bt_ctf_field_type_common *child_type;
                int child_index =
-                       g_array_index(field_path->indexes, int, i);
+                       bt_g_array_index(field_path->indexes, int, i);
 
                /* Get child field type */
                child_type = bt_ctf_field_type_common_borrow_field_at_index(type,
@@ -827,9 +827,9 @@ int get_field_paths_lca_index(struct bt_ctf_field_path *field_path1,
                        break;
                }
 
-               target_index = g_array_index(field_path1->indexes, int,
+               target_index = bt_g_array_index(field_path1->indexes, int,
                        lca_index);
-               ctx_index = g_array_index(field_path2->indexes, int,
+               ctx_index = bt_g_array_index(field_path2->indexes, int,
                        lca_index);
 
                if (target_index != ctx_index) {
@@ -910,9 +910,9 @@ int validate_target_field_path(struct bt_ctf_field_path *target_field_path,
                 * Make sure the target field path is located before the
                 * context field path.
                 */
-               target_index = g_array_index(target_field_path->indexes,
+               target_index = bt_g_array_index(target_field_path->indexes,
                        int, lca_index);
-               ctx_index = g_array_index(ctx_field_path->indexes,
+               ctx_index = bt_g_array_index(ctx_field_path->indexes,
                        int, lca_index);
 
                if (target_index >= ctx_index) {
index 516c31f19ab1be814ca80688c87cca4b6a3df239..ae3e68715cfccec7754dcdbc0976607d713a5878 100644 (file)
@@ -39,7 +39,7 @@ void destroy_component_class(struct bt_object *obj)
        if (class->destroy_listeners) {
                for (i = class->destroy_listeners->len - 1; i >= 0; i--) {
                        struct bt_component_class_destroy_listener *listener =
-                               &g_array_index(class->destroy_listeners,
+                               &bt_g_array_index(class->destroy_listeners,
                                        struct bt_component_class_destroy_listener,
                                        i);
 
index e73a1c7a384e00a957bf2cddc48db09cd76f1a06..b5f4d28d3c6cbae59f371a615f6a46f88807657e 100644 (file)
@@ -133,7 +133,7 @@ void destroy_component(struct bt_object *obj)
 
        for (i = component->destroy_listeners->len - 1; i >= 0; i--) {
                struct bt_component_destroy_listener *listener =
-                       &g_array_index(component->destroy_listeners,
+                       &bt_g_array_index(component->destroy_listeners,
                                struct bt_component_destroy_listener, i);
 
                listener->func(component, listener->data);
@@ -610,7 +610,7 @@ void bt_component_remove_destroy_listener(struct bt_component *component,
 
        for (i = 0; i < component->destroy_listeners->len; i++) {
                struct bt_component_destroy_listener *listener =
-                       &g_array_index(component->destroy_listeners,
+                       &bt_g_array_index(component->destroy_listeners,
                                struct bt_component_destroy_listener, i);
 
                if (listener->func == func && listener->data == data) {
index d07762494966daaf7df3053abdf3216b7e3626cb..08d8846dcf79f467c204f0fdc08651ed5031cbd8 100644 (file)
@@ -929,7 +929,7 @@ enum bt_graph_listener_func_status bt_graph_notify_port_added(
 
        for (i = 0; i < listeners->len; i++) {
                struct bt_graph_listener_port_added *listener =
-                       &g_array_index(listeners,
+                       &bt_g_array_index(listeners,
                                struct bt_graph_listener_port_added, i);
 
 
index 69e51993ba5a5a16475e8e0d36e528a3e27507fb..c53a784976b92bdcc9181ba65cd8008b9b44c6a2 100644 (file)
@@ -17,7 +17,7 @@
 #include "object.h"
 
 #define BT_INTEGER_RANGE_SET_RANGE_AT_INDEX(_rs, _index)               \
-       (&g_array_index((_rs)->ranges, struct bt_integer_range, (_index)))
+       (&bt_g_array_index((_rs)->ranges, struct bt_integer_range, (_index)))
 
 struct bt_integer_range {
        union {
index 65ec447de3482cde9af315a229f643f9a6164fdf..6cb140801bd4874dc93999ae1bf373fb2c602658 100644 (file)
@@ -460,7 +460,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin,
                /* Find the corresponding component class descriptor entry */
                for (i = 0; i < comp_class_full_descriptors->len; i++) {
                        struct comp_class_full_descriptor *cc_full_descr =
-                               &g_array_index(comp_class_full_descriptors,
+                               &bt_g_array_index(comp_class_full_descriptors,
                                        struct comp_class_full_descriptor, i);
 
                        if (cur_cc_descr_attr->comp_class_descriptor !=
@@ -751,7 +751,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin,
        /* Add described component classes to plugin */
        for (i = 0; i < comp_class_full_descriptors->len; i++) {
                struct comp_class_full_descriptor *cc_full_descr =
-                       &g_array_index(comp_class_full_descriptors,
+                       &bt_g_array_index(comp_class_full_descriptors,
                                struct comp_class_full_descriptor, i);
                struct bt_component_class *comp_class = NULL;
                struct bt_component_class_source *src_comp_class = NULL;
index 29c4f72a92921004690eed2004eb412b939e8c93..159614a250905489687a92e885d9d0ce041120e4 100644 (file)
 #include <glib.h>
 
 #define BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(_fc, _index)              \
-       (&g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \
+       (&bt_g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \
                struct bt_field_class_enumeration_mapping, (_index)))
 
 #define BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(_mapping, _index)   \
-       (&g_array_index((_mapping)->ranges,                             \
+       (&bt_g_array_index((_mapping)->ranges,                          \
                struct bt_field_class_enumeration_mapping_range, (_index)))
 
 struct bt_field_class {
index fb07e11c313d191aeaadef7040184cf8e4482ef1..79e9d8f17b26d091ba2bea736191759afd7b9d2c 100644 (file)
@@ -37,7 +37,7 @@ struct bt_field_path_item *bt_field_path_borrow_item_by_index_inline(
 {
        BT_ASSERT_DBG(field_path);
        BT_ASSERT_DBG(index < field_path->items->len);
-       return &g_array_index(field_path->items, struct bt_field_path_item,
+       return &bt_g_array_index(field_path->items, struct bt_field_path_item,
                index);
 }
 
index 41ea5f642cb9ef11ebca33fd7acd707b62357ac1..d1906c5fdd89fb2a43eaf3d918db30551372038c 100644 (file)
@@ -389,7 +389,7 @@ struct bt_field *create_string_field(struct bt_field_class *fc)
        }
 
        g_array_set_size(string_field->buf, 1);
-       g_array_index(string_field->buf, char, 0) = '\0';
+       bt_g_array_index(string_field->buf, char, 0) = '\0';
        BT_LIB_LOGD("Created string field object: %!+f", string_field);
 
 end:
@@ -875,7 +875,7 @@ void clear_string_field(struct bt_field *field)
 
        BT_ASSERT_DBG(field);
        string_field->length = 0;
-       g_array_index(string_field->buf, char, 0) = '\0';
+       bt_g_array_index(string_field->buf, char, 0) = '\0';
        bt_field_set_single(field, true);
 }
 
index 9f7068a7d00311f7947564e48f675ab16d2b39e5..1518214999b29f28e62cc8f0ff0ac770db91e32a 100644 (file)
@@ -85,7 +85,7 @@ void destroy_trace_class(struct bt_object *obj)
                /* Call all the trace class destruction listeners */
                for (i = 0; i < tc->destruction_listeners->len; i++) {
                        struct bt_trace_class_destruction_listener_elem elem =
-                               g_array_index(tc->destruction_listeners,
+                               bt_g_array_index(tc->destruction_listeners,
                                                struct bt_trace_class_destruction_listener_elem, i);
 
                        if (elem.func) {
@@ -188,7 +188,7 @@ enum bt_trace_class_add_listener_status bt_trace_class_add_destruction_listener(
        /* Find the next available spot */
        for (i = 0; i < tc->destruction_listeners->len; i++) {
                struct bt_trace_class_destruction_listener_elem elem =
-                       g_array_index(tc->destruction_listeners,
+                       bt_g_array_index(tc->destruction_listeners,
                                struct bt_trace_class_destruction_listener_elem, i);
 
                if (!elem.func) {
@@ -215,7 +215,7 @@ static
 bool has_listener_id(const struct bt_trace_class *tc, uint64_t listener_id)
 {
        BT_ASSERT(listener_id < tc->destruction_listeners->len);
-       return (&g_array_index(tc->destruction_listeners,
+       return (&bt_g_array_index(tc->destruction_listeners,
                        struct bt_trace_class_destruction_listener_elem,
                        listener_id))->func;
 }
@@ -233,7 +233,7 @@ enum bt_trace_class_remove_listener_status bt_trace_class_remove_destruction_lis
                has_listener_id(tc, listener_id),
                "Trace class has no such trace class destruction listener ID: "
                "%![tc-]+T, %" PRIu64, tc, listener_id);
-       elem = &g_array_index(tc->destruction_listeners,
+       elem = &bt_g_array_index(tc->destruction_listeners,
                        struct bt_trace_class_destruction_listener_elem,
                        listener_id);
        BT_ASSERT(elem->func);
index e2a462ec8d6097a7b4da69428fd840855c35af03..982325f715ce5b0584d658e04e9593ee1cf41d33 100644 (file)
@@ -87,7 +87,7 @@ void destroy_trace(struct bt_object *obj)
                /* Call all the trace destruction listeners */
                for (i = 0; i < trace->destruction_listeners->len; i++) {
                        struct bt_trace_destruction_listener_elem elem =
-                               g_array_index(trace->destruction_listeners,
+                               bt_g_array_index(trace->destruction_listeners,
                                        struct bt_trace_destruction_listener_elem, i);
 
                        if (elem.func) {
@@ -453,7 +453,7 @@ enum bt_trace_add_listener_status bt_trace_add_destruction_listener(
        /* Find the next available spot */
        for (i = 0; i < trace->destruction_listeners->len; i++) {
                struct bt_trace_destruction_listener_elem elem =
-                       g_array_index(trace->destruction_listeners,
+                       bt_g_array_index(trace->destruction_listeners,
                                struct bt_trace_destruction_listener_elem, i);
 
                if (!elem.func) {
@@ -480,7 +480,7 @@ static
 bool has_listener_id(const struct bt_trace *trace, uint64_t listener_id)
 {
        BT_ASSERT(listener_id < trace->destruction_listeners->len);
-       return (&g_array_index(trace->destruction_listeners,
+       return (&bt_g_array_index(trace->destruction_listeners,
                        struct bt_trace_destruction_listener_elem,
                        listener_id))->func;
 }
@@ -498,7 +498,7 @@ enum bt_trace_remove_listener_status bt_trace_remove_destruction_listener(
                has_listener_id(trace, listener_id),
                "Trace has no such trace destruction listener ID: "
                "%![trace-]+t, %" PRIu64, trace, listener_id);
-       elem = &g_array_index(trace->destruction_listeners,
+       elem = &bt_g_array_index(trace->destruction_listeners,
                        struct bt_trace_destruction_listener_elem,
                        listener_id);
        BT_ASSERT(elem->func);
index 4919463dcecbd52268f8b41e69a8896d6305d29e..d187441628f6179a2e5afa31515aa93cc2ec4bf1 100644 (file)
@@ -101,12 +101,12 @@ enum bt_param_validation_status bt_param_validation_error(
 
                g_string_assign(str, "Error validating parameter `");
 
-               append_scope_to_string(str, &g_array_index(ctx->scope_stack,
+               append_scope_to_string(str, &bt_g_array_index(ctx->scope_stack,
                        struct validate_ctx_stack_element, 0), true);
 
                for (i = 1; i < ctx->scope_stack->len; i++) {
                        append_scope_to_string(str,
-                               &g_array_index(ctx->scope_stack,
+                               &bt_g_array_index(ctx->scope_stack,
                                        struct validate_ctx_stack_element, i), false);
                }
 
index 3c204b6a3a20287b9918bc480b56fe33531c6cae..7014f10201b5a696d914958c93a89713091d8846 100644 (file)
@@ -238,7 +238,7 @@ static int stack_push(struct stack *stack, struct ctf_field_class *base_class, s
         g_array_set_size(stack->entries, stack->size + 1);
     }
 
-    entry = &g_array_index(stack->entries, struct stack_entry, stack->size);
+    entry = &bt_g_array_index(stack->entries, struct stack_entry, stack->size);
     entry->base_class = base_class;
     entry->base_len = base_len;
     entry->index = 0;
@@ -335,7 +335,7 @@ static inline struct stack_entry *stack_top(struct stack *stack)
 {
     BT_ASSERT_DBG(stack);
     BT_ASSERT_DBG(stack_size(stack));
-    return &g_array_index(stack->entries, struct stack_entry, stack->size - 1);
+    return &bt_g_array_index(stack->entries, struct stack_entry, stack->size - 1);
 }
 
 static inline size_t available_bits(struct bt_bfcr *bfcr)
index 6bf43756e0a0033694e5243b88fed1b241e966ec..f87b426092ba2bb4f250f8d376edb86c647d27fc 100644 (file)
@@ -598,7 +598,7 @@ static inline void _ctf_field_class_enum_destroy(struct ctf_field_class_enum *fc
 
         for (i = 0; i < fc->mappings->len; i++) {
             struct ctf_field_class_enum_mapping *mapping =
-                &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
+                &bt_g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
 
             _ctf_field_class_enum_mapping_fini(mapping);
         }
@@ -630,7 +630,7 @@ static inline void _ctf_field_class_struct_destroy(struct ctf_field_class_struct
 
         for (i = 0; i < fc->members->len; i++) {
             struct ctf_named_field_class *named_fc =
-                &g_array_index(fc->members, struct ctf_named_field_class, i);
+                &bt_g_array_index(fc->members, struct ctf_named_field_class, i);
 
             _ctf_named_field_class_fini(named_fc);
         }
@@ -676,7 +676,7 @@ static inline void _ctf_field_class_variant_destroy(struct ctf_field_class_varia
 
         for (i = 0; i < fc->options->len; i++) {
             struct ctf_named_field_class *named_fc =
-                &g_array_index(fc->options, struct ctf_named_field_class, i);
+                &bt_g_array_index(fc->options, struct ctf_named_field_class, i);
 
             _ctf_named_field_class_fini(named_fc);
         }
@@ -738,7 +738,7 @@ ctf_field_class_enum_mapping_borrow_range_by_index(struct ctf_field_class_enum_m
 {
     BT_ASSERT_DBG(mapping);
     BT_ASSERT_DBG(index < mapping->ranges->len);
-    return &g_array_index(mapping->ranges, struct ctf_range, index);
+    return &bt_g_array_index(mapping->ranges, struct ctf_range, index);
 }
 
 static inline struct ctf_field_class_enum_mapping *
@@ -746,7 +746,7 @@ ctf_field_class_enum_borrow_mapping_by_index(struct ctf_field_class_enum *fc, ui
 {
     BT_ASSERT_DBG(fc);
     BT_ASSERT_DBG(index < fc->mappings->len);
-    return &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, index);
+    return &bt_g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, index);
 }
 
 static inline struct ctf_field_class_enum_mapping *
@@ -819,7 +819,7 @@ ctf_field_class_struct_borrow_member_by_index(struct ctf_field_class_struct *fc,
 {
     BT_ASSERT_DBG(fc);
     BT_ASSERT_DBG(index < fc->members->len);
-    return &g_array_index(fc->members, struct ctf_named_field_class, index);
+    return &bt_g_array_index(fc->members, struct ctf_named_field_class, index);
 }
 
 static inline struct ctf_named_field_class *
@@ -907,7 +907,7 @@ static inline void ctf_field_class_struct_append_member(struct ctf_field_class_s
     BT_ASSERT(orig_name);
     g_array_set_size(fc->members, fc->members->len + 1);
 
-    named_fc = &g_array_index(fc->members, struct ctf_named_field_class, fc->members->len - 1);
+    named_fc = &bt_g_array_index(fc->members, struct ctf_named_field_class, fc->members->len - 1);
     _ctf_named_field_class_init(named_fc);
     g_string_assign(named_fc->orig_name, orig_name);
     _ctf_named_field_class_unescape_orig_name(named_fc);
@@ -923,7 +923,7 @@ ctf_field_class_variant_borrow_option_by_index(struct ctf_field_class_variant *f
 {
     BT_ASSERT_DBG(fc);
     BT_ASSERT_DBG(index < fc->options->len);
-    return &g_array_index(fc->options, struct ctf_named_field_class, index);
+    return &bt_g_array_index(fc->options, struct ctf_named_field_class, index);
 }
 
 static inline struct ctf_named_field_class *
@@ -954,7 +954,7 @@ ctf_field_class_variant_borrow_range_by_index(struct ctf_field_class_variant *fc
 {
     BT_ASSERT_DBG(fc);
     BT_ASSERT_DBG(index < fc->ranges->len);
-    return &g_array_index(fc->ranges, struct ctf_field_class_variant_range, index);
+    return &bt_g_array_index(fc->ranges, struct ctf_field_class_variant_range, index);
 }
 
 static inline void ctf_field_class_variant_append_option(struct ctf_field_class_variant *fc,
@@ -967,7 +967,7 @@ static inline void ctf_field_class_variant_append_option(struct ctf_field_class_
     BT_ASSERT(orig_name);
     g_array_set_size(fc->options, fc->options->len + 1);
 
-    named_fc = &g_array_index(fc->options, struct ctf_named_field_class, fc->options->len - 1);
+    named_fc = &bt_g_array_index(fc->options, struct ctf_named_field_class, fc->options->len - 1);
     _ctf_named_field_class_init(named_fc);
     g_string_assign(named_fc->orig_name, orig_name);
     _ctf_named_field_class_unescape_orig_name(named_fc);
@@ -1139,7 +1139,7 @@ static inline int64_t ctf_field_path_borrow_index_by_index(struct ctf_field_path
 {
     BT_ASSERT_DBG(fp);
     BT_ASSERT_DBG(index < fp->path->len);
-    return g_array_index(fp->path, int64_t, index);
+    return bt_g_array_index(fp->path, int64_t, index);
 }
 
 static inline void ctf_field_path_clear(struct ctf_field_path *fp)
@@ -1280,10 +1280,10 @@ _ctf_field_class_enum_copy(struct ctf_field_class_enum *fc)
         uint64_t range_i;
 
         struct ctf_field_class_enum_mapping *mapping =
-            &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
+            &bt_g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
 
         for (range_i = 0; range_i < mapping->ranges->len; range_i++) {
-            struct ctf_range *range = &g_array_index(mapping->ranges, struct ctf_range, range_i);
+            struct ctf_range *range = &bt_g_array_index(mapping->ranges, struct ctf_range, range_i);
 
             ctf_field_class_enum_map_range(copy_fc, mapping->label->str, range->lower.u,
                                            range->upper.u);
@@ -1322,7 +1322,7 @@ _ctf_field_class_struct_copy(struct ctf_field_class_struct *fc)
 
     for (i = 0; i < fc->members->len; i++) {
         struct ctf_named_field_class *named_fc =
-            &g_array_index(fc->members, struct ctf_named_field_class, i);
+            &bt_g_array_index(fc->members, struct ctf_named_field_class, i);
 
         ctf_field_class_struct_append_member(copy_fc, named_fc->name->str,
                                              ctf_field_class_copy(named_fc->fc));
@@ -1358,7 +1358,7 @@ _ctf_field_class_variant_copy(struct ctf_field_class_variant *fc)
 
     for (i = 0; i < fc->options->len; i++) {
         struct ctf_named_field_class *named_fc =
-            &g_array_index(fc->options, struct ctf_named_field_class, i);
+            &bt_g_array_index(fc->options, struct ctf_named_field_class, i);
 
         ctf_field_class_variant_append_option(copy_fc, named_fc->name->str,
                                               ctf_field_class_copy(named_fc->fc));
@@ -1366,7 +1366,7 @@ _ctf_field_class_variant_copy(struct ctf_field_class_variant *fc)
 
     for (i = 0; i < fc->ranges->len; i++) {
         struct ctf_field_class_variant_range *range =
-            &g_array_index(fc->ranges, struct ctf_field_class_variant_range, i);
+            &bt_g_array_index(fc->ranges, struct ctf_field_class_variant_range, i);
 
         g_array_append_val(copy_fc->ranges, *range);
     }
@@ -1635,7 +1635,7 @@ static inline void ctf_trace_class_destroy(struct ctf_trace_class *tc)
 
         for (i = 0; i < tc->env_entries->len; i++) {
             struct ctf_trace_class_env_entry *entry =
-                &g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, i);
+                &bt_g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, i);
 
             _ctf_trace_class_env_entry_fini(entry);
         }
@@ -1656,8 +1656,8 @@ static inline void ctf_trace_class_append_env_entry(struct ctf_trace_class *tc,
     BT_ASSERT(name);
     g_array_set_size(tc->env_entries, tc->env_entries->len + 1);
 
-    entry =
-        &g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, tc->env_entries->len - 1);
+    entry = &bt_g_array_index(tc->env_entries, struct ctf_trace_class_env_entry,
+                              tc->env_entries->len - 1);
     entry->type = type;
     _ctf_trace_class_env_entry_init(entry);
     g_string_assign(entry->name, name);
@@ -1718,7 +1718,7 @@ ctf_trace_class_borrow_env_entry_by_index(struct ctf_trace_class *tc, uint64_t i
 {
     BT_ASSERT_DBG(tc);
     BT_ASSERT_DBG(index < tc->env_entries->len);
-    return &g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, index);
+    return &bt_g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, index);
 }
 
 static inline struct ctf_trace_class_env_entry *
index eed758535a24c95bbd249791907ad02edf025c8d..4efc5ed61b9b6e6786750cbed3461cd3a1f40d6d 100644 (file)
@@ -394,7 +394,7 @@ static void stack_push(struct stack *stack, bt_field *base)
         g_array_set_size(stack->entries, stack->size + 1);
     }
 
-    entry = &g_array_index(stack->entries, struct stack_entry, stack->size);
+    entry = &bt_g_array_index(stack->entries, struct stack_entry, stack->size);
     entry->base = base;
     entry->index = 0;
     stack->size++;
@@ -423,7 +423,7 @@ static inline struct stack_entry *stack_top(struct stack *stack)
 {
     BT_ASSERT_DBG(stack);
     BT_ASSERT_DBG(stack_size(stack));
-    return &g_array_index(stack->entries, struct stack_entry, stack->size - 1);
+    return &bt_g_array_index(stack->entries, struct stack_entry, stack->size - 1);
 }
 
 static inline bool stack_empty(struct stack *stack)
@@ -1862,7 +1862,7 @@ update_def_clock:
     }
 
     if (G_UNLIKELY(int_fc->storing_index >= 0)) {
-        g_array_index(msg_it->stored_values, uint64_t, (uint64_t) int_fc->storing_index) = value;
+        bt_g_array_index(msg_it->stored_values, uint64_t, (uint64_t) int_fc->storing_index) = value;
     }
 
     if (G_UNLIKELY(!fc->in_ir || msg_it->dry_run)) {
@@ -1948,7 +1948,7 @@ static enum bt_bfcr_status bfcr_signed_int_cb(int64_t value, struct ctf_field_cl
     BT_ASSERT_DBG(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE);
 
     if (G_UNLIKELY(int_fc->storing_index >= 0)) {
-        g_array_index(msg_it->stored_values, uint64_t, (uint64_t) int_fc->storing_index) =
+        bt_g_array_index(msg_it->stored_values, uint64_t, (uint64_t) int_fc->storing_index) =
             (uint64_t) value;
     }
 
@@ -2191,7 +2191,8 @@ static int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *dat
     int64_t length;
     int ret;
 
-    length = (uint64_t) g_array_index(msg_it->stored_values, uint64_t, seq_fc->stored_length_index);
+    length =
+        (uint64_t) bt_g_array_index(msg_it->stored_values, uint64_t, seq_fc->stored_length_index);
 
     if (G_UNLIKELY(msg_it->dry_run)) {
         goto end;
@@ -2242,7 +2243,7 @@ bfcr_borrow_variant_selected_field_class_cb(struct ctf_field_class *fc, void *da
     } tag;
 
     /* Get variant's tag */
-    tag.u = g_array_index(msg_it->stored_values, uint64_t, var_fc->stored_tag_index);
+    tag.u = bt_g_array_index(msg_it->stored_values, uint64_t, var_fc->stored_tag_index);
 
     /*
      * Check each range to find the selected option's index.
index e56ab5269db78448922f8765279d265b9df8e26c..8795b4511a0d2aad87ba1a2e5934324ade7ed50d 100644 (file)
@@ -668,7 +668,7 @@ fs_sink_ctf_field_class_struct_borrow_member_by_index(struct fs_sink_ctf_field_c
 {
     BT_ASSERT_DBG(fc);
     BT_ASSERT_DBG(index < fc->members->len);
-    return &g_array_index(fc->members, struct fs_sink_ctf_named_field_class, index);
+    return &bt_g_array_index(fc->members, struct fs_sink_ctf_named_field_class, index);
 }
 
 static inline struct fs_sink_ctf_named_field_class *
@@ -759,7 +759,7 @@ fs_sink_ctf_field_class_struct_append_member(struct fs_sink_ctf_field_class_stru
     g_array_set_size(fc->members, fc->members->len + 1);
 
     named_fc =
-        &g_array_index(fc->members, struct fs_sink_ctf_named_field_class, fc->members->len - 1);
+        &bt_g_array_index(fc->members, struct fs_sink_ctf_named_field_class, fc->members->len - 1);
     _fs_sink_ctf_named_field_class_init(named_fc);
     g_string_assign(named_fc->name, name);
     named_fc->fc = member_fc;
@@ -772,7 +772,7 @@ fs_sink_ctf_field_class_variant_borrow_option_by_index(struct fs_sink_ctf_field_
 {
     BT_ASSERT_DBG(fc);
     BT_ASSERT_DBG(index < fc->options->len);
-    return &g_array_index(fc->options, struct fs_sink_ctf_named_field_class, index);
+    return &bt_g_array_index(fc->options, struct fs_sink_ctf_named_field_class, index);
 }
 
 static inline struct fs_sink_ctf_named_field_class *
@@ -811,7 +811,7 @@ fs_sink_ctf_field_class_variant_append_option(struct fs_sink_ctf_field_class_var
     g_array_set_size(fc->options, fc->options->len + 1);
 
     named_fc =
-        &g_array_index(fc->options, struct fs_sink_ctf_named_field_class, fc->options->len - 1);
+        &bt_g_array_index(fc->options, struct fs_sink_ctf_named_field_class, fc->options->len - 1);
     _fs_sink_ctf_named_field_class_init(named_fc);
     g_string_assign(named_fc->name, name);
     named_fc->fc = option_fc;
index 4030d7d2c15fac5417a4d7063e43cbef67e82dcd..80adcc3aa3bc32f3729a2c312f6aedb24927351c 100644 (file)
@@ -57,7 +57,7 @@ struct ctx
 static inline struct field_path_elem *cur_path_stack_at(struct ctx *ctx, uint64_t i)
 {
     BT_ASSERT(i < ctx->cur_path->len);
-    return &g_array_index(ctx->cur_path, struct field_path_elem, i);
+    return &bt_g_array_index(ctx->cur_path, struct field_path_elem, i);
 }
 
 static inline struct field_path_elem *cur_path_stack_top(struct ctx *ctx)
index a98de98869fbd63e0aa877619294d4db47a6214f..a99599e3b99831daf6e1eeb7481520ec173627b8 100644 (file)
@@ -660,7 +660,7 @@ void destroy_enum_field_class_mapping(struct enum_field_class_mapping *mapping)
 static
 struct int_range *int_range_at(GArray *ranges, uint64_t index)
 {
-       return &g_array_index(ranges, struct int_range, index);
+       return &bt_g_array_index(ranges, struct int_range, index);
 }
 
 static
index c31f7c8be4a309deee02787099caa580512cb1eb..0a0f2bc43451f455df794f251c6656bf2a32937a 100644 (file)
@@ -151,7 +151,7 @@ bool has_event(struct event *event)
        size_t i;
 
        for (i = 0; i < events->len; i++) {
-               struct event *ev = &g_array_index(events, struct event, i);
+               struct event *ev = &bt_g_array_index(events, struct event, i);
 
                if (compare_events(event, ev)) {
                        return true;
@@ -167,7 +167,7 @@ size_t event_pos(struct event *event)
        size_t i;
 
        for (i = 0; i < events->len; i++) {
-               struct event *ev = &g_array_index(events, struct event, i);
+               struct event *ev = &bt_g_array_index(events, struct event, i);
 
                if (compare_events(event, ev)) {
                        return i;
This page took 0.042583 seconds and 4 git commands to generate.