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)
commitd50d46f31cc000f03601eeaf8a0806a0c183c1d0
treec0dfa3251224a132a2214c55c36d845dc7e4923b
parentc8a4375195b0ca586c43e5733dfc0266b4ba8a50
common: introduce bt_g_array_index

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
This page took 0.026798 seconds and 4 git commands to generate.