lib: make message iterator creation functions return a status
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 5 Sep 2019 18:44:50 +0000 (14:44 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 6 Sep 2019 18:07:44 +0000 (14:07 -0400)
commite803df70898ad94809e70156df2e6bdfd4b1ee2a
tree764d8e86165ac284e159b18bf904d5f103e701ed
parent5f2a1585bf407f3f3aa7e63d9041b75390cf8563
lib: make message iterator creation functions return a status

These two functions:

- bt_self_component_port_input_message_iterator_create_from_message_iterator
- bt_self_component_port_input_message_iterator_create_from_sink_component

call some user code at some point (the upstream message iterator's init
function), which can possibly fail (return ERROR).  However, they
currently just return the pointer to the created message iterator, no
status.  So on failure (NULL return value), the caller has to assume
that it translates to a MEMORY_ERROR, given that this is the semantic
for all creation functions that just return a pointer.

Therefore, change them to return a status, and return the pointer by
output parameter.

Wrappers for the Python bindings are necessary, because these functions
offer no guarantee about the value of the output pointer on failure.
But the argout typemap checks whether the pointer is NULL to know if the
function has failed or not.

A test is added in Python to check that if
_create_input_port_message_iterator (both in _UserMessageIterator and
_UserSinkComponent) fails, the error is propagated correctly.

Change-Id: I8151b7e9702d5210c28e2c4a9f323f1d990233ed
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2004
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
16 files changed:
include/babeltrace2/graph/self-component-port-input-message-iterator.h
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/native_bt_message_iterator.i
src/bindings/python/bt2/bt2/native_bt_message_iterator.i.h
src/lib/graph/component-class-sink-simple.c
src/lib/graph/iterator.c
src/plugins/ctf/fs-sink/fs-sink.c
src/plugins/lttng-utils/debug-info/debug-info.c
src/plugins/text/details/details.c
src/plugins/text/pretty/pretty.c
src/plugins/utils/counter/counter.c
src/plugins/utils/dummy/dummy.c
src/plugins/utils/muxer/muxer.c
src/plugins/utils/trimmer/trimmer.c
tests/bindings/python/bt2/test_message_iterator.py
This page took 0.025633 seconds and 4 git commands to generate.