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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 10 Sep 2019 15:20:25 +0000 (11:20 -0400)
commitab8b2b1ba138ce05c6eb7f1e16c0bc7784d6edfa
tree7f2089816e0d526f1d7eab6cd62741aa63f54244
parent9db4399ff6a1c1e182f416985f85f6e2fcb0b5c4
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.026481 seconds and 4 git commands to generate.