From d24d56638469189904fb6ddbb3c725817b3e9417 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sun, 30 Jun 2019 02:26:38 -0400 Subject: [PATCH] lib: strictly type function return status enumerations Rigour strikes again. This patch makes each function (or group of related functions) of the library which returns a status enumeration return its own, function-specific status enumeration. For example, where bt_graph_run() used to return the generic `bt_graph_status` type, it now returns `bt_graph_run_status`. The benefits are: * Each function defines its own set of available status codes. With appropriate compiler warnings, you can catch comparisons between a returned status and an incompatible enumerator, and assignments of incompatible enumerators. For example, with clang 8: file.c:13:13: warning: implicit conversion from enumeration type 'enum bt_component_class_init_method_status' to different enumeration type 'enum bt_component_class_port_connected_method_status' [-Wenum-conversion] bt_component_class_port_connected_method_status status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; This was not possible before because all the status-returning functions of a given header could possibly return any value defined by the header-wide status enumeration. * A function's possible return values are self-documented: there's no need to document that a given function can only return some subset of the header-wide status enumerators. * In future minor releases of Babeltrace 2, we can add new status codes for a specific function. * Some smart IDEs will list the possible enumerators when checking the return value of a function or when returning a value from a function. To uniformize the status enumerator integer values, the new `` public header contains definitions for all the possible status codes. They are definitions instead of enumerators because they are not meant to be used directly by user code. To make sure a user does not write: #include to use the `__BT_FUNC_STATUS_*` definitions directly (which would inhibit the precious type checking that this patch is all about), the compiler will show the error: > Do NOT include in user code. unless you define `__BT_FUNC_STATUS_ENABLE` before including the header. Each public header which needs `__BT_FUNC_STATUS_*` definitions to define its own status enumerations does: /* For __BT_FUNC_STATUS_* */ #define __BT_FUNC_STATUS_ENABLE #include #undef __BT_FUNC_STATUS_ENABLE at the beginning of the file, and: #include at the end of the file. The `` header cancels all the existing `__BT_FUNC_STATUS_*` definitions so that they are not available to user code. Within the library, `"lib/func-status.h"` uses the definitions of `` to define its own, similar definitions, but without the `__` prefix for improved internal code readability. Internal library code does not need to "undefine" those definitions. As this system guarantees that any public status enumerator is an alias of one of the `__BT_FUNC_STATUS_*` definitions, the library code never uses the function-specific status enumerators directly: it always uses one of the `BT_FUNC_STATUS_*` definitions found in `"lib/func-status.h"`. This made it easier to adapt existing code. This also allows to pass such status codes easily between internal and public functions because they are `int` values until they finally reach public enumeration types where they are implicitly casted. When an internal (hidden, static) function returns a status code, it now returns `int`, using one of the `BT_FUNC_STATUS_*` values, where this could be used by at least two functions returning different public status enumerations. In internal headers, all the bt_*_status_string() are removed in favor of bt_common_func_status_string() which returns only the suffix string (e.g., `OK`, `ERROR`, `OVERFLOW`). This function is typically used when logging. The `*_NOMEM` enumerators are renamed to `*_MEMORY_ERROR` to make this clear and remove this abbreviation which was the only one amongst other public status enumerators. Because the Python bindings are within the Babeltrace project, they use the `__BT_FUNC_STATUS_*` definitions internally. Those values will not change in the future anyway. All the _handle_*status() and bt2.utils._handle_ret() functions are removed in favor of bt2.utils._handle_func_status() which can handle all the possible status codes and raise a corresponding exception, possibly with a given message. Signed-off-by: Philippe Proulx Change-Id: I3966ac0e691219102897920617711c518c34fbdf --- extras/gen-babeltrace-h.py | 11 +- include/Makefile.am | 4 +- include/babeltrace2/babeltrace.h | 2 +- include/babeltrace2/func-status.h | 90 ++++ .../babeltrace2/graph/component-class-const.h | 5 - .../graph/component-class-filter.h | 49 +-- .../babeltrace2/graph/component-class-sink.h | 61 ++- .../graph/component-class-source.h | 46 +- include/babeltrace2/graph/component-class.h | 87 +++- include/babeltrace2/graph/graph-const.h | 9 - include/babeltrace2/graph/graph.h | 126 ++++-- include/babeltrace2/graph/message-iterator.h | 66 +++ .../graph/port-output-message-iterator.h | 10 +- .../babeltrace2/graph/query-executor-const.h | 11 - include/babeltrace2/graph/query-executor.h | 29 +- .../babeltrace2/graph/self-component-filter.h | 6 +- ...lf-component-port-input-message-iterator.h | 10 +- .../babeltrace2/graph/self-component-sink.h | 4 +- .../babeltrace2/graph/self-component-source.h | 4 +- include/babeltrace2/graph/self-component.h | 19 +- .../babeltrace2/graph/self-message-iterator.h | 11 - include/babeltrace2/plugin/plugin-const.h | 56 ++- include/babeltrace2/plugin/plugin-dev.h | 27 +- .../babeltrace2/trace-ir/clock-class-const.h | 21 +- include/babeltrace2/trace-ir/clock-class.h | 22 +- .../trace-ir/clock-snapshot-const.h | 20 +- .../babeltrace2/trace-ir/event-class-const.h | 5 - include/babeltrace2/trace-ir/event-class.h | 35 +- include/babeltrace2/trace-ir/event-const.h | 5 - include/babeltrace2/trace-ir/event.h | 3 - .../babeltrace2/trace-ir/field-class-const.h | 21 +- include/babeltrace2/trace-ir/field-class.h | 57 ++- include/babeltrace2/trace-ir/field-const.h | 25 +- include/babeltrace2/trace-ir/field.h | 49 ++- include/babeltrace2/trace-ir/packet-const.h | 5 - include/babeltrace2/trace-ir/packet.h | 20 +- .../babeltrace2/trace-ir/stream-class-const.h | 5 - include/babeltrace2/trace-ir/stream-class.h | 31 +- include/babeltrace2/trace-ir/stream-const.h | 5 - include/babeltrace2/trace-ir/stream.h | 19 +- .../babeltrace2/trace-ir/trace-class-const.h | 30 +- include/babeltrace2/trace-ir/trace-class.h | 30 +- include/babeltrace2/trace-ir/trace-const.h | 28 +- include/babeltrace2/trace-ir/trace.h | 19 +- include/babeltrace2/types.h | 1 + ...e-iterator-const.h => undef-func-status.h} | 36 +- include/babeltrace2/value-const.h | 40 +- include/babeltrace2/value.h | 116 +++-- src/bindings/python/bt2/bt2/__init__.py.in | 24 +- src/bindings/python/bt2/bt2/clock_class.py | 19 +- src/bindings/python/bt2/bt2/clock_snapshot.py | 8 +- src/bindings/python/bt2/bt2/component.py | 31 +- src/bindings/python/bt2/bt2/event_class.py | 15 +- src/bindings/python/bt2/bt2/field.py | 14 +- src/bindings/python/bt2/bt2/field_class.py | 24 +- src/bindings/python/bt2/bt2/graph.py | 30 +- .../python/bt2/bt2/message_iterator.py | 21 +- src/bindings/python/bt2/bt2/native_bt.i | 15 +- .../python/bt2/bt2/native_bt_component.i | 2 +- .../bt2/bt2/native_bt_component_class.i | 397 ++++++++---------- src/bindings/python/bt2/bt2/native_bt_graph.i | 106 ++--- .../python/bt2/bt2/native_bt_logging.i | 20 +- .../bt2/bt2/native_bt_message_iterator.i | 44 +- .../python/bt2/bt2/native_bt_plugin.i | 32 +- src/bindings/python/bt2/bt2/native_bt_trace.i | 12 +- .../python/bt2/bt2/native_bt_trace_class.i | 12 +- src/bindings/python/bt2/bt2/native_bt_value.i | 8 +- src/bindings/python/bt2/bt2/plugin.py | 24 +- src/bindings/python/bt2/bt2/port.py | 4 +- src/bindings/python/bt2/bt2/query_executor.py | 19 +- src/bindings/python/bt2/bt2/stream_class.py | 22 +- src/bindings/python/bt2/bt2/trace.py | 7 +- src/bindings/python/bt2/bt2/trace_class.py | 8 +- src/bindings/python/bt2/bt2/utils.py | 60 ++- src/bindings/python/bt2/bt2/value.py | 18 +- src/cli/babeltrace2-cfg-cli-args.c | 25 +- src/cli/babeltrace2-cfg.c | 2 +- src/cli/babeltrace2.c | 133 +++--- src/common/common.h | 91 ++-- src/lib/Makefile.am | 5 +- src/lib/func-status.h | 49 +++ src/lib/graph/component-class-sink-colander.c | 46 +- src/lib/graph/component-class.c | 115 ++--- src/lib/graph/component-filter.c | 13 +- src/lib/graph/component-sink.c | 7 +- src/lib/graph/component-source.c | 8 +- src/lib/graph/component.c | 40 +- src/lib/graph/component.h | 8 +- src/lib/graph/connection.h | 1 - src/lib/graph/graph.c | 199 ++++----- src/lib/graph/graph.h | 53 +-- src/lib/graph/iterator.c | 209 ++++----- src/lib/graph/message/iterator.h | 7 +- src/lib/graph/query-executor.c | 34 +- src/lib/graph/query-executor.h | 45 -- src/lib/plugin/plugin-so.c | 157 ++++--- src/lib/plugin/plugin-so.h | 5 +- src/lib/plugin/plugin.c | 97 +++-- src/lib/plugin/plugin.h | 24 +- src/lib/trace-ir/clock-class.c | 14 +- src/lib/trace-ir/clock-class.h | 4 +- src/lib/trace-ir/clock-snapshot.c | 8 +- src/lib/trace-ir/event-class.c | 19 +- src/lib/trace-ir/field-class.c | 44 +- src/lib/trace-ir/field.c | 38 +- src/lib/trace-ir/packet.c | 6 +- src/lib/trace-ir/stream-class.c | 19 +- src/lib/trace-ir/stream.c | 5 +- src/lib/trace-ir/trace-class.c | 26 +- src/lib/trace-ir/trace.c | 14 +- src/lib/value.c | 139 +++--- src/lib/value.h | 2 +- src/plugins/ctf/common/msg-iter/msg-iter.c | 9 +- src/plugins/ctf/fs-sink/fs-sink-trace.c | 2 +- src/plugins/ctf/fs-sink/fs-sink.c | 182 ++++---- src/plugins/ctf/fs-sink/fs-sink.h | 6 +- src/plugins/ctf/fs-src/data-stream-file.c | 10 +- src/plugins/ctf/fs-src/data-stream-file.h | 2 +- src/plugins/ctf/fs-src/fs.c | 65 +-- src/plugins/ctf/fs-src/fs.h | 10 +- src/plugins/ctf/fs-src/query.c | 86 ++-- src/plugins/ctf/fs-src/query.h | 4 +- src/plugins/ctf/lttng-live/lttng-live.c | 77 ++-- src/plugins/ctf/lttng-live/lttng-live.h | 8 +- .../ctf/lttng-live/viewer-connection.c | 50 +-- .../ctf/lttng-live/viewer-connection.h | 2 +- .../lttng-utils/debug-info/debug-info.c | 157 ++++--- .../lttng-utils/debug-info/debug-info.h | 8 +- .../debug-info/trace-ir-data-copy.c | 36 +- .../lttng-utils/debug-info/trace-ir-mapping.c | 17 +- .../debug-info/trace-ir-metadata-copy.c | 85 ++-- .../trace-ir-metadata-field-class-copy.c | 36 +- src/plugins/text/details/details.c | 75 ++-- src/plugins/text/details/details.h | 6 +- src/plugins/text/details/write.c | 6 +- src/plugins/text/dmesg/dmesg.c | 80 ++-- src/plugins/text/dmesg/dmesg.h | 8 +- src/plugins/text/pretty/pretty.c | 88 ++-- src/plugins/text/pretty/pretty.h | 9 +- src/plugins/utils/counter/counter.c | 69 +-- src/plugins/utils/counter/counter.h | 6 +- src/plugins/utils/dummy/dummy.c | 63 +-- src/plugins/utils/dummy/dummy.h | 6 +- src/plugins/utils/muxer/muxer.c | 190 +++++---- src/plugins/utils/muxer/muxer.h | 10 +- src/plugins/utils/trimmer/trimmer.c | 197 +++++---- src/plugins/utils/trimmer/trimmer.h | 6 +- .../python-plugin-provider.c | 92 ++-- tests/bindings/python/bt2/test_clock_class.py | 4 +- tests/bindings/python/bt2/test_graph.py | 4 +- .../python/bt2/test_query_executor.py | 10 +- tests/lib/plugin.c | 26 +- tests/lib/test-plugin-plugins/minimal.c | 4 +- tests/lib/test-plugin-plugins/sfs.c | 23 +- tests/lib/test_trace_ir_ref.c | 8 +- .../src.ctf.fs/query/test_query_trace_info.py | 8 +- 156 files changed, 3289 insertions(+), 2659 deletions(-) create mode 100644 include/babeltrace2/func-status.h create mode 100644 include/babeltrace2/graph/message-iterator.h rename include/babeltrace2/{graph/message-iterator-const.h => undef-func-status.h} (63%) create mode 100644 src/lib/func-status.h diff --git a/extras/gen-babeltrace-h.py b/extras/gen-babeltrace-h.py index 7c64a676..75d328fe 100644 --- a/extras/gen-babeltrace-h.py +++ b/extras/gen-babeltrace-h.py @@ -45,14 +45,22 @@ def _c_includes_from_sections(sections): src = '' for section in sections: + # CTF writer is not part of the Babeltrace library if 'ctf' in section.title.lower(): continue src += '/* {} */\n'.format(section.title) + lines = [] for filename in sorted(section.filenames): - src += '#include <{}>\n'.format(filename) + # not part of the API + if 'func-status' in filename: + continue + lines.append('#include <{}>\n'.format(filename)) + + lines.sort() + src += ''.join(lines) src += '\n' return src[:-1] @@ -92,5 +100,6 @@ def _main(): print(_c_includes_from_sections(sections)) print('#endif /* BABELTRACE_BABELTRACE_H */') + if __name__ == '__main__': _main() diff --git a/include/Makefile.am b/include/Makefile.am index 9b4f0530..32084661 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,9 +2,11 @@ babeltrace2includedir = "$(includedir)/babeltrace2" babeltrace2include_HEADERS = \ babeltrace2/babeltrace.h \ + babeltrace2/func-status.h \ babeltrace2/logging.h \ babeltrace2/property.h \ babeltrace2/types.h \ + babeltrace2/undef-func-status.h \ babeltrace2/util.h \ babeltrace2/value-const.h \ babeltrace2/value.h \ @@ -108,7 +110,7 @@ babeltrace2graphinclude_HEADERS = \ babeltrace2/graph/message-event.h \ babeltrace2/graph/message-message-iterator-inactivity-const.h \ babeltrace2/graph/message-message-iterator-inactivity.h \ - babeltrace2/graph/message-iterator-const.h \ + babeltrace2/graph/message-iterator.h \ babeltrace2/graph/message-packet-beginning-const.h \ babeltrace2/graph/message-packet-beginning.h \ babeltrace2/graph/message-packet-end-const.h \ diff --git a/include/babeltrace2/babeltrace.h b/include/babeltrace2/babeltrace.h index 20d50f59..646cff67 100644 --- a/include/babeltrace2/babeltrace.h +++ b/include/babeltrace2/babeltrace.h @@ -87,7 +87,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/babeltrace2/func-status.h b/include/babeltrace2/func-status.h new file mode 100644 index 00000000..60b68628 --- /dev/null +++ b/include/babeltrace2/func-status.h @@ -0,0 +1,90 @@ +/* + * No include guards here: this header is included by a public header to + * get the `__BT_FUNC_STATUS_*` definitions locally, and then + * is included at the end of the + * header to undefine all those definitions. + * + * If we forget to include at the end + * of a public header, we want to get the "redefined" compiler warning + * to catch it. + */ + +/* + * Copyright (c) 2019 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * This is just extra protection, in case the user tries to include + * in user code: this is a redminder that + * this header is reserved for internal use. + * + * The correct way for a public header to include this is: + * + * #define __BT_FUNC_STATUS_ENABLE + * #include + * #undef __BT_FUNC_STATUS_ENABLE + */ +#ifndef __BT_FUNC_STATUS_ENABLE +# error Do NOT include in user code. +#endif + +/* + * This is NOT part of the API. + * + * Do NOT use a `__BT_FUNC_STATUS_*` value in user code: this inhibits + * precious type checking. + */ + +/* Value is too large for the given data type */ +#define __BT_FUNC_STATUS_OVERFLOW -75 + +/* Invalid query parameters */ +#define __BT_FUNC_STATUS_INVALID_PARAMS -24 + +/* Invalid query object */ +#define __BT_FUNC_STATUS_INVALID_OBJECT -23 + +/* Memory allocation error */ +#define __BT_FUNC_STATUS_MEMORY_ERROR -12 + +/* Plugin loading error */ +#define __BT_FUNC_STATUS_LOADING_ERROR -2 + +/* General error */ +#define __BT_FUNC_STATUS_ERROR -1 + +/* Saul Goodman */ +#define __BT_FUNC_STATUS_OK 0 + +/* End of iteration/consumption */ +#define __BT_FUNC_STATUS_END 1 + +/* Something can't be found */ +#define __BT_FUNC_STATUS_NOT_FOUND 2 + +/* Try operation again later */ +#define __BT_FUNC_STATUS_AGAIN 11 + +/* Unsupported operation */ +#define __BT_FUNC_STATUS_UNSUPPORTED 95 + +/* Object is canceled */ +#define __BT_FUNC_STATUS_CANCELED 125 diff --git a/include/babeltrace2/graph/component-class-const.h b/include/babeltrace2/graph/component-class-const.h index ad018311..5d9cc7af 100644 --- a/include/babeltrace2/graph/component-class-const.h +++ b/include/babeltrace2/graph/component-class-const.h @@ -31,11 +31,6 @@ extern "C" { #endif -typedef enum bt_component_class_status { - BT_COMPONENT_CLASS_STATUS_OK = 0, - BT_COMPONENT_CLASS_STATUS_NOMEM = -12, -} bt_component_class_status; - typedef enum bt_component_class_type { BT_COMPONENT_CLASS_TYPE_SOURCE = 0, BT_COMPONENT_CLASS_TYPE_FILTER = 1, diff --git a/include/babeltrace2/graph/component-class-filter.h b/include/babeltrace2/graph/component-class-filter.h index af7fbf18..49a52872 100644 --- a/include/babeltrace2/graph/component-class-filter.h +++ b/include/babeltrace2/graph/component-class-filter.h @@ -26,18 +26,9 @@ #include -/* For bt_self_component_status */ -#include - -/* For bt_self_message_iterator_status */ -#include - -/* For bt_query_status */ +/* For bt_component_class_*_status */ #include -/* For bt_component_class_status */ -#include - /* * For bt_component_class, bt_component_class_filter, bt_port_input, * bt_port_output, bt_query_executor, bt_self_component_class_filter, @@ -54,7 +45,7 @@ extern "C" { #endif -typedef bt_self_component_status +typedef bt_component_class_init_method_status (*bt_component_class_filter_init_method)( bt_self_component_filter *self_component, const bt_value *params, void *init_method_data); @@ -62,7 +53,7 @@ typedef bt_self_component_status typedef void (*bt_component_class_filter_finalize_method)( bt_self_component_filter *self_component); -typedef bt_self_message_iterator_status +typedef bt_component_class_message_iterator_init_method_status (*bt_component_class_filter_message_iterator_init_method)( bt_self_message_iterator *message_iterator, bt_self_component_filter *self_component, @@ -72,18 +63,18 @@ typedef void (*bt_component_class_filter_message_iterator_finalize_method)( bt_self_message_iterator *message_iterator); -typedef bt_self_message_iterator_status +typedef bt_component_class_message_iterator_next_method_status (*bt_component_class_filter_message_iterator_next_method)( bt_self_message_iterator *message_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); -typedef bt_self_message_iterator_status +typedef bt_component_class_message_iterator_seek_ns_from_origin_method_status (*bt_component_class_filter_message_iterator_seek_ns_from_origin_method)( bt_self_message_iterator *message_iterator, int64_t ns_from_origin); -typedef bt_self_message_iterator_status +typedef bt_component_class_message_iterator_seek_beginning_method_status (*bt_component_class_filter_message_iterator_seek_beginning_method)( bt_self_message_iterator *message_iterator); @@ -96,20 +87,20 @@ typedef bt_bool (*bt_component_class_filter_message_iterator_can_seek_beginning_method)( bt_self_message_iterator *message_iterator); -typedef bt_query_status +typedef bt_component_class_query_method_status (*bt_component_class_filter_query_method)( bt_self_component_class_filter *comp_class, const bt_query_executor *query_executor, const char *object, const bt_value *params, bt_logging_level logging_level, const bt_value **result); -typedef bt_self_component_status +typedef bt_component_class_port_connected_method_status (*bt_component_class_filter_input_port_connected_method)( bt_self_component_filter *self_component, bt_self_component_port_input *self_port, const bt_port_output *other_port); -typedef bt_self_component_status +typedef bt_component_class_port_connected_method_status (*bt_component_class_filter_output_port_connected_method)( bt_self_component_filter *self_component, bt_self_component_port_output *self_port, @@ -127,57 +118,57 @@ bt_component_class_filter *bt_component_class_filter_create( const char *name, bt_component_class_filter_message_iterator_next_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_filter_set_init_method( bt_component_class_filter *comp_class, bt_component_class_filter_init_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_filter_set_finalize_method( bt_component_class_filter *comp_class, bt_component_class_filter_finalize_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_filter_set_input_port_connected_method( bt_component_class_filter *comp_class, bt_component_class_filter_input_port_connected_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_filter_set_output_port_connected_method( bt_component_class_filter *comp_class, bt_component_class_filter_output_port_connected_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_filter_set_query_method( bt_component_class_filter *comp_class, bt_component_class_filter_query_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_init_method( bt_component_class_filter *comp_class, bt_component_class_filter_message_iterator_init_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_finalize_method( bt_component_class_filter *comp_class, bt_component_class_filter_message_iterator_finalize_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method( bt_component_class_filter *comp_class, bt_component_class_filter_message_iterator_seek_ns_from_origin_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_seek_beginning_method( bt_component_class_filter *comp_class, bt_component_class_filter_message_iterator_seek_beginning_method method); -extern bt_bool +extern bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method( bt_component_class_filter *comp_class, bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method method); -extern bt_bool +extern bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_can_seek_beginning_method( bt_component_class_filter *comp_class, bt_component_class_filter_message_iterator_can_seek_beginning_method method); diff --git a/include/babeltrace2/graph/component-class-sink.h b/include/babeltrace2/graph/component-class-sink.h index f4b2bb8c..02394090 100644 --- a/include/babeltrace2/graph/component-class-sink.h +++ b/include/babeltrace2/graph/component-class-sink.h @@ -26,15 +26,9 @@ #include -/* For bt_self_component_status */ -#include - -/* For bt_query_status */ +/* For bt_component_class_*_status */ #include -/* For bt_component_class_status */ -#include - /* * For bt_component_class, bt_component_class_sink, bt_port_output, * bt_query_executor, bt_self_component_class_sink, @@ -46,18 +40,24 @@ /* For bt_logging_level */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif -typedef bt_self_component_status (*bt_component_class_sink_init_method)( +typedef bt_component_class_init_method_status +(*bt_component_class_sink_init_method)( bt_self_component_sink *self_component, const bt_value *params, void *init_method_data); typedef void (*bt_component_class_sink_finalize_method)( bt_self_component_sink *self_component); -typedef bt_query_status +typedef bt_component_class_query_method_status (*bt_component_class_sink_query_method)( bt_self_component_class_sink *comp_class, const bt_query_executor *query_executor, @@ -65,18 +65,33 @@ typedef bt_query_status bt_logging_level logging_level, const bt_value **result); -typedef bt_self_component_status +typedef bt_component_class_port_connected_method_status (*bt_component_class_sink_input_port_connected_method)( bt_self_component_sink *self_component, bt_self_component_port_input *self_port, const bt_port_output *other_port); -typedef bt_self_component_status +typedef enum bt_component_class_sink_graph_is_configured_method_status { + BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_component_class_sink_graph_is_configured_method_status; + +typedef bt_component_class_sink_graph_is_configured_method_status (*bt_component_class_sink_graph_is_configured_method)( bt_self_component_sink *self_component); -typedef bt_self_component_status (*bt_component_class_sink_consume_method)( - bt_self_component_sink *self_component); +typedef enum bt_component_class_sink_consume_method_status { + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END = __BT_FUNC_STATUS_END, +} bt_component_class_sink_consume_method_status; + +typedef bt_component_class_sink_consume_method_status +(*bt_component_class_sink_consume_method)( + bt_self_component_sink *self_component); static inline bt_component_class *bt_component_class_sink_as_component_class( @@ -90,25 +105,33 @@ bt_component_class_sink *bt_component_class_sink_create( const char *name, bt_component_class_sink_consume_method method); -extern bt_component_class_status bt_component_class_sink_set_init_method( +extern +bt_component_class_set_method_status +bt_component_class_sink_set_init_method( bt_component_class_sink *comp_class, bt_component_class_sink_init_method method); -extern bt_component_class_status bt_component_class_sink_set_finalize_method( +extern +bt_component_class_set_method_status +bt_component_class_sink_set_finalize_method( bt_component_class_sink *comp_class, bt_component_class_sink_finalize_method method); -extern bt_component_class_status +extern +bt_component_class_set_method_status bt_component_class_sink_set_input_port_connected_method( bt_component_class_sink *comp_class, bt_component_class_sink_input_port_connected_method method); -extern bt_component_class_status +extern +bt_component_class_set_method_status bt_component_class_sink_set_graph_is_configured_method( bt_component_class_sink *comp_class, bt_component_class_sink_graph_is_configured_method method); -extern bt_component_class_status bt_component_class_sink_set_query_method( +extern +bt_component_class_set_method_status +bt_component_class_sink_set_query_method( bt_component_class_sink *comp_class, bt_component_class_sink_query_method method); @@ -116,4 +139,6 @@ extern bt_component_class_status bt_component_class_sink_set_query_method( } #endif +#include + #endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_H */ diff --git a/include/babeltrace2/graph/component-class-source.h b/include/babeltrace2/graph/component-class-source.h index 05fb5a4b..55515bc5 100644 --- a/include/babeltrace2/graph/component-class-source.h +++ b/include/babeltrace2/graph/component-class-source.h @@ -26,18 +26,9 @@ #include -/* For bt_self_component_status */ -#include - -/* For bt_self_message_iterator_status */ -#include - -/* For bt_query_status */ +/* For bt_component_class_*_status */ #include -/* For bt_component_class_status */ -#include - /* * For bt_component_class, bt_component_class_source, bt_port_input, * bt_query_executor, bt_self_component_class_source, @@ -54,7 +45,7 @@ extern "C" { #endif -typedef bt_self_component_status +typedef bt_component_class_init_method_status (*bt_component_class_source_init_method)( bt_self_component_source *self_component, const bt_value *params, void *init_method_data); @@ -62,7 +53,7 @@ typedef bt_self_component_status typedef void (*bt_component_class_source_finalize_method)( bt_self_component_source *self_component); -typedef bt_self_message_iterator_status +typedef bt_component_class_message_iterator_init_method_status (*bt_component_class_source_message_iterator_init_method)( bt_self_message_iterator *message_iterator, bt_self_component_source *self_component, @@ -72,18 +63,18 @@ typedef void (*bt_component_class_source_message_iterator_finalize_method)( bt_self_message_iterator *message_iterator); -typedef bt_self_message_iterator_status +typedef bt_component_class_message_iterator_next_method_status (*bt_component_class_source_message_iterator_next_method)( bt_self_message_iterator *message_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); -typedef bt_self_message_iterator_status +typedef bt_component_class_message_iterator_seek_ns_from_origin_method_status (*bt_component_class_source_message_iterator_seek_ns_from_origin_method)( bt_self_message_iterator *message_iterator, int64_t ns_from_origin); -typedef bt_self_message_iterator_status +typedef bt_component_class_message_iterator_seek_beginning_method_status (*bt_component_class_source_message_iterator_seek_beginning_method)( bt_self_message_iterator *message_iterator); @@ -96,14 +87,15 @@ typedef bt_bool (*bt_component_class_source_message_iterator_can_seek_beginning_method)( bt_self_message_iterator *message_iterator); -typedef bt_query_status (*bt_component_class_source_query_method)( +typedef bt_component_class_query_method_status +(*bt_component_class_source_query_method)( bt_self_component_class_source *comp_class, const bt_query_executor *query_executor, const char *object, const bt_value *params, bt_logging_level logging_level, const bt_value **result); -typedef bt_self_component_status +typedef bt_component_class_port_connected_method_status (*bt_component_class_source_output_port_connected_method)( bt_self_component_source *self_component, bt_self_component_port_output *self_port, @@ -121,52 +113,52 @@ bt_component_class_source *bt_component_class_source_create( const char *name, bt_component_class_source_message_iterator_next_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_source_set_init_method( bt_component_class_source *comp_class, bt_component_class_source_init_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_source_set_finalize_method( bt_component_class_source *comp_class, bt_component_class_source_finalize_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_source_set_output_port_connected_method( bt_component_class_source *comp_class, bt_component_class_source_output_port_connected_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_source_set_query_method( bt_component_class_source *comp_class, bt_component_class_source_query_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_source_set_message_iterator_init_method( bt_component_class_source *comp_class, bt_component_class_source_message_iterator_init_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_source_set_message_iterator_finalize_method( bt_component_class_source *comp_class, bt_component_class_source_message_iterator_finalize_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_source_set_message_iterator_seek_ns_from_origin_method( bt_component_class_source *comp_class, bt_component_class_source_message_iterator_seek_ns_from_origin_method method); -extern bt_component_class_status +extern bt_component_class_set_method_status bt_component_class_source_set_message_iterator_seek_beginning_method( bt_component_class_source *comp_class, bt_component_class_source_message_iterator_seek_beginning_method method); -extern bt_bool +extern bt_component_class_set_method_status bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method( bt_component_class_source *comp_class, bt_component_class_source_message_iterator_can_seek_ns_from_origin_method method); -extern bt_bool +extern bt_component_class_set_method_status bt_component_class_source_set_message_iterator_can_seek_beginning_method( bt_component_class_source *comp_class, bt_component_class_source_message_iterator_can_seek_beginning_method method); diff --git a/include/babeltrace2/graph/component-class.h b/include/babeltrace2/graph/component-class.h index f2b85930..d96fbb03 100644 --- a/include/babeltrace2/graph/component-class.h +++ b/include/babeltrace2/graph/component-class.h @@ -24,33 +24,86 @@ * SOFTWARE. */ -/* For BT_QUERY_EXECUTOR_STATUS_* */ -#include - /* For bt_component_class */ #include -/* For bt_component_class_status */ -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { #endif -typedef enum bt_query_status { - BT_QUERY_STATUS_OK = BT_QUERY_EXECUTOR_STATUS_OK, - BT_QUERY_STATUS_AGAIN = BT_QUERY_EXECUTOR_STATUS_AGAIN, - BT_QUERY_STATUS_ERROR = BT_QUERY_EXECUTOR_STATUS_ERROR, - BT_QUERY_STATUS_NOMEM = BT_QUERY_EXECUTOR_STATUS_NOMEM, - BT_QUERY_STATUS_INVALID_OBJECT = BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT, - BT_QUERY_STATUS_INVALID_PARAMS = BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS, -} bt_query_status; +typedef enum bt_component_class_init_method_status { + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_component_class_init_method_status; -extern bt_component_class_status bt_component_class_set_description( - bt_component_class *component_class, +typedef enum bt_component_class_port_connected_method_status { + BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_component_class_port_connected_method_status; + +typedef enum bt_component_class_query_method_status { + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_OBJECT = __BT_FUNC_STATUS_INVALID_OBJECT, + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS = __BT_FUNC_STATUS_INVALID_PARAMS, +} bt_component_class_query_method_status; + +typedef enum bt_component_class_message_iterator_init_method_status { + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_component_class_message_iterator_init_method_status; + +typedef enum bt_component_class_message_iterator_next_method_status { + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END = __BT_FUNC_STATUS_END, +} bt_component_class_message_iterator_next_method_status; + +typedef enum bt_component_class_message_iterator_seek_beginning_method_status { + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_component_class_message_iterator_seek_beginning_method_status; + +typedef enum bt_component_class_message_iterator_seek_ns_from_origin_method_status { + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_component_class_message_iterator_seek_ns_from_origin_method_status; + +typedef enum bt_component_class_set_method_status { + BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_component_class_set_method_status; + +typedef enum bt_component_class_set_description_status { + BT_COMPONENT_CLASS_SET_DESCRIPTION_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_component_class_set_description_status; + +extern bt_component_class_set_description_status +bt_component_class_set_description(bt_component_class *component_class, const char *description); -extern bt_component_class_status bt_component_class_set_help( +typedef enum bt_component_class_set_help_status { + BT_COMPONENT_CLASS_SET_HELP_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_COMPONENT_CLASS_SET_HELP_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_component_class_set_help_status; + +extern bt_component_class_set_help_status bt_component_class_set_help( bt_component_class *component_class, const char *help); @@ -58,4 +111,6 @@ extern bt_component_class_status bt_component_class_set_help( } #endif +#include + #endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_H */ diff --git a/include/babeltrace2/graph/graph-const.h b/include/babeltrace2/graph/graph-const.h index 97672b7b..34abb3b5 100644 --- a/include/babeltrace2/graph/graph-const.h +++ b/include/babeltrace2/graph/graph-const.h @@ -31,15 +31,6 @@ extern "C" { #endif -typedef enum bt_graph_status { - BT_GRAPH_STATUS_OK = 0, - BT_GRAPH_STATUS_END = 1, - BT_GRAPH_STATUS_AGAIN = 11, - BT_GRAPH_STATUS_CANCELED = 125, - BT_GRAPH_STATUS_ERROR = -1, - BT_GRAPH_STATUS_NOMEM = -12, -} bt_graph_status; - extern bt_bool bt_graph_is_canceled(const bt_graph *graph); extern void bt_graph_get_ref(const bt_graph *graph); diff --git a/include/babeltrace2/graph/graph.h b/include/babeltrace2/graph/graph.h index 34a74fa4..d6bd7bad 100644 --- a/include/babeltrace2/graph/graph.h +++ b/include/babeltrace2/graph/graph.h @@ -33,57 +33,59 @@ */ #include -/* For bt_graph_status */ -#include - /* For bt_logging_level */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif -typedef enum bt_graph_listener_status { - BT_GRAPH_LISTENER_STATUS_OK = 0, - BT_GRAPH_LISTENER_STATUS_ERROR = -1, - BT_GRAPH_LISTENER_STATUS_NOMEM = -12, -} bt_graph_listener_status; +typedef enum bt_graph_listener_func_status { + BT_GRAPH_LISTENER_FUNC_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_GRAPH_LISTENER_FUNC_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_GRAPH_LISTENER_FUNC_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_graph_listener_func_status; -typedef bt_graph_listener_status +typedef bt_graph_listener_func_status (*bt_graph_filter_component_input_port_added_listener_func)( const bt_component_filter *component, const bt_port_input *port, void *data); -typedef bt_graph_listener_status +typedef bt_graph_listener_func_status (*bt_graph_sink_component_input_port_added_listener_func)( const bt_component_sink *component, const bt_port_input *port, void *data); -typedef bt_graph_listener_status +typedef bt_graph_listener_func_status (*bt_graph_source_component_output_port_added_listener_func)( const bt_component_source *component, const bt_port_output *port, void *data); -typedef bt_graph_listener_status +typedef bt_graph_listener_func_status (*bt_graph_filter_component_output_port_added_listener_func)( const bt_component_filter *component, const bt_port_output *port, void *data); -typedef bt_graph_listener_status +typedef bt_graph_listener_func_status (*bt_graph_source_filter_component_ports_connected_listener_func)( const bt_component_source *source_component, const bt_component_filter *filter_component, const bt_port_output *upstream_port, const bt_port_input *downstream_port, void *data); -typedef bt_graph_listener_status +typedef bt_graph_listener_func_status (*bt_graph_source_sink_component_ports_connected_listener_func)( const bt_component_source *source_component, const bt_component_sink *sink_component, const bt_port_output *upstream_port, const bt_port_input *downstream_port, void *data); -typedef bt_graph_listener_status +typedef bt_graph_listener_func_status (*bt_graph_filter_filter_component_ports_connected_listener_func)( const bt_component_filter *filter_component_upstream, const bt_component_filter *filter_component_downstream, @@ -91,7 +93,7 @@ typedef bt_graph_listener_status const bt_port_input *downstream_port, void *data); -typedef bt_graph_listener_status +typedef bt_graph_listener_func_status (*bt_graph_filter_sink_component_ports_connected_listener_func)( const bt_component_filter *filter_component, const bt_component_sink *sink_component, @@ -102,108 +104,160 @@ typedef void (* bt_graph_listener_removed_func)(void *data); extern bt_graph *bt_graph_create(void); -extern bt_graph_status bt_graph_add_source_component(bt_graph *graph, +typedef enum bt_graph_add_component_status { + BT_GRAPH_ADD_COMPONENT_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_GRAPH_ADD_COMPONENT_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_GRAPH_ADD_COMPONENT_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_graph_add_component_status; + +extern bt_graph_add_component_status +bt_graph_add_source_component(bt_graph *graph, const bt_component_class_source *component_class, const char *name, const bt_value *params, bt_logging_level log_level, const bt_component_source **component); -extern bt_graph_status bt_graph_add_source_component_with_init_method_data( +extern bt_graph_add_component_status +bt_graph_add_source_component_with_init_method_data( bt_graph *graph, const bt_component_class_source *component_class, const char *name, const bt_value *params, void *init_method_data, bt_logging_level log_level, const bt_component_source **component); -extern bt_graph_status bt_graph_add_filter_component(bt_graph *graph, +extern bt_graph_add_component_status +bt_graph_add_filter_component(bt_graph *graph, const bt_component_class_filter *component_class, const char *name, const bt_value *params, bt_logging_level log_level, const bt_component_filter **component); -extern bt_graph_status bt_graph_add_filter_component_with_init_method_data( +extern bt_graph_add_component_status +bt_graph_add_filter_component_with_init_method_data( bt_graph *graph, const bt_component_class_filter *component_class, const char *name, const bt_value *params, void *init_method_data, bt_logging_level log_level, const bt_component_filter **component); -extern bt_graph_status bt_graph_add_sink_component( +extern bt_graph_add_component_status +bt_graph_add_sink_component( bt_graph *graph, const bt_component_class_sink *component_class, const char *name, const bt_value *params, bt_logging_level log_level, const bt_component_sink **component); -extern bt_graph_status bt_graph_add_sink_component_with_init_method_data( +extern bt_graph_add_component_status +bt_graph_add_sink_component_with_init_method_data( bt_graph *graph, const bt_component_class_sink *component_class, const char *name, const bt_value *params, void *init_method_data, bt_logging_level log_level, const bt_component_sink **component); -extern bt_graph_status bt_graph_connect_ports(bt_graph *graph, +typedef enum bt_graph_connect_ports_status { + BT_GRAPH_CONNECT_PORTS_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_GRAPH_CONNECT_PORTS_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_GRAPH_CONNECT_PORTS_STATUS_CANCELED = __BT_FUNC_STATUS_CANCELED, + BT_GRAPH_CONNECT_PORTS_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_graph_connect_ports_status; + +extern bt_graph_connect_ports_status bt_graph_connect_ports(bt_graph *graph, const bt_port_output *upstream, const bt_port_input *downstream, const bt_connection **connection); -extern bt_graph_status bt_graph_run(bt_graph *graph); - -extern bt_graph_status bt_graph_consume(bt_graph *graph); - -extern bt_graph_status bt_graph_add_filter_component_input_port_added_listener( +typedef enum bt_graph_run_status { + BT_GRAPH_RUN_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_GRAPH_RUN_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_GRAPH_RUN_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_GRAPH_RUN_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_GRAPH_RUN_STATUS_END = __BT_FUNC_STATUS_END, + BT_GRAPH_RUN_STATUS_CANCELED = __BT_FUNC_STATUS_CANCELED, +} bt_graph_run_status; + +extern bt_graph_run_status bt_graph_run(bt_graph *graph); + +typedef enum bt_graph_consume_status { + BT_GRAPH_CONSUME_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_GRAPH_CONSUME_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_GRAPH_CONSUME_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_GRAPH_CONSUME_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_GRAPH_CONSUME_STATUS_END = __BT_FUNC_STATUS_END, + BT_GRAPH_CONSUME_STATUS_CANCELED = __BT_FUNC_STATUS_CANCELED, +} bt_graph_consume_status; + +extern bt_graph_consume_status bt_graph_consume(bt_graph *graph); + +typedef enum bt_graph_add_listener_status { + BT_GRAPH_ADD_LISTENER_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_GRAPH_ADD_LISTENER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_graph_add_listener_status; + +extern bt_graph_add_listener_status +bt_graph_add_filter_component_input_port_added_listener( bt_graph *graph, bt_graph_filter_component_input_port_added_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, int *listener_id); -extern bt_graph_status bt_graph_add_sink_component_input_port_added_listener( +extern bt_graph_add_listener_status +bt_graph_add_sink_component_input_port_added_listener( bt_graph *graph, bt_graph_sink_component_input_port_added_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, int *listener_id); -extern bt_graph_status bt_graph_add_source_component_output_port_added_listener( +extern bt_graph_add_listener_status +bt_graph_add_source_component_output_port_added_listener( bt_graph *graph, bt_graph_source_component_output_port_added_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, int *listener_id); -extern bt_graph_status bt_graph_add_filter_component_output_port_added_listener( +extern bt_graph_add_listener_status +bt_graph_add_filter_component_output_port_added_listener( bt_graph *graph, bt_graph_filter_component_output_port_added_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, int *listener_id); -extern bt_graph_status +extern bt_graph_add_listener_status bt_graph_add_source_filter_component_ports_connected_listener( bt_graph *graph, bt_graph_source_filter_component_ports_connected_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, int *listener_id); -extern bt_graph_status +extern bt_graph_add_listener_status bt_graph_add_filter_filter_component_ports_connected_listener( bt_graph *graph, bt_graph_filter_filter_component_ports_connected_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, int *listener_id); -extern bt_graph_status +extern bt_graph_add_listener_status bt_graph_add_source_sink_component_ports_connected_listener( bt_graph *graph, bt_graph_source_sink_component_ports_connected_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, int *listener_id); -extern bt_graph_status +extern bt_graph_add_listener_status bt_graph_add_filter_sink_component_ports_connected_listener( bt_graph *graph, bt_graph_filter_sink_component_ports_connected_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, int *listener_id); -extern bt_graph_status bt_graph_cancel(bt_graph *graph); +typedef enum bt_graph_cancel_status { + BT_GRAPH_CANCEL_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_graph_cancel_status; + +extern bt_graph_cancel_status bt_graph_cancel(bt_graph *graph); #ifdef __cplusplus } #endif +#include + #endif /* BABELTRACE_GRAPH_GRAPH_H */ diff --git a/include/babeltrace2/graph/message-iterator.h b/include/babeltrace2/graph/message-iterator.h new file mode 100644 index 00000000..d3b91e38 --- /dev/null +++ b/include/babeltrace2/graph/message-iterator.h @@ -0,0 +1,66 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_H +#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_H + +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2015 Jérémie Galarneau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum bt_message_iterator_next_status { + BT_MESSAGE_ITERATOR_NEXT_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_MESSAGE_ITERATOR_NEXT_STATUS_END = __BT_FUNC_STATUS_END, + BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_message_iterator_next_status; + +typedef enum bt_message_iterator_seek_beginning_status { + BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_END = __BT_FUNC_STATUS_END, + BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_message_iterator_seek_beginning_status; + +typedef enum bt_message_iterator_seek_ns_from_origin_status { + BT_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_STATUS_END = __BT_FUNC_STATUS_END, + BT_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_message_iterator_seek_ns_from_origin_status; + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_H */ diff --git a/include/babeltrace2/graph/port-output-message-iterator.h b/include/babeltrace2/graph/port-output-message-iterator.h index ebbd2e50..bfddd467 100644 --- a/include/babeltrace2/graph/port-output-message-iterator.h +++ b/include/babeltrace2/graph/port-output-message-iterator.h @@ -25,8 +25,8 @@ #include -/* For bt_message_iterator_status */ -#include +/* For bt_message_iterator_*_status */ +#include /* * For bt_port, bt_message, bt_message_iterator, @@ -52,7 +52,7 @@ bt_port_output_message_iterator_create( bt_graph *graph, const bt_port_output *output_port); -extern bt_message_iterator_status +extern bt_message_iterator_next_status bt_port_output_message_iterator_next( bt_port_output_message_iterator *iterator, bt_message_array_const *msgs, uint64_t *count); @@ -64,12 +64,12 @@ extern bt_bool bt_port_output_message_iterator_can_seek_ns_from_origin( extern bt_bool bt_port_output_message_iterator_can_seek_beginning( bt_port_output_message_iterator *iterator); -extern bt_message_iterator_status +extern bt_message_iterator_seek_ns_from_origin_status bt_port_output_message_iterator_seek_ns_from_origin( bt_port_output_message_iterator *iterator, int64_t ns_from_origin); -extern bt_message_iterator_status +extern bt_message_iterator_seek_beginning_status bt_port_output_message_iterator_seek_beginning( bt_port_output_message_iterator *iterator); diff --git a/include/babeltrace2/graph/query-executor-const.h b/include/babeltrace2/graph/query-executor-const.h index 0e0413e5..16f8a854 100644 --- a/include/babeltrace2/graph/query-executor-const.h +++ b/include/babeltrace2/graph/query-executor-const.h @@ -30,17 +30,6 @@ extern "C" { #endif -typedef enum bt_query_executor_status { - BT_QUERY_EXECUTOR_STATUS_OK = 0, - BT_QUERY_EXECUTOR_STATUS_AGAIN = 11, - BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED = 95, - BT_QUERY_EXECUTOR_STATUS_CANCELED = 125, - BT_QUERY_EXECUTOR_STATUS_ERROR = -1, - BT_QUERY_EXECUTOR_STATUS_NOMEM = -12, - BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT = -23, - BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS = -24, -} bt_query_executor_status; - extern bt_bool bt_query_executor_is_canceled( const bt_query_executor *query_executor); diff --git a/include/babeltrace2/graph/query-executor.h b/include/babeltrace2/graph/query-executor.h index fe5c4789..07838fcf 100644 --- a/include/babeltrace2/graph/query-executor.h +++ b/include/babeltrace2/graph/query-executor.h @@ -23,15 +23,17 @@ * SOFTWARE. */ -/* For bt_query_executor_status */ -#include - /* For bt_query_executor, bt_component_class, bt_value */ #include /* For bt_logging_level */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif @@ -39,19 +41,36 @@ extern "C" { extern bt_query_executor *bt_query_executor_create(void); +typedef enum bt_query_executor_query_status { + BT_QUERY_EXECUTOR_QUERY_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_QUERY_EXECUTOR_QUERY_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_QUERY_EXECUTOR_QUERY_STATUS_UNSUPPORTED = __BT_FUNC_STATUS_UNSUPPORTED, + BT_QUERY_EXECUTOR_QUERY_STATUS_CANCELED = __BT_FUNC_STATUS_CANCELED, + BT_QUERY_EXECUTOR_QUERY_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_QUERY_EXECUTOR_QUERY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_QUERY_EXECUTOR_QUERY_STATUS_INVALID_OBJECT = __BT_FUNC_STATUS_INVALID_OBJECT, + BT_QUERY_EXECUTOR_QUERY_STATUS_INVALID_PARAMS = __BT_FUNC_STATUS_INVALID_PARAMS, +} bt_query_executor_query_status; + extern -bt_query_executor_status bt_query_executor_query( +bt_query_executor_query_status bt_query_executor_query( bt_query_executor *query_executor, const bt_component_class *component_class, const char *object, const bt_value *params, bt_logging_level logging_level, const bt_value **result); +typedef enum bt_query_executor_cancel_status { + BT_QUERY_EXECUTOR_CANCEL_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_query_executor_cancel_status; + extern -bt_query_executor_status bt_query_executor_cancel( +bt_query_executor_cancel_status bt_query_executor_cancel( bt_query_executor *query_executor); #ifdef __cplusplus } #endif +#include + #endif /* BABELTRACE_GRAPH_QUERY_EXECUTOR_H */ diff --git a/include/babeltrace2/graph/self-component-filter.h b/include/babeltrace2/graph/self-component-filter.h index 7d646b5a..c36e0564 100644 --- a/include/babeltrace2/graph/self-component-filter.h +++ b/include/babeltrace2/graph/self-component-filter.h @@ -26,7 +26,7 @@ #include -/* For bt_self_component_status */ +/* For bt_self_component_*_status */ #include /* @@ -65,7 +65,7 @@ bt_self_component_filter_borrow_output_port_by_index( bt_self_component_filter *self_component, uint64_t index); -extern bt_self_component_status +extern bt_self_component_add_port_status bt_self_component_filter_add_output_port( bt_self_component_filter *self_component, const char *name, void *user_data, @@ -81,7 +81,7 @@ bt_self_component_filter_borrow_input_port_by_index( bt_self_component_filter *self_component, uint64_t index); -extern bt_self_component_status +extern bt_self_component_add_port_status bt_self_component_filter_add_input_port( bt_self_component_filter *self_component, const char *name, void *user_data, diff --git a/include/babeltrace2/graph/self-component-port-input-message-iterator.h b/include/babeltrace2/graph/self-component-port-input-message-iterator.h index dbdf7110..814c197f 100644 --- a/include/babeltrace2/graph/self-component-port-input-message-iterator.h +++ b/include/babeltrace2/graph/self-component-port-input-message-iterator.h @@ -25,8 +25,8 @@ #include -/* For bt_message_iterator_status */ -#include +/* For bt_message_iterator_*_status */ +#include /* * For bt_component, bt_message_iterator, @@ -56,7 +56,7 @@ extern bt_component * bt_self_component_port_input_message_iterator_borrow_component( bt_self_component_port_input_message_iterator *iterator); -extern bt_message_iterator_status +extern bt_message_iterator_next_status bt_self_component_port_input_message_iterator_next( bt_self_component_port_input_message_iterator *iterator, bt_message_array_const *msgs, uint64_t *count); @@ -69,12 +69,12 @@ bt_self_component_port_input_message_iterator_can_seek_ns_from_origin( extern bt_bool bt_self_component_port_input_message_iterator_can_seek_beginning( bt_self_component_port_input_message_iterator *iterator); -extern bt_message_iterator_status +extern bt_message_iterator_seek_ns_from_origin_status bt_self_component_port_input_message_iterator_seek_ns_from_origin( bt_self_component_port_input_message_iterator *iterator, int64_t ns_from_origin); -extern bt_message_iterator_status +extern bt_message_iterator_seek_beginning_status bt_self_component_port_input_message_iterator_seek_beginning( bt_self_component_port_input_message_iterator *iterator); diff --git a/include/babeltrace2/graph/self-component-sink.h b/include/babeltrace2/graph/self-component-sink.h index f3fe5b5a..4b3c3354 100644 --- a/include/babeltrace2/graph/self-component-sink.h +++ b/include/babeltrace2/graph/self-component-sink.h @@ -25,7 +25,7 @@ #include -/* For bt_self_component_status */ +/* For bt_self_component_*_status */ #include /* @@ -62,7 +62,7 @@ extern bt_self_component_port_input * bt_self_component_sink_borrow_input_port_by_index( bt_self_component_sink *self_component, uint64_t index); -extern bt_self_component_status +extern bt_self_component_add_port_status bt_self_component_sink_add_input_port( bt_self_component_sink *self_component, const char *name, void *user_data, diff --git a/include/babeltrace2/graph/self-component-source.h b/include/babeltrace2/graph/self-component-source.h index 0e82cf56..188337bd 100644 --- a/include/babeltrace2/graph/self-component-source.h +++ b/include/babeltrace2/graph/self-component-source.h @@ -25,7 +25,7 @@ #include -/* For bt_self_component_status */ +/* For bt_self_component_*_status */ #include /* @@ -63,7 +63,7 @@ bt_self_component_source_borrow_output_port_by_index( bt_self_component_source *self_component, uint64_t index); -extern bt_self_component_status +extern bt_self_component_add_port_status bt_self_component_source_add_output_port( bt_self_component_source *self_component, const char *name, void *user_data, diff --git a/include/babeltrace2/graph/self-component.h b/include/babeltrace2/graph/self-component.h index 4d53697f..898c0d9a 100644 --- a/include/babeltrace2/graph/self-component.h +++ b/include/babeltrace2/graph/self-component.h @@ -26,17 +26,20 @@ /* For bt_component, bt_self_component, __BT_UPCAST */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif -typedef enum bt_self_component_status { - BT_SELF_COMPONENT_STATUS_OK = 0, - BT_SELF_COMPONENT_STATUS_END = 1, - BT_SELF_COMPONENT_STATUS_AGAIN = 11, - BT_SELF_COMPONENT_STATUS_ERROR = -1, - BT_SELF_COMPONENT_STATUS_NOMEM = -12, -} bt_self_component_status; +typedef enum bt_self_component_add_port_status { + BT_SELF_COMPONENT_ADD_PORT_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_self_component_add_port_status; static inline const bt_component *bt_self_component_as_component( @@ -55,4 +58,6 @@ extern void bt_self_component_set_data( } #endif +#include + #endif /* BABELTRACE_GRAPH_SELF_COMPONENT_H */ diff --git a/include/babeltrace2/graph/self-message-iterator.h b/include/babeltrace2/graph/self-message-iterator.h index 0ff3c0d3..d7f7b5ee 100644 --- a/include/babeltrace2/graph/self-message-iterator.h +++ b/include/babeltrace2/graph/self-message-iterator.h @@ -23,9 +23,6 @@ * SOFTWARE. */ -/* For BT_MESSAGE_ITERATOR_STATUS_* */ -#include - /* For bt_self_component, bt_self_message_iterator, bt_self_port_output */ #include @@ -33,14 +30,6 @@ extern "C" { #endif -typedef enum bt_self_message_iterator_status { - BT_SELF_MESSAGE_ITERATOR_STATUS_OK = BT_MESSAGE_ITERATOR_STATUS_OK, - BT_SELF_MESSAGE_ITERATOR_STATUS_END = BT_MESSAGE_ITERATOR_STATUS_END, - BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN = BT_MESSAGE_ITERATOR_STATUS_AGAIN, - BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR = BT_MESSAGE_ITERATOR_STATUS_ERROR, - BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM = BT_MESSAGE_ITERATOR_STATUS_NOMEM, -} bt_self_message_iterator_status; - extern bt_self_component * bt_self_message_iterator_borrow_component( bt_self_message_iterator *message_iterator); diff --git a/include/babeltrace2/plugin/plugin-const.h b/include/babeltrace2/plugin/plugin-const.h index e8a8a2b6..db01f89b 100644 --- a/include/babeltrace2/plugin/plugin-const.h +++ b/include/babeltrace2/plugin/plugin-const.h @@ -39,32 +39,60 @@ /* For bt_property_availability */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif -typedef enum bt_plugin_status { - BT_PLUGIN_STATUS_OK = 0, - BT_PLUGIN_STATUS_NOT_FOUND = 2, - BT_PLUGIN_STATUS_ERROR = -1, - BT_PLUGIN_STATUS_LOADING_ERROR = -2, - BT_PLUGIN_STATUS_NOMEM = -12, -} bt_plugin_status; +typedef enum bt_plugin_find_status { + BT_PLUGIN_FIND_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_PLUGIN_FIND_STATUS_NOT_FOUND = __BT_FUNC_STATUS_NOT_FOUND, + BT_PLUGIN_FIND_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_PLUGIN_FIND_STATUS_LOADING_ERROR = __BT_FUNC_STATUS_LOADING_ERROR, + BT_PLUGIN_FIND_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_plugin_find_status; -extern bt_plugin_status bt_plugin_find(const char *plugin_name, +extern bt_plugin_find_status bt_plugin_find(const char *plugin_name, bt_bool fail_on_load_error, const bt_plugin **plugin); -extern bt_plugin_status bt_plugin_find_all_from_file( +typedef enum bt_plugin_find_all_from_file_status { + BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_NOT_FOUND = __BT_FUNC_STATUS_NOT_FOUND, + BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_LOADING_ERROR = __BT_FUNC_STATUS_LOADING_ERROR, + BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_plugin_find_all_from_file_status; + +extern bt_plugin_find_all_from_file_status bt_plugin_find_all_from_file( const char *path, bt_bool fail_on_load_error, const bt_plugin_set **plugin_set); -extern bt_plugin_status bt_plugin_find_all_from_dir( +typedef enum bt_plugin_find_all_from_dir_status { + BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_NOT_FOUND = __BT_FUNC_STATUS_NOT_FOUND, + BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_LOADING_ERROR = __BT_FUNC_STATUS_LOADING_ERROR, + BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_plugin_find_all_from_dir_status; + +extern bt_plugin_find_all_from_dir_status bt_plugin_find_all_from_dir( const char *path, bt_bool recurse, bt_bool fail_on_load_error, const bt_plugin_set **plugin_set); -extern bt_plugin_status bt_plugin_find_all_from_static( - bt_bool fail_on_load_error, - const bt_plugin_set **plugin_set); +typedef enum bt_plugin_find_all_from_static_status { + BT_PLUGIN_FIND_ALL_FROM_STATIC_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_PLUGIN_FIND_ALL_FROM_STATIC_STATUS_NOT_FOUND = __BT_FUNC_STATUS_NOT_FOUND, + BT_PLUGIN_FIND_ALL_FROM_STATIC_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_PLUGIN_FIND_ALL_FROM_STATIC_STATUS_LOADING_ERROR = __BT_FUNC_STATUS_LOADING_ERROR, + BT_PLUGIN_FIND_ALL_FROM_STATIC_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_plugin_find_all_from_static_status; + +extern bt_plugin_find_all_from_static_status bt_plugin_find_all_from_static( + bt_bool fail_on_load_error, const bt_plugin_set **plugin_set); extern const char *bt_plugin_get_name(const bt_plugin *plugin); @@ -134,4 +162,6 @@ extern void bt_plugin_put_ref(const bt_plugin *plugin); } #endif +#include + #endif /* BABELTRACE_PLUGIN_PLUGIN_CONST_H */ diff --git a/include/babeltrace2/plugin/plugin-dev.h b/include/babeltrace2/plugin/plugin-dev.h index b266a92b..6c4e0b52 100644 --- a/include/babeltrace2/plugin/plugin-dev.h +++ b/include/babeltrace2/plugin/plugin-dev.h @@ -29,9 +29,6 @@ #include -/* For enum bt_plugin_status */ -#include - /* For bt_component_class_type */ #include @@ -40,6 +37,14 @@ #include #include +/* For bt_self_plugin */ +#include + +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + /* * _BT_HIDDEN: set the hidden attribute for internal functions * On Windows, symbols are local unless explicitly exported, @@ -63,15 +68,13 @@ extern "C" { #define __BT_PLUGIN_VERSION_MINOR 0 /* Plugin initialization function type */ -typedef enum bt_self_plugin_status { - BT_SELF_PLUGIN_STATUS_OK = 0, - BT_SELF_PLUGIN_STATUS_NOMEM = -12, - BT_SELF_PLUGIN_STATUS_ERROR = -1, -} bt_self_plugin_status; +typedef enum bt_plugin_init_func_status { + BT_PLUGIN_INIT_FUNC_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_PLUGIN_INIT_FUNC_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_PLUGIN_INIT_FUNC_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, +} bt_plugin_init_func_status; -typedef struct bt_self_plugin bt_self_plugin; - -typedef bt_self_plugin_status (*bt_plugin_init_func)( +typedef bt_plugin_init_func_status (*bt_plugin_init_func)( bt_self_plugin *plugin); /* Plugin exit function type */ @@ -1476,4 +1479,6 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ } #endif +#include + #endif /* BABELTRACE_PLUGIN_PLUGIN_DEV_H */ diff --git a/include/babeltrace2/trace-ir/clock-class-const.h b/include/babeltrace2/trace-ir/clock-class-const.h index a06241c2..da34e3ec 100644 --- a/include/babeltrace2/trace-ir/clock-class-const.h +++ b/include/babeltrace2/trace-ir/clock-class-const.h @@ -32,16 +32,15 @@ /* For bt_bool, bt_uuid, bt_clock_class */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif -typedef enum bt_clock_class_status { - BT_CLOCK_CLASS_STATUS_OK = 0, - BT_CLOCK_CLASS_STATUS_NOMEM = -12, - BT_CLOCK_CLASS_STATUS_OVERFLOW = -75, -} bt_clock_class_status; - extern const char *bt_clock_class_get_name( const bt_clock_class *clock_class); @@ -63,7 +62,13 @@ extern bt_bool bt_clock_class_origin_is_unix_epoch( extern bt_uuid bt_clock_class_get_uuid( const bt_clock_class *clock_class); -extern bt_clock_class_status bt_clock_class_cycles_to_ns_from_origin( +typedef enum bt_clock_class_cycles_to_ns_from_origin_status { + BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW = __BT_FUNC_STATUS_OVERFLOW, + BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_clock_class_cycles_to_ns_from_origin_status; + +extern bt_clock_class_cycles_to_ns_from_origin_status +bt_clock_class_cycles_to_ns_from_origin( const bt_clock_class *clock_class, uint64_t cycles, int64_t *ns_from_origin); @@ -88,4 +93,6 @@ extern void bt_clock_class_put_ref(const bt_clock_class *clock_class); } #endif +#include + #endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_CONST_H */ diff --git a/include/babeltrace2/trace-ir/clock-class.h b/include/babeltrace2/trace-ir/clock-class.h index 719d7a3e..cf03ca80 100644 --- a/include/babeltrace2/trace-ir/clock-class.h +++ b/include/babeltrace2/trace-ir/clock-class.h @@ -32,8 +32,10 @@ /* For bt_bool, bt_uuid, bt_clock_class, bt_trace_class */ #include -/* For bt_clock_class_status */ -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { @@ -41,10 +43,20 @@ extern "C" { extern bt_clock_class *bt_clock_class_create(bt_self_component *self_comp); -extern bt_clock_class_status bt_clock_class_set_name( +typedef enum bt_clock_class_set_name_status { + BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_CLOCK_CLASS_SET_NAME_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_clock_class_set_name_status; + +extern bt_clock_class_set_name_status bt_clock_class_set_name( bt_clock_class *clock_class, const char *name); -extern bt_clock_class_status bt_clock_class_set_description( +typedef enum bt_clock_class_set_description_status { + BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_clock_class_set_description_status; + +extern bt_clock_class_set_description_status bt_clock_class_set_description( bt_clock_class *clock_class, const char *description); extern void bt_clock_class_set_frequency(bt_clock_class *clock_class, @@ -66,4 +78,6 @@ extern void bt_clock_class_set_uuid(bt_clock_class *clock_class, } #endif +#include + #endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_H */ diff --git a/include/babeltrace2/trace-ir/clock-snapshot-const.h b/include/babeltrace2/trace-ir/clock-snapshot-const.h index 6ac6576a..ee246408 100644 --- a/include/babeltrace2/trace-ir/clock-snapshot-const.h +++ b/include/babeltrace2/trace-ir/clock-snapshot-const.h @@ -32,22 +32,28 @@ /* For bt_clock_class, bt_clock_snapshot */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif -typedef enum bt_clock_snapshot_status { - BT_CLOCK_SNAPSHOT_STATUS_OK = 0, - BT_CLOCK_SNAPSHOT_STATUS_OVERFLOW = -75, -} bt_clock_snapshot_status; - extern const bt_clock_class *bt_clock_snapshot_borrow_clock_class_const( const bt_clock_snapshot *clock_snapshot); extern uint64_t bt_clock_snapshot_get_value( const bt_clock_snapshot *clock_snapshot); -extern bt_clock_snapshot_status bt_clock_snapshot_get_ns_from_origin( +typedef enum bt_clock_snapshot_get_ns_from_origin_status { + BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW = __BT_FUNC_STATUS_OVERFLOW, +} bt_clock_snapshot_get_ns_from_origin_status; + +extern bt_clock_snapshot_get_ns_from_origin_status +bt_clock_snapshot_get_ns_from_origin( const bt_clock_snapshot *clock_snapshot, int64_t *ns_from_origin); @@ -55,4 +61,6 @@ extern bt_clock_snapshot_status bt_clock_snapshot_get_ns_from_origin( } #endif +#include + #endif /* BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H */ diff --git a/include/babeltrace2/trace-ir/event-class-const.h b/include/babeltrace2/trace-ir/event-class-const.h index cde2df9b..79c4105a 100644 --- a/include/babeltrace2/trace-ir/event-class-const.h +++ b/include/babeltrace2/trace-ir/event-class-const.h @@ -40,11 +40,6 @@ extern "C" { #endif -typedef enum bt_event_class_status { - BT_EVENT_CLASS_STATUS_OK = 0, - BT_EVENT_CLASS_STATUS_NOMEM = -12, -} bt_event_class_status; - typedef enum bt_event_class_log_level { BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY, BT_EVENT_CLASS_LOG_LEVEL_ALERT, diff --git a/include/babeltrace2/trace-ir/event-class.h b/include/babeltrace2/trace-ir/event-class.h index b6d712ee..23b21ef1 100644 --- a/include/babeltrace2/trace-ir/event-class.h +++ b/include/babeltrace2/trace-ir/event-class.h @@ -27,13 +27,18 @@ * http://www.efficios.com/ctf */ -/* For bt_event_class_status, bt_event_class_log_level */ +#include + +/* For bt_event_class_log_level */ #include /* For bt_event_class, bt_stream_class */ #include -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { @@ -48,23 +53,39 @@ extern bt_event_class *bt_event_class_create_with_id( extern bt_stream_class *bt_event_class_borrow_stream_class( bt_event_class *event_class); -extern bt_event_class_status bt_event_class_set_name( +typedef enum bt_event_class_set_name_status { + BT_EVENT_CLASS_SET_NAME_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_EVENT_CLASS_SET_NAME_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_event_class_set_name_status; + +extern bt_event_class_set_name_status bt_event_class_set_name( bt_event_class *event_class, const char *name); extern void bt_event_class_set_log_level(bt_event_class *event_class, bt_event_class_log_level log_level); -extern bt_event_class_status bt_event_class_set_emf_uri( +typedef enum bt_event_class_set_emf_uri_status { + BT_EVENT_CLASS_SET_EMF_URI_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_EVENT_CLASS_SET_EMF_URI_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_event_class_set_emf_uri_status; + +extern bt_event_class_set_emf_uri_status bt_event_class_set_emf_uri( bt_event_class *event_class, const char *emf_uri); -extern bt_event_class_status +typedef enum bt_event_class_set_field_class_status { + BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_event_class_set_field_class_status; + +extern bt_event_class_set_field_class_status bt_event_class_set_specific_context_field_class(bt_event_class *event_class, bt_field_class *field_class); extern bt_field_class * bt_event_class_borrow_specific_context_field_class(bt_event_class *event_class); -extern bt_event_class_status bt_event_class_set_payload_field_class( +extern bt_event_class_set_field_class_status +bt_event_class_set_payload_field_class( bt_event_class *event_class, bt_field_class *field_class); @@ -75,4 +96,6 @@ extern bt_field_class *bt_event_class_borrow_payload_field_class( } #endif +#include + #endif /* BABELTRACE_TRACE_IR_EVENT_CLASS_H */ diff --git a/include/babeltrace2/trace-ir/event-const.h b/include/babeltrace2/trace-ir/event-const.h index 15623bd4..32e04942 100644 --- a/include/babeltrace2/trace-ir/event-const.h +++ b/include/babeltrace2/trace-ir/event-const.h @@ -34,11 +34,6 @@ extern "C" { #endif -typedef enum bt_event_status { - BT_EVENT_STATUS_OK = 0, - BT_EVENT_STATUS_NOMEM = -12, -} bt_event_status; - extern const bt_event_class *bt_event_borrow_class_const( const bt_event *event); diff --git a/include/babeltrace2/trace-ir/event.h b/include/babeltrace2/trace-ir/event.h index 3fb39396..69e943d1 100644 --- a/include/babeltrace2/trace-ir/event.h +++ b/include/babeltrace2/trace-ir/event.h @@ -30,9 +30,6 @@ /* For bt_event, bt_event_class, bt_field, bt_packet */ #include -/* For bt_event_status */ -#include - #ifdef __cplusplus extern "C" { #endif diff --git a/include/babeltrace2/trace-ir/field-class-const.h b/include/babeltrace2/trace-ir/field-class-const.h index b07ee4b6..c2ab2ebe 100644 --- a/include/babeltrace2/trace-ir/field-class-const.h +++ b/include/babeltrace2/trace-ir/field-class-const.h @@ -39,15 +39,15 @@ #include #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif -typedef enum bt_field_class_status { - BT_FIELD_CLASS_STATUS_OK = 0, - BT_FIELD_CLASS_STATUS_NOMEM = -12, -} bt_field_class_status; - typedef enum bt_field_class_type { BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER, BT_FIELD_CLASS_TYPE_SIGNED_INTEGER, @@ -124,13 +124,18 @@ bt_field_class_signed_enumeration_mapping_get_range_by_index( const bt_field_class_signed_enumeration_mapping *mapping, uint64_t index, int64_t *lower, int64_t *upper); -extern bt_field_class_status +typedef enum bt_field_class_enumeration_get_mapping_labels_by_value_status { + BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_class_enumeration_get_mapping_labels_by_value_status; + +extern bt_field_class_enumeration_get_mapping_labels_by_value_status bt_field_class_unsigned_enumeration_get_mapping_labels_by_value( const bt_field_class *field_class, uint64_t value, bt_field_class_enumeration_mapping_label_array *label_array, uint64_t *count); -extern bt_field_class_status +extern bt_field_class_enumeration_get_mapping_labels_by_value_status bt_field_class_signed_enumeration_get_mapping_labels_by_value( const bt_field_class *field_class, int64_t value, bt_field_class_enumeration_mapping_label_array *label_array, @@ -209,4 +214,6 @@ extern void bt_field_class_put_ref(const bt_field_class *field_class); } #endif +#include + #endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H */ diff --git a/include/babeltrace2/trace-ir/field-class.h b/include/babeltrace2/trace-ir/field-class.h index 8da8acde..d9bab006 100644 --- a/include/babeltrace2/trace-ir/field-class.h +++ b/include/babeltrace2/trace-ir/field-class.h @@ -27,17 +27,19 @@ * http://www.efficios.com/ctf */ +#include +#include + /* For bt_bool, bt_field_class, bt_trace_class */ #include -/* - * For bt_field_class_status, - * bt_field_class_integer_preferred_display_base - */ +/* For bt_field_class_integer_preferred_display_base */ #include -#include -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { @@ -68,11 +70,18 @@ extern bt_field_class *bt_field_class_unsigned_enumeration_create( extern bt_field_class *bt_field_class_signed_enumeration_create( bt_trace_class *trace_class); -extern bt_field_class_status bt_field_class_unsigned_enumeration_map_range( +typedef enum bt_field_class_enumeration_map_range_status { + BT_FIELD_CLASS_ENUMERATION_MAP_RANGE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_CLASS_ENUMERATION_MAP_RANGE_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_class_enumeration_map_range_status; + +extern bt_field_class_enumeration_map_range_status +bt_field_class_unsigned_enumeration_map_range( bt_field_class *field_class, const char *label, uint64_t range_lower, uint64_t range_upper); -extern bt_field_class_status bt_field_class_signed_enumeration_map_range( +extern bt_field_class_enumeration_map_range_status +bt_field_class_signed_enumeration_map_range( bt_field_class *field_class, const char *label, int64_t range_lower, int64_t range_upper); @@ -82,7 +91,13 @@ extern bt_field_class *bt_field_class_string_create( extern bt_field_class *bt_field_class_structure_create( bt_trace_class *trace_class); -extern bt_field_class_status bt_field_class_structure_append_member( +typedef enum bt_field_class_structure_append_member_status { + BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_class_structure_append_member_status; + +extern bt_field_class_structure_append_member_status +bt_field_class_structure_append_member( bt_field_class *struct_field_class, const char *name, bt_field_class *field_class); @@ -105,7 +120,12 @@ extern bt_field_class *bt_field_class_dynamic_array_create( extern bt_field_class *bt_field_class_array_borrow_element_field_class( bt_field_class *field_class); -extern bt_field_class_status +typedef enum bt_field_class_dynamic_array_set_length_field_class_status { + BT_FIELD_CLASS_DYNAMIC_ARRAY_SET_LENGTH_FIELD_CLASS_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_CLASS_DYNAMIC_ARRAY_SET_LENGTH_FIELD_CLASS_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_class_dynamic_array_set_length_field_class_status; + +extern bt_field_class_dynamic_array_set_length_field_class_status bt_field_class_dynamic_array_set_length_field_class( bt_field_class *field_class, bt_field_class *length_field_class); @@ -113,11 +133,22 @@ bt_field_class_dynamic_array_set_length_field_class( extern bt_field_class *bt_field_class_variant_create( bt_trace_class *trace_class); -extern bt_field_class_status +typedef enum bt_field_class_variant_set_selector_field_class_status { + BT_FIELD_CLASS_VARIANT_SET_SELECTOR_FIELD_CLASS_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_CLASS_VARIANT_SET_SELECTOR_FIELD_CLASS_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_class_variant_set_selector_field_class_status; + +extern bt_field_class_variant_set_selector_field_class_status bt_field_class_variant_set_selector_field_class(bt_field_class *field_class, bt_field_class *selector_field_class); -extern bt_field_class_status bt_field_class_variant_append_option( +typedef enum bt_field_class_variant_append_option_status { + BT_FIELD_CLASS_VARIANT_APPEND_OPTION_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_CLASS_VARIANT_APPEND_OPTION_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_class_variant_append_option_status; + +extern bt_field_class_variant_append_option_status +bt_field_class_variant_append_option( bt_field_class *var_field_class, const char *name, bt_field_class *field_class); @@ -136,4 +167,6 @@ extern bt_field_class *bt_field_class_variant_option_borrow_field_class( } #endif +#include + #endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_H */ diff --git a/include/babeltrace2/trace-ir/field-const.h b/include/babeltrace2/trace-ir/field-const.h index 7c5b46d0..484d1e81 100644 --- a/include/babeltrace2/trace-ir/field-const.h +++ b/include/babeltrace2/trace-ir/field-const.h @@ -35,15 +35,15 @@ /* For bt_field, bt_field_class */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif -typedef enum bt_field_status { - BT_FIELD_STATUS_OK = 0, - BT_FIELD_STATUS_NOMEM = -12, -} bt_field_status; - extern const bt_field_class *bt_field_borrow_class_const( const bt_field *field); @@ -57,13 +57,18 @@ extern uint64_t bt_field_unsigned_integer_get_value( extern double bt_field_real_get_value(const bt_field *field); -extern bt_field_status bt_field_unsigned_enumeration_get_mapping_labels( - const bt_field *field, +typedef enum bt_field_enumeration_get_mapping_labels_status { + BT_FIELD_ENUMERATION_GET_MAPPING_LABELS_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_ENUMERATION_GET_MAPPING_LABELS_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_enumeration_get_mapping_labels_status; + +extern bt_field_enumeration_get_mapping_labels_status +bt_field_unsigned_enumeration_get_mapping_labels(const bt_field *field, bt_field_class_enumeration_mapping_label_array *label_array, uint64_t *count); -extern bt_field_status bt_field_signed_enumeration_get_mapping_labels( - const bt_field *field, +extern bt_field_enumeration_get_mapping_labels_status +bt_field_signed_enumeration_get_mapping_labels(const bt_field *field, bt_field_class_enumeration_mapping_label_array *label_array, uint64_t *count); @@ -96,4 +101,6 @@ bt_field_variant_borrow_selected_option_field_const( } #endif +#include + #endif /* BABELTRACE_TRACE_IR_FIELDS_CONST_H */ diff --git a/include/babeltrace2/trace-ir/field.h b/include/babeltrace2/trace-ir/field.h index d336faf3..8dadd687 100644 --- a/include/babeltrace2/trace-ir/field.h +++ b/include/babeltrace2/trace-ir/field.h @@ -32,8 +32,10 @@ /* For bt_field, bt_field_class */ #include -/* For bt_field_status */ -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { @@ -47,16 +49,26 @@ extern void bt_field_unsigned_integer_set_value(bt_field *field, extern void bt_field_real_set_value(bt_field *field, double value); -extern bt_field_status bt_field_string_set_value(bt_field *field, - const char *value); +typedef enum bt_field_string_set_value_status { + BT_FIELD_STRING_SET_VALUE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_STRING_SET_VALUE_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_string_set_value_status; -extern bt_field_status bt_field_string_append(bt_field *field, - const char *value); +extern bt_field_string_set_value_status bt_field_string_set_value( + bt_field *field, const char *value); -extern bt_field_status bt_field_string_append_with_length(bt_field *field, - const char *value, uint64_t length); +typedef enum bt_field_string_append_status { + BT_FIELD_STRING_APPEND_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_STRING_APPEND_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_string_append_status; -extern bt_field_status bt_field_string_clear(bt_field *field); +extern bt_field_string_append_status bt_field_string_append( + bt_field *field, const char *value); + +extern bt_field_string_append_status bt_field_string_append_with_length( + bt_field *field, const char *value, uint64_t length); + +extern void bt_field_string_clear(bt_field *field); extern bt_field *bt_field_structure_borrow_member_field_by_index( bt_field *field, uint64_t index); @@ -67,10 +79,21 @@ extern bt_field *bt_field_structure_borrow_member_field_by_name( extern bt_field *bt_field_array_borrow_element_field_by_index( bt_field *field, uint64_t index); -extern bt_field_status bt_field_dynamic_array_set_length(bt_field *field, - uint64_t length); +typedef enum bt_field_dynamic_array_set_length_status { + BT_FIELD_DYNAMIC_ARRAY_SET_LENGTH_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_FIELD_DYNAMIC_ARRAY_SET_LENGTH_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_dynamic_array_set_length_status; + +extern bt_field_dynamic_array_set_length_status +bt_field_dynamic_array_set_length( + bt_field *field, uint64_t length); -extern bt_field_status bt_field_variant_select_option_field( +typedef enum bt_field_variant_select_option_field_status { + BT_FIELD_VARIANT_SELECT_OPTION_FIELD_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_field_variant_select_option_field_status; + +extern bt_field_variant_select_option_field_status +bt_field_variant_select_option_field( bt_field *field, uint64_t index); extern bt_field *bt_field_variant_borrow_selected_option_field( @@ -80,4 +103,6 @@ extern bt_field *bt_field_variant_borrow_selected_option_field( } #endif +#include + #endif /* BABELTRACE_TRACE_IR_FIELDS_H */ diff --git a/include/babeltrace2/trace-ir/packet-const.h b/include/babeltrace2/trace-ir/packet-const.h index 2aa39eb6..948a061a 100644 --- a/include/babeltrace2/trace-ir/packet-const.h +++ b/include/babeltrace2/trace-ir/packet-const.h @@ -40,11 +40,6 @@ extern "C" { #endif -typedef enum bt_packet_status { - BT_PACKET_STATUS_OK = 0, - BT_PACKET_STATUS_NOMEM = -12, -} bt_packet_status; - extern const bt_stream *bt_packet_borrow_stream_const( const bt_packet *packet); diff --git a/include/babeltrace2/trace-ir/packet.h b/include/babeltrace2/trace-ir/packet.h index 17c4e377..07b92b7c 100644 --- a/include/babeltrace2/trace-ir/packet.h +++ b/include/babeltrace2/trace-ir/packet.h @@ -26,13 +26,15 @@ * http://www.efficios.com/ctf */ +#include + /* For bt_packet, bt_packet_context_field, bt_stream */ #include -/* For bt_packet_status */ -#include - -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { @@ -45,12 +47,18 @@ extern bt_stream *bt_packet_borrow_stream(bt_packet *packet); extern bt_field *bt_packet_borrow_context_field(bt_packet *packet); +typedef enum bt_packet_move_context_field_status { + BT_PACKET_MOVE_CONTEXT_FIELD_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_packet_move_context_field_status; + extern -bt_packet_status bt_packet_move_context_field(bt_packet *packet, - bt_packet_context_field *context); +bt_packet_move_context_field_status bt_packet_move_context_field( + bt_packet *packet, bt_packet_context_field *context); #ifdef __cplusplus } #endif +#include + #endif /* BABELTRACE_TRACE_IR_PACKET_H */ diff --git a/include/babeltrace2/trace-ir/stream-class-const.h b/include/babeltrace2/trace-ir/stream-class-const.h index 662eb245..8687c985 100644 --- a/include/babeltrace2/trace-ir/stream-class-const.h +++ b/include/babeltrace2/trace-ir/stream-class-const.h @@ -39,11 +39,6 @@ extern "C" { #endif -typedef enum bt_stream_class_status { - BT_STREAM_CLASS_STATUS_OK = 0, - BT_STREAM_CLASS_STATUS_NOMEM = -12, -} bt_stream_class_status; - extern const bt_trace_class *bt_stream_class_borrow_trace_class_const( const bt_stream_class *stream_class); diff --git a/include/babeltrace2/trace-ir/stream-class.h b/include/babeltrace2/trace-ir/stream-class.h index f6a950f8..c7cab857 100644 --- a/include/babeltrace2/trace-ir/stream-class.h +++ b/include/babeltrace2/trace-ir/stream-class.h @@ -35,8 +35,10 @@ */ #include -/* For bt_stream_class_status */ -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { @@ -51,7 +53,12 @@ extern bt_stream_class *bt_stream_class_create_with_id( extern bt_trace_class *bt_stream_class_borrow_trace_class( bt_stream_class *stream_class); -extern bt_stream_class_status bt_stream_class_set_name( +typedef enum bt_stream_class_set_name_status { + BT_STREAM_CLASS_SET_NAME_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_STREAM_CLASS_SET_NAME_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_stream_class_set_name_status; + +extern bt_stream_class_set_name_status bt_stream_class_set_name( bt_stream_class *stream_class, const char *name); extern void bt_stream_class_set_assigns_automatic_event_class_id( @@ -76,7 +83,12 @@ extern void bt_stream_class_set_supports_discarded_packets( bt_bool supports_discarded_packets, bt_bool with_default_clock_snapshots); -extern bt_stream_class_status +typedef enum bt_stream_class_set_field_class_status { + BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_stream_class_set_field_class_status; + +extern bt_stream_class_set_field_class_status bt_stream_class_set_packet_context_field_class( bt_stream_class *stream_class, bt_field_class *field_class); @@ -85,7 +97,7 @@ extern bt_field_class * bt_stream_class_borrow_packet_context_field_class( bt_stream_class *stream_class); -extern bt_stream_class_status +extern bt_stream_class_set_field_class_status bt_stream_class_set_event_common_context_field_class( bt_stream_class *stream_class, bt_field_class *field_class); @@ -105,7 +117,12 @@ bt_stream_class_borrow_event_class_by_id( extern bt_clock_class *bt_stream_class_borrow_default_clock_class( bt_stream_class *stream_class); -extern bt_stream_class_status bt_stream_class_set_default_clock_class( +typedef enum bt_stream_class_set_default_clock_class_status { + BT_STREAM_CLASS_SET_DEFAULT_CLOCK_CLASS_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_stream_class_set_default_clock_class_status; + +extern bt_stream_class_set_default_clock_class_status +bt_stream_class_set_default_clock_class( bt_stream_class *stream_class, bt_clock_class *clock_class); @@ -113,4 +130,6 @@ extern bt_stream_class_status bt_stream_class_set_default_clock_class( } #endif +#include + #endif /* BABELTRACE_TRACE_IR_STREAM_CLASS_H */ diff --git a/include/babeltrace2/trace-ir/stream-const.h b/include/babeltrace2/trace-ir/stream-const.h index 9607ef41..9a1d236b 100644 --- a/include/babeltrace2/trace-ir/stream-const.h +++ b/include/babeltrace2/trace-ir/stream-const.h @@ -36,11 +36,6 @@ extern "C" { #endif -typedef enum bt_stream_status { - BT_STREAM_STATUS_OK = 0, - BT_STREAM_STATUS_NOMEM = -12, -} bt_stream_status; - extern const bt_stream_class *bt_stream_borrow_class_const( const bt_stream *stream); diff --git a/include/babeltrace2/trace-ir/stream.h b/include/babeltrace2/trace-ir/stream.h index dbf9eff7..ec0edf79 100644 --- a/include/babeltrace2/trace-ir/stream.h +++ b/include/babeltrace2/trace-ir/stream.h @@ -27,13 +27,15 @@ * http://www.efficios.com/ctf */ +#include + /* For bt_trace, bt_stream, bt_stream_class */ #include -/* For bt_stream_status */ -#include - -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { @@ -50,11 +52,18 @@ extern bt_trace *bt_stream_borrow_trace(bt_stream *stream); extern bt_stream_class *bt_stream_borrow_class(bt_stream *stream); -extern bt_stream_status bt_stream_set_name(bt_stream *stream, +typedef enum bt_stream_set_name_status { + BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_STREAM_SET_NAME_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_stream_set_name_status; + +extern bt_stream_set_name_status bt_stream_set_name(bt_stream *stream, const char *name); #ifdef __cplusplus } #endif +#include + #endif /* BABELTRACE_TRACE_IR_STREAM_H */ diff --git a/include/babeltrace2/trace-ir/trace-class-const.h b/include/babeltrace2/trace-ir/trace-class-const.h index 9cabb87c..1ceb6deb 100644 --- a/include/babeltrace2/trace-ir/trace-class-const.h +++ b/include/babeltrace2/trace-ir/trace-class-const.h @@ -27,23 +27,23 @@ * http://www.efficios.com/ctf */ +#include + /* * For bt_bool, bt_uuid, bt_trace_class, bt_stream_class, * bt_field_class, bt_value */ #include -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { #endif -typedef enum bt_trace_class_status { - BT_TRACE_CLASS_STATUS_OK = 0, - BT_TRACE_CLASS_STATUS_NOMEM = -12, -} bt_trace_class_status; - typedef void (* bt_trace_class_destruction_listener_func)( const bt_trace_class *trace_class, void *data); @@ -77,12 +77,24 @@ bt_trace_class_borrow_stream_class_by_index_const( extern const bt_stream_class *bt_trace_class_borrow_stream_class_by_id_const( const bt_trace_class *trace_class, uint64_t id); -extern bt_trace_class_status bt_trace_class_add_destruction_listener( +typedef enum bt_trace_class_add_listener_status { + BT_TRACE_CLASS_ADD_LISTENER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_TRACE_CLASS_ADD_LISTENER_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_trace_class_add_listener_status; + +extern bt_trace_class_add_listener_status +bt_trace_class_add_destruction_listener( const bt_trace_class *trace_class, bt_trace_class_destruction_listener_func listener, void *data, uint64_t *listener_id); -extern bt_trace_class_status bt_trace_class_remove_destruction_listener( +typedef enum bt_trace_class_remove_listener_status { + BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_trace_class_remove_listener_status; + +extern bt_trace_class_remove_listener_status +bt_trace_class_remove_destruction_listener( const bt_trace_class *trace_class, uint64_t listener_id); extern void bt_trace_class_get_ref(const bt_trace_class *trace_class); @@ -106,4 +118,6 @@ extern void bt_trace_class_put_ref(const bt_trace_class *trace_class); } #endif +#include + #endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H */ diff --git a/include/babeltrace2/trace-ir/trace-class.h b/include/babeltrace2/trace-ir/trace-class.h index ba1372f1..1a32127e 100644 --- a/include/babeltrace2/trace-ir/trace-class.h +++ b/include/babeltrace2/trace-ir/trace-class.h @@ -27,16 +27,18 @@ * http://www.efficios.com/ctf */ +#include + /* * For bt_bool, bt_uuid, bt_trace_class, bt_stream_class, * bt_field_class, bt_self_component */ #include -/* For bt_trace_class_status */ -#include - -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { @@ -47,17 +49,29 @@ extern bt_trace_class *bt_trace_class_create(bt_self_component *self_comp); extern void bt_trace_class_set_assigns_automatic_stream_class_id( bt_trace_class *trace_class, bt_bool value); -extern bt_trace_class_status bt_trace_class_set_name( +typedef enum bt_trace_class_set_name_status { + BT_TRACE_CLASS_SET_NAME_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_TRACE_CLASS_SET_NAME_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_trace_class_set_name_status; + +extern bt_trace_class_set_name_status bt_trace_class_set_name( bt_trace_class *trace_class, const char *name); extern void bt_trace_class_set_uuid(bt_trace_class *trace_class, bt_uuid uuid); -extern bt_trace_class_status bt_trace_class_set_environment_entry_integer( +typedef enum bt_trace_class_set_environment_entry_status { + BT_TRACE_CLASS_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_TRACE_CLASS_SET_ENVIRONMENT_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_trace_class_set_environment_entry_status; + +extern bt_trace_class_set_environment_entry_status +bt_trace_class_set_environment_entry_integer( bt_trace_class *trace_class, const char *name, int64_t value); -extern bt_trace_class_status bt_trace_class_set_environment_entry_string( +extern bt_trace_class_set_environment_entry_status +bt_trace_class_set_environment_entry_string( bt_trace_class *trace_class, const char *name, const char *value); @@ -71,4 +85,6 @@ extern bt_stream_class *bt_trace_class_borrow_stream_class_by_id( } #endif +#include + #endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_H */ diff --git a/include/babeltrace2/trace-ir/trace-const.h b/include/babeltrace2/trace-ir/trace-const.h index 98e7b526..a0ee825d 100644 --- a/include/babeltrace2/trace-ir/trace-const.h +++ b/include/babeltrace2/trace-ir/trace-const.h @@ -27,23 +27,23 @@ * http://www.efficios.com/ctf */ +#include + /* * For bt_bool, bt_uuid, bt_trace, bt_stream, bt_stream_class, * bt_field_class, bt_value */ #include -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { #endif -typedef enum bt_trace_status { - BT_TRACE_STATUS_OK = 0, - BT_TRACE_STATUS_NOMEM = -12, -} bt_trace_status; - typedef void (* bt_trace_destruction_listener_func)( const bt_trace *trace, void *data); @@ -60,12 +60,22 @@ extern const bt_stream *bt_trace_borrow_stream_by_index_const( extern const bt_stream *bt_trace_borrow_stream_by_id_const( const bt_trace *trace, uint64_t id); -extern bt_trace_status bt_trace_add_destruction_listener( +typedef enum bt_trace_add_listener_status { + BT_TRACE_ADD_LISTENER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_TRACE_ADD_LISTENER_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_trace_add_listener_status; + +extern bt_trace_add_listener_status bt_trace_add_destruction_listener( const bt_trace *trace, bt_trace_destruction_listener_func listener, void *data, uint64_t *listener_id); -extern bt_trace_status bt_trace_remove_destruction_listener( +typedef enum bt_trace_remove_listener_status { + BT_TRACE_REMOVE_LISTENER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_TRACE_REMOVE_LISTENER_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_trace_remove_listener_status; + +extern bt_trace_remove_listener_status bt_trace_remove_destruction_listener( const bt_trace *trace, uint64_t listener_id); extern void bt_trace_get_ref(const bt_trace *trace); @@ -89,4 +99,6 @@ extern void bt_trace_put_ref(const bt_trace *trace); } #endif +#include + #endif /* BABELTRACE_TRACE_IR_TRACE_CONST_H */ diff --git a/include/babeltrace2/trace-ir/trace.h b/include/babeltrace2/trace-ir/trace.h index 57128670..c759ca63 100644 --- a/include/babeltrace2/trace-ir/trace.h +++ b/include/babeltrace2/trace-ir/trace.h @@ -27,13 +27,15 @@ * http://www.efficios.com/ctf */ +#include + /* For bt_bool, bt_trace, bt_trace_class, bt_stream */ #include -/* For bt_trace_status */ -#include - -#include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE #ifdef __cplusplus extern "C" { @@ -43,7 +45,12 @@ extern bt_trace_class *bt_trace_borrow_class(bt_trace *trace); extern bt_trace *bt_trace_create(bt_trace_class *trace_class); -extern bt_trace_status bt_trace_set_name(bt_trace *trace, +typedef enum bt_trace_set_name_status { + BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_TRACE_SET_NAME_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_trace_set_name_status; + +extern bt_trace_set_name_status bt_trace_set_name(bt_trace *trace, const char *name); extern bt_stream *bt_trace_borrow_stream_by_index(bt_trace *trace, @@ -56,4 +63,6 @@ extern bt_stream *bt_trace_borrow_stream_by_id(bt_trace *trace, } #endif +#include + #endif /* BABELTRACE_TRACE_IR_TRACE_H */ diff --git a/include/babeltrace2/types.h b/include/babeltrace2/types.h index 3ebf5370..6884f175 100644 --- a/include/babeltrace2/types.h +++ b/include/babeltrace2/types.h @@ -135,6 +135,7 @@ typedef struct bt_self_component_port_output bt_self_component_port_output; typedef struct bt_self_component_sink bt_self_component_sink; typedef struct bt_self_component_source bt_self_component_source; typedef struct bt_self_message_iterator bt_self_message_iterator; +typedef struct bt_self_plugin bt_self_plugin; typedef struct bt_self_port bt_self_port; typedef struct bt_self_port_input bt_self_port_input; typedef struct bt_self_port_output bt_self_port_output; diff --git a/include/babeltrace2/graph/message-iterator-const.h b/include/babeltrace2/undef-func-status.h similarity index 63% rename from include/babeltrace2/graph/message-iterator-const.h rename to include/babeltrace2/undef-func-status.h index 43a6ab19..f505a75c 100644 --- a/include/babeltrace2/graph/message-iterator-const.h +++ b/include/babeltrace2/undef-func-status.h @@ -1,9 +1,8 @@ -#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_CONST_H -#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_CONST_H +#ifndef BABELTRACE_UNDEF_FUNC_STATUS_H +#define BABELTRACE_UNDEF_FUNC_STATUS_H /* - * Copyright 2017-2018 Philippe Proulx - * Copyright 2015 Jérémie Galarneau + * Copyright (c) 2019 Philippe Proulx * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,20 +23,17 @@ * SOFTWARE. */ -#ifdef __cplusplus -extern "C" { -#endif +#undef __BT_FUNC_STATUS_OVERFLOW +#undef __BT_FUNC_STATUS_INVALID_PARAMS +#undef __BT_FUNC_STATUS_INVALID_OBJECT +#undef __BT_FUNC_STATUS_MEMORY_ERROR +#undef __BT_FUNC_STATUS_LOADING_ERROR +#undef __BT_FUNC_STATUS_ERROR +#undef __BT_FUNC_STATUS_OK +#undef __BT_FUNC_STATUS_END +#undef __BT_FUNC_STATUS_NOT_FOUND +#undef __BT_FUNC_STATUS_AGAIN +#undef __BT_FUNC_STATUS_UNSUPPORTED +#undef __BT_FUNC_STATUS_CANCELED -typedef enum bt_message_iterator_status { - BT_MESSAGE_ITERATOR_STATUS_OK = 0, - BT_MESSAGE_ITERATOR_STATUS_END = 1, - BT_MESSAGE_ITERATOR_STATUS_AGAIN = 11, - BT_MESSAGE_ITERATOR_STATUS_ERROR = -1, - BT_MESSAGE_ITERATOR_STATUS_NOMEM = -12, -} bt_message_iterator_status; - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_CONST_H */ +#endif /* BABELTRACE_UNDEF_FUNC_STATUS_H */ diff --git a/include/babeltrace2/value-const.h b/include/babeltrace2/value-const.h index 5142abfd..01aed6e4 100644 --- a/include/babeltrace2/value-const.h +++ b/include/babeltrace2/value-const.h @@ -29,21 +29,15 @@ /* For bt_bool, bt_value */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif -typedef enum bt_value_status { - /// Operation canceled. - BT_VALUE_STATUS_CANCELED = 125, - - /// Cannot allocate memory. - BT_VALUE_STATUS_NOMEM = -12, - - /// Okay, no error. - BT_VALUE_STATUS_OK = 0, -} bt_value_status; - typedef enum bt_value_type { /// Null value object. BT_VALUE_TYPE_NULL = 0, @@ -120,7 +114,12 @@ bt_bool bt_value_is_map(const bt_value *object) return bt_value_get_type(object) == BT_VALUE_TYPE_MAP; } -extern bt_value_status bt_value_copy(const bt_value *object, +typedef enum bt_value_copy_status { + BT_VALUE_COPY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_VALUE_COPY_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_value_copy_status; + +extern bt_value_copy_status bt_value_copy(const bt_value *object, bt_value **copy); extern bt_bool bt_value_compare(const bt_value *object_a, @@ -161,14 +160,25 @@ extern const bt_value *bt_value_map_borrow_entry_value_const( typedef bt_bool (* bt_value_map_foreach_entry_const_func)(const char *key, const bt_value *object, void *data); -extern bt_value_status bt_value_map_foreach_entry_const( +typedef enum bt_value_map_foreach_entry_const_status { + BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_CANCELED = __BT_FUNC_STATUS_CANCELED, +} bt_value_map_foreach_entry_const_status; + +extern bt_value_map_foreach_entry_const_status bt_value_map_foreach_entry_const( const bt_value *map_obj, bt_value_map_foreach_entry_const_func func, void *data); extern bt_bool bt_value_map_has_entry(const bt_value *map_obj, const char *key); -extern bt_value_status bt_value_map_extend( +typedef enum bt_value_map_extend_status { + BT_VALUE_MAP_EXTEND_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_VALUE_MAP_EXTEND_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_value_map_extend_status; + +extern bt_value_map_extend_status bt_value_map_extend( const bt_value *base_map_obj, const bt_value *extension_map_obj, bt_value **extended_map_obj); @@ -194,4 +204,6 @@ extern void bt_value_put_ref(const bt_value *value); } #endif +#include + #endif /* BABELTRACE_VALUES_CONST_H */ diff --git a/include/babeltrace2/value.h b/include/babeltrace2/value.h index c2481745..13759409 100644 --- a/include/babeltrace2/value.h +++ b/include/babeltrace2/value.h @@ -29,9 +29,14 @@ /* For bt_bool, bt_value */ #include -/* For bt_value_status, bt_value_type */ +/* For bt_value_type */ #include +/* For __BT_FUNC_STATUS_* */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #ifdef __cplusplus extern "C" { #endif @@ -66,41 +71,56 @@ extern bt_value *bt_value_string_create(void); extern bt_value *bt_value_string_create_init(const char *val); -extern bt_value_status bt_value_string_set(bt_value *string_obj, +typedef enum bt_value_string_set_status { + BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_VALUE_STRING_SET_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_value_string_set_status; + +extern bt_value_string_set_status bt_value_string_set(bt_value *string_obj, const char *val); extern bt_value *bt_value_array_create(void); -extern bt_value *bt_value_array_borrow_element_by_index( - bt_value *array_obj, uint64_t index); +extern bt_value *bt_value_array_borrow_element_by_index(bt_value *array_obj, + uint64_t index); -extern bt_value_status bt_value_array_append_element( - bt_value *array_obj, - bt_value *element_obj); +typedef enum bt_value_array_append_element_status { + BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_value_array_append_element_status; -extern bt_value_status bt_value_array_append_bool_element( - bt_value *array_obj, bt_bool val); +extern bt_value_array_append_element_status bt_value_array_append_element( + bt_value *array_obj, bt_value *element_obj); -extern bt_value_status bt_value_array_append_unsigned_integer_element( - bt_value *array_obj, uint64_t val); +extern bt_value_array_append_element_status +bt_value_array_append_bool_element(bt_value *array_obj, bt_bool val); -extern bt_value_status bt_value_array_append_signed_integer_element( - bt_value *array_obj, int64_t val); +extern bt_value_array_append_element_status +bt_value_array_append_unsigned_integer_element(bt_value *array_obj, + uint64_t val); -extern bt_value_status bt_value_array_append_real_element( - bt_value *array_obj, double val); +extern bt_value_array_append_element_status +bt_value_array_append_signed_integer_element(bt_value *array_obj, int64_t val); -extern bt_value_status bt_value_array_append_string_element( - bt_value *array_obj, const char *val); +extern bt_value_array_append_element_status +bt_value_array_append_real_element(bt_value *array_obj, double val); -extern bt_value_status bt_value_array_append_empty_array_element( - bt_value *array_obj); +extern bt_value_array_append_element_status +bt_value_array_append_string_element(bt_value *array_obj, const char *val); -extern bt_value_status bt_value_array_append_empty_map_element( - bt_value *array_obj); +extern bt_value_array_append_element_status +bt_value_array_append_empty_array_element(bt_value *array_obj); -extern bt_value_status bt_value_array_set_element_by_index( - bt_value *array_obj, uint64_t index, +extern bt_value_array_append_element_status +bt_value_array_append_empty_map_element(bt_value *array_obj); + +typedef enum bt_value_array_set_element_by_index_status { + BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_value_array_set_element_by_index_status; + +extern bt_value_array_set_element_by_index_status +bt_value_array_set_element_by_index(bt_value *array_obj, uint64_t index, bt_value *element_obj); extern bt_value *bt_value_map_create(void); @@ -111,38 +131,52 @@ extern bt_value *bt_value_map_borrow_entry_value( typedef bt_bool (* bt_value_map_foreach_entry_func)(const char *key, bt_value *object, void *data); -extern bt_value_status bt_value_map_foreach_entry( - bt_value *map_obj, - bt_value_map_foreach_entry_func func, void *data); +typedef enum bt_value_map_foreach_entry_status { + BT_VALUE_MAP_FOREACH_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_VALUE_MAP_FOREACH_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_VALUE_MAP_FOREACH_ENTRY_STATUS_CANCELED = __BT_FUNC_STATUS_CANCELED, +} bt_value_map_foreach_entry_status; -extern bt_value_status bt_value_map_insert_entry( - bt_value *map_obj, const char *key, - bt_value *element_obj); +extern bt_value_map_foreach_entry_status bt_value_map_foreach_entry( + bt_value *map_obj, bt_value_map_foreach_entry_func func, + void *data); -extern bt_value_status bt_value_map_insert_bool_entry( +typedef enum bt_value_map_insert_entry_status { + BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_value_map_insert_entry_status; + +extern bt_value_map_insert_entry_status bt_value_map_insert_entry( + bt_value *map_obj, const char *key, bt_value *element_obj); + +extern bt_value_map_insert_entry_status bt_value_map_insert_bool_entry( bt_value *map_obj, const char *key, bt_bool val); -extern bt_value_status bt_value_map_insert_unsigned_integer_entry( - bt_value *map_obj, const char *key, uint64_t val); +extern bt_value_map_insert_entry_status +bt_value_map_insert_unsigned_integer_entry(bt_value *map_obj, const char *key, + uint64_t val); -extern bt_value_status bt_value_map_insert_signed_integer_entry( - bt_value *map_obj, const char *key, int64_t val); +extern bt_value_map_insert_entry_status +bt_value_map_insert_signed_integer_entry(bt_value *map_obj, const char *key, + int64_t val); -extern bt_value_status bt_value_map_insert_real_entry( +extern bt_value_map_insert_entry_status bt_value_map_insert_real_entry( bt_value *map_obj, const char *key, double val); -extern bt_value_status bt_value_map_insert_string_entry( - bt_value *map_obj, const char *key, +extern bt_value_map_insert_entry_status +bt_value_map_insert_string_entry(bt_value *map_obj, const char *key, const char *val); -extern bt_value_status bt_value_map_insert_empty_array_entry( - bt_value *map_obj, const char *key); +extern bt_value_map_insert_entry_status +bt_value_map_insert_empty_array_entry(bt_value *map_obj, const char *key); -extern bt_value_status bt_value_map_insert_empty_map_entry( - bt_value *map_obj, const char *key); +extern bt_value_map_insert_entry_status +bt_value_map_insert_empty_map_entry(bt_value *map_obj, const char *key); #ifdef __cplusplus } #endif +#include + #endif /* BABELTRACE_VALUES_H */ diff --git a/src/bindings/python/bt2/bt2/__init__.py.in b/src/bindings/python/bt2/bt2/__init__.py.in index 98a1eb5d..0faede10 100644 --- a/src/bindings/python/bt2/bt2/__init__.py.in +++ b/src/bindings/python/bt2/bt2/__init__.py.in @@ -74,31 +74,35 @@ class CreationError(Error): '''Raised when object creation fails due to memory issues.''' -class InvalidQueryObject(Error): +class InvalidObject(Error): pass -class InvalidQueryParams(Error): +class InvalidParams(Error): pass -class TryAgain(Exception): +class OverflowError(OverflowError): pass -class Stop(StopIteration): +class Unsupported(Exception): pass -class IncompleteUserClass(Error): +class TryAgain(Exception): pass -class GraphCanceled(Exception): +class Stop(StopIteration): + pass + + +class IncompleteUserClass(Error): pass -class QueryExecutorCanceled(Exception): +class Canceled(Exception): pass @@ -106,7 +110,7 @@ class NonexistentClockSnapshot(Error): pass -class PluginLoadingError(Error): +class LoadingError(Error): pass @@ -120,10 +124,10 @@ def _init_and_register_exit(): import bt2.native_bt as _native_bt import atexit - atexit.register(_native_bt.py3_cc_exit_handler) + atexit.register(_native_bt.bt2_cc_exit_handler) version = (_native_bt.version_get_major(), _native_bt.version_get_minor(), _native_bt.version_get_patch(), _native_bt.version_get_extra()) - _native_bt.py3_cc_init_from_bt2() + _native_bt.bt2_cc_init_from_bt2() _init_and_register_exit() diff --git a/src/bindings/python/bt2/bt2/clock_class.py b/src/bindings/python/bt2/bt2/clock_class.py index 59a93cd7..6d0ff72a 100644 --- a/src/bindings/python/bt2/bt2/clock_class.py +++ b/src/bindings/python/bt2/bt2/clock_class.py @@ -58,8 +58,9 @@ class _ClockClass(object._SharedObject): def _name(self, name): utils._check_str(name) - ret = native_bt.clock_class_set_name(self._ptr, name) - utils._handle_ret(ret, "cannot set clock class object's name") + status = native_bt.clock_class_set_name(self._ptr, name) + utils._handle_func_status(status, + "cannot set clock class object's name") _name = property(fset=_name) @@ -69,8 +70,9 @@ class _ClockClass(object._SharedObject): def _description(self, description): utils._check_str(description) - ret = native_bt.clock_class_set_description(self._ptr, description) - utils._handle_ret(ret, "cannot set clock class object's description") + status = native_bt.clock_class_set_description(self._ptr, description) + utils._handle_func_status(status, + "cannot set clock class object's description") _description = property(fset=_description) @@ -133,12 +135,7 @@ class _ClockClass(object._SharedObject): def cycles_to_ns_from_origin(self, cycles): utils._check_uint64(cycles) - ret, ns = native_bt.clock_class_cycles_to_ns_from_origin(self._ptr, cycles) - + status, ns = native_bt.clock_class_cycles_to_ns_from_origin(self._ptr, cycles) error_msg = "cannot convert clock value to nanoseconds from origin for given clock class" - - if ret == native_bt.CLOCK_CLASS_STATUS_OVERFLOW: - raise OverflowError(error_msg) - - utils._handle_ret(ret, error_msg) + utils._handle_func_status(status, error_msg) return ns diff --git a/src/bindings/python/bt2/bt2/clock_snapshot.py b/src/bindings/python/bt2/bt2/clock_snapshot.py index 89d7a11b..46abdc78 100644 --- a/src/bindings/python/bt2/bt2/clock_snapshot.py +++ b/src/bindings/python/bt2/bt2/clock_snapshot.py @@ -40,11 +40,9 @@ class _ClockSnapshot(object._UniqueObject): @property def ns_from_origin(self): - ret, ns = native_bt.clock_snapshot_get_ns_from_origin(self._ptr) - - if ret == native_bt.CLOCK_SNAPSHOT_STATUS_OVERFLOW: - raise OverflowError("cannot get clock snapshot's nanoseconds from origin") - + status, ns = native_bt.clock_snapshot_get_ns_from_origin(self._ptr) + utils._handle_func_status(status, + "cannot get clock snapshot's nanoseconds from origin") return ns def __eq__(self, other): diff --git a/src/bindings/python/bt2/bt2/component.py b/src/bindings/python/bt2/bt2/component.py index 7f56757d..b8026cc2 100644 --- a/src/bindings/python/bt2/bt2/component.py +++ b/src/bindings/python/bt2/bt2/component.py @@ -95,15 +95,6 @@ class _GenericSinkComponentClass(_GenericComponentClass): _as_component_class_ptr = staticmethod(native_bt.component_class_sink_as_component_class) -def _handle_component_status(status, gen_error_msg): - if status == native_bt.SELF_COMPONENT_STATUS_END: - raise bt2.Stop - elif status == native_bt.SELF_COMPONENT_STATUS_AGAIN: - raise bt2.TryAgain - elif status < 0: - raise bt2.Error(gen_error_msg) - - class _PortIterator(collections.abc.Iterator): def __init__(self, comp_ports): self._comp_ports = comp_ports @@ -445,13 +436,13 @@ class _UserComponentType(type): if _UserSourceComponent in bases: _UserComponentType._set_iterator_class(cls, iter_cls) - cc_ptr = native_bt.py3_component_class_source_create(cls, + cc_ptr = native_bt.bt2_component_class_source_create(cls, comp_cls_name, comp_cls_descr, comp_cls_help) elif _UserFilterComponent in bases: _UserComponentType._set_iterator_class(cls, iter_cls) - cc_ptr = native_bt.py3_component_class_filter_create(cls, + cc_ptr = native_bt.bt2_component_class_filter_create(cls, comp_cls_name, comp_cls_descr, comp_cls_help) @@ -459,7 +450,7 @@ class _UserComponentType(type): if not hasattr(cls, '_consume'): raise bt2.IncompleteUserClass("cannot create component class '{}': missing a _consume() method".format(class_name)) - cc_ptr = native_bt.py3_component_class_sink_create(cls, + cc_ptr = native_bt.bt2_component_class_sink_create(cls, comp_cls_name, comp_cls_descr, comp_cls_help) @@ -694,8 +685,8 @@ class _UserSourceComponent(_UserComponent, _SourceComponent): utils._check_str(name) fn = native_bt.self_component_source_add_output_port comp_status, self_port_ptr = fn(self._ptr, name, user_data) - _handle_component_status(comp_status, - 'cannot add output port to source component object') + utils._handle_func_status(comp_status, + 'cannot add output port to source component object') assert self_port_ptr is not None return bt2.port._UserComponentOutputPort._create_from_ptr(self_port_ptr) @@ -732,8 +723,8 @@ class _UserFilterComponent(_UserComponent, _FilterComponent): utils._check_str(name) fn = native_bt.self_component_filter_add_output_port comp_status, self_port_ptr = fn(self._ptr, name, user_data) - _handle_component_status(comp_status, - 'cannot add output port to filter component object') + utils._handle_func_status(comp_status, + 'cannot add output port to filter component object') assert self_port_ptr return bt2.port._UserComponentOutputPort._create_from_ptr(self_port_ptr) @@ -741,8 +732,8 @@ class _UserFilterComponent(_UserComponent, _FilterComponent): utils._check_str(name) fn = native_bt.self_component_filter_add_input_port comp_status, self_port_ptr = fn(self._ptr, name, user_data) - _handle_component_status(comp_status, - 'cannot add input port to filter component object') + utils._handle_func_status(comp_status, + 'cannot add input port to filter component object') assert self_port_ptr return bt2.port._UserComponentInputPort._create_from_ptr(self_port_ptr) @@ -767,7 +758,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponent): utils._check_str(name) fn = native_bt.self_component_sink_add_input_port comp_status, self_port_ptr = fn(self._ptr, name, user_data) - _handle_component_status(comp_status, - 'cannot add input port to sink component object') + utils._handle_func_status(comp_status, + 'cannot add input port to sink component object') assert self_port_ptr return bt2.port._UserComponentInputPort._create_from_ptr(self_port_ptr) diff --git a/src/bindings/python/bt2/bt2/event_class.py b/src/bindings/python/bt2/bt2/event_class.py index d3141b86..cb7cc73f 100644 --- a/src/bindings/python/bt2/bt2/event_class.py +++ b/src/bindings/python/bt2/bt2/event_class.py @@ -112,8 +112,9 @@ class _EventClass(object._SharedObject): def _emf_uri(self, emf_uri): utils._check_str(emf_uri) - ret = native_bt.event_class_set_emf_uri(self._ptr, emf_uri) - utils._handle_ret(ret, "cannot set event class object's EMF URI") + status = native_bt.event_class_set_emf_uri(self._ptr, emf_uri) + utils._handle_func_status(status, + "cannot set event class object's EMF URI") _emf_uri = property(fset=_emf_uri) @@ -129,8 +130,9 @@ class _EventClass(object._SharedObject): def _specific_context_field_class(self, context_field_class): if context_field_class is not None: utils._check_type(context_field_class, bt2.field_class._StructureFieldClass) - ret = native_bt.event_class_set_specific_context_field_class(self._ptr, context_field_class._ptr) - utils._handle_ret(ret, "cannot set event class object's context field class") + status = native_bt.event_class_set_specific_context_field_class(self._ptr, context_field_class._ptr) + utils._handle_func_status(status, + "cannot set event class object's context field class") _specific_context_field_class = property(fset=_specific_context_field_class) @@ -146,8 +148,9 @@ class _EventClass(object._SharedObject): def _payload_field_class(self, payload_field_class): if payload_field_class is not None: utils._check_type(payload_field_class, bt2.field_class._StructureFieldClass) - ret = native_bt.event_class_set_payload_field_class(self._ptr, payload_field_class._ptr) - utils._handle_ret(ret, "cannot set event class object's payload field class") + status = native_bt.event_class_set_payload_field_class(self._ptr, payload_field_class._ptr) + utils._handle_func_status(status, + "cannot set event class object's payload field class") _payload_field_class = property(fset=_payload_field_class) diff --git a/src/bindings/python/bt2/bt2/field.py b/src/bindings/python/bt2/bt2/field.py index 8e9dba6a..0f3e5e7e 100644 --- a/src/bindings/python/bt2/bt2/field.py +++ b/src/bindings/python/bt2/bt2/field.py @@ -279,8 +279,9 @@ class _EnumerationField(_IntegerField): @property def labels(self): - ret, labels = self._get_mapping_labels(self._ptr) - utils._handle_ret(ret, "cannot get label for enumeration field") + status, labels = self._get_mapping_labels(self._ptr) + utils._handle_func_status(status, + "cannot get label for enumeration field") assert labels is not None return labels @@ -345,8 +346,9 @@ class _StringField(_Field): def __iadd__(self, value): value = self._value_to_str(value) - ret = native_bt.field_string_append(self._ptr, value) - utils._handle_ret(ret, "cannot append to string field object's value") + status = native_bt.field_string_append(self._ptr, value) + utils._handle_func_status(status, + "cannot append to string field object's value") return self @@ -552,8 +554,8 @@ class _DynamicArrayField(_ArrayField, _Field): def _set_length(self, length): utils._check_uint64(length) - ret = native_bt.field_dynamic_array_set_length(self._ptr, length) - utils._handle_ret(ret, "cannot set dynamic array length") + status = native_bt.field_dynamic_array_set_length(self._ptr, length) + utils._handle_func_status(status, "cannot set dynamic array length") length = property(fget=_ArrayField._get_length, fset=_set_length) diff --git a/src/bindings/python/bt2/bt2/field_class.py b/src/bindings/python/bt2/bt2/field_class.py index 27a37d96..7ea00c21 100644 --- a/src/bindings/python/bt2/bt2/field_class.py +++ b/src/bindings/python/bt2/bt2/field_class.py @@ -173,12 +173,13 @@ class _EnumerationFieldClass(_IntegerFieldClass, collections.abc.Mapping): if upper is None: upper = lower - ret = self._map_range(self._ptr, label, lower, upper) - utils._handle_ret(ret, "cannot add mapping to enumeration field class object") + status = self._map_range(self._ptr, label, lower, upper) + utils._handle_func_status(status, + "cannot add mapping to enumeration field class object") def labels_by_value(self, value): - ret, labels = self._get_mapping_labels_by_value(self._ptr, value) - utils._handle_ret(ret, "cannot get mapping labels") + status, labels = self._get_mapping_labels_by_value(self._ptr, value) + utils._handle_func_status(status, "cannot get mapping labels") return labels def __iter__(self): @@ -283,8 +284,9 @@ class _FieldContainer(collections.abc.Mapping): def _append_element_common(self, name, field_class): utils._check_str(name) utils._check_type(field_class, _FieldClass) - ret = self._append_element(self._ptr, name, field_class._ptr) - utils._handle_ret(ret, "cannot add field to {} field class object".format(self._NAME.lower())) + status = self._append_element(self._ptr, name, field_class._ptr) + utils._handle_func_status(status, + "cannot add field to {} field class object".format(self._NAME.lower())) def __iadd__(self, fields): for name, field_class in fields.items(): @@ -347,8 +349,9 @@ class _VariantFieldClass(_FieldClass, _FieldContainer): def _set_selector_field_class(self, selector_fc): utils._check_type(selector_fc, bt2.field_class._EnumerationFieldClass) - ret = native_bt.field_class_variant_set_selector_field_class(self._ptr, selector_fc._ptr) - utils._handle_ret(ret, "cannot set variant selector field type") + status = native_bt.field_class_variant_set_selector_field_class(self._ptr, selector_fc._ptr) + utils._handle_func_status(status, + "cannot set variant selector field type") _selector_field_class = property(fset=_set_selector_field_class) @@ -377,8 +380,9 @@ class _DynamicArrayFieldClass(_ArrayFieldClass): def _set_length_field_class(self, length_fc): utils._check_type(length_fc, _UnsignedIntegerFieldClass) - ret = native_bt.field_class_dynamic_array_set_length_field_class(self._ptr, length_fc._ptr) - utils._handle_ret(ret, "cannot set dynamic array length field type") + status = native_bt.field_class_dynamic_array_set_length_field_class(self._ptr, length_fc._ptr) + utils._handle_func_status(status, + "cannot set dynamic array length field type") _length_field_class = property(fset=_set_length_field_class) diff --git a/src/bindings/python/bt2/bt2/graph.py b/src/bindings/python/bt2/bt2/graph.py index f1270b5a..c1443101 100644 --- a/src/bindings/python/bt2/bt2/graph.py +++ b/src/bindings/python/bt2/bt2/graph.py @@ -65,15 +65,6 @@ class Graph(object._SharedObject): super().__init__(ptr) - def _handle_status(self, status, gen_error_msg): - if status == native_bt.GRAPH_STATUS_CANCELED: - raise bt2.GraphCanceled - elif status == native_bt.GRAPH_STATUS_END: - raise bt2.Stop - elif status == native_bt.GRAPH_STATUS_AGAIN: - raise bt2.TryAgain - elif status < 0: - raise bt2.Error(gen_error_msg) def add_component(self, component_class, name, params=None, logging_level=bt2.logging.LoggingLevel.NONE): @@ -113,7 +104,7 @@ class Graph(object._SharedObject): status, comp_ptr = add_fn(self._ptr, cc_ptr, name, params_ptr, logging_level) - self._handle_status(status, 'cannot add component to graph') + utils._handle_func_status(status, 'cannot add component to graph') assert comp_ptr return bt2.component._create_component_from_ptr(comp_ptr, cc_type) @@ -123,7 +114,8 @@ class Graph(object._SharedObject): status, conn_ptr = native_bt.graph_connect_ports(self._ptr, upstream_port._ptr, downstream_port._ptr) - self._handle_status(status, 'cannot connect component ports within graph') + utils._handle_func_status(status, + 'cannot connect component ports within graph') assert(conn_ptr) return bt2.connection._Connection._create_from_ptr(conn_ptr) @@ -131,7 +123,7 @@ class Graph(object._SharedObject): if not callable(listener): raise TypeError("'listener' parameter is not callable") - fn = native_bt.py3_graph_add_port_added_listener + fn = native_bt.bt2_graph_add_port_added_listener listener_from_native = functools.partial(_graph_port_added_listener_from_native, listener) @@ -144,7 +136,7 @@ class Graph(object._SharedObject): if not callable(listener): raise TypeError("'listener' parameter is not callable") - fn = native_bt.py3_graph_add_ports_connected_listener + fn = native_bt.bt2_graph_add_ports_connected_listener listener_from_native = functools.partial(_graph_ports_connected_listener_from_native, listener) @@ -156,14 +148,18 @@ class Graph(object._SharedObject): def run(self): status = native_bt.graph_run(self._ptr) - if status == native_bt.GRAPH_STATUS_END: + try: + utils._handle_func_status(status, + 'graph object stopped running because of an unexpected error') + except bt2.Stop: + # done return - - self._handle_status(status, 'graph object stopped running because of an unexpected error') + except Exception: + raise def cancel(self): status = native_bt.graph_cancel(self._ptr) - self._handle_status(status, 'cannot cancel graph object') + utils._handle_func_status(status, 'cannot cancel graph object') @property def is_canceled(self): diff --git a/src/bindings/python/bt2/bt2/message_iterator.py b/src/bindings/python/bt2/bt2/message_iterator.py index b56b17a2..66a64222 100644 --- a/src/bindings/python/bt2/bt2/message_iterator.py +++ b/src/bindings/python/bt2/bt2/message_iterator.py @@ -38,19 +38,11 @@ class _GenericMessageIterator(object._SharedObject, _MessageIterator): self._at = 0 super().__init__(ptr) - def _handle_status(self, status, gen_error_msg): - if status == native_bt.MESSAGE_ITERATOR_STATUS_AGAIN: - raise bt2.TryAgain - elif status == native_bt.MESSAGE_ITERATOR_STATUS_END: - raise bt2.Stop - elif status < 0: - raise bt2.Error(gen_error_msg) - def __next__(self): if len(self._current_msgs) == self._at: status, msgs = self._get_msg_range(self._ptr) - self._handle_status(status, - 'unexpected error: cannot advance the message iterator') + utils._handle_func_status(status, + 'unexpected error: cannot advance the message iterator') self._current_msgs = msgs self._at = 0 @@ -70,12 +62,13 @@ class _GenericMessageIterator(object._SharedObject, _MessageIterator): self._at = 0 status = self._seek_beginning(self._ptr) - self._handle_status(status, 'cannot seek message iterator beginning') + utils._handle_func_status(status, + 'cannot seek message iterator beginning') # This is created when a component wants to iterate on one of its input ports. class _UserComponentInputPortMessageIterator(_GenericMessageIterator): - _get_msg_range = staticmethod(native_bt.py3_self_component_port_input_get_msg_range) + _get_msg_range = staticmethod(native_bt.bt2_self_component_port_input_get_msg_range) _get_ref = staticmethod(native_bt.self_component_port_input_message_iterator_get_ref) _put_ref = staticmethod(native_bt.self_component_port_input_message_iterator_put_ref) _can_seek_beginning = staticmethod(native_bt.self_component_port_input_message_iterator_can_seek_beginning) @@ -85,7 +78,7 @@ class _UserComponentInputPortMessageIterator(_GenericMessageIterator): # This is created when the user wants to iterate on a component's output port, # from outside the graph. class _OutputPortMessageIterator(_GenericMessageIterator): - _get_msg_range = staticmethod(native_bt.py3_port_output_get_msg_range) + _get_msg_range = staticmethod(native_bt.bt2_port_output_get_msg_range) _get_ref = staticmethod(native_bt.port_output_message_iterator_get_ref) _put_ref = staticmethod(native_bt.port_output_message_iterator_put_ref) _can_seek_beginning = staticmethod(native_bt.port_output_message_iterator_can_seek_beginning) @@ -125,7 +118,7 @@ class _UserMessageIterator(_MessageIterator): @property def _component(self): - return native_bt.py3_get_user_component_from_user_msg_iter(self._ptr) + return native_bt.bt2_get_user_component_from_user_msg_iter(self._ptr) @property def addr(self): diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i index 293189d6..f9fb4512 100644 --- a/src/bindings/python/bt2/bt2/native_bt.i +++ b/src/bindings/python/bt2/bt2/native_bt.i @@ -33,7 +33,15 @@ #include "logging.h" #include -#include + +/* + * This is not part of the API, but because those bindings reside within + * the project, we take the liberty to use them. + */ +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #include "common/assert.h" #include "py-common/py-common.h" @@ -172,8 +180,13 @@ typedef int bt_bool; $result = $1; } +/* Property enumeration */ %include +/* Common function status codes */ +#define __BT_FUNC_STATUS_ENABLE +%include + /* Per-module interface files */ %include "native_bt_clock_class.i" %include "native_bt_clock_snapshot.i" diff --git a/src/bindings/python/bt2/bt2/native_bt_component.i b/src/bindings/python/bt2/bt2/native_bt_component.i index 33b3a7f6..ae44579b 100644 --- a/src/bindings/python/bt2/bt2/native_bt_component.i +++ b/src/bindings/python/bt2/bt2/native_bt_component.i @@ -77,7 +77,7 @@ * we reflect that here. */ %typemap(argout) void *user_data { - if (PyLong_AsLong($result) == BT_SELF_COMPONENT_STATUS_OK) { + if (PyLong_AsLong($result) == __BT_FUNC_STATUS_OK) { Py_INCREF($1); } } diff --git a/src/bindings/python/bt2/bt2/native_bt_component_class.i b/src/bindings/python/bt2/bt2/native_bt_component_class.i index 8219040d..93aaf1b7 100644 --- a/src/bindings/python/bt2/bt2/native_bt_component_class.i +++ b/src/bindings/python/bt2/bt2/native_bt_component_class.i @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +%include %include %include %include @@ -42,7 +43,7 @@ * to create a user Python component anyway. * * This hash table is written to when a user-defined Python component - * class is created by one of the bt_py3_component_class_*_create() + * class is created by one of the bt_bt2_component_class_*_create() * functions. * * This function is read from when a user calls bt_component_create() @@ -96,11 +97,12 @@ static PyObject *py_mod_bt2_exc_error_type = NULL; static PyObject *py_mod_bt2_exc_try_again_type = NULL; static PyObject *py_mod_bt2_exc_stop_type = NULL; static PyObject *py_mod_bt2_exc_msg_iter_canceled_type = NULL; -static PyObject *py_mod_bt2_exc_invalid_query_object_type = NULL; -static PyObject *py_mod_bt2_exc_invalid_query_params_type = NULL; +static PyObject *py_mod_bt2_exc_invalid_object_type = NULL; +static PyObject *py_mod_bt2_exc_invalid_params_type = NULL; +static PyObject *py_mod_bt2_exc_unsupported_type = NULL; static -void bt_py3_cc_init_from_bt2(void) +void bt_bt2_cc_init_from_bt2(void) { /* * This is called once the bt2 package is loaded. @@ -121,22 +123,25 @@ void bt_py3_cc_init_from_bt2(void) py_mod_bt2_exc_stop_type = PyObject_GetAttrString(py_mod_bt2, "Stop"); BT_ASSERT(py_mod_bt2_exc_stop_type); - py_mod_bt2_exc_invalid_query_object_type = - PyObject_GetAttrString(py_mod_bt2, "InvalidQueryObject"); - BT_ASSERT(py_mod_bt2_exc_invalid_query_object_type); - py_mod_bt2_exc_invalid_query_params_type = - PyObject_GetAttrString(py_mod_bt2, "InvalidQueryParams"); - BT_ASSERT(py_mod_bt2_exc_invalid_query_params_type); + py_mod_bt2_exc_invalid_object_type = + PyObject_GetAttrString(py_mod_bt2, "InvalidObject"); + BT_ASSERT(py_mod_bt2_exc_invalid_object_type); + py_mod_bt2_exc_invalid_params_type = + PyObject_GetAttrString(py_mod_bt2, "InvalidParams"); + BT_ASSERT(py_mod_bt2_exc_invalid_params_type); + py_mod_bt2_exc_unsupported_type = + PyObject_GetAttrString(py_mod_bt2, "Unsupported"); + BT_ASSERT(py_mod_bt2_exc_unsupported_type); } static -void bt_py3_cc_exit_handler(void) +void bt_bt2_cc_exit_handler(void) { /* * This is an exit handler (set by the bt2 package). * * We only give back the references that we took in - * bt_py3_cc_init_from_bt2() here. The global variables continue + * bt_bt2_cc_init_from_bt2() here. The global variables continue * to exist for the code of this file, but they are now borrowed * references. If this code is executed, it means that somehow * the modules are still loaded, so it should be safe to use @@ -150,8 +155,8 @@ void bt_py3_cc_exit_handler(void) Py_XDECREF(py_mod_bt2_exc_try_again_type); Py_XDECREF(py_mod_bt2_exc_stop_type); Py_XDECREF(py_mod_bt2_exc_msg_iter_canceled_type); - Py_XDECREF(py_mod_bt2_exc_invalid_query_object_type); - Py_XDECREF(py_mod_bt2_exc_invalid_query_params_type); + Py_XDECREF(py_mod_bt2_exc_invalid_object_type); + Py_XDECREF(py_mod_bt2_exc_invalid_params_type); } @@ -159,7 +164,7 @@ void bt_py3_cc_exit_handler(void) __attribute__((destructor)) static -void bt_py3_native_comp_class_dtor(void) { +void native_comp_class_dtor(void) { /* Destroy component class association hash table */ if (bt_cc_ptr_to_py_cls) { BT_LOGD_STR("Destroying native component class to Python component class hash table."); @@ -167,8 +172,8 @@ void bt_py3_native_comp_class_dtor(void) { } } -static -void bt2_py_loge_exception(void) +static inline +void log_exception(int log_level) { GString *gstr; @@ -179,7 +184,7 @@ void bt2_py_loge_exception(void) goto end; } - BT_LOGE_STR(gstr->str); + BT_LOG_WRITE(log_level, BT_LOG_TAG, "%s", gstr->str); end: if (gstr) { @@ -187,63 +192,22 @@ end: } } -static -bt_self_component_status bt_py3_exc_to_self_component_status(void) +static inline +void loge_exception(void) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; - PyObject *exc = PyErr_Occurred(); - - if (!exc) { - goto end; - } - - if (PyErr_GivenExceptionMatches(exc, - py_mod_bt2_exc_try_again_type)) { - status = BT_SELF_COMPONENT_STATUS_AGAIN; - } else if (PyErr_GivenExceptionMatches(exc, - py_mod_bt2_exc_stop_type)) { - status = BT_SELF_COMPONENT_STATUS_END; - } else { - bt2_py_loge_exception(); - status = BT_SELF_COMPONENT_STATUS_ERROR; - } - -end: - PyErr_Clear(); - return status; + log_exception(BT_LOG_ERROR); } -/* Component class proxy methods (delegate to the attached Python object) */ - -static -bt_self_message_iterator_status bt_py3_exc_to_self_message_iterator_status(void) +static inline +void logw_exception(void) { - enum bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; - PyObject *exc = PyErr_Occurred(); - - if (!exc) { - goto end; - } - - if (PyErr_GivenExceptionMatches(exc, py_mod_bt2_exc_stop_type)) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; - } else if (PyErr_GivenExceptionMatches(exc, py_mod_bt2_exc_try_again_type)) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN; - } else { - bt2_py_loge_exception(); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; - } - -end: - PyErr_Clear(); - return status; + log_exception(BT_LOG_WARN); } -static -enum bt_query_status bt_py3_exc_to_query_status(void) +static inline +int py_exc_to_status(void) { - enum bt_query_status status = BT_QUERY_STATUS_OK; + int status = __BT_FUNC_STATUS_OK; PyObject *exc = PyErr_Occurred(); if (!exc) { @@ -251,17 +215,24 @@ enum bt_query_status bt_py3_exc_to_query_status(void) } if (PyErr_GivenExceptionMatches(exc, - py_mod_bt2_exc_invalid_query_object_type)) { - status = BT_QUERY_STATUS_INVALID_OBJECT; + py_mod_bt2_exc_try_again_type)) { + status = __BT_FUNC_STATUS_AGAIN; } else if (PyErr_GivenExceptionMatches(exc, - py_mod_bt2_exc_invalid_query_params_type)) { - status = BT_QUERY_STATUS_INVALID_PARAMS; + py_mod_bt2_exc_stop_type)) { + status = __BT_FUNC_STATUS_END; } else if (PyErr_GivenExceptionMatches(exc, - py_mod_bt2_exc_try_again_type)) { - status = BT_QUERY_STATUS_AGAIN; + py_mod_bt2_exc_invalid_object_type)) { + status = __BT_FUNC_STATUS_INVALID_OBJECT; + } else if (PyErr_GivenExceptionMatches(exc, + py_mod_bt2_exc_invalid_params_type)) { + status = __BT_FUNC_STATUS_INVALID_PARAMS; + } else if (PyErr_GivenExceptionMatches(exc, + py_mod_bt2_exc_unsupported_type)) { + status = __BT_FUNC_STATUS_UNSUPPORTED; } else { - bt2_py_loge_exception(); - status = BT_QUERY_STATUS_ERROR; + /* Unknown exception: convert to general error */ + logw_exception(); + status = __BT_FUNC_STATUS_ERROR; } end: @@ -269,8 +240,10 @@ end: return status; } +/* Component class proxy methods (delegate to the attached Python object) */ + static -bt_self_component_status bt_py3_component_class_init( +bt_component_class_init_method_status component_class_init( bt_self_component *self_component, void *self_component_v, swig_type_info *self_comp_cls_type_swig_type, @@ -279,7 +252,7 @@ bt_self_component_status bt_py3_component_class_init( { const bt_component *component = bt_self_component_as_component(self_component); const bt_component_class *component_class = bt_component_borrow_class_const(component); - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status status = __BT_FUNC_STATUS_OK; PyObject *py_cls = NULL; PyObject *py_comp = NULL; PyObject *py_params_ptr = NULL; @@ -329,10 +302,9 @@ bt_self_component_status bt_py3_component_class_init( py_comp = PyObject_CallMethod(py_cls, "_init_from_native", "(OO)", py_comp_ptr, py_params_ptr); if (!py_comp) { - bt2_py_loge_exception(); - BT_LOGE("Failed to call Python class's _init_from_native() method: " + BT_LOGW("Failed to call Python class's _init_from_native() method: " "py-cls-addr=%p", py_cls); - + logw_exception(); goto error; } @@ -346,7 +318,7 @@ bt_self_component_status bt_py3_component_class_init( goto end; error: - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = __BT_FUNC_STATUS_ERROR; /* * Clear any exception: we're returning a bad status anyway. If @@ -369,12 +341,12 @@ end: */ static -bt_self_component_status bt_py3_component_class_source_init( +bt_component_class_init_method_status component_class_source_init( bt_self_component_source *self_component_source, const bt_value *params, void *init_method_data) { bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source); - return bt_py3_component_class_init( + return component_class_init( self_component, self_component_source, SWIGTYPE_p_bt_self_component_source, @@ -382,12 +354,12 @@ bt_self_component_status bt_py3_component_class_source_init( } static -bt_self_component_status bt_py3_component_class_filter_init( +bt_component_class_init_method_status component_class_filter_init( bt_self_component_filter *self_component_filter, const bt_value *params, void *init_method_data) { bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter); - return bt_py3_component_class_init( + return component_class_init( self_component, self_component_filter, SWIGTYPE_p_bt_self_component_filter, @@ -395,12 +367,12 @@ bt_self_component_status bt_py3_component_class_filter_init( } static -bt_self_component_status bt_py3_component_class_sink_init( +bt_component_class_init_method_status component_class_sink_init( bt_self_component_sink *self_component_sink, const bt_value *params, void *init_method_data) { bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink); - return bt_py3_component_class_init( + return component_class_init( self_component, self_component_sink, SWIGTYPE_p_bt_self_component_sink, @@ -408,7 +380,7 @@ bt_self_component_status bt_py3_component_class_sink_init( } static -void bt_py3_component_class_finalize(bt_self_component *self_component) +void component_class_finalize(bt_self_component *self_component) { PyObject *py_comp = bt_self_component_get_data(self_component); BT_ASSERT(py_comp); @@ -418,7 +390,8 @@ void bt_py3_component_class_finalize(bt_self_component *self_component) "_finalize", NULL); if (PyErr_Occurred()) { - BT_LOGW("User's _finalize() method raised an exception: ignoring."); + BT_LOGW("User component's _finalize() method raised an exception: ignoring:"); + logw_exception(); } /* @@ -432,28 +405,28 @@ void bt_py3_component_class_finalize(bt_self_component *self_component) } static -void bt_py3_component_class_source_finalize(bt_self_component_source *self_component_source) +void component_class_source_finalize(bt_self_component_source *self_component_source) { bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source); - bt_py3_component_class_finalize(self_component); + component_class_finalize(self_component); } static -void bt_py3_component_class_filter_finalize(bt_self_component_filter *self_component_filter) +void component_class_filter_finalize(bt_self_component_filter *self_component_filter) { bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter); - bt_py3_component_class_finalize(self_component); + component_class_finalize(self_component); } static -void bt_py3_component_class_sink_finalize(bt_self_component_sink *self_component_sink) +void component_class_sink_finalize(bt_self_component_sink *self_component_sink) { bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink); - bt_py3_component_class_finalize(self_component); + component_class_finalize(self_component); } static -bt_bool bt_py3_component_class_can_seek_beginning( +bt_bool component_class_can_seek_beginning( bt_self_message_iterator *self_message_iterator) { PyObject *py_iter; @@ -474,7 +447,7 @@ bt_bool bt_py3_component_class_can_seek_beginning( * Once can_seek_beginning can report errors, convert the * exception to a status. For now, log and return false; */ - bt2_py_loge_exception(); + loge_exception(); PyErr_Clear(); } @@ -484,28 +457,25 @@ bt_bool bt_py3_component_class_can_seek_beginning( } static -bt_self_message_iterator_status bt_py3_component_class_seek_beginning( - bt_self_message_iterator *self_message_iterator) +bt_component_class_message_iterator_seek_beginning_method_status +component_class_seek_beginning(bt_self_message_iterator *self_message_iterator) { PyObject *py_iter; PyObject *py_result; - bt_self_message_iterator_status status; + bt_component_class_message_iterator_seek_beginning_method_status status; py_iter = bt_self_message_iterator_get_data(self_message_iterator); BT_ASSERT(py_iter); - - py_result = PyObject_CallMethod(py_iter, "_seek_beginning_from_native", NULL); - + py_result = PyObject_CallMethod(py_iter, "_seek_beginning_from_native", + NULL); BT_ASSERT(!py_result || py_result == Py_None); - status = bt_py3_exc_to_self_message_iterator_status(); - + status = py_exc_to_status(); Py_XDECREF(py_result); - return status; } static -bt_self_component_status bt_py3_component_class_port_connected( +bt_component_class_port_connected_method_status component_class_port_connected( bt_self_component *self_component, void *self_component_port, swig_type_info *self_component_port_swig_type, @@ -513,7 +483,7 @@ bt_self_component_status bt_py3_component_class_port_connected( const void *other_port, swig_type_info *other_port_swig_type) { - bt_self_component_status status; + bt_component_class_port_connected_method_status status; PyObject *py_comp = NULL; PyObject *py_self_port_ptr = NULL; PyObject *py_other_port_ptr = NULL; @@ -521,12 +491,11 @@ bt_self_component_status bt_py3_component_class_port_connected( py_comp = bt_self_component_get_data(self_component); BT_ASSERT(py_comp); - py_self_port_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(self_component_port), self_component_port_swig_type, 0); if (!py_self_port_ptr) { BT_LOGF_STR("Failed to create a SWIG pointer object."); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -534,34 +503,32 @@ bt_self_component_status bt_py3_component_class_port_connected( other_port_swig_type, 0); if (!py_other_port_ptr) { BT_LOGF_STR("Failed to create a SWIG pointer object."); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto end; } py_method_result = PyObject_CallMethod(py_comp, "_port_connected_from_native", "(OiO)", py_self_port_ptr, self_component_port_type, py_other_port_ptr); - BT_ASSERT(!py_method_result || py_method_result == Py_None); - - status = bt_py3_exc_to_self_component_status(); + status = py_exc_to_status(); end: Py_XDECREF(py_self_port_ptr); Py_XDECREF(py_other_port_ptr); Py_XDECREF(py_method_result); - return status; } static -bt_self_component_status bt_py3_component_class_source_output_port_connected( +bt_component_class_port_connected_method_status +component_class_source_output_port_connected( bt_self_component_source *self_component_source, bt_self_component_port_output *self_component_port_output, const bt_port_input *other_port_input) { bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source); - return bt_py3_component_class_port_connected( + return component_class_port_connected( self_component, self_component_port_output, SWIGTYPE_p_bt_self_component_port_output, @@ -571,14 +538,15 @@ bt_self_component_status bt_py3_component_class_source_output_port_connected( } static -bt_self_component_status bt_py3_component_class_filter_input_port_connected( +bt_component_class_port_connected_method_status +component_class_filter_input_port_connected( bt_self_component_filter *self_component_filter, bt_self_component_port_input *self_component_port_input, const bt_port_output *other_port_output) { bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter); - return bt_py3_component_class_port_connected( + return component_class_port_connected( self_component, self_component_port_input, SWIGTYPE_p_bt_self_component_port_input, @@ -588,14 +556,15 @@ bt_self_component_status bt_py3_component_class_filter_input_port_connected( } static -bt_self_component_status bt_py3_component_class_filter_output_port_connected( +bt_component_class_port_connected_method_status +component_class_filter_output_port_connected( bt_self_component_filter *self_component_filter, bt_self_component_port_output *self_component_port_output, const bt_port_input *other_port_input) { bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter); - return bt_py3_component_class_port_connected( + return component_class_port_connected( self_component, self_component_port_output, SWIGTYPE_p_bt_self_component_port_output, @@ -605,14 +574,15 @@ bt_self_component_status bt_py3_component_class_filter_output_port_connected( } static -bt_self_component_status bt_py3_component_class_sink_input_port_connected( +bt_component_class_port_connected_method_status +component_class_sink_input_port_connected( bt_self_component_sink *self_component_sink, bt_self_component_port_input *self_component_port_input, const bt_port_output *other_port_output) { bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink); - return bt_py3_component_class_port_connected( + return component_class_port_connected( self_component, self_component_port_input, SWIGTYPE_p_bt_self_component_port_input, @@ -622,29 +592,26 @@ bt_self_component_status bt_py3_component_class_sink_input_port_connected( } static -bt_self_component_status bt_py3_component_class_sink_graph_is_configured( +bt_component_class_sink_graph_is_configured_method_status +component_class_sink_graph_is_configured( bt_self_component_sink *self_component_sink) { PyObject *py_comp = NULL; PyObject *py_method_result = NULL; - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_graph_is_configured_method_status status = __BT_FUNC_STATUS_OK; bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink); py_comp = bt_self_component_get_data(self_component); py_method_result = PyObject_CallMethod(py_comp, "_graph_is_configured_from_native", NULL); - BT_ASSERT(!py_method_result || py_method_result == Py_None); - - status = bt_py3_exc_to_self_component_status(); - + status = py_exc_to_status(); Py_XDECREF(py_method_result); - return status; } static -bt_query_status bt_py3_component_class_query( +bt_component_class_query_method_status component_class_query( const bt_component_class *component_class, const bt_query_executor *query_executor, const char *object, const bt_value *params, @@ -657,7 +624,7 @@ bt_query_status bt_py3_component_class_query( PyObject *py_query_func = NULL; PyObject *py_object = NULL; PyObject *py_results_addr = NULL; - bt_query_status status = BT_QUERY_STATUS_OK; + bt_component_class_query_method_status status = __BT_FUNC_STATUS_OK; py_cls = lookup_cc_ptr_to_py_cls(component_class); if (!py_cls) { @@ -689,11 +656,10 @@ bt_query_status bt_py3_component_class_query( py_results_addr = PyObject_CallMethod(py_cls, "_query_from_native", "(OOOi)", py_query_exec_ptr, py_object, py_params_ptr, (int) log_level); - if (!py_results_addr) { - BT_LOGE("Failed to call Python class's _query_from_native() method: " + BT_LOGW("Failed to call Python class's _query_from_native() method: " "py-cls-addr=%p", py_cls); - status = bt_py3_exc_to_query_status(); + status = py_exc_to_status(); goto end; } @@ -709,7 +675,7 @@ bt_query_status bt_py3_component_class_query( error: PyErr_Clear(); - status = BT_QUERY_STATUS_ERROR; + status = __BT_FUNC_STATUS_ERROR; end: Py_XDECREF(py_params_ptr); @@ -721,7 +687,7 @@ end: } static -bt_query_status bt_py3_component_class_source_query( +bt_component_class_query_method_status component_class_source_query( bt_self_component_class_source *self_component_class_source, const bt_query_executor *query_executor, const char *object, const bt_value *params, @@ -730,11 +696,12 @@ bt_query_status bt_py3_component_class_source_query( { const bt_component_class_source *component_class_source = bt_self_component_class_source_as_component_class_source(self_component_class_source); const bt_component_class *component_class = bt_component_class_source_as_component_class_const(component_class_source); - return bt_py3_component_class_query(component_class, query_executor, object, params, log_level, result); + + return component_class_query(component_class, query_executor, object, params, log_level, result); } static -bt_query_status bt_py3_component_class_filter_query( +bt_component_class_query_method_status component_class_filter_query( bt_self_component_class_filter *self_component_class_filter, const bt_query_executor *query_executor, const char *object, const bt_value *params, @@ -743,11 +710,12 @@ bt_query_status bt_py3_component_class_filter_query( { const bt_component_class_filter *component_class_filter = bt_self_component_class_filter_as_component_class_filter(self_component_class_filter); const bt_component_class *component_class = bt_component_class_filter_as_component_class_const(component_class_filter); - return bt_py3_component_class_query(component_class, query_executor, object, params, log_level, result); + + return component_class_query(component_class, query_executor, object, params, log_level, result); } static -bt_query_status bt_py3_component_class_sink_query( +bt_component_class_query_method_status component_class_sink_query( bt_self_component_class_sink *self_component_class_sink, const bt_query_executor *query_executor, const char *object, const bt_value *params, @@ -756,16 +724,18 @@ bt_query_status bt_py3_component_class_sink_query( { const bt_component_class_sink *component_class_sink = bt_self_component_class_sink_as_component_class_sink(self_component_class_sink); const bt_component_class *component_class = bt_component_class_sink_as_component_class_const(component_class_sink); - return bt_py3_component_class_query(component_class, query_executor, object, params, log_level, result); + + return component_class_query(component_class, query_executor, object, params, log_level, result); } static -bt_self_message_iterator_status bt_py3_component_class_message_iterator_init( +bt_component_class_message_iterator_init_method_status +component_class_message_iterator_init( bt_self_message_iterator *self_message_iterator, bt_self_component *self_component, bt_self_component_port_output *self_component_port_output) { - bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_init_method_status status = __BT_FUNC_STATUS_OK; PyObject *py_comp_cls = NULL; PyObject *py_iter_cls = NULL; PyObject *py_iter_ptr = NULL; @@ -807,7 +777,7 @@ bt_self_message_iterator_status bt_py3_component_class_message_iterator_init( if (!py_iter) { BT_LOGE("Failed to call Python class's __new__() method: " "py-cls-addr=%p", py_iter_cls); - bt2_py_loge_exception(); + loge_exception(); goto error; } @@ -823,17 +793,19 @@ bt_self_message_iterator_status bt_py3_component_class_message_iterator_init( * user Python component object from which the iterator was * created). */ - py_component_port_output_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(self_component_port_output), + py_component_port_output_ptr = SWIG_NewPointerObj( + SWIG_as_voidptr(self_component_port_output), SWIGTYPE_p_bt_self_component_port_output, 0); if (!py_component_port_output_ptr) { BT_LOGE_STR("Failed to create a SWIG pointer object."); goto error; } - py_init_method_result = PyObject_CallMethod(py_iter, "_init_from_native", "O", py_component_port_output_ptr); + py_init_method_result = PyObject_CallMethod(py_iter, + "_init_from_native", "O", py_component_port_output_ptr); if (!py_init_method_result) { - BT_LOGE_STR("User's __init__() method failed."); - bt2_py_loge_exception(); + BT_LOGW_STR("User's __init__() method failed:"); + logw_exception(); goto error; } @@ -860,13 +832,13 @@ bt_self_message_iterator_status bt_py3_component_class_message_iterator_init( goto end; error: - status = bt_py3_exc_to_self_message_iterator_status(); - if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + status = py_exc_to_status(); + if (status == __BT_FUNC_STATUS_OK) { /* * Looks like there wasn't any exception from the Python * side, but we're still in an error state here. */ - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = __BT_FUNC_STATUS_ERROR; } /* @@ -887,27 +859,31 @@ end: } static -bt_self_message_iterator_status bt_py3_component_class_source_message_iterator_init( +bt_component_class_message_iterator_init_method_status +component_class_source_message_iterator_init( bt_self_message_iterator *self_message_iterator, bt_self_component_source *self_component_source, bt_self_component_port_output *self_component_port_output) { bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source); - return bt_py3_component_class_message_iterator_init(self_message_iterator, self_component, self_component_port_output); + + return component_class_message_iterator_init(self_message_iterator, self_component, self_component_port_output); } static -bt_self_message_iterator_status bt_py3_component_class_filter_message_iterator_init( +bt_component_class_message_iterator_init_method_status +component_class_filter_message_iterator_init( bt_self_message_iterator *self_message_iterator, bt_self_component_filter *self_component_filter, bt_self_component_port_output *self_component_port_output) { bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter); - return bt_py3_component_class_message_iterator_init(self_message_iterator, self_component, self_component_port_output); + + return component_class_message_iterator_init(self_message_iterator, self_component, self_component_port_output); } static -void bt_py3_component_class_message_iterator_finalize( +void component_class_message_iterator_finalize( bt_self_message_iterator *message_iterator) { PyObject *py_message_iter = bt_self_message_iterator_get_data(message_iterator); @@ -920,7 +896,8 @@ void bt_py3_component_class_message_iterator_finalize( "_finalize", NULL); if (PyErr_Occurred()) { - BT_LOGW("User's _finalize() method raised an exception: ignoring."); + BT_LOGW("User's _finalize() method raised an exception: ignoring:"); + logw_exception(); } /* @@ -936,12 +913,13 @@ void bt_py3_component_class_message_iterator_finalize( /* Valid for both sources and filters. */ static -bt_self_message_iterator_status bt_py3_component_class_message_iterator_next( +bt_component_class_message_iterator_next_method_status +component_class_message_iterator_next( bt_self_message_iterator *message_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = __BT_FUNC_STATUS_OK; PyObject *py_message_iter = bt_self_message_iterator_get_data(message_iterator); PyObject *py_method_result = NULL; @@ -949,8 +927,8 @@ bt_self_message_iterator_status bt_py3_component_class_message_iterator_next( py_method_result = PyObject_CallMethod(py_message_iter, "_next_from_native", NULL); if (!py_method_result) { - status = bt_py3_exc_to_self_message_iterator_status(); - BT_ASSERT(status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK); + status = py_exc_to_status(); + BT_ASSERT(status != __BT_FUNC_STATUS_OK); goto end; } @@ -972,24 +950,23 @@ end: } static -bt_self_component_status bt_py3_component_class_sink_consume( - bt_self_component_sink *self_component_sink) +bt_component_class_sink_consume_method_status +component_class_sink_consume(bt_self_component_sink *self_component_sink) { bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink); PyObject *py_comp = bt_self_component_get_data(self_component); PyObject *py_method_result = NULL; - bt_self_component_status status; + bt_component_class_sink_consume_method_status status; BT_ASSERT(py_comp); py_method_result = PyObject_CallMethod(py_comp, "_consume", NULL); - - status = bt_py3_exc_to_self_component_status(); - if (!py_method_result && status == BT_SELF_COMPONENT_STATUS_OK) { + status = py_exc_to_status(); + if (!py_method_result && status == __BT_FUNC_STATUS_OK) { /* Pretty sure this should never happen, but just in case */ BT_LOGE("User's _consume() method failed without raising an exception: " "status=%d", status); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = __BT_FUNC_STATUS_ERROR; } Py_XDECREF(py_method_result); @@ -997,7 +974,7 @@ bt_self_component_status bt_py3_component_class_sink_consume( } static -int bt_py3_component_class_set_help_and_desc( +int component_class_set_help_and_desc( bt_component_class *component_class, const char *description, const char *help) { @@ -1028,7 +1005,7 @@ end: } static -bt_component_class_source *bt_py3_component_class_source_create( +bt_component_class_source *bt_bt2_component_class_source_create( PyObject *py_cls, const char *name, const char *description, const char *help) { @@ -1037,9 +1014,8 @@ bt_component_class_source *bt_py3_component_class_source_create( int ret; BT_ASSERT(py_cls); - component_class_source = bt_component_class_source_create(name, - bt_py3_component_class_message_iterator_next); + component_class_message_iterator_next); if (!component_class_source) { BT_LOGE_STR("Cannot create source component class."); goto end; @@ -1047,32 +1023,31 @@ bt_component_class_source *bt_py3_component_class_source_create( component_class = bt_component_class_source_as_component_class(component_class_source); - if (bt_py3_component_class_set_help_and_desc(component_class, description, help)) { + if (component_class_set_help_and_desc(component_class, description, help)) { goto end; } - ret = bt_component_class_source_set_init_method(component_class_source, bt_py3_component_class_source_init); + ret = bt_component_class_source_set_init_method(component_class_source, component_class_source_init); BT_ASSERT(ret == 0); - ret = bt_component_class_source_set_finalize_method(component_class_source, bt_py3_component_class_source_finalize); + ret = bt_component_class_source_set_finalize_method(component_class_source, component_class_source_finalize); BT_ASSERT(ret == 0); ret = bt_component_class_source_set_message_iterator_can_seek_beginning_method(component_class_source, - bt_py3_component_class_can_seek_beginning); + component_class_can_seek_beginning); BT_ASSERT(ret == 0); ret = bt_component_class_source_set_message_iterator_seek_beginning_method(component_class_source, - bt_py3_component_class_seek_beginning); + component_class_seek_beginning); BT_ASSERT(ret == 0); ret = bt_component_class_source_set_output_port_connected_method(component_class_source, - bt_py3_component_class_source_output_port_connected); + component_class_source_output_port_connected); BT_ASSERT(ret == 0); - ret = bt_component_class_source_set_query_method(component_class_source, bt_py3_component_class_source_query); + ret = bt_component_class_source_set_query_method(component_class_source, component_class_source_query); BT_ASSERT(ret == 0); ret = bt_component_class_source_set_message_iterator_init_method( - component_class_source, bt_py3_component_class_source_message_iterator_init); + component_class_source, component_class_source_message_iterator_init); BT_ASSERT(ret == 0); ret = bt_component_class_source_set_message_iterator_finalize_method( - component_class_source, bt_py3_component_class_message_iterator_finalize); + component_class_source, component_class_message_iterator_finalize); BT_ASSERT(ret == 0); - register_cc_ptr_to_py_cls(component_class, py_cls); end: @@ -1080,7 +1055,7 @@ end: } static -bt_component_class_filter *bt_py3_component_class_filter_create( +bt_component_class_filter *bt_bt2_component_class_filter_create( PyObject *py_cls, const char *name, const char *description, const char *help) { @@ -1089,9 +1064,8 @@ bt_component_class_filter *bt_py3_component_class_filter_create( int ret; BT_ASSERT(py_cls); - component_class_filter = bt_component_class_filter_create(name, - bt_py3_component_class_message_iterator_next); + component_class_message_iterator_next); if (!component_class_filter) { BT_LOGE_STR("Cannot create filter component class."); goto end; @@ -1099,35 +1073,34 @@ bt_component_class_filter *bt_py3_component_class_filter_create( component_class = bt_component_class_filter_as_component_class(component_class_filter); - if (bt_py3_component_class_set_help_and_desc(component_class, description, help)) { + if (component_class_set_help_and_desc(component_class, description, help)) { goto end; } - ret = bt_component_class_filter_set_init_method(component_class_filter, bt_py3_component_class_filter_init); + ret = bt_component_class_filter_set_init_method(component_class_filter, component_class_filter_init); BT_ASSERT(ret == 0); - ret = bt_component_class_filter_set_finalize_method (component_class_filter, bt_py3_component_class_filter_finalize); + ret = bt_component_class_filter_set_finalize_method (component_class_filter, component_class_filter_finalize); BT_ASSERT(ret == 0); ret = bt_component_class_filter_set_message_iterator_can_seek_beginning_method(component_class_filter, - bt_py3_component_class_can_seek_beginning); + component_class_can_seek_beginning); BT_ASSERT(ret == 0); ret = bt_component_class_filter_set_message_iterator_seek_beginning_method(component_class_filter, - bt_py3_component_class_seek_beginning); + component_class_seek_beginning); BT_ASSERT(ret == 0); ret = bt_component_class_filter_set_input_port_connected_method(component_class_filter, - bt_py3_component_class_filter_input_port_connected); + component_class_filter_input_port_connected); BT_ASSERT(ret == 0); ret = bt_component_class_filter_set_output_port_connected_method(component_class_filter, - bt_py3_component_class_filter_output_port_connected); + component_class_filter_output_port_connected); BT_ASSERT(ret == 0); - ret = bt_component_class_filter_set_query_method(component_class_filter, bt_py3_component_class_filter_query); + ret = bt_component_class_filter_set_query_method(component_class_filter, component_class_filter_query); BT_ASSERT(ret == 0); ret = bt_component_class_filter_set_message_iterator_init_method( - component_class_filter, bt_py3_component_class_filter_message_iterator_init); + component_class_filter, component_class_filter_message_iterator_init); BT_ASSERT(ret == 0); ret = bt_component_class_filter_set_message_iterator_finalize_method( - component_class_filter, bt_py3_component_class_message_iterator_finalize); + component_class_filter, component_class_message_iterator_finalize); BT_ASSERT(ret == 0); - register_cc_ptr_to_py_cls(component_class, py_cls); end: @@ -1135,7 +1108,7 @@ end: } static -bt_component_class_sink *bt_py3_component_class_sink_create( +bt_component_class_sink *bt_bt2_component_class_sink_create( PyObject *py_cls, const char *name, const char *description, const char *help) { @@ -1144,8 +1117,7 @@ bt_component_class_sink *bt_py3_component_class_sink_create( int ret; BT_ASSERT(py_cls); - - component_class_sink = bt_component_class_sink_create(name, bt_py3_component_class_sink_consume); + component_class_sink = bt_component_class_sink_create(name, component_class_sink_consume); if (!component_class_sink) { BT_LOGE_STR("Cannot create sink component class."); @@ -1154,23 +1126,22 @@ bt_component_class_sink *bt_py3_component_class_sink_create( component_class = bt_component_class_sink_as_component_class(component_class_sink); - if (bt_py3_component_class_set_help_and_desc(component_class, description, help)) { + if (component_class_set_help_and_desc(component_class, description, help)) { goto end; } - ret = bt_component_class_sink_set_init_method(component_class_sink, bt_py3_component_class_sink_init); + ret = bt_component_class_sink_set_init_method(component_class_sink, component_class_sink_init); BT_ASSERT(ret == 0); - ret = bt_component_class_sink_set_finalize_method(component_class_sink, bt_py3_component_class_sink_finalize); + ret = bt_component_class_sink_set_finalize_method(component_class_sink, component_class_sink_finalize); BT_ASSERT(ret == 0); ret = bt_component_class_sink_set_input_port_connected_method(component_class_sink, - bt_py3_component_class_sink_input_port_connected); + component_class_sink_input_port_connected); BT_ASSERT(ret == 0); ret = bt_component_class_sink_set_graph_is_configured_method(component_class_sink, - bt_py3_component_class_sink_graph_is_configured); + component_class_sink_graph_is_configured); BT_ASSERT(ret == 0); - ret = bt_component_class_sink_set_query_method(component_class_sink, bt_py3_component_class_sink_query); + ret = bt_component_class_sink_set_query_method(component_class_sink, component_class_sink_query); BT_ASSERT(ret == 0); - register_cc_ptr_to_py_cls(component_class, py_cls); end: @@ -1178,14 +1149,14 @@ end: } %} -struct bt_component_class_source *bt_py3_component_class_source_create( +struct bt_component_class_source *bt_bt2_component_class_source_create( PyObject *py_cls, const char *name, const char *description, const char *help); -struct bt_component_class_filter *bt_py3_component_class_filter_create( +struct bt_component_class_filter *bt_bt2_component_class_filter_create( PyObject *py_cls, const char *name, const char *description, const char *help); -struct bt_component_class_sink *bt_py3_component_class_sink_create( +struct bt_component_class_sink *bt_bt2_component_class_sink_create( PyObject *py_cls, const char *name, const char *description, const char *help); -void bt_py3_cc_init_from_bt2(void); -void bt_py3_cc_exit_handler(void); +void bt_bt2_cc_init_from_bt2(void); +void bt_bt2_cc_exit_handler(void); diff --git a/src/bindings/python/bt2/bt2/native_bt_graph.i b/src/bindings/python/bt2/bt2/native_bt_graph.i index 9f9e1d3b..13d635e9 100644 --- a/src/bindings/python/bt2/bt2/native_bt_graph.i +++ b/src/bindings/python/bt2/bt2/native_bt_graph.i @@ -107,15 +107,14 @@ /* Helper functions for Python */ %{ - -static void graph_listener_removed(void *py_callable) +static +void graph_listener_removed(void *py_callable) { BT_ASSERT(py_callable); Py_DECREF(py_callable); } -static bt_graph_listener_status -port_added_listener( +static bt_graph_listener_func_status port_added_listener( const void *component, swig_type_info *component_swig_type, bt_component_class_type component_class_type, @@ -127,43 +126,43 @@ port_added_listener( PyObject *py_component_ptr = NULL; PyObject *py_port_ptr = NULL; PyObject *py_res = NULL; - bt_graph_listener_status status; + bt_graph_listener_func_status status; py_component_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(component), component_swig_type, 0); if (!py_component_ptr) { BT_LOGF_STR("Failed to create component SWIG pointer object."); - status = BT_GRAPH_LISTENER_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto end; } py_port_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(port), port_swig_type, 0); if (!py_port_ptr) { BT_LOGF_STR("Failed to create port SWIG pointer object."); - status = BT_GRAPH_LISTENER_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto end; } py_res = PyObject_CallFunction(py_callable, "(OiOi)", py_component_ptr, component_class_type, py_port_ptr, port_type); if (!py_res) { - bt2_py_loge_exception(); + loge_exception(); PyErr_Clear(); - status = BT_GRAPH_LISTENER_STATUS_ERROR; + status = __BT_FUNC_STATUS_ERROR; goto end; } BT_ASSERT(py_res == Py_None); - status = BT_GRAPH_LISTENER_STATUS_OK; + status = __BT_FUNC_STATUS_OK; end: Py_XDECREF(py_res); Py_XDECREF(py_port_ptr); Py_XDECREF(py_component_ptr); - return status; } -static bt_graph_listener_status +static +bt_graph_listener_func_status source_component_output_port_added_listener(const bt_component_source *component_source, const bt_port_output *port_output, void *py_callable) { @@ -172,7 +171,8 @@ source_component_output_port_added_listener(const bt_component_source *component port_output, SWIGTYPE_p_bt_port_output, BT_PORT_TYPE_OUTPUT, py_callable); } -static bt_graph_listener_status +static +bt_graph_listener_func_status filter_component_input_port_added_listener(const bt_component_filter *component_filter, const bt_port_input *port_input, void *py_callable) { @@ -181,7 +181,8 @@ filter_component_input_port_added_listener(const bt_component_filter *component_ port_input, SWIGTYPE_p_bt_port_input, BT_PORT_TYPE_INPUT, py_callable); } -static bt_graph_listener_status +static +bt_graph_listener_func_status filter_component_output_port_added_listener(const bt_component_filter *component_filter, const bt_port_output *port_output, void *py_callable) { @@ -190,7 +191,8 @@ filter_component_output_port_added_listener(const bt_component_filter *component port_output, SWIGTYPE_p_bt_port_output, BT_PORT_TYPE_OUTPUT, py_callable); } -static bt_graph_listener_status +static +bt_graph_listener_func_status sink_component_input_port_added_listener(const bt_component_sink *component_sink, const bt_port_input *port_input, void *py_callable) { @@ -199,14 +201,14 @@ sink_component_input_port_added_listener(const bt_component_sink *component_sink port_input, SWIGTYPE_p_bt_port_input, BT_PORT_TYPE_INPUT, py_callable); } -static PyObject * -bt_py3_graph_add_port_added_listener(struct bt_graph *graph, - PyObject *py_callable) +static +PyObject *bt_bt2_graph_add_port_added_listener(struct bt_graph *graph, + PyObject *py_callable) { PyObject *py_listener_ids = NULL; PyObject *py_listener_id = NULL; int listener_id; - bt_graph_status status; + bt_graph_add_listener_status status; BT_ASSERT(graph); BT_ASSERT(py_callable); @@ -224,7 +226,7 @@ bt_py3_graph_add_port_added_listener(struct bt_graph *graph, status = bt_graph_add_source_component_output_port_added_listener( graph, source_component_output_port_added_listener, graph_listener_removed, py_callable, &listener_id); - if (status != BT_GRAPH_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto error; } @@ -240,7 +242,7 @@ bt_py3_graph_add_port_added_listener(struct bt_graph *graph, status = bt_graph_add_filter_component_input_port_added_listener( graph, filter_component_input_port_added_listener, graph_listener_removed, py_callable, &listener_id); - if (status != BT_GRAPH_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto error; } @@ -256,7 +258,7 @@ bt_py3_graph_add_port_added_listener(struct bt_graph *graph, status = bt_graph_add_filter_component_output_port_added_listener( graph, filter_component_output_port_added_listener, graph_listener_removed, py_callable, &listener_id); - if (status != BT_GRAPH_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto error; } @@ -272,7 +274,7 @@ bt_py3_graph_add_port_added_listener(struct bt_graph *graph, status = bt_graph_add_sink_component_input_port_added_listener( graph, sink_component_input_port_added_listener, graph_listener_removed, py_callable, &listener_id); - if (status != BT_GRAPH_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto error; } @@ -303,8 +305,8 @@ end: return py_listener_ids; } -static bt_graph_listener_status -ports_connected_listener( +static +bt_graph_listener_func_status ports_connected_listener( const void *upstream_component, swig_type_info *upstream_component_swig_type, bt_component_class_type upstream_component_class_type, @@ -320,13 +322,13 @@ ports_connected_listener( PyObject *py_downstream_component_ptr = NULL; PyObject *py_downstream_port_ptr = NULL; PyObject *py_res = NULL; - bt_graph_listener_status status; + bt_graph_listener_func_status status; py_upstream_component_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(upstream_component), upstream_component_swig_type, 0); if (!py_upstream_component_ptr) { BT_LOGF_STR("Failed to create upstream component SWIG pointer object."); - status = BT_GRAPH_LISTENER_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -334,7 +336,7 @@ ports_connected_listener( SWIG_as_voidptr(upstream_port), SWIGTYPE_p_bt_port_output, 0); if (!py_upstream_port_ptr) { BT_LOGF_STR("Failed to create upstream port SWIG pointer object."); - status = BT_GRAPH_LISTENER_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -342,7 +344,7 @@ ports_connected_listener( downstream_component_swig_type, 0); if (!py_downstream_component_ptr) { BT_LOGF_STR("Failed to create downstream component SWIG pointer object."); - status = BT_GRAPH_LISTENER_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -350,7 +352,7 @@ ports_connected_listener( SWIG_as_voidptr(downstream_port), SWIGTYPE_p_bt_port_input, 0); if (!py_downstream_port_ptr) { BT_LOGF_STR("Failed to create downstream port SWIG pointer object."); - status = BT_GRAPH_LISTENER_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -360,14 +362,14 @@ ports_connected_listener( py_downstream_component_ptr, downstream_component_class_type, py_downstream_port_ptr); if (!py_res) { - bt2_py_loge_exception(); + loge_exception(); PyErr_Clear(); - status = BT_GRAPH_LISTENER_STATUS_ERROR; + status = __BT_FUNC_STATUS_ERROR; goto end; } BT_ASSERT(py_res == Py_None); - status = BT_GRAPH_LISTENER_STATUS_OK; + status = __BT_FUNC_STATUS_OK; end: Py_XDECREF(py_upstream_component_ptr); @@ -375,12 +377,11 @@ end: Py_XDECREF(py_downstream_component_ptr); Py_XDECREF(py_downstream_port_ptr); Py_XDECREF(py_res); - return status; } -static bt_graph_listener_status -source_filter_component_ports_connected_listener( +static +bt_graph_listener_func_status source_filter_component_ports_connected_listener( const bt_component_source *source_component, const bt_component_filter *filter_component, const bt_port_output *upstream_port, @@ -394,8 +395,8 @@ source_filter_component_ports_connected_listener( py_callable); } -static bt_graph_listener_status -source_sink_component_ports_connected_listener( +static +bt_graph_listener_func_status source_sink_component_ports_connected_listener( const bt_component_source *source_component, const bt_component_sink *sink_component, const bt_port_output *upstream_port, @@ -409,8 +410,8 @@ source_sink_component_ports_connected_listener( py_callable); } -static bt_graph_listener_status -filter_filter_component_ports_connected_listener( +static +bt_graph_listener_func_status filter_filter_component_ports_connected_listener( const bt_component_filter *filter_component_left, const bt_component_filter *filter_component_right, const bt_port_output *upstream_port, @@ -424,8 +425,8 @@ filter_filter_component_ports_connected_listener( py_callable); } -static bt_graph_listener_status -filter_sink_component_ports_connected_listener( +static +bt_graph_listener_func_status filter_sink_component_ports_connected_listener( const bt_component_filter *filter_component, const bt_component_sink *sink_component, const bt_port_output *upstream_port, @@ -439,14 +440,14 @@ filter_sink_component_ports_connected_listener( py_callable); } -static PyObject* -bt_py3_graph_add_ports_connected_listener(struct bt_graph *graph, - PyObject *py_callable) +static +PyObject *bt_bt2_graph_add_ports_connected_listener(struct bt_graph *graph, + PyObject *py_callable) { PyObject *py_listener_ids = NULL; PyObject *py_listener_id = NULL; int listener_id; - bt_graph_status status; + bt_graph_add_listener_status status; BT_ASSERT(graph); BT_ASSERT(py_callable); @@ -462,7 +463,7 @@ bt_py3_graph_add_ports_connected_listener(struct bt_graph *graph, status = bt_graph_add_source_filter_component_ports_connected_listener( graph, source_filter_component_ports_connected_listener, graph_listener_removed, py_callable, &listener_id); - if (status != BT_GRAPH_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto error; } @@ -478,7 +479,7 @@ bt_py3_graph_add_ports_connected_listener(struct bt_graph *graph, status = bt_graph_add_source_sink_component_ports_connected_listener( graph, source_sink_component_ports_connected_listener, graph_listener_removed, py_callable, &listener_id); - if (status != BT_GRAPH_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto error; } @@ -494,7 +495,7 @@ bt_py3_graph_add_ports_connected_listener(struct bt_graph *graph, status = bt_graph_add_filter_filter_component_ports_connected_listener( graph, filter_filter_component_ports_connected_listener, graph_listener_removed, py_callable, &listener_id); - if (status != BT_GRAPH_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto error; } @@ -510,7 +511,7 @@ bt_py3_graph_add_ports_connected_listener(struct bt_graph *graph, status = bt_graph_add_filter_sink_component_ports_connected_listener( graph, filter_sink_component_ports_connected_listener, graph_listener_removed, py_callable, &listener_id); - if (status != BT_GRAPH_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto error; } @@ -539,10 +540,9 @@ end: Py_XDECREF(py_listener_id); return py_listener_ids; } - %} -PyObject *bt_py3_graph_add_port_added_listener(struct bt_graph *graph, +PyObject *bt_bt2_graph_add_port_added_listener(struct bt_graph *graph, PyObject *py_callable); -PyObject *bt_py3_graph_add_ports_connected_listener(struct bt_graph *graph, +PyObject *bt_bt2_graph_add_ports_connected_listener(struct bt_graph *graph, PyObject *py_callable); diff --git a/src/bindings/python/bt2/bt2/native_bt_logging.i b/src/bindings/python/bt2/bt2/native_bt_logging.i index 5867cacf..32c8a09f 100644 --- a/src/bindings/python/bt2/bt2/native_bt_logging.i +++ b/src/bindings/python/bt2/bt2/native_bt_logging.i @@ -22,22 +22,4 @@ * THE SOFTWARE. */ -%{ -#include -%} - -/* Log levels */ -enum bt_logging_level { - BT_LOGGING_LEVEL_TRACE = 1, - BT_LOGGING_LEVEL_DEBUG = 2, - BT_LOGGING_LEVEL_INFO = 3, - BT_LOGGING_LEVEL_WARN = 4, - BT_LOGGING_LEVEL_ERROR = 5, - BT_LOGGING_LEVEL_FATAL = 6, - BT_LOGGING_LEVEL_NONE = 0xff, -}; - -/* Logging functions */ -enum bt_logging_level bt_logging_get_minimal_level(void); -enum bt_logging_level bt_logging_get_global_level(void); -void bt_logging_set_global_level(enum bt_logging_level log_level); +%include diff --git a/src/bindings/python/bt2/bt2/native_bt_message_iterator.i b/src/bindings/python/bt2/bt2/native_bt_message_iterator.i index 47bd3a9b..a8b55e55 100644 --- a/src/bindings/python/bt2/bt2/native_bt_message_iterator.i +++ b/src/bindings/python/bt2/bt2/native_bt_message_iterator.i @@ -22,14 +22,14 @@ * THE SOFTWARE. */ -%include +%include %include %include %include /* Helper functions for Python */ %{ -static PyObject *bt_py3_get_user_component_from_user_msg_iter( +static PyObject *bt_bt2_get_user_component_from_user_msg_iter( bt_self_message_iterator *self_message_iterator) { bt_self_component *self_component = bt_self_message_iterator_borrow_component(self_message_iterator); @@ -50,7 +50,9 @@ PyObject *create_pylist_from_messages(bt_message_array_const messages, { uint64_t i; PyObject *py_msg_list = PyList_New(message_count); + BT_ASSERT(py_msg_list); + for (i = 0; i < message_count; i++) { PyList_SET_ITEM(py_msg_list, i, SWIG_NewPointerObj(SWIG_as_voidptr(messages[i]), @@ -61,15 +63,15 @@ PyObject *create_pylist_from_messages(bt_message_array_const messages, } static -PyObject *bt_py3_get_msg_range_common(bt_message_iterator_status status, +PyObject *get_msg_range_common(bt_message_iterator_next_status status, bt_message_array_const messages, uint64_t message_count) { PyObject *py_status; PyObject *py_return_tuple; PyObject *py_msg_list = Py_None; - + py_status = SWIG_From_long_SS_long(status); - if (status != BT_MESSAGE_ITERATOR_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto end; } @@ -80,43 +82,37 @@ end: BT_ASSERT(py_return_tuple); PyTuple_SET_ITEM(py_return_tuple, 0, py_status); PyTuple_SET_ITEM(py_return_tuple, 1, py_msg_list); - return py_return_tuple; } -static PyObject -*bt_py3_self_component_port_input_get_msg_range( +static PyObject *bt_bt2_self_component_port_input_get_msg_range( bt_self_component_port_input_message_iterator *iter) { bt_message_array_const messages; uint64_t message_count = 0; - bt_message_iterator_status status; + bt_message_iterator_next_status status; - status = bt_self_component_port_input_message_iterator_next(iter, &messages, - &message_count); - - return bt_py3_get_msg_range_common(status, messages, message_count); + status = bt_self_component_port_input_message_iterator_next(iter, + &messages, &message_count); + return get_msg_range_common(status, messages, message_count); } -static PyObject -*bt_py3_port_output_get_msg_range( +static PyObject *bt_bt2_port_output_get_msg_range( bt_port_output_message_iterator *iter) { bt_message_array_const messages; uint64_t message_count = 0; - bt_message_iterator_status status; + bt_message_iterator_next_status status; - status = - bt_port_output_message_iterator_next(iter, &messages, - &message_count); - - return bt_py3_get_msg_range_common(status, messages, message_count); + status = bt_port_output_message_iterator_next(iter, &messages, + &message_count); + return get_msg_range_common(status, messages, message_count); } %} -PyObject *bt_py3_get_user_component_from_user_msg_iter( +PyObject *bt_bt2_get_user_component_from_user_msg_iter( bt_self_message_iterator *self_message_iterator); -PyObject *bt_py3_self_component_port_input_get_msg_range( +PyObject *bt_bt2_self_component_port_input_get_msg_range( bt_self_component_port_input_message_iterator *iter); -PyObject *bt_py3_port_output_get_msg_range( +PyObject *bt_bt2_port_output_get_msg_range( bt_port_output_message_iterator *iter); diff --git a/src/bindings/python/bt2/bt2/native_bt_plugin.i b/src/bindings/python/bt2/bt2/native_bt_plugin.i index 9d2677c7..4cdf9a41 100644 --- a/src/bindings/python/bt2/bt2/native_bt_plugin.i +++ b/src/bindings/python/bt2/bt2/native_bt_plugin.i @@ -69,32 +69,31 @@ /* Helpers */ -bt_property_availability bt_plugin_get_version_wrapper( +bt_property_availability bt_bt2_plugin_get_version( const bt_plugin *plugin, unsigned int *major, unsigned int *minor, unsigned int *patch, const char **extra); -bt_plugin_status bt_plugin_find_wrapper(const char *plugin_name, +bt_plugin_find_status bt_bt2_plugin_find(const char *plugin_name, bt_bool fail_on_load_error, const bt_plugin **plugin); -bt_plugin_status bt_plugin_find_all_from_file_wrapper( +bt_plugin_find_all_from_file_status bt_bt2_plugin_find_all_from_file( const char *path, bt_bool fail_on_load_error, const bt_plugin_set **plugin_set); -bt_plugin_status bt_plugin_find_all_from_dir_wrapper( +bt_plugin_find_all_from_dir_status bt_bt2_plugin_find_all_from_dir( const char *path, bt_bool recurse, bt_bool fail_on_load_error, const bt_plugin_set **plugin_set); %{ - /* - * This *_wrapper() functions below ensure that when the API function + * Those bt_bt2_*() functions below ensure that when the API function * fails, the output parameter is set to `NULL`. This is necessary * because the epilogue of the `something **OUT` typemap will use that * value to make a Python object. We can't rely on the initial value of * `*OUT`; it could point to unreadable memory. */ -bt_property_availability bt_plugin_get_version_wrapper( +bt_property_availability bt_bt2_plugin_get_version( const bt_plugin *plugin, unsigned int *major, unsigned int *minor, unsigned int *patch, const char **extra) { @@ -109,48 +108,47 @@ bt_property_availability bt_plugin_get_version_wrapper( return ret; } -bt_plugin_status bt_plugin_find_wrapper(const char *plugin_name, +bt_plugin_find_status bt_bt2_plugin_find(const char *plugin_name, bt_bool fail_on_load_error, const bt_plugin **plugin) { - bt_plugin_status status; + bt_plugin_find_status status; status = bt_plugin_find(plugin_name, fail_on_load_error, plugin); - if (status != BT_PLUGIN_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { *plugin = NULL; } return status; } -bt_plugin_status bt_plugin_find_all_from_file_wrapper( +bt_plugin_find_all_from_file_status bt_bt2_plugin_find_all_from_file( const char *path, bt_bool fail_on_load_error, const bt_plugin_set **plugin_set) { - bt_plugin_status status; + bt_plugin_find_all_from_file_status status; status = bt_plugin_find_all_from_file(path, fail_on_load_error, plugin_set); - if (status != BT_PLUGIN_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { *plugin_set = NULL; } return status; } -bt_plugin_status bt_plugin_find_all_from_dir_wrapper( +bt_plugin_find_all_from_dir_status bt_bt2_plugin_find_all_from_dir( const char *path, bt_bool recurse, bt_bool fail_on_load_error, const bt_plugin_set **plugin_set) { - bt_plugin_status status; + bt_plugin_find_all_from_dir_status status; status = bt_plugin_find_all_from_dir(path, recurse, fail_on_load_error, plugin_set); - if (status != BT_PLUGIN_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { *plugin_set = NULL; } return status; } - %} diff --git a/src/bindings/python/bt2/bt2/native_bt_trace.i b/src/bindings/python/bt2/bt2/native_bt_trace.i index 8fcc5db9..3e27a368 100644 --- a/src/bindings/python/bt2/bt2/native_bt_trace.i +++ b/src/bindings/python/bt2/bt2/native_bt_trace.i @@ -43,33 +43,31 @@ trace_destroyed_listener(const bt_trace *trace, void *py_callable) if (py_res != NULL) { BT_ASSERT(py_res == Py_None); } else { - bt2_py_loge_exception(); + loge_exception(); } Py_DECREF(py_trace_ptr); Py_XDECREF(py_res); } -uint64_t bt_py3_trace_add_destruction_listener(bt_trace *trace, PyObject *py_callable) +uint64_t bt_bt2_trace_add_destruction_listener(bt_trace *trace, PyObject *py_callable) { uint64_t id = UINT64_C(-1); - bt_trace_status status; + bt_trace_add_listener_status status; BT_ASSERT(trace); BT_ASSERT(py_callable); - status = bt_trace_add_destruction_listener( trace, trace_destroyed_listener, py_callable, &id); - if (status != BT_TRACE_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { BT_LOGF_STR("Failed to add trace destruction listener."); abort(); } Py_INCREF(py_callable); - return id; } %} -uint64_t bt_py3_trace_add_destruction_listener(bt_trace *trace, +uint64_t bt_bt2_trace_add_destruction_listener(bt_trace *trace, PyObject *py_callable); diff --git a/src/bindings/python/bt2/bt2/native_bt_trace_class.i b/src/bindings/python/bt2/bt2/native_bt_trace_class.i index a4fdbba7..57166bc9 100644 --- a/src/bindings/python/bt2/bt2/native_bt_trace_class.i +++ b/src/bindings/python/bt2/bt2/native_bt_trace_class.i @@ -44,34 +44,32 @@ trace_class_destroyed_listener(const bt_trace_class *trace_class, void *py_calla if (py_res != NULL) { BT_ASSERT(py_res == Py_None); } else { - bt2_py_loge_exception(); + loge_exception(); } Py_DECREF(py_trace_class_ptr); Py_XDECREF(py_res); } -uint64_t bt_py3_trace_class_add_destruction_listener(bt_trace_class *trace_class, +uint64_t bt_bt2_trace_class_add_destruction_listener(bt_trace_class *trace_class, PyObject *py_callable) { uint64_t id = UINT64_C(-1); - bt_trace_class_status status; + bt_trace_class_add_listener_status status; BT_ASSERT(trace_class); BT_ASSERT(py_callable); - status = bt_trace_class_add_destruction_listener( trace_class, trace_class_destroyed_listener, py_callable, &id); - if (status != BT_TRACE_CLASS_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { BT_LOGF_STR("Failed to add trace class destruction listener."); abort(); } Py_INCREF(py_callable); - return id; } %} -uint64_t bt_py3_trace_class_add_destruction_listener(bt_trace_class *trace_class, +uint64_t bt_bt2_trace_class_add_destruction_listener(bt_trace_class *trace_class, PyObject *py_callable); diff --git a/src/bindings/python/bt2/bt2/native_bt_value.i b/src/bindings/python/bt2/bt2/native_bt_value.i index 8072614d..e9eea043 100644 --- a/src/bindings/python/bt2/bt2/native_bt_value.i +++ b/src/bindings/python/bt2/bt2/native_bt_value.i @@ -32,11 +32,11 @@ struct bt_value_map_get_keys_data { static int bt_value_map_get_keys_cb(const char *key, const struct bt_value *object, void *data) { - enum bt_value_status status; + bt_value_array_append_element_status status; struct bt_value_map_get_keys_data *priv_data = data; status = bt_value_array_append_string_element(priv_data->keys, key); - if (status != BT_VALUE_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { return BT_FALSE; } @@ -45,7 +45,7 @@ static int bt_value_map_get_keys_cb(const char *key, const struct bt_value *obje static struct bt_value *bt_value_map_get_keys(const struct bt_value *map_obj) { - enum bt_value_status status; + bt_value_map_foreach_entry_const_status status; struct bt_value_map_get_keys_data data; data.keys = bt_value_array_create(); @@ -55,7 +55,7 @@ static struct bt_value *bt_value_map_get_keys(const struct bt_value *map_obj) status = bt_value_map_foreach_entry_const(map_obj, bt_value_map_get_keys_cb, &data); - if (status != BT_VALUE_STATUS_OK) { + if (status != __BT_FUNC_STATUS_OK) { goto error; } diff --git a/src/bindings/python/bt2/bt2/plugin.py b/src/bindings/python/bt2/bt2/plugin.py index b32f8ce2..16c7c4a1 100644 --- a/src/bindings/python/bt2/bt2/plugin.py +++ b/src/bindings/python/bt2/bt2/plugin.py @@ -27,13 +27,6 @@ import os.path import bt2 -def _handle_status(status, gen_error_msg): - if status == native_bt.PLUGIN_STATUS_LOADING_ERROR: - raise bt2.PluginLoadingError - elif status < 0: - raise bt2.Error(gen_error_msg) - - def find_plugins(path, recurse=True, fail_on_load_error=False): utils._check_str(path) utils._check_bool(recurse) @@ -41,17 +34,16 @@ def find_plugins(path, recurse=True, fail_on_load_error=False): plugin_set_ptr = None if os.path.isfile(path): - status, plugin_set_ptr = native_bt.plugin_find_all_from_file_wrapper(path, fail_on_load_error) + status, plugin_set_ptr = native_bt.bt2_plugin_find_all_from_file(path, fail_on_load_error) elif os.path.isdir(path): - status, plugin_set_ptr = native_bt.plugin_find_all_from_dir_wrapper(path, int(recurse), int(fail_on_load_error)) + status, plugin_set_ptr = native_bt.bt2_plugin_find_all_from_dir(path, int(recurse), int(fail_on_load_error)) else: raise bt2.Error("invalid path: '{}'".format(path)) - _handle_status(status, 'failed to find plugins') - - if status == native_bt.PLUGIN_STATUS_NOT_FOUND: + if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return + utils._handle_func_status(status, 'failed to find plugins') assert plugin_set_ptr is not None return _PluginSet._create_from_ptr(plugin_set_ptr) @@ -59,12 +51,12 @@ def find_plugins(path, recurse=True, fail_on_load_error=False): def find_plugin(name, fail_on_load_error=False): utils._check_str(name) utils._check_bool(fail_on_load_error) - status, ptr = native_bt.plugin_find_wrapper(name, int(fail_on_load_error)) - _handle_status(status, 'failed to find plugin') + status, ptr = native_bt.bt2_plugin_find(name, int(fail_on_load_error)) - if status == native_bt.PLUGIN_STATUS_NOT_FOUND: + if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return + utils._handle_func_status(status, 'failed to find plugin') assert ptr is not None return _Plugin._create_from_ptr(ptr) @@ -214,7 +206,7 @@ class _Plugin(object._SharedObject): @property def version(self): - status, major, minor, patch, extra = native_bt.plugin_get_version_wrapper(self._ptr) + status, major, minor, patch, extra = native_bt.bt2_plugin_get_version(self._ptr) if status == native_bt.PROPERTY_AVAILABILITY_NOT_AVAILABLE: return diff --git a/src/bindings/python/bt2/bt2/port.py b/src/bindings/python/bt2/bt2/port.py index f7c23669..4ba59f06 100644 --- a/src/bindings/python/bt2/bt2/port.py +++ b/src/bindings/python/bt2/bt2/port.py @@ -32,7 +32,7 @@ def _create_from_ptr_and_get_ref(ptr, port_type): cls = _PORT_TYPE_TO_PYCLS.get(port_type, None) if cls is None: - raise bt2.Error('unknown port type: {}'.format(port_type)) + raise TypeError('unknown port type: {}'.format(port_type)) return cls._create_from_ptr_and_get_ref(ptr) @@ -41,7 +41,7 @@ def _create_self_from_ptr_and_get_ref(ptr, port_type): cls = _PORT_TYPE_TO_USER_PYCLS.get(port_type, None) if cls is None: - raise bt2.Error('unknown port type: {}'.format(port_type)) + raise TypeError('unknown port type: {}'.format(port_type)) return cls._create_from_ptr_and_get_ref(ptr) diff --git a/src/bindings/python/bt2/bt2/query_executor.py b/src/bindings/python/bt2/bt2/query_executor.py index 072410fb..f0e984ef 100644 --- a/src/bindings/python/bt2/bt2/query_executor.py +++ b/src/bindings/python/bt2/bt2/query_executor.py @@ -30,18 +30,6 @@ class QueryExecutor(object._SharedObject): _get_ref = staticmethod(native_bt.query_executor_get_ref) _put_ref = staticmethod(native_bt.query_executor_put_ref) - def _handle_status(self, status, gen_error_msg): - if status == native_bt.QUERY_EXECUTOR_STATUS_AGAIN: - raise bt2.TryAgain - elif status == native_bt.QUERY_EXECUTOR_STATUS_CANCELED: - raise bt2.QueryExecutorCanceled - elif status == native_bt.QUERY_EXECUTOR_STATUS_INVALID_OBJECT: - raise bt2.InvalidQueryObject - elif status == native_bt.QUERY_EXECUTOR_STATUS_INVALID_PARAMS: - raise bt2.InvalidQueryParams - elif status < 0: - raise bt2.Error(gen_error_msg) - def __init__(self): ptr = native_bt.query_executor_create() @@ -52,7 +40,8 @@ class QueryExecutor(object._SharedObject): def cancel(self): status = native_bt.query_executor_cancel(self._ptr) - self._handle_status(status, 'cannot cancel query executor object') + utils._handle_func_status(status, + 'cannot cancel query executor object') @property def is_canceled(self): @@ -63,7 +52,7 @@ class QueryExecutor(object._SharedObject): def query(self, component_class, object, params=None, logging_level=bt2.logging.LoggingLevel.NONE): if self.is_canceled: - raise bt2.QueryExecutorCanceled + raise bt2.Canceled if not isinstance(component_class, bt2.component._GenericComponentClass): err = False @@ -92,6 +81,6 @@ class QueryExecutor(object._SharedObject): status, result_ptr = native_bt.query_executor_query(self._ptr, cc_ptr, object, params_ptr, logging_level) - self._handle_status(status, 'cannot query component class') + utils._handle_func_status(status, 'cannot query component class') assert(result_ptr) return bt2.value._create_from_ptr(result_ptr) diff --git a/src/bindings/python/bt2/bt2/stream_class.py b/src/bindings/python/bt2/bt2/stream_class.py index 54b5b38b..c22e05a5 100644 --- a/src/bindings/python/bt2/bt2/stream_class.py +++ b/src/bindings/python/bt2/bt2/stream_class.py @@ -103,8 +103,9 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): def _name(self, name): utils._check_str(name) - ret = native_bt.stream_class_set_name(self._ptr, name) - utils._handle_ret(ret, "cannot set stream class object's name") + status = native_bt.stream_class_set_name(self._ptr, name) + utils._handle_func_status(status, + "cannot set stream class object's name") _name = property(fset=_name) @@ -194,8 +195,8 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): @id.setter def id(self, id): utils._check_int64(id) - ret = native_bt.stream_class_set_id(self._ptr, id) - utils._handle_ret(ret, "cannot set stream class object's ID") + status = native_bt.stream_class_set_id(self._ptr, id) + utils._handle_func_status(status, "cannot set stream class object's ID") @property def packet_context_field_class(self): @@ -210,9 +211,10 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): if packet_context_field_class is not None: utils._check_type(packet_context_field_class, bt2.field_class._StructureFieldClass) - ret = native_bt.stream_class_set_packet_context_field_class(self._ptr, - packet_context_field_class._ptr) - utils._handle_ret(ret, "cannot set stream class' packet context field class") + status = native_bt.stream_class_set_packet_context_field_class(self._ptr, + packet_context_field_class._ptr) + utils._handle_func_status(status, + "cannot set stream class' packet context field class") _packet_context_field_class = property(fset=_packet_context_field_class) @@ -231,9 +233,9 @@ class _StreamClass(object._SharedObject, collections.abc.Mapping): bt2.field_class._StructureFieldClass) set_context_fn = native_bt.stream_class_set_event_common_context_field_class - ret = set_context_fn(self._ptr, event_common_context_field_class._ptr) - - utils._handle_ret(ret, "cannot set stream class' event context field type") + status = set_context_fn(self._ptr, event_common_context_field_class._ptr) + utils._handle_func_status(status, + "cannot set stream class' event context field type") _event_common_context_field_class = property(fset=_event_common_context_field_class) diff --git a/src/bindings/python/bt2/bt2/trace.py b/src/bindings/python/bt2/bt2/trace.py index 5830ec3f..9ab1a080 100644 --- a/src/bindings/python/bt2/bt2/trace.py +++ b/src/bindings/python/bt2/bt2/trace.py @@ -76,8 +76,9 @@ class _Trace(object._SharedObject, collections.abc.Mapping): def _name(self, name): utils._check_str(name) - ret = native_bt.trace_set_name(self._ptr, name) - utils._handle_ret(ret, "cannot set trace class object's name") + status = native_bt.trace_set_name(self._ptr, name) + utils._handle_func_status(status, + "cannot set trace class object's name") _name = property(fset=_name) @@ -111,7 +112,7 @@ class _Trace(object._SharedObject, collections.abc.Mapping): if not callable(listener): raise TypeError("'listener' parameter is not callable") - fn = native_bt.py3_trace_add_destruction_listener + fn = native_bt.bt2_trace_add_destruction_listener listener_from_native = functools.partial(_trace_destruction_listener_from_native, listener) diff --git a/src/bindings/python/bt2/bt2/trace_class.py b/src/bindings/python/bt2/bt2/trace_class.py index 5713db8c..08d6cedc 100644 --- a/src/bindings/python/bt2/bt2/trace_class.py +++ b/src/bindings/python/bt2/bt2/trace_class.py @@ -55,9 +55,9 @@ class _TraceClassEnv(collections.abc.MutableMapping): else: raise TypeError('expected str or int, got {}'.format(type(value))) - ret = set_env_entry_fn(self._trace_class._ptr, key, value) - - utils._handle_ret(ret, "cannot set trace class object's environment entry") + status = set_env_entry_fn(self._trace_class._ptr, key, value) + utils._handle_func_status(status, + "cannot set trace class object's environment entry") def __delitem__(self, key): raise NotImplementedError @@ -324,7 +324,7 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping): if not callable(listener): raise TypeError("'listener' parameter is not callable") - fn = native_bt.py3_trace_class_add_destruction_listener + fn = native_bt.bt2_trace_class_add_destruction_listener listener_from_native = functools.partial(_trace_class_destruction_listener_from_native, listener) diff --git a/src/bindings/python/bt2/bt2/utils.py b/src/bindings/python/bt2/bt2/utils.py index 636e9213..4c0c2d91 100644 --- a/src/bindings/python/bt2/bt2/utils.py +++ b/src/bindings/python/bt2/bt2/utils.py @@ -22,6 +22,7 @@ import bt2 import bt2.logging +from bt2 import native_bt def _check_bool(o): @@ -118,11 +119,6 @@ def _raise_bt2_error(msg): raise bt2.Error(msg) -def _handle_ret(ret, msg=None): - if int(ret) < 0: - _raise_bt2_error(msg) - - def _handle_ptr(ptr, msg=None): if ptr is None: _raise_bt2_error(msg) @@ -143,3 +139,57 @@ def _check_log_level(log_level): if log_level not in log_levels: raise ValueError("'{}' is not a valid logging level".format(log_level)) + + +def _handle_func_status(status, msg=None): + if status == native_bt.__BT_FUNC_STATUS_OK: + # no error + return + + if status == native_bt.__BT_FUNC_STATUS_ERROR or status == native_bt.__BT_FUNC_STATUS_MEMORY_ERROR: + if msg is None: + raise bt2.Error + else: + raise bt2.Error(msg) + elif status == native_bt.__BT_FUNC_STATUS_END: + if msg is None: + raise bt2.Stop + else: + raise bt2.Stop(msg) + elif status == native_bt.__BT_FUNC_STATUS_AGAIN: + if msg is None: + raise bt2.TryAgain + else: + raise bt2.TryAgain(msg) + elif status == native_bt.__BT_FUNC_STATUS_CANCELED: + if msg is None: + raise bt2.Canceled + else: + raise bt2.Canceled(msg) + elif status == native_bt.__BT_FUNC_STATUS_LOADING_ERROR: + if msg is None: + raise bt2.LoadingError + else: + raise bt2.LoadingError(msg) + elif status == native_bt.__BT_FUNC_STATUS_OVERFLOW: + if msg is None: + raise bt2.OverflowError + else: + raise bt2.OverflowError(msg) + elif status == native_bt.__BT_FUNC_STATUS_INVALID_OBJECT: + if msg is None: + raise bt2.InvalidObject + else: + raise bt2.InvalidObject(msg) + elif status == native_bt.__BT_FUNC_STATUS_INVALID_PARAMS: + if msg is None: + raise bt2.InvalidParams + else: + raise bt2.InvalidParams(msg) + elif status == native_bt.__BT_FUNC_STATUS_UNSUPPORTED: + if msg is None: + raise bt2.Unsupported + else: + raise bt2.Unsupported(msg) + else: + assert False diff --git a/src/bindings/python/bt2/bt2/value.py b/src/bindings/python/bt2/bt2/value.py index 6cea6cd5..b6a5a4a1 100644 --- a/src/bindings/python/bt2/bt2/value.py +++ b/src/bindings/python/bt2/bt2/value.py @@ -29,13 +29,6 @@ import abc import bt2 -def _handle_status(status, obj_name): - if status >= 0: - return - else: - raise RuntimeError('unexpected error') - - def _create_from_ptr(ptr): if ptr is None or ptr == native_bt.value_null: return @@ -88,9 +81,6 @@ class _Value(object._SharedObject, metaclass=abc.ABCMeta): def __ne__(self, other): return not (self == other) - def _handle_status(self, status): - _handle_status(status, self._NAME) - def _check_create_status(self, ptr): if ptr is None: raise bt2.CreationError( @@ -370,7 +360,7 @@ class StringValue(collections.abc.Sequence, _Value): def _set_value(self, value): status = native_bt.value_string_set(self._ptr, self._value_to_str(value)) - self._handle_status(status) + utils._handle_func_status(status) value = property(fset=_set_value) @@ -473,7 +463,7 @@ class ArrayValue(_Container, collections.abc.MutableSequence, _Value): status = native_bt.value_array_set_element_by_index( self._ptr, index, ptr) - self._handle_status(status) + utils._handle_func_status(status) def append(self, value): value = create_value(value) @@ -484,7 +474,7 @@ class ArrayValue(_Container, collections.abc.MutableSequence, _Value): ptr = value._ptr status = native_bt.value_array_append_element(self._ptr, ptr) - self._handle_status(status) + utils._handle_func_status(status) def __iadd__(self, iterable): # Python will raise a TypeError if there's anything wrong with @@ -590,7 +580,7 @@ class MapValue(_Container, collections.abc.MutableMapping, _Value): ptr = value._ptr status = native_bt.value_map_insert_entry(self._ptr, key, ptr) - self._handle_status(status) + utils._handle_func_status(status) def __repr__(self): items = ['{}: {}'.format(repr(k), repr(v)) for k, v in self.items()] diff --git a/src/cli/babeltrace2-cfg-cli-args.c b/src/cli/babeltrace2-cfg-cli-args.c index ce176287..3b76322f 100644 --- a/src/cli/babeltrace2-cfg-cli-args.c +++ b/src/cli/babeltrace2-cfg-cli-args.c @@ -269,7 +269,7 @@ bt_value *ini_parse_array(struct ini_parsing_state *state) while (!(token_type == G_TOKEN_CHAR && g_scanner_cur_value(state->scanner).v_char == ']')) { /* Parse the item... */ bt_value *item_value; - bt_value_status status; + bt_value_array_append_element_status append_status; item_value = ini_parse_value(state); if (!item_value) { @@ -277,10 +277,10 @@ bt_value *ini_parse_array(struct ini_parsing_state *state) } /* ... and add it to the result array. */ - status = bt_value_array_append_element(array_value, item_value); + append_status = bt_value_array_append_element(array_value, + item_value); BT_VALUE_PUT_REF_AND_RESET(item_value); - - if (status != BT_VALUE_STATUS_OK) { + if (append_status < 0) { goto error; } @@ -2490,7 +2490,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], bt_value *connection_args = NULL; char error_buf[256] = { 0 }; long retry_duration = -1; - bt_value_status status; + bt_value_map_extend_status extend_status; struct poptOption run_long_options[] = { { "base-params", 'b', POPT_ARG_STRING, NULL, OPT_BASE_PARAMS, NULL, NULL }, { "component", 'c', POPT_ARG_STRING, NULL, OPT_COMPONENT, NULL, NULL }, @@ -2610,9 +2610,8 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], BT_ASSERT(cur_base_params); bt_value_put_ref(cur_cfg_comp->params); - status = bt_value_copy(cur_base_params, - &cur_cfg_comp->params); - if (status != BT_VALUE_STATUS_OK) { + if (bt_value_copy(cur_base_params, + &cur_cfg_comp->params) < 0) { print_err_oom(); goto error; } @@ -2638,10 +2637,10 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], goto error; } - status = bt_value_map_extend(cur_cfg_comp->params, - params, ¶ms_to_set); + extend_status = bt_value_map_extend( + cur_cfg_comp->params, params, ¶ms_to_set); BT_VALUE_PUT_REF_AND_RESET(params); - if (status != BT_VALUE_STATUS_OK) { + if (extend_status != BT_VALUE_MAP_EXTEND_STATUS_OK) { printf_err("Cannot extend current component parameters with --params option's argument:\n %s\n", arg); goto error; @@ -4468,8 +4467,8 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], /* Consume and keep leftover arguments */ while ((leftover = poptGetArg(pc))) { - bt_value_status status = bt_value_array_append_string_element(leftovers, leftover); - if (status != BT_VALUE_STATUS_OK) { + if (bt_value_array_append_string_element(leftovers, leftover) != + BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) { print_err_oom(); goto error; } diff --git a/src/cli/babeltrace2-cfg.c b/src/cli/babeltrace2-cfg.c index 4c764a9e..4ab27b0b 100644 --- a/src/cli/babeltrace2-cfg.c +++ b/src/cli/babeltrace2-cfg.c @@ -60,7 +60,7 @@ int bt_config_append_plugin_paths( ret = bt_value_array_append_string_element( plugin_paths, dir->str); - if (ret != BT_VALUE_STATUS_OK) { + if (ret < 0) { ret = -1; goto end; } diff --git a/src/cli/babeltrace2.c b/src/cli/babeltrace2.c index c89fabce..0b026f78 100644 --- a/src/cli/babeltrace2.c +++ b/src/cli/babeltrace2.c @@ -160,7 +160,7 @@ int query(struct bt_config *cfg, const bt_component_class *comp_cls, const bt_value **user_result, const char **fail_reason) { const bt_value *result = NULL; - bt_query_executor_status status; + bt_query_executor_query_status query_status; *fail_reason = "unknown error"; int ret = 0; @@ -182,17 +182,18 @@ int query(struct bt_config *cfg, const bt_component_class *comp_cls, } while (true) { - status = bt_query_executor_query(the_query_executor, - comp_cls, obj, params, cfg->log_level, &result); - switch (status) { - case BT_QUERY_EXECUTOR_STATUS_OK: + query_status = bt_query_executor_query( + the_query_executor, comp_cls, obj, params, + cfg->log_level, &result); + switch (query_status) { + case BT_QUERY_EXECUTOR_QUERY_STATUS_OK: goto ok; - case BT_QUERY_EXECUTOR_STATUS_AGAIN: + case BT_QUERY_EXECUTOR_QUERY_STATUS_AGAIN: { const uint64_t sleep_time_us = 100000; /* Wait 100 ms and retry */ - BT_LOGD("Got BT_QUERY_EXECUTOR_STATUS_AGAIN: sleeping: " + BT_LOGD("Got BT_QUERY_EXECUTOR_QUERY_STATUS_AGAIN: sleeping: " "time-us=%" PRIu64, sleep_time_us); if (usleep(sleep_time_us)) { @@ -209,25 +210,27 @@ int query(struct bt_config *cfg, const bt_component_class *comp_cls, continue; } - case BT_QUERY_EXECUTOR_STATUS_CANCELED: + case BT_QUERY_EXECUTOR_QUERY_STATUS_CANCELED: *fail_reason = "canceled by user"; goto error; - case BT_QUERY_EXECUTOR_STATUS_ERROR: + case BT_QUERY_EXECUTOR_QUERY_STATUS_ERROR: goto error; - case BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT: + case BT_QUERY_EXECUTOR_QUERY_STATUS_INVALID_OBJECT: *fail_reason = "invalid or unknown query object"; goto error; - case BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS: + case BT_QUERY_EXECUTOR_QUERY_STATUS_INVALID_PARAMS: *fail_reason = "invalid query parameters"; goto error; - case BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED: + case BT_QUERY_EXECUTOR_QUERY_STATUS_UNSUPPORTED: *fail_reason = "unsupported action"; goto error; - case BT_QUERY_EXECUTOR_STATUS_NOMEM: + case BT_QUERY_EXECUTOR_QUERY_STATUS_MEMORY_ERROR: *fail_reason = "not enough memory"; goto error; default: - BT_LOGF("Unknown query status: status=%d", status); + BT_LOGF("Unknown query status: status=%s", + bt_common_func_status_string( + query_status)); abort(); } } @@ -798,7 +801,7 @@ int load_dynamic_plugins(const bt_value *plugin_paths) const bt_value *plugin_path_value = NULL; const char *plugin_path; const bt_plugin_set *plugin_set = NULL; - bt_plugin_status status; + bt_plugin_find_all_from_dir_status status; plugin_path_value = bt_value_array_borrow_element_by_index_const( @@ -822,13 +825,14 @@ int load_dynamic_plugins(const bt_value *plugin_paths) BT_LOGE("Unable to load dynamic plugins from directory: " "path=\"%s\"", plugin_path); continue; - } else if (status == BT_PLUGIN_STATUS_NOT_FOUND) { + } else if (status == + BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_NOT_FOUND) { BT_LOGI("No plugins found in directory: path=\"%s\"", plugin_path); continue; } - BT_ASSERT(status == BT_PLUGIN_STATUS_OK); + BT_ASSERT(status == BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_OK); BT_ASSERT(plugin_set); add_to_loaded_plugins(plugin_set); bt_plugin_set_put_ref(plugin_set); @@ -842,7 +846,7 @@ int load_static_plugins(void) { int ret = 0; const bt_plugin_set *plugin_set; - bt_plugin_status status; + bt_plugin_find_all_from_static_status status; BT_LOGI("Loading static plugins."); status = bt_plugin_find_all_from_static(BT_FALSE, &plugin_set); @@ -850,15 +854,17 @@ int load_static_plugins(void) BT_LOGE("Unable to load static plugins."); ret = -1; goto end; - } else if (status == BT_PLUGIN_STATUS_NOT_FOUND) { + } else if (status == + BT_PLUGIN_FIND_ALL_FROM_STATIC_STATUS_NOT_FOUND) { BT_LOGI("No static plugins found."); goto end; } - BT_ASSERT(status == BT_PLUGIN_STATUS_OK); + BT_ASSERT(status == BT_PLUGIN_FIND_ALL_FROM_STATIC_STATUS_OK); BT_ASSERT(plugin_set); add_to_loaded_plugins(plugin_set); bt_plugin_set_put_ref(plugin_set); + end: return ret; } @@ -1621,7 +1627,8 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( uint64_t i; input_port_count_func_t port_count_fn; borrow_input_port_by_index_func_t port_by_index_fn; - bt_graph_status status = BT_GRAPH_STATUS_ERROR; + bt_graph_connect_ports_status connect_ports_status = + BT_GRAPH_CONNECT_PORTS_STATUS_OK; bool insert_trimmer = false; bt_value *trimmer_params = NULL; char *intersection_begin = NULL; @@ -1647,7 +1654,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( range = (struct trace_range *) g_hash_table_lookup( ctx->intersections, &port_id); if (range) { - bt_value_status status; + bt_value_map_insert_entry_status insert_status; intersection_begin = s_from_ns( range->intersection_range_begin_ns); @@ -1664,15 +1671,15 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( goto error; } - status = bt_value_map_insert_string_entry( + insert_status = bt_value_map_insert_string_entry( trimmer_params, "begin", intersection_begin); - if (status != BT_VALUE_STATUS_OK) { + if (insert_status < 0) { goto error; } - status = bt_value_map_insert_string_entry( + insert_status = bt_value_map_insert_string_entry( trimmer_params, "end", intersection_end); - if (status != BT_VALUE_STATUS_OK) { + if (insert_status < 0) { goto error; } } @@ -1766,7 +1773,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( * source and the trimmer. */ char *trimmer_name = NULL; - bt_graph_status graph_status; + bt_graph_add_component_status add_comp_status; ret = asprintf(&trimmer_name, "stream-intersection-trimmer-%s", @@ -1777,12 +1784,13 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( ret = 0; ctx->connect_ports = false; - graph_status = bt_graph_add_filter_component( + add_comp_status = bt_graph_add_filter_component( ctx->graph, trimmer_class, trimmer_name, trimmer_params, ctx->cfg->log_level, &trimmer); free(trimmer_name); - if (graph_status != BT_GRAPH_STATUS_OK) { + if (add_comp_status != + BT_GRAPH_ADD_COMPONENT_STATUS_OK) { goto error; } BT_ASSERT(trimmer); @@ -1813,15 +1821,14 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( } /* We have a winner! */ - status = bt_graph_connect_ports(ctx->graph, + connect_ports_status = bt_graph_connect_ports(ctx->graph, out_upstream_port, in_downstream_port, NULL); downstream_port = NULL; - switch (status) { - case BT_GRAPH_STATUS_OK: + switch (connect_ports_status) { + case BT_GRAPH_CONNECT_PORTS_STATUS_OK: break; - case BT_GRAPH_STATUS_CANCELED: + case BT_GRAPH_CONNECT_PORTS_STATUS_CANCELED: BT_LOGI_STR("Graph was canceled by user."); - status = BT_GRAPH_STATUS_OK; break; default: BT_LOGE("Cannot create connection: graph refuses to connect ports: " @@ -1981,13 +1988,14 @@ end: } static -bt_graph_listener_status +bt_graph_listener_func_status graph_output_port_added_listener(struct cmd_run_ctx *ctx, const bt_port_output *out_port) { const bt_component *comp; const bt_port *port = bt_port_output_as_port_const(out_port); - bt_graph_listener_status ret = BT_GRAPH_LISTENER_STATUS_OK; + bt_graph_listener_func_status ret = + BT_GRAPH_LISTENER_FUNC_STATUS_OK; comp = bt_port_borrow_component_const(port); BT_LOGI("Port added to a graph's component: comp-addr=%p, " @@ -2012,7 +2020,7 @@ graph_output_port_added_listener(struct cmd_run_ctx *ctx, if (cmd_run_ctx_connect_upstream_port(ctx, out_port)) { BT_LOGF_STR("Cannot connect upstream port."); fprintf(stderr, "Added port could not be connected: aborting\n"); - ret = BT_GRAPH_LISTENER_STATUS_ERROR; + ret = BT_GRAPH_LISTENER_FUNC_STATUS_ERROR; goto end; } @@ -2021,7 +2029,7 @@ end: } static -bt_graph_listener_status graph_source_output_port_added_listener( +bt_graph_listener_func_status graph_source_output_port_added_listener( const bt_component_source *component, const bt_port_output *port, void *data) { @@ -2029,7 +2037,7 @@ bt_graph_listener_status graph_source_output_port_added_listener( } static -bt_graph_listener_status graph_filter_output_port_added_listener( +bt_graph_listener_func_status graph_filter_output_port_added_listener( const bt_component_filter *component, const bt_port_output *port, void *data) { @@ -2072,7 +2080,7 @@ static int cmd_run_ctx_init(struct cmd_run_ctx *ctx, struct bt_config *cfg) { int ret = 0; - bt_graph_status status; + bt_graph_add_component_status add_comp_status; ctx->cfg = cfg; ctx->connect_ports = false; @@ -2109,18 +2117,18 @@ int cmd_run_ctx_init(struct cmd_run_ctx *ctx, struct bt_config *cfg) } the_graph = ctx->graph; - status = bt_graph_add_source_component_output_port_added_listener( + add_comp_status = bt_graph_add_source_component_output_port_added_listener( ctx->graph, graph_source_output_port_added_listener, NULL, ctx, NULL); - if (status != BT_GRAPH_STATUS_OK) { + if (add_comp_status != BT_GRAPH_ADD_COMPONENT_STATUS_OK) { BT_LOGE_STR("Cannot add \"port added\" listener to graph."); goto error; } - status = bt_graph_add_filter_component_output_port_added_listener( + add_comp_status = bt_graph_add_filter_component_output_port_added_listener( ctx->graph, graph_filter_output_port_added_listener, NULL, ctx, NULL); - if (status != BT_GRAPH_STATUS_OK) { + if (add_comp_status != BT_GRAPH_ADD_COMPONENT_STATUS_OK) { BT_LOGE_STR("Cannot add \"port added\" listener to graph."); goto error; } @@ -2560,27 +2568,6 @@ end: return ret; } -static inline -const char *bt_graph_status_str(bt_graph_status status) -{ - switch (status) { - case BT_GRAPH_STATUS_OK: - return "BT_GRAPH_STATUS_OK"; - case BT_GRAPH_STATUS_END: - return "BT_GRAPH_STATUS_END"; - case BT_GRAPH_STATUS_AGAIN: - return "BT_GRAPH_STATUS_AGAIN"; - case BT_GRAPH_STATUS_CANCELED: - return "BT_GRAPH_STATUS_CANCELED"; - case BT_GRAPH_STATUS_ERROR: - return "BT_GRAPH_STATUS_ERROR"; - case BT_GRAPH_STATUS_NOMEM: - return "BT_GRAPH_STATUS_NOMEM"; - default: - return "(unknown)"; - } -} - static int cmd_run(struct bt_config *cfg) { @@ -2631,7 +2618,7 @@ int cmd_run(struct bt_config *cfg) /* Run the graph */ while (true) { - bt_graph_status graph_status = bt_graph_run(ctx.graph); + bt_graph_run_status run_status = bt_graph_run(ctx.graph); /* * Reset console in case something messed with console @@ -2641,22 +2628,22 @@ int cmd_run(struct bt_config *cfg) fflush(stdout); fprintf(stderr, "%s", bt_common_color_reset()); BT_LOGT("bt_graph_run() returned: status=%s", - bt_graph_status_str(graph_status)); + bt_common_func_status_string(run_status)); - switch (graph_status) { - case BT_GRAPH_STATUS_OK: + switch (run_status) { + case BT_GRAPH_RUN_STATUS_OK: break; - case BT_GRAPH_STATUS_CANCELED: + case BT_GRAPH_RUN_STATUS_CANCELED: BT_LOGI_STR("Graph was canceled by user."); goto error; - case BT_GRAPH_STATUS_AGAIN: + case BT_GRAPH_RUN_STATUS_AGAIN: if (bt_graph_is_canceled(ctx.graph)) { BT_LOGI_STR("Graph was canceled by user."); goto error; } if (cfg->cmd_data.run.retry_duration_us > 0) { - BT_LOGT("Got BT_GRAPH_STATUS_AGAIN: sleeping: " + BT_LOGT("Got BT_GRAPH_RUN_STATUS_AGAIN: sleeping: " "time-us=%" PRIu64, cfg->cmd_data.run.retry_duration_us); @@ -2668,7 +2655,7 @@ int cmd_run(struct bt_config *cfg) } } break; - case BT_GRAPH_STATUS_END: + case BT_GRAPH_RUN_STATUS_END: goto end; default: BT_LOGE_STR("Graph failed to complete successfully"); diff --git a/src/common/common.h b/src/common/common.h index 23c913ef..809c2e50 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -33,15 +33,16 @@ #include #include -#include #include #include #include -#include -#include #include #include +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + #include "common/assert.h" #include "common/macros.h" #include "common/safe.h" @@ -548,26 +549,6 @@ end: return str; } -static inline -const char *bt_common_self_message_iterator_status_string( - enum bt_self_message_iterator_status status) -{ - switch (status) { - case BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN: - return "BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN"; - case BT_SELF_MESSAGE_ITERATOR_STATUS_END: - return "BT_SELF_MESSAGE_ITERATOR_STATUS_END"; - case BT_SELF_MESSAGE_ITERATOR_STATUS_OK: - return "BT_SELF_MESSAGE_ITERATOR_STATUS_OK"; - case BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR: - return "BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR"; - case BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM: - return "BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM"; - default: - return "(unknown)"; - } -}; - static inline const char *bt_common_logging_level_string( enum bt_logging_level level) @@ -593,40 +574,33 @@ const char *bt_common_logging_level_string( }; static inline -const char *bt_self_component_status_string( - enum bt_self_component_status status) -{ - switch (status) { - case BT_SELF_COMPONENT_STATUS_OK: - return "BT_SELF_COMPONENT_STATUS_OK"; - case BT_SELF_COMPONENT_STATUS_END: - return "BT_SELF_COMPONENT_STATUS_END"; - case BT_SELF_COMPONENT_STATUS_AGAIN: - return "BT_SELF_COMPONENT_STATUS_AGAIN"; - case BT_SELF_COMPONENT_STATUS_ERROR: - return "BT_SELF_COMPONENT_STATUS_ERROR"; - case BT_SELF_COMPONENT_STATUS_NOMEM: - return "BT_SELF_COMPONENT_STATUS_NOMEM"; - default: - return "(unknown)"; - } -} - -static inline -const char *bt_message_iterator_status_string( - enum bt_message_iterator_status status) +const char *bt_common_func_status_string(int status) { switch (status) { - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - return "BT_MESSAGE_ITERATOR_STATUS_AGAIN"; - case BT_MESSAGE_ITERATOR_STATUS_END: - return "BT_MESSAGE_ITERATOR_STATUS_END"; - case BT_MESSAGE_ITERATOR_STATUS_OK: - return "BT_MESSAGE_ITERATOR_STATUS_OK"; - case BT_MESSAGE_ITERATOR_STATUS_ERROR: - return "BT_MESSAGE_ITERATOR_STATUS_ERROR"; - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - return "BT_MESSAGE_ITERATOR_STATUS_NOMEM"; + case __BT_FUNC_STATUS_OVERFLOW: + return "OVERFLOW"; + case __BT_FUNC_STATUS_INVALID_PARAMS: + return "INVALID_PARAMS"; + case __BT_FUNC_STATUS_INVALID_OBJECT: + return "INVALID_OBJECT"; + case __BT_FUNC_STATUS_MEMORY_ERROR: + return "MEMORY_ERROR"; + case __BT_FUNC_STATUS_LOADING_ERROR: + return "LOADING_ERROR"; + case __BT_FUNC_STATUS_ERROR: + return "ERROR"; + case __BT_FUNC_STATUS_OK: + return "OK"; + case __BT_FUNC_STATUS_END: + return "END"; + case __BT_FUNC_STATUS_NOT_FOUND: + return "NOT_FOUND"; + case __BT_FUNC_STATUS_AGAIN: + return "AGAIN"; + case __BT_FUNC_STATUS_UNSUPPORTED: + return "UNSUPPORTED"; + case __BT_FUNC_STATUS_CANCELED: + return "CANCELED"; default: return "(unknown)"; } @@ -723,11 +697,6 @@ end: return ret; } -static inline -enum bt_self_message_iterator_status bt_common_message_iterator_status_to_self( - enum bt_message_iterator_status status) -{ - return (int) status; -} +#include #endif /* BABELTRACE_COMMON_INTERNAL_H */ diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index db80b960..c00a0ee1 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -6,12 +6,13 @@ libbabeltrace2_la_SOURCES = \ assert-post.h \ assert-pre.h \ babeltrace2.c \ + func-status.h \ lib-logging.c \ - logging.h \ logging.c \ - object.h \ + logging.h \ object-pool.c \ object-pool.h \ + object.h \ property.h \ util.c \ value.c \ diff --git a/src/lib/func-status.h b/src/lib/func-status.h new file mode 100644 index 00000000..ed3dd0cc --- /dev/null +++ b/src/lib/func-status.h @@ -0,0 +1,49 @@ +#ifndef BABELTRACE_FUNC_STATUS_INTERNAL_H +#define BABELTRACE_FUNC_STATUS_INTERNAL_H + +/* + * Copyright (c) 2019 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define __BT_FUNC_STATUS_ENABLE +#include +#undef __BT_FUNC_STATUS_ENABLE + +/* + * Aliases without a `__` prefix for internal code: this is just easier + * to read. + */ +#define BT_FUNC_STATUS_OVERFLOW __BT_FUNC_STATUS_OVERFLOW +#define BT_FUNC_STATUS_INVALID_PARAMS __BT_FUNC_STATUS_INVALID_PARAMS +#define BT_FUNC_STATUS_INVALID_OBJECT __BT_FUNC_STATUS_INVALID_OBJECT +#define BT_FUNC_STATUS_MEMORY_ERROR __BT_FUNC_STATUS_MEMORY_ERROR +#define BT_FUNC_STATUS_LOADING_ERROR __BT_FUNC_STATUS_LOADING_ERROR +#define BT_FUNC_STATUS_ERROR __BT_FUNC_STATUS_ERROR +#define BT_FUNC_STATUS_OK __BT_FUNC_STATUS_OK +#define BT_FUNC_STATUS_END __BT_FUNC_STATUS_END +#define BT_FUNC_STATUS_NOT_FOUND __BT_FUNC_STATUS_NOT_FOUND +#define BT_FUNC_STATUS_AGAIN __BT_FUNC_STATUS_AGAIN +#define BT_FUNC_STATUS_UNSUPPORTED __BT_FUNC_STATUS_UNSUPPORTED +#define BT_FUNC_STATUS_CANCELED __BT_FUNC_STATUS_CANCELED + +#include + +#endif /* BABELTRACE_FUNC_STATUS_INTERNAL_H */ diff --git a/src/lib/graph/component-class-sink-colander.c b/src/lib/graph/component-class-sink-colander.c index 8a238f81..b68a3ab0 100644 --- a/src/lib/graph/component-class-sink-colander.c +++ b/src/lib/graph/component-class-sink-colander.c @@ -34,16 +34,18 @@ #include #include "component-class-sink-colander.h" +#include "lib/func-status.h" static struct bt_component_class_sink *colander_comp_cls; static -enum bt_self_component_status colander_init( +enum bt_component_class_init_method_status colander_init( struct bt_self_component_sink *self_comp, const struct bt_value *params, void *init_method_data) { - enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + enum bt_component_class_init_method_status status = + BT_FUNC_STATUS_OK; struct bt_component_class_sink_colander_priv_data *colander_data = NULL; struct bt_component_class_sink_colander_data *user_provided_data = init_method_data; @@ -53,7 +55,7 @@ enum bt_self_component_status colander_init( struct bt_component_class_sink_colander_priv_data, 1); if (!colander_data) { BT_LOGE_STR("Failed to allocate colander data."); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -61,7 +63,7 @@ enum bt_self_component_status colander_init( colander_data->count_addr = user_provided_data->count_addr; status = bt_self_component_sink_add_input_port(self_comp, "in", NULL, NULL); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { BT_LOGE_STR("Cannot add input port."); goto end; } @@ -90,10 +92,12 @@ void colander_finalize(struct bt_self_component_sink *self_comp) } static -enum bt_self_component_status colander_graph_is_configured( +enum bt_component_class_sink_graph_is_configured_method_status +colander_graph_is_configured( bt_self_component_sink *self_comp) { - enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + enum bt_component_class_sink_graph_is_configured_method_status status = + BT_FUNC_STATUS_OK; struct bt_component_class_sink_colander_priv_data *colander_data = bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); @@ -111,7 +115,7 @@ enum bt_self_component_status colander_graph_is_configured( BT_LIB_LOGE("Cannot create message iterator on " "self component input port: %![port-]+p", self_port); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -120,11 +124,12 @@ end: } static -enum bt_self_component_status colander_consume( +enum bt_component_class_sink_consume_method_status colander_consume( struct bt_self_component_sink *self_comp) { - enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; - enum bt_message_iterator_status msg_iter_status; + enum bt_component_class_sink_consume_method_status status = + BT_FUNC_STATUS_OK; + enum bt_message_iterator_next_status next_status; struct bt_component_class_sink_colander_priv_data *colander_data = bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); @@ -132,24 +137,23 @@ enum bt_self_component_status colander_consume( BT_ASSERT(colander_data); BT_ASSERT(colander_data->msg_iter); - msg_iter_status = - bt_self_component_port_input_message_iterator_next( - colander_data->msg_iter, &msgs, - colander_data->count_addr); - switch (msg_iter_status) { - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - status = BT_SELF_COMPONENT_STATUS_AGAIN; + next_status = bt_self_component_port_input_message_iterator_next( + colander_data->msg_iter, &msgs, + colander_data->count_addr); + switch (next_status) { + case BT_FUNC_STATUS_AGAIN: + status = BT_FUNC_STATUS_AGAIN; goto end; - case BT_MESSAGE_ITERATOR_STATUS_END: - status = BT_SELF_COMPONENT_STATUS_END; + case BT_FUNC_STATUS_END: + status = BT_FUNC_STATUS_END; goto end; - case BT_MESSAGE_ITERATOR_STATUS_OK: + case BT_FUNC_STATUS_OK: /* Move messages to user (count already set) */ memcpy(colander_data->msgs, msgs, sizeof(*msgs) * *colander_data->count_addr); break; default: - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } diff --git a/src/lib/graph/component-class.c b/src/lib/graph/component-class.c index 95c9b021..9d7e17b5 100644 --- a/src/lib/graph/component-class.c +++ b/src/lib/graph/component-class.c @@ -39,6 +39,7 @@ #include #include "component-class.h" +#include "lib/func-status.h" #define BT_ASSERT_PRE_COMP_CLS_HOT(_cc) \ BT_ASSERT_PRE_HOT(((const struct bt_component_class *) (_cc)), \ @@ -246,7 +247,7 @@ end: return (void *) sink_class; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_source_set_init_method( struct bt_component_class_source *comp_cls, bt_component_class_source_init_method method) @@ -257,10 +258,10 @@ bt_component_class_source_set_init_method( comp_cls->methods.init = method; BT_LIB_LOGD("Set source component class's initialization method: " "%!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_init_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_init_method method) @@ -271,10 +272,10 @@ bt_component_class_filter_set_init_method( comp_cls->methods.init = method; BT_LIB_LOGD("Set filter component class's initialization method: " "%!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_sink_set_init_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_init_method method) @@ -285,10 +286,10 @@ bt_component_class_sink_set_init_method( comp_cls->methods.init = method; BT_LIB_LOGD("Set sink component class's initialization method: " "%!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_source_set_finalize_method( struct bt_component_class_source *comp_cls, bt_component_class_source_finalize_method method) @@ -299,10 +300,10 @@ bt_component_class_source_set_finalize_method( comp_cls->methods.finalize = method; BT_LIB_LOGD("Set source component class's finalization method: " "%!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_finalize_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_finalize_method method) @@ -313,10 +314,10 @@ bt_component_class_filter_set_finalize_method( comp_cls->methods.finalize = method; BT_LIB_LOGD("Set filter component class's finalization method: " "%!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_sink_set_finalize_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_finalize_method method) @@ -327,10 +328,10 @@ bt_component_class_sink_set_finalize_method( comp_cls->methods.finalize = method; BT_LIB_LOGD("Set sink component class's finalization method: " "%!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_source_set_query_method( struct bt_component_class_source *comp_cls, bt_component_class_source_query_method method) @@ -341,10 +342,10 @@ bt_component_class_source_set_query_method( comp_cls->methods.query = method; BT_LIB_LOGD("Set source component class's query method: " "%!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_query_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_query_method method) @@ -355,10 +356,10 @@ bt_component_class_filter_set_query_method( comp_cls->methods.query = method; BT_LIB_LOGD("Set filter component class's query method: " "%!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_sink_set_query_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_query_method method) @@ -369,10 +370,10 @@ bt_component_class_sink_set_query_method( comp_cls->methods.query = method; BT_LIB_LOGD("Set sink component class's query method: " "%!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_input_port_connected_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_input_port_connected_method method) @@ -383,10 +384,10 @@ bt_component_class_filter_set_input_port_connected_method( comp_cls->methods.input_port_connected = method; BT_LIB_LOGD("Set filter component class's \"input port connected\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_sink_set_input_port_connected_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_input_port_connected_method method) @@ -397,10 +398,10 @@ bt_component_class_sink_set_input_port_connected_method( comp_cls->methods.input_port_connected = method; BT_LIB_LOGD("Set sink component class's \"input port connected\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_source_set_output_port_connected_method( struct bt_component_class_source *comp_cls, bt_component_class_source_output_port_connected_method method) @@ -411,10 +412,10 @@ bt_component_class_source_set_output_port_connected_method( comp_cls->methods.output_port_connected = method; BT_LIB_LOGD("Set source component class's \"output port connected\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_output_port_connected_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_output_port_connected_method method) @@ -425,10 +426,10 @@ bt_component_class_filter_set_output_port_connected_method( comp_cls->methods.output_port_connected = method; BT_LIB_LOGD("Set filter component class's \"output port connected\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_sink_set_graph_is_configured_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_graph_is_configured_method method) @@ -439,10 +440,11 @@ bt_component_class_sink_set_graph_is_configured_method( comp_cls->methods.graph_is_configured = method; BT_LIB_LOGD("Set sink component class's \"graph is configured\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -int bt_component_class_source_set_message_iterator_init_method( +enum bt_component_class_set_method_status +bt_component_class_source_set_message_iterator_init_method( struct bt_component_class_source *comp_cls, bt_component_class_source_message_iterator_init_method method) { @@ -452,10 +454,10 @@ int bt_component_class_source_set_message_iterator_init_method( comp_cls->methods.msg_iter_init = method; BT_LIB_LOGD("Set source component class's message iterator initialization method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_init_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_message_iterator_init_method method) @@ -466,10 +468,10 @@ bt_component_class_filter_set_message_iterator_init_method( comp_cls->methods.msg_iter_init = method; BT_LIB_LOGD("Set filter component class's message iterator initialization method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_source_set_message_iterator_finalize_method( struct bt_component_class_source *comp_cls, bt_component_class_source_message_iterator_finalize_method method) @@ -480,10 +482,10 @@ bt_component_class_source_set_message_iterator_finalize_method( comp_cls->methods.msg_iter_finalize = method; BT_LIB_LOGD("Set source component class's message iterator finalization method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_finalize_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_message_iterator_finalize_method method) @@ -494,10 +496,10 @@ bt_component_class_filter_set_message_iterator_finalize_method( comp_cls->methods.msg_iter_finalize = method; BT_LIB_LOGD("Set filter component class's message iterator finalization method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_message_iterator_seek_ns_from_origin_method method) @@ -508,10 +510,10 @@ bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method( comp_cls->methods.msg_iter_seek_ns_from_origin = method; BT_LIB_LOGD("Set filter component class's message iterator \"seek nanoseconds from origin\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_source_set_message_iterator_seek_ns_from_origin_method( struct bt_component_class_source *comp_cls, bt_component_class_source_message_iterator_seek_ns_from_origin_method method) @@ -522,10 +524,10 @@ bt_component_class_source_set_message_iterator_seek_ns_from_origin_method( comp_cls->methods.msg_iter_seek_ns_from_origin = method; BT_LIB_LOGD("Set source component class's message iterator \"seek nanoseconds from origin\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_seek_beginning_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_message_iterator_seek_beginning_method method) @@ -536,10 +538,10 @@ bt_component_class_filter_set_message_iterator_seek_beginning_method( comp_cls->methods.msg_iter_seek_beginning = method; BT_LIB_LOGD("Set filter component class's message iterator \"seek beginning\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_source_set_message_iterator_seek_beginning_method( struct bt_component_class_source *comp_cls, bt_component_class_source_message_iterator_seek_beginning_method method) @@ -550,10 +552,10 @@ bt_component_class_source_set_message_iterator_seek_beginning_method( comp_cls->methods.msg_iter_seek_beginning = method; BT_LIB_LOGD("Set source component class's message iterator \"seek beginning\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_can_seek_beginning_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_message_iterator_can_seek_beginning_method method) @@ -564,10 +566,10 @@ bt_component_class_filter_set_message_iterator_can_seek_beginning_method( comp_cls->methods.msg_iter_can_seek_beginning = method; BT_LIB_LOGD("Set filter component class's message iterator \"can seek beginning\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_source_set_message_iterator_can_seek_beginning_method( struct bt_component_class_source *comp_cls, bt_component_class_source_message_iterator_can_seek_beginning_method method) @@ -578,10 +580,10 @@ bt_component_class_source_set_message_iterator_can_seek_beginning_method( comp_cls->methods.msg_iter_can_seek_beginning = method; BT_LIB_LOGD("Set source component class's message iterator \"can seek beginning\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method method) @@ -592,10 +594,10 @@ bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method( comp_cls->methods.msg_iter_can_seek_ns_from_origin = method; BT_LIB_LOGD("Set filter component class's message iterator \"can seek nanoseconds from origin\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_component_class_status +enum bt_component_class_set_method_status bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method( struct bt_component_class_source *comp_cls, bt_component_class_source_message_iterator_can_seek_ns_from_origin_method method) @@ -606,10 +608,11 @@ bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method( comp_cls->methods.msg_iter_can_seek_ns_from_origin = method; BT_LIB_LOGD("Set source component class's message iterator \"can seek nanoseconds from origin\" method" ": %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -bt_component_class_status bt_component_class_set_description( +enum bt_component_class_set_description_status +bt_component_class_set_description( struct bt_component_class *comp_cls, const char *description) { @@ -622,10 +625,10 @@ bt_component_class_status bt_component_class_set_description( comp_cls, bt_component_class_get_name(comp_cls), bt_component_class_type_string(comp_cls->type)); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -bt_component_class_status bt_component_class_set_help( +enum bt_component_class_set_help_status bt_component_class_set_help( struct bt_component_class *comp_cls, const char *help) { @@ -634,7 +637,7 @@ bt_component_class_status bt_component_class_set_help( BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); g_string_assign(comp_cls->help, help); BT_LIB_LOGD("Set component class's help text: %!+C", comp_cls); - return BT_COMPONENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } const char *bt_component_class_get_name(const struct bt_component_class *comp_cls) diff --git a/src/lib/graph/component-filter.c b/src/lib/graph/component-filter.c index a39e7e5a..5efff1ab 100644 --- a/src/lib/graph/component-filter.c +++ b/src/lib/graph/component-filter.c @@ -35,6 +35,7 @@ #include "component-filter.h" #include "component.h" #include "component-class.h" +#include "lib/func-status.h" BT_HIDDEN void bt_component_filter_destroy(struct bt_component *component) @@ -111,18 +112,18 @@ bt_self_component_filter_borrow_output_port_by_index( (void *) comp, index); } -enum bt_self_component_status bt_self_component_filter_add_output_port( +enum bt_self_component_add_port_status bt_self_component_filter_add_output_port( struct bt_self_component_filter *self_comp, const char *name, void *user_data, struct bt_self_component_port_output **self_port) { struct bt_component *comp = (void *) self_comp; - enum bt_self_component_status status; + enum bt_self_component_add_port_status status; struct bt_port *port = NULL; /* bt_component_add_output_port() logs details and errors */ status = bt_component_add_output_port(comp, name, user_data, &port); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { goto end; } @@ -179,18 +180,18 @@ bt_self_component_filter_borrow_input_port_by_index( (void *) component, index); } -enum bt_self_component_status bt_self_component_filter_add_input_port( +enum bt_self_component_add_port_status bt_self_component_filter_add_input_port( struct bt_self_component_filter *self_comp, const char *name, void *user_data, struct bt_self_component_port_input **self_port) { - enum bt_self_component_status status; + enum bt_self_component_add_port_status status; struct bt_port *port = NULL; struct bt_component *comp = (void *) self_comp; /* bt_component_add_input_port() logs details/errors */ status = bt_component_add_input_port(comp, name, user_data, &port); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { goto end; } diff --git a/src/lib/graph/component-sink.c b/src/lib/graph/component-sink.c index fe25db6e..669e15df 100644 --- a/src/lib/graph/component-sink.c +++ b/src/lib/graph/component-sink.c @@ -34,6 +34,7 @@ #include "component-sink.h" #include "component.h" +#include "lib/func-status.h" BT_HIDDEN void bt_component_sink_destroy(struct bt_component *component) @@ -113,18 +114,18 @@ bt_self_component_sink_borrow_input_port_by_index( (void *) component, index); } -enum bt_self_component_status bt_self_component_sink_add_input_port( +enum bt_self_component_add_port_status bt_self_component_sink_add_input_port( struct bt_self_component_sink *self_comp, const char *name, void *user_data, struct bt_self_component_port_input **self_port) { - enum bt_self_component_status status; + enum bt_self_component_add_port_status status; struct bt_port *port = NULL; struct bt_component *comp = (void *) self_comp; /* bt_component_add_input_port() logs details/errors */ status = bt_component_add_input_port(comp, name, user_data, &port); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { goto end; } diff --git a/src/lib/graph/component-source.c b/src/lib/graph/component-source.c index 53d8b6d4..e62c5bd1 100644 --- a/src/lib/graph/component-source.c +++ b/src/lib/graph/component-source.c @@ -29,13 +29,13 @@ #include "compat/compiler.h" #include #include -#include #include #include "component-source.h" #include "component.h" #include "port.h" #include "message/iterator.h" +#include "lib/func-status.h" BT_HIDDEN void bt_component_source_destroy(struct bt_component *component) @@ -110,18 +110,18 @@ bt_self_component_source_borrow_output_port_by_index( (void *) comp, index); } -enum bt_self_component_status bt_self_component_source_add_output_port( +enum bt_self_component_add_port_status bt_self_component_source_add_output_port( struct bt_self_component_source *self_comp, const char *name, void *user_data, struct bt_self_component_port_output **self_port) { struct bt_component *comp = (void *) self_comp; - enum bt_self_component_status status; + enum bt_self_component_add_port_status status; struct bt_port *port = NULL; /* bt_component_add_output_port() logs details and errors */ status = bt_component_add_output_port(comp, name, user_data, &port); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { goto end; } diff --git a/src/lib/graph/component.c b/src/lib/graph/component.c index 90129b07..825d8963 100644 --- a/src/lib/graph/component.c +++ b/src/lib/graph/component.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "common/macros.h" #include "compat/compiler.h" #include @@ -50,6 +51,7 @@ #include "graph.h" #include "message/iterator.h" #include "port.h" +#include "lib/func-status.h" static struct bt_component * (* const component_create_funcs[])( @@ -193,14 +195,14 @@ enum bt_component_class_type bt_component_get_class_type( } static -enum bt_self_component_status add_port( +enum bt_self_component_add_port_status add_port( struct bt_component *component, GPtrArray *ports, enum bt_port_type port_type, const char *name, void *user_data, struct bt_port **port) { struct bt_port *new_port = NULL; struct bt_graph *graph = NULL; - enum bt_self_component_status status; + enum bt_self_component_add_port_status status; BT_ASSERT_PRE_NON_NULL(component, "Component"); BT_ASSERT_PRE_NON_NULL(name, "Name"); @@ -223,7 +225,7 @@ enum bt_self_component_status add_port( new_port = bt_port_create(component, port_type, name, user_data); if (!new_port) { BT_LOGE_STR("Cannot create port object."); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto error; } @@ -240,12 +242,12 @@ enum bt_self_component_status add_port( */ graph = bt_component_borrow_graph(component); if (graph) { - enum bt_graph_listener_status listener_status; + enum bt_graph_listener_func_status listener_status; listener_status = bt_graph_notify_port_added(graph, new_port); - if (listener_status != BT_GRAPH_LISTENER_STATUS_OK) { + if (listener_status != BT_FUNC_STATUS_OK) { bt_graph_make_faulty(graph); - status = listener_status; + status = (int) listener_status; goto error; } } @@ -254,7 +256,7 @@ enum bt_self_component_status add_port( "%![comp-]+c, %![port-]+p", component, new_port); *port = new_port; - status = BT_SELF_COMPONENT_STATUS_OK; + status = BT_FUNC_STATUS_OK; goto end; error: @@ -461,7 +463,7 @@ struct bt_port_output *bt_component_borrow_output_port_by_index( } BT_HIDDEN -enum bt_self_component_status bt_component_add_input_port( +enum bt_self_component_add_port_status bt_component_add_input_port( struct bt_component *component, const char *name, void *user_data, struct bt_port **port) { @@ -471,7 +473,7 @@ enum bt_self_component_status bt_component_add_input_port( } BT_HIDDEN -enum bt_self_component_status bt_component_add_output_port( +enum bt_self_component_add_port_status bt_component_add_output_port( struct bt_component *component, const char *name, void *user_data, struct bt_port **port) { @@ -481,14 +483,16 @@ enum bt_self_component_status bt_component_add_output_port( } BT_HIDDEN -enum bt_self_component_status bt_component_port_connected( +enum bt_component_class_port_connected_method_status +bt_component_port_connected( struct bt_component *comp, struct bt_port *self_port, struct bt_port *other_port) { - typedef enum bt_self_component_status (*method_t)( + typedef enum bt_component_class_port_connected_method_status (*method_t)( void *, void *, const void *); - enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + enum bt_self_component_add_port_status status = + BT_FUNC_STATUS_OK; method_t method = NULL; BT_ASSERT(comp); @@ -549,14 +553,14 @@ enum bt_self_component_status bt_component_port_connected( BT_LIB_LOGD("Calling user's \"port connected\" method: " "%![comp-]+c, %![self-port-]+p, %![other-port-]+p", comp, self_port, other_port); - status = method(comp, self_port, (void *) other_port); + status = (int) method(comp, self_port, (void *) other_port); BT_LOGD("User method returned: status=%s", - bt_self_component_status_string(status)); - BT_ASSERT_POST(status == BT_SELF_COMPONENT_STATUS_OK || - status == BT_SELF_COMPONENT_STATUS_ERROR || - status == BT_SELF_COMPONENT_STATUS_NOMEM, + bt_common_func_status_string(status)); + BT_ASSERT_POST(status == BT_FUNC_STATUS_OK || + status == BT_FUNC_STATUS_ERROR || + status == BT_FUNC_STATUS_MEMORY_ERROR, "Unexpected returned component status: status=%s", - bt_self_component_status_string(status)); + bt_common_func_status_string(status)); } return status; diff --git a/src/lib/graph/component.h b/src/lib/graph/component.h index 169d1a46..c993ce69 100644 --- a/src/lib/graph/component.h +++ b/src/lib/graph/component.h @@ -26,6 +26,7 @@ #include "common/macros.h" #include +#include #include "lib/object.h" #include #include @@ -84,7 +85,8 @@ int bt_component_create(struct bt_component_class *component_class, struct bt_component **component); BT_HIDDEN -enum bt_self_component_status bt_component_port_connected( +enum bt_component_class_port_connected_method_status +bt_component_port_connected( struct bt_component *comp, struct bt_port *self_port, struct bt_port *other_port); @@ -115,12 +117,12 @@ struct bt_port_output *bt_component_borrow_output_port_by_name( struct bt_component *comp, const char *name); BT_HIDDEN -enum bt_self_component_status bt_component_add_input_port( +enum bt_self_component_add_port_status bt_component_add_input_port( struct bt_component *component, const char *name, void *user_data, struct bt_port **port); BT_HIDDEN -enum bt_self_component_status bt_component_add_output_port( +enum bt_self_component_add_port_status bt_component_add_output_port( struct bt_component *component, const char *name, void *user_data, struct bt_port **port); diff --git a/src/lib/graph/connection.h b/src/lib/graph/connection.h index f54cf240..530dfd9f 100644 --- a/src/lib/graph/connection.h +++ b/src/lib/graph/connection.h @@ -25,7 +25,6 @@ */ #include -#include #include "lib/object.h" #include "common/assert.h" #include "common/macros.h" diff --git a/src/lib/graph/graph.c b/src/lib/graph/graph.c index 62175cf9..deb7a115 100644 --- a/src/lib/graph/graph.c +++ b/src/lib/graph/graph.c @@ -49,15 +49,16 @@ #include "message/event.h" #include "message/packet.h" -typedef enum bt_graph_listener_status (*port_added_func_t)( - const void *, const void *, void *); +typedef enum bt_graph_listener_func_status +(*port_added_func_t)(const void *, const void *, void *); -typedef enum bt_graph_listener_status (*ports_connected_func_t)( - const void *, const void *, const void *, const void *, void *); - -typedef enum bt_self_component_status (*comp_init_method_t)(const void *, +typedef enum bt_graph_listener_func_status +(*ports_connected_func_t)(const void *, const void *, const void *, const void *, void *); +typedef enum bt_component_class_init_method_status +(*comp_init_method_t)(const void *, const void *, void *); + struct bt_graph_listener { bt_graph_listener_removed_func removed; void *data; @@ -393,20 +394,20 @@ error: goto end; } -enum bt_graph_status bt_graph_connect_ports( +enum bt_graph_connect_ports_status bt_graph_connect_ports( struct bt_graph *graph, const struct bt_port_output *upstream_port_out, const struct bt_port_input *downstream_port_in, const struct bt_connection **user_connection) { - enum bt_graph_status status = BT_GRAPH_STATUS_OK; - enum bt_graph_listener_status listener_status; + enum bt_graph_connect_ports_status status = BT_FUNC_STATUS_OK; + enum bt_graph_listener_func_status listener_status; struct bt_connection *connection = NULL; struct bt_port *upstream_port = (void *) upstream_port_out; struct bt_port *downstream_port = (void *) downstream_port_in; struct bt_component *upstream_component = NULL; struct bt_component *downstream_component = NULL; - enum bt_self_component_status component_status; + enum bt_component_class_port_connected_method_status port_connected_status; bool init_can_consume; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); @@ -441,7 +442,7 @@ enum bt_graph_status bt_graph_connect_ports( (void *) downstream_port); if (!connection) { BT_LOGW("Cannot create connection object."); - status = BT_GRAPH_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -458,17 +459,17 @@ enum bt_graph_status bt_graph_connect_ports( */ BT_LIB_LOGD("Notifying upstream component that its port is connected: " "%![comp-]+c, %![port-]+p", upstream_component, upstream_port); - component_status = bt_component_port_connected(upstream_component, + port_connected_status = bt_component_port_connected(upstream_component, (void *) upstream_port, (void *) downstream_port); - if (component_status != BT_SELF_COMPONENT_STATUS_OK) { + if (port_connected_status != BT_FUNC_STATUS_OK) { BT_LIB_LOGW("Error while notifying upstream component that its port is connected: " "status=%s, %![graph-]+g, %![up-comp-]+c, " "%![down-comp-]+c, %![up-port-]+p, %![down-port-]+p", - bt_self_component_status_string(component_status), + bt_common_func_status_string(port_connected_status), graph, upstream_component, downstream_component, upstream_port, downstream_port); bt_connection_end(connection, true); - status = (int) component_status; + status = (int) port_connected_status; goto end; } @@ -476,17 +477,17 @@ enum bt_graph_status bt_graph_connect_ports( BT_LIB_LOGD("Notifying downstream component that its port is connected: " "%![comp-]+c, %![port-]+p", downstream_component, downstream_port); - component_status = bt_component_port_connected(downstream_component, + port_connected_status = bt_component_port_connected(downstream_component, (void *) downstream_port, (void *) upstream_port); - if (component_status != BT_SELF_COMPONENT_STATUS_OK) { + if (port_connected_status != BT_FUNC_STATUS_OK) { BT_LIB_LOGW("Error while notifying downstream component that its port is connected: " "status=%s, %![graph-]+g, %![up-comp-]+c, " "%![down-comp-]+c, %![up-port-]+p, %![down-port-]+p", - bt_self_component_status_string(component_status), + bt_common_func_status_string(port_connected_status), graph, upstream_component, downstream_component, upstream_port, downstream_port); bt_connection_end(connection, true); - status = (int) component_status; + status = (int) port_connected_status; goto end; } @@ -497,7 +498,7 @@ enum bt_graph_status bt_graph_connect_ports( */ BT_LOGD_STR("Notifying graph's user that new component ports are connected."); listener_status = bt_graph_notify_ports_connected(graph, upstream_port, downstream_port); - if (listener_status != BT_GRAPH_LISTENER_STATUS_OK) { + if (listener_status != BT_FUNC_STATUS_OK) { status = (int) listener_status; goto end; } @@ -516,7 +517,7 @@ enum bt_graph_status bt_graph_connect_ports( } end: - if (status != BT_GRAPH_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { bt_graph_make_faulty(graph); } @@ -527,35 +528,35 @@ end: } static inline -enum bt_graph_status consume_graph_sink(struct bt_component_sink *comp) +int consume_graph_sink(struct bt_component_sink *comp) { - enum bt_self_component_status comp_status; + enum bt_component_class_sink_consume_method_status consume_status; struct bt_component_class_sink *sink_class = NULL; BT_ASSERT(comp); sink_class = (void *) comp->parent.class; BT_ASSERT(sink_class->methods.consume); BT_LIB_LOGD("Calling user's consume method: %!+c", comp); - comp_status = sink_class->methods.consume((void *) comp); + consume_status = sink_class->methods.consume((void *) comp); BT_LOGD("User method returned: status=%s", - bt_self_component_status_string(comp_status)); - BT_ASSERT_POST(comp_status == BT_SELF_COMPONENT_STATUS_OK || - comp_status == BT_SELF_COMPONENT_STATUS_END || - comp_status == BT_SELF_COMPONENT_STATUS_AGAIN || - comp_status == BT_SELF_COMPONENT_STATUS_ERROR || - comp_status == BT_SELF_COMPONENT_STATUS_NOMEM, + bt_common_func_status_string(consume_status)); + BT_ASSERT_POST(consume_status == BT_FUNC_STATUS_OK || + consume_status == BT_FUNC_STATUS_END || + consume_status == BT_FUNC_STATUS_AGAIN || + consume_status == BT_FUNC_STATUS_ERROR || + consume_status == BT_FUNC_STATUS_MEMORY_ERROR, "Invalid component status returned by consuming method: " - "status=%s", bt_self_component_status_string(comp_status)); - if (comp_status < 0) { + "status=%s", bt_common_func_status_string(consume_status)); + if (consume_status < 0) { BT_LOGW_STR("Consume method failed."); goto end; } BT_LIB_LOGD("Consumed from sink: %![comp-]+c, status=%s", - comp, bt_self_component_status_string(comp_status)); + comp, bt_common_func_status_string(consume_status)); end: - return (int) comp_status; + return consume_status; } /* @@ -564,14 +565,14 @@ end: * still something to consume afterwards. */ static inline -enum bt_graph_status consume_sink_node(struct bt_graph *graph, GList *node) +int consume_sink_node(struct bt_graph *graph, GList *node) { - enum bt_graph_status status; + int status; struct bt_component_sink *sink; sink = node->data; status = consume_graph_sink(sink); - if (G_UNLIKELY(status != BT_GRAPH_STATUS_END)) { + if (G_UNLIKELY(status != BT_FUNC_STATUS_END)) { g_queue_push_tail_link(graph->sinks_to_consume, node); goto end; } @@ -581,21 +582,21 @@ enum bt_graph_status consume_sink_node(struct bt_graph *graph, GList *node) /* Don't forward an END status if there are sinks left to consume. */ if (!g_queue_is_empty(graph->sinks_to_consume)) { - status = BT_GRAPH_STATUS_OK; + status = BT_FUNC_STATUS_OK; goto end; } end: BT_LIB_LOGD("Consumed sink node: %![comp-]+c, status=%s", - sink, bt_graph_status_string(status)); + sink, bt_common_func_status_string(status)); return status; } BT_HIDDEN -enum bt_graph_status bt_graph_consume_sink_no_check(struct bt_graph *graph, +int bt_graph_consume_sink_no_check(struct bt_graph *graph, struct bt_component_sink *sink) { - enum bt_graph_status status; + int status; GList *sink_node; int index; @@ -604,7 +605,7 @@ enum bt_graph_status bt_graph_consume_sink_no_check(struct bt_graph *graph, if (g_queue_is_empty(graph->sinks_to_consume)) { BT_LOGD_STR("Graph's sink queue is empty: end of graph."); - status = BT_GRAPH_STATUS_END; + status = BT_FUNC_STATUS_END; goto end; } @@ -612,7 +613,7 @@ enum bt_graph_status bt_graph_consume_sink_no_check(struct bt_graph *graph, if (index < 0) { BT_LIB_LOGD("Sink component is not marked as consumable: " "component sink is ended: %![comp-]+c", sink); - status = BT_GRAPH_STATUS_END; + status = BT_FUNC_STATUS_END; goto end; } @@ -625,9 +626,9 @@ end: } static inline -enum bt_graph_status consume_no_check(struct bt_graph *graph) +int consume_no_check(struct bt_graph *graph) { - enum bt_graph_status status = BT_GRAPH_STATUS_OK; + int status = BT_FUNC_STATUS_OK; struct bt_component *sink; GList *current_node; @@ -637,7 +638,7 @@ enum bt_graph_status consume_no_check(struct bt_graph *graph) if (G_UNLIKELY(g_queue_is_empty(graph->sinks_to_consume))) { BT_LOGD_STR("Graph's sink queue is empty: end of graph."); - status = BT_GRAPH_STATUS_END; + status = BT_FUNC_STATUS_END; goto end; } @@ -650,9 +651,9 @@ end: return status; } -enum bt_graph_status bt_graph_consume(struct bt_graph *graph) +enum bt_graph_consume_status bt_graph_consume(struct bt_graph *graph) { - enum bt_graph_status status; + enum bt_graph_consume_status status; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph); @@ -674,9 +675,9 @@ end: return status; } -enum bt_graph_status bt_graph_run(struct bt_graph *graph) +enum bt_graph_run_status bt_graph_run(struct bt_graph *graph) { - enum bt_graph_status status; + enum bt_graph_run_status status; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph); @@ -703,12 +704,12 @@ enum bt_graph_status bt_graph_run(struct bt_graph *graph) if (G_UNLIKELY(graph->canceled)) { BT_LIB_LOGI("Stopping the graph: graph is canceled: " "%!+g", graph); - status = BT_GRAPH_STATUS_CANCELED; + status = BT_FUNC_STATUS_CANCELED; goto end; } status = consume_no_check(graph); - if (G_UNLIKELY(status == BT_GRAPH_STATUS_AGAIN)) { + if (G_UNLIKELY(status == BT_FUNC_STATUS_AGAIN)) { /* * If AGAIN is received and there are multiple * sinks, go ahead and consume from the next @@ -721,23 +722,23 @@ enum bt_graph_status bt_graph_run(struct bt_graph *graph) * sleep for an arbitrary amount of time. */ if (graph->sinks_to_consume->length > 1) { - status = BT_GRAPH_STATUS_OK; + status = BT_FUNC_STATUS_OK; } } - } while (status == BT_GRAPH_STATUS_OK); + } while (status == BT_FUNC_STATUS_OK); if (g_queue_is_empty(graph->sinks_to_consume)) { - status = BT_GRAPH_STATUS_END; + status = BT_FUNC_STATUS_END; } end: BT_LIB_LOGI("Graph ran: %![graph-]+g, status=%s", graph, - bt_graph_status_string(status)); + bt_common_func_status_string(status)); bt_graph_set_can_consume(graph, true); return status; } -enum bt_graph_status +enum bt_graph_add_listener_status bt_graph_add_source_component_output_port_added_listener( struct bt_graph *graph, bt_graph_source_component_output_port_added_listener_func func, @@ -769,10 +770,10 @@ bt_graph_add_source_component_output_port_added_listener( *out_listener_id = listener_id; } - return BT_GRAPH_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_graph_status +enum bt_graph_add_listener_status bt_graph_add_filter_component_output_port_added_listener( struct bt_graph *graph, bt_graph_filter_component_output_port_added_listener_func func, @@ -804,10 +805,10 @@ bt_graph_add_filter_component_output_port_added_listener( *out_listener_id = listener_id; } - return BT_GRAPH_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_graph_status +enum bt_graph_add_listener_status bt_graph_add_filter_component_input_port_added_listener( struct bt_graph *graph, bt_graph_filter_component_input_port_added_listener_func func, @@ -839,10 +840,10 @@ bt_graph_add_filter_component_input_port_added_listener( *out_listener_id = listener_id; } - return BT_GRAPH_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_graph_status +enum bt_graph_add_listener_status bt_graph_add_sink_component_input_port_added_listener( struct bt_graph *graph, bt_graph_sink_component_input_port_added_listener_func func, @@ -874,10 +875,10 @@ bt_graph_add_sink_component_input_port_added_listener( *out_listener_id = listener_id; } - return BT_GRAPH_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_graph_status +enum bt_graph_add_listener_status bt_graph_add_source_filter_component_ports_connected_listener( struct bt_graph *graph, bt_graph_source_filter_component_ports_connected_listener_func func, @@ -910,10 +911,10 @@ bt_graph_add_source_filter_component_ports_connected_listener( *out_listener_id = listener_id; } - return BT_GRAPH_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_graph_status +enum bt_graph_add_listener_status bt_graph_add_source_sink_component_ports_connected_listener( struct bt_graph *graph, bt_graph_source_sink_component_ports_connected_listener_func func, @@ -946,10 +947,10 @@ bt_graph_add_source_sink_component_ports_connected_listener( *out_listener_id = listener_id; } - return BT_GRAPH_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_graph_status +enum bt_graph_add_listener_status bt_graph_add_filter_filter_component_ports_connected_listener( struct bt_graph *graph, bt_graph_filter_filter_component_ports_connected_listener_func func, @@ -982,10 +983,10 @@ bt_graph_add_filter_filter_component_ports_connected_listener( *out_listener_id = listener_id; } - return BT_GRAPH_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_graph_status +enum bt_graph_add_listener_status bt_graph_add_filter_sink_component_ports_connected_listener( struct bt_graph *graph, bt_graph_filter_sink_component_ports_connected_listener_func func, @@ -1018,17 +1019,17 @@ bt_graph_add_filter_sink_component_ports_connected_listener( *out_listener_id = listener_id; } - return BT_GRAPH_STATUS_OK; + return BT_FUNC_STATUS_OK; } BT_HIDDEN -enum bt_graph_listener_status bt_graph_notify_port_added( +enum bt_graph_listener_func_status bt_graph_notify_port_added( struct bt_graph *graph, struct bt_port *port) { uint64_t i; GArray *listeners; struct bt_component *comp; - enum bt_graph_listener_status status = BT_GRAPH_LISTENER_STATUS_OK; + enum bt_graph_listener_func_status status = BT_FUNC_STATUS_OK; BT_ASSERT(graph); BT_ASSERT(port); @@ -1089,7 +1090,7 @@ enum bt_graph_listener_status bt_graph_notify_port_added( BT_ASSERT(listener->func); status = listener->func(comp, port, listener->base.data); - if (status != BT_GRAPH_LISTENER_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { goto end; } } @@ -1099,7 +1100,7 @@ end: } BT_HIDDEN -enum bt_graph_listener_status bt_graph_notify_ports_connected( +enum bt_graph_listener_func_status bt_graph_notify_ports_connected( struct bt_graph *graph, struct bt_port *upstream_port, struct bt_port *downstream_port) { @@ -1107,7 +1108,7 @@ enum bt_graph_listener_status bt_graph_notify_ports_connected( GArray *listeners; struct bt_component *upstream_comp; struct bt_component *downstream_comp; - enum bt_graph_listener_status status = BT_GRAPH_LISTENER_STATUS_OK; + enum bt_graph_listener_func_status status = BT_FUNC_STATUS_OK; BT_ASSERT(graph); BT_ASSERT(upstream_port); @@ -1167,7 +1168,7 @@ enum bt_graph_listener_status bt_graph_notify_ports_connected( BT_ASSERT(listener->func); status = listener->func(upstream_comp, downstream_comp, upstream_port, downstream_port, listener->base.data); - if (status != BT_GRAPH_LISTENER_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { goto end; } } @@ -1176,13 +1177,12 @@ end: return status; } -enum bt_graph_status bt_graph_cancel(struct bt_graph *graph) +enum bt_graph_cancel_status bt_graph_cancel(struct bt_graph *graph) { - BT_ASSERT_PRE_NON_NULL(graph, "Graph"); graph->canceled = true; BT_LIB_LOGI("Canceled graph: %!+i", graph); - return BT_GRAPH_STATUS_OK; + return BT_FUNC_STATUS_OK; } bt_bool bt_graph_is_canceled(const struct bt_graph *graph) @@ -1226,7 +1226,7 @@ end: } static -enum bt_graph_status add_component_with_init_method_data( +int add_component_with_init_method_data( struct bt_graph *graph, struct bt_component_class *comp_cls, comp_init_method_t init_method, @@ -1234,8 +1234,8 @@ enum bt_graph_status add_component_with_init_method_data( void *init_method_data, bt_logging_level log_level, struct bt_component **user_component) { - enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK; - enum bt_self_component_status comp_status; + int status = BT_FUNC_STATUS_OK; + enum bt_component_class_init_method_status init_status; struct bt_component *component = NULL; int ret; bool init_can_consume; @@ -1265,7 +1265,7 @@ enum bt_graph_status add_component_with_init_method_data( new_params = bt_value_map_create(); if (!new_params) { BT_LOGE_STR("Cannot create empty map value object."); - graph_status = BT_GRAPH_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -1276,7 +1276,7 @@ enum bt_graph_status add_component_with_init_method_data( if (ret) { BT_LOGE("Cannot create empty component object: ret=%d", ret); - graph_status = BT_GRAPH_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -1291,12 +1291,13 @@ enum bt_graph_status add_component_with_init_method_data( if (init_method) { BT_LOGD_STR("Calling user's initialization method."); - comp_status = init_method(component, params, init_method_data); + init_status = init_method(component, params, init_method_data); BT_LOGD("User method returned: status=%s", - bt_self_component_status_string(comp_status)); - if (comp_status != BT_SELF_COMPONENT_STATUS_OK) { - BT_LOGW_STR("Initialization method failed."); - graph_status = (int) comp_status; + bt_common_func_status_string(init_status)); + if (init_status != BT_FUNC_STATUS_OK) { + BT_LIB_LOGW("Component initialization method failed: " + "%!+c", component); + status = init_status; bt_component_set_graph(component, NULL); g_ptr_array_remove_fast(graph->components, component); goto end; @@ -1338,7 +1339,7 @@ enum bt_graph_status add_component_with_init_method_data( } end: - if (graph_status != BT_GRAPH_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { bt_graph_make_faulty(graph); } @@ -1346,10 +1347,10 @@ end: bt_object_put_ref(new_params); (void) init_can_consume; bt_graph_set_can_consume(graph, init_can_consume); - return graph_status; + return status; } -enum bt_graph_status +enum bt_graph_add_component_status bt_graph_add_source_component_with_init_method_data( struct bt_graph *graph, const struct bt_component_class_source *comp_cls, @@ -1363,7 +1364,7 @@ bt_graph_add_source_component_with_init_method_data( name, params, init_method_data, log_level, (void *) component); } -enum bt_graph_status bt_graph_add_source_component( +enum bt_graph_add_component_status bt_graph_add_source_component( struct bt_graph *graph, const struct bt_component_class_source *comp_cls, const char *name, const struct bt_value *params, @@ -1374,7 +1375,7 @@ enum bt_graph_status bt_graph_add_source_component( graph, comp_cls, name, params, NULL, log_level, component); } -enum bt_graph_status +enum bt_graph_add_component_status bt_graph_add_filter_component_with_init_method_data( struct bt_graph *graph, const struct bt_component_class_filter *comp_cls, @@ -1388,7 +1389,7 @@ bt_graph_add_filter_component_with_init_method_data( name, params, init_method_data, log_level, (void *) component); } -enum bt_graph_status bt_graph_add_filter_component( +enum bt_graph_add_component_status bt_graph_add_filter_component( struct bt_graph *graph, const struct bt_component_class_filter *comp_cls, const char *name, const struct bt_value *params, @@ -1399,7 +1400,7 @@ enum bt_graph_status bt_graph_add_filter_component( graph, comp_cls, name, params, NULL, log_level, component); } -enum bt_graph_status +enum bt_graph_add_component_status bt_graph_add_sink_component_with_init_method_data( struct bt_graph *graph, const struct bt_component_class_sink *comp_cls, @@ -1413,7 +1414,7 @@ bt_graph_add_sink_component_with_init_method_data( name, params, init_method_data, log_level, (void *) component); } -enum bt_graph_status bt_graph_add_sink_component( +enum bt_graph_add_component_status bt_graph_add_sink_component( struct bt_graph *graph, const struct bt_component_class_sink *comp_cls, const char *name, const struct bt_value *params, diff --git a/src/lib/graph/graph.h b/src/lib/graph/graph.h index ace6ca2e..30d59fb9 100644 --- a/src/lib/graph/graph.h +++ b/src/lib/graph/graph.h @@ -37,6 +37,7 @@ #include "component.h" #include "component-sink.h" #include "connection.h" +#include "lib/func-status.h" /* Protection: this file uses BT_LIB_LOG*() macros directly */ #ifndef BT_LIB_LOG_SUPPORTED @@ -90,7 +91,7 @@ struct bt_graph { /* * If this is false, then the public API's consuming * functions (bt_graph_consume() and bt_graph_run()) return - * BT_GRAPH_STATUS_CANNOT_CONSUME. The internal "no check" + * BT_FUNC_STATUS_CANNOT_CONSUME. The internal "no check" * functions always work. * * In bt_port_output_message_iterator_create(), on success, @@ -152,15 +153,15 @@ void _bt_graph_set_can_consume(struct bt_graph *graph, bool can_consume) #endif BT_HIDDEN -enum bt_graph_status bt_graph_consume_sink_no_check(struct bt_graph *graph, +int bt_graph_consume_sink_no_check(struct bt_graph *graph, struct bt_component_sink *sink); BT_HIDDEN -enum bt_graph_listener_status bt_graph_notify_port_added(struct bt_graph *graph, +enum bt_graph_listener_func_status bt_graph_notify_port_added(struct bt_graph *graph, struct bt_port *port); BT_HIDDEN -enum bt_graph_listener_status bt_graph_notify_ports_connected( +enum bt_graph_listener_func_status bt_graph_notify_ports_connected( struct bt_graph *graph, struct bt_port *upstream_port, struct bt_port *downstream_port); @@ -184,27 +185,6 @@ BT_HIDDEN void bt_graph_add_message(struct bt_graph *graph, struct bt_message *msg); -static inline -const char *bt_graph_status_string(enum bt_graph_status status) -{ - switch (status) { - case BT_GRAPH_STATUS_CANCELED: - return "BT_GRAPH_STATUS_CANCELED"; - case BT_GRAPH_STATUS_AGAIN: - return "BT_GRAPH_STATUS_AGAIN"; - case BT_GRAPH_STATUS_END: - return "BT_GRAPH_STATUS_END"; - case BT_GRAPH_STATUS_OK: - return "BT_GRAPH_STATUS_OK"; - case BT_GRAPH_STATUS_ERROR: - return "BT_GRAPH_STATUS_ERROR"; - case BT_GRAPH_STATUS_NOMEM: - return "BT_GRAPH_STATUS_NOMEM"; - default: - return "(unknown)"; - } -} - static inline const char *bt_graph_configuration_state_string( enum bt_graph_configuration_state state) @@ -222,9 +202,9 @@ const char *bt_graph_configuration_state_string( } static inline -enum bt_graph_status bt_graph_configure(struct bt_graph *graph) +int bt_graph_configure(struct bt_graph *graph) { - enum bt_graph_status status = BT_GRAPH_STATUS_OK; + int status = BT_FUNC_STATUS_OK; uint64_t i; BT_ASSERT(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY); @@ -252,7 +232,7 @@ enum bt_graph_status bt_graph_configure(struct bt_graph *graph) } if (comp_cls_sink->methods.graph_is_configured) { - enum bt_self_component_status comp_status; + enum bt_component_class_sink_graph_is_configured_method_status comp_status; BT_LIB_LOGD("Calling user's \"graph is configured\" method: " "%![graph-]+g, %![comp-]+c", @@ -260,19 +240,18 @@ enum bt_graph_status bt_graph_configure(struct bt_graph *graph) comp_status = comp_cls_sink->methods.graph_is_configured( (void *) comp_sink); BT_LIB_LOGD("User method returned: status=%s", - bt_self_component_status_string(comp_status)); - BT_ASSERT_POST(comp_status == BT_SELF_COMPONENT_STATUS_OK || - comp_status == BT_SELF_COMPONENT_STATUS_ERROR || - comp_status == BT_SELF_COMPONENT_STATUS_NOMEM, + bt_common_func_status_string(comp_status)); + BT_ASSERT_POST(comp_status == BT_FUNC_STATUS_OK || + comp_status == BT_FUNC_STATUS_ERROR || + comp_status == BT_FUNC_STATUS_MEMORY_ERROR, "Unexpected returned status: status=%s", - bt_self_component_status_string(comp_status)); + bt_common_func_status_string(comp_status)); - if (comp_status != BT_SELF_COMPONENT_STATUS_OK) { - status = BT_GRAPH_STATUS_ERROR; + if (comp_status != BT_FUNC_STATUS_OK) { + status = BT_FUNC_STATUS_ERROR; BT_LIB_LOGW("User's \"graph is configured\" method failed: " "%![comp-]+c, status=%s", - comp, - bt_self_component_status_string( + comp, bt_common_func_status_string( comp_status)); goto end; } diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index db8fa537..b1d57b59 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -34,11 +34,14 @@ #include #include "lib/trace-ir/packet.h" #include "lib/trace-ir/stream.h" +#include +#include +#include #include #include #include #include -#include +#include #include #include #include @@ -78,6 +81,7 @@ #include "message/stream.h" #include "message/packet.h" #include "message/stream-activity.h" +#include "lib/func-status.h" /* * TODO: Use graph's state (number of active iterators, etc.) and @@ -415,7 +419,7 @@ struct bt_self_component_port_input_message_iterator * bt_self_component_port_input_message_iterator_create( struct bt_self_component_port_input *self_port) { - typedef enum bt_self_message_iterator_status (*init_method_t)( + typedef enum bt_component_class_message_iterator_init_method_status (*init_method_t)( void *, void *, void *); init_method_t init_method = NULL; @@ -484,14 +488,14 @@ bt_self_component_port_input_message_iterator_create( } if (init_method) { - int iter_status; + enum bt_component_class_message_iterator_init_method_status iter_status; BT_LIB_LOGD("Calling user's initialization method: %!+i", iterator); iter_status = init_method(iterator, upstream_comp, upstream_port); BT_LOGD("User method returned: status=%s", - bt_message_iterator_status_string(iter_status)); - if (iter_status != BT_MESSAGE_ITERATOR_STATUS_OK) { + bt_common_func_status_string(iter_status)); + if (iter_status != BT_FUNC_STATUS_OK) { BT_LOGW_STR("Initialization method failed."); BT_OBJECT_PUT_REF_AND_RESET(iterator); goto end; @@ -545,7 +549,7 @@ bool clock_snapshots_are_monotonic_one( const struct bt_clock_snapshot *clock_snapshot = NULL; bt_message_type message_type = bt_message_get_type(msg); int64_t ns_from_origin; - enum bt_clock_snapshot_status clock_snapshot_status; + enum bt_clock_snapshot_get_ns_from_origin_status clock_snapshot_status; /* * The default is true: if we can't figure out the clock snapshot @@ -605,7 +609,7 @@ bool clock_snapshots_are_monotonic_one( } clock_snapshot_status = bt_clock_snapshot_get_ns_from_origin(clock_snapshot, &ns_from_origin); - if (clock_snapshot_status != BT_CLOCK_SNAPSHOT_STATUS_OK) { + if (clock_snapshot_status != BT_FUNC_STATUS_OK) { goto end; } @@ -793,19 +797,20 @@ end: */ static -bt_message_iterator_status call_iterator_next_method( +enum bt_component_class_message_iterator_next_method_status +call_iterator_next_method( struct bt_self_component_port_input_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *user_count) { - bt_message_iterator_status status; + enum bt_component_class_message_iterator_next_method_status status; BT_ASSERT(iterator->methods.next); BT_LOGD_STR("Calling user's \"next\" method."); status = iterator->methods.next(iterator, msgs, capacity, user_count); BT_LOGD("User method returned: status=%s, msg-count=%" PRIu64, - bt_message_iterator_status_string(status), *user_count); + bt_common_func_status_string(status), *user_count); - if (status == BT_MESSAGE_ITERATOR_STATUS_OK) { + if (status == BT_FUNC_STATUS_OK) { BT_ASSERT_POST(clock_classes_are_compatible(iterator, msgs, *user_count), "Clocks are not compatible"); BT_ASSERT_POST(clock_snapshots_are_monotonic(iterator, msgs, *user_count), @@ -815,12 +820,12 @@ bt_message_iterator_status call_iterator_next_method( return status; } -enum bt_message_iterator_status +enum bt_message_iterator_next_status bt_self_component_port_input_message_iterator_next( struct bt_self_component_port_input_message_iterator *iterator, bt_message_array_const *msgs, uint64_t *user_count) { - int status = BT_MESSAGE_ITERATOR_STATUS_OK; + enum bt_message_iterator_next_status status = BT_FUNC_STATUS_OK; BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); BT_ASSERT_PRE_NON_NULL(msgs, "Message array (output)"); @@ -845,7 +850,7 @@ bt_self_component_port_input_message_iterator_next( * and status. */ *user_count = 0; - status = call_iterator_next_method(iterator, + status = (int) call_iterator_next_method(iterator, (void *) iterator->base.msgs->pdata, MSG_BATCH_SIZE, user_count); if (status < 0) { @@ -866,16 +871,16 @@ bt_self_component_port_input_message_iterator_next( BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE); switch (status) { - case BT_MESSAGE_ITERATOR_STATUS_OK: + case BT_FUNC_STATUS_OK: BT_ASSERT_POST(*user_count <= MSG_BATCH_SIZE, "Invalid returned message count: greater than " "batch size: count=%" PRIu64 ", batch-size=%u", *user_count, MSG_BATCH_SIZE); *msgs = (void *) iterator->base.msgs->pdata; break; - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: + case BT_FUNC_STATUS_AGAIN: goto end; - case BT_MESSAGE_ITERATOR_STATUS_END: + case BT_FUNC_STATUS_END: set_self_comp_port_input_msg_iterator_state(iterator, BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED); goto end; @@ -888,13 +893,13 @@ end: return status; } -enum bt_message_iterator_status bt_port_output_message_iterator_next( +enum bt_message_iterator_next_status bt_port_output_message_iterator_next( struct bt_port_output_message_iterator *iterator, bt_message_array_const *msgs_to_user, uint64_t *count_to_user) { - enum bt_message_iterator_status status; - enum bt_graph_status graph_status; + enum bt_message_iterator_next_status status; + int graph_status; BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); BT_ASSERT_PRE_NON_NULL(msgs_to_user, "Message array (output)"); @@ -904,14 +909,14 @@ enum bt_message_iterator_status bt_port_output_message_iterator_next( graph_status = bt_graph_consume_sink_no_check(iterator->graph, iterator->colander); switch (graph_status) { - case BT_GRAPH_STATUS_CANCELED: - case BT_GRAPH_STATUS_AGAIN: - case BT_GRAPH_STATUS_END: - case BT_GRAPH_STATUS_NOMEM: + case BT_FUNC_STATUS_CANCELED: + case BT_FUNC_STATUS_AGAIN: + case BT_FUNC_STATUS_END: + case BT_FUNC_STATUS_MEMORY_ERROR: status = (int) graph_status; break; - case BT_GRAPH_STATUS_OK: - status = BT_MESSAGE_ITERATOR_STATUS_OK; + case BT_FUNC_STATUS_OK: + status = BT_FUNC_STATUS_OK; /* * On success, the colander sink moves the messages @@ -923,7 +928,7 @@ enum bt_message_iterator_status bt_port_output_message_iterator_next( break; default: /* Other errors */ - status = BT_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; } return status; @@ -987,7 +992,7 @@ bt_port_output_message_iterator_create(struct bt_graph *graph, struct bt_component_class_sink *colander_comp_cls = NULL; struct bt_component *output_port_comp = NULL; struct bt_component_sink *colander_comp; - enum bt_graph_status graph_status; + int graph_status; struct bt_port_input *colander_in_port = NULL; struct bt_component_class_sink_colander_data colander_data; int ret; @@ -1042,16 +1047,15 @@ bt_port_output_message_iterator_create(struct bt_graph *graph, * class module does not use this level anyway since it belongs * to the library. */ - graph_status = - bt_graph_add_sink_component_with_init_method_data( + graph_status = bt_graph_add_sink_component_with_init_method_data( (void *) graph, colander_comp_cls, "colander-36ac3409-b1a8-4d60-ab1f-4fdf341a8fb1", NULL, &colander_data, BT_LOGGING_LEVEL_NONE, (void *) &iterator->colander); - if (graph_status != BT_GRAPH_STATUS_OK) { + if (graph_status != BT_FUNC_STATUS_OK) { BT_LIB_LOGW("Cannot add colander sink component to graph: " "%1[graph-]+g, status=%s", graph, - bt_graph_status_string(graph_status)); + bt_common_func_status_string(graph_status)); goto error; } @@ -1065,11 +1069,11 @@ bt_port_output_message_iterator_create(struct bt_graph *graph, BT_ASSERT(colander_in_port); graph_status = bt_graph_connect_ports(graph, output_port, colander_in_port, NULL); - if (graph_status != BT_GRAPH_STATUS_OK) { + if (graph_status != BT_FUNC_STATUS_OK) { BT_LIB_LOGW("Cannot add colander sink component to graph: " "%![graph-]+g, %![comp-]+c, status=%s", graph, iterator->colander, - bt_graph_status_string(graph_status)); + bt_common_func_status_string(graph_status)); goto error; } @@ -1085,10 +1089,10 @@ bt_port_output_message_iterator_create(struct bt_graph *graph, /* Also set the graph as being configured. */ graph_status = bt_graph_configure(graph); - if (graph_status != BT_GRAPH_STATUS_OK) { + if (graph_status != BT_FUNC_STATUS_OK) { BT_LIB_LOGW("Cannot configure graph after having added colander: " "%![graph-]+g, status=%s", graph, - bt_graph_status_string(graph_status)); + bt_common_func_status_string(graph_status)); goto error; } goto end; @@ -1179,23 +1183,23 @@ bt_bool bt_self_component_port_input_message_iterator_can_seek_beginning( static inline void set_iterator_state_after_seeking( struct bt_self_component_port_input_message_iterator *iterator, - enum bt_message_iterator_status status) + int status) { enum bt_self_component_port_input_message_iterator_state new_state = 0; /* Set iterator's state depending on seeking status */ switch (status) { - case BT_MESSAGE_ITERATOR_STATUS_OK: + case BT_FUNC_STATUS_OK: new_state = BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE; break; - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: + case BT_FUNC_STATUS_AGAIN: new_state = BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN; break; - case BT_MESSAGE_ITERATOR_STATUS_ERROR: - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: + case BT_FUNC_STATUS_ERROR: + case BT_FUNC_STATUS_MEMORY_ERROR: new_state = BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR; break; - case BT_MESSAGE_ITERATOR_STATUS_END: + case BT_FUNC_STATUS_END: new_state = BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED; break; default: @@ -1213,11 +1217,11 @@ void reset_iterator_expectations( iterator->clock_expectation.type = CLOCK_EXPECTATION_UNSET; } -enum bt_message_iterator_status +enum bt_message_iterator_seek_beginning_status bt_self_component_port_input_message_iterator_seek_beginning( struct bt_self_component_port_input_message_iterator *iterator) { - int status; + enum bt_message_iterator_seek_beginning_status status; BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator); @@ -1242,18 +1246,17 @@ bt_self_component_port_input_message_iterator_seek_beginning( BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING); status = iterator->methods.seek_beginning(iterator); BT_LOGD("User method returned: status=%s", - bt_message_iterator_status_string(status)); - BT_ASSERT_POST(status == BT_MESSAGE_ITERATOR_STATUS_OK || - status == BT_MESSAGE_ITERATOR_STATUS_ERROR || - status == BT_MESSAGE_ITERATOR_STATUS_NOMEM || - status == BT_MESSAGE_ITERATOR_STATUS_AGAIN, + bt_common_func_status_string(status)); + BT_ASSERT_POST(status == BT_FUNC_STATUS_OK || + status == BT_FUNC_STATUS_ERROR || + status == BT_FUNC_STATUS_MEMORY_ERROR || + status == BT_FUNC_STATUS_AGAIN, "Unexpected status: %![iter-]+i, status=%s", - iterator, bt_common_self_message_iterator_status_string(status)); + iterator, bt_common_func_status_string(status)); set_iterator_state_after_seeking(iterator, status); return status; } - /* * Structure used to record the state of a given stream during the fast-forward * phase of an auto-seek. @@ -1326,12 +1329,12 @@ void destroy_auto_seek_stream_states(GHashTable *stream_states) */ static inline -enum bt_message_iterator_status auto_seek_handle_message( +int auto_seek_handle_message( struct bt_self_component_port_input_message_iterator *iterator, int64_t ns_from_origin, const struct bt_message *msg, bool *got_first, GHashTable *stream_states) { - enum bt_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK; + int status = BT_FUNC_STATUS_OK; int64_t msg_ns_from_origin; const struct bt_clock_snapshot *clk_snapshot = NULL; int ret; @@ -1386,7 +1389,7 @@ enum bt_message_iterator_status auto_seek_handle_message( msg_disc_items->default_begin_cs, &msg_ns_from_origin); if (ret) { - status = BT_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } @@ -1399,7 +1402,7 @@ enum bt_message_iterator_status auto_seek_handle_message( msg_disc_items->default_end_cs, &msg_ns_from_origin); if (ret) { - status = BT_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } @@ -1419,7 +1422,7 @@ enum bt_message_iterator_status auto_seek_handle_message( msg_disc_items->default_end_cs->clock_class, ns_from_origin, &new_begin_raw_value); if (ret) { - status = BT_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } @@ -1503,7 +1506,7 @@ enum bt_message_iterator_status auto_seek_handle_message( ret = bt_clock_snapshot_get_ns_from_origin(clk_snapshot, &msg_ns_from_origin); if (ret) { - status = BT_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } @@ -1523,7 +1526,7 @@ skip_msg: /* Update stream's state: stream began. */ stream_state = create_auto_seek_stream_state(); if (!stream_state) { - status = BT_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -1622,12 +1625,12 @@ push_msg: msg = NULL; end: - BT_ASSERT(!msg || status != BT_MESSAGE_ITERATOR_STATUS_OK); + BT_ASSERT(!msg || status != BT_FUNC_STATUS_OK); return status; } static -enum bt_message_iterator_status find_message_ge_ns_from_origin( +int find_message_ge_ns_from_origin( struct bt_self_component_port_input_message_iterator *iterator, int64_t ns_from_origin, GHashTable *stream_states) { @@ -1667,16 +1670,16 @@ enum bt_message_iterator_status find_message_ge_ns_from_origin( BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE); switch (status) { - case BT_MESSAGE_ITERATOR_STATUS_OK: + case BT_FUNC_STATUS_OK: BT_ASSERT_POST(user_count <= MSG_BATCH_SIZE, "Invalid returned message count: greater than " "batch size: count=%" PRIu64 ", batch-size=%u", user_count, MSG_BATCH_SIZE); break; - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - case BT_MESSAGE_ITERATOR_STATUS_ERROR: - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - case BT_MESSAGE_ITERATOR_STATUS_END: + case BT_FUNC_STATUS_AGAIN: + case BT_FUNC_STATUS_ERROR: + case BT_FUNC_STATUS_MEMORY_ERROR: + case BT_FUNC_STATUS_END: goto end; default: abort(); @@ -1693,7 +1696,7 @@ enum bt_message_iterator_status find_message_ge_ns_from_origin( status = auto_seek_handle_message(iterator, ns_from_origin, messages[i], &got_first, stream_states); - if (status == BT_MESSAGE_ITERATOR_STATUS_OK) { + if (status == BT_FUNC_STATUS_OK) { /* Message was either pushed or moved */ messages[i] = NULL; } else { @@ -1721,7 +1724,7 @@ end: */ static -enum bt_self_message_iterator_status post_auto_seek_next( +enum bt_component_class_message_iterator_next_method_status post_auto_seek_next( struct bt_self_component_port_input_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) @@ -1748,7 +1751,7 @@ enum bt_self_message_iterator_status post_auto_seek_next( iterator->auto_seek.original_next_callback = NULL; } - return BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + return BT_FUNC_STATUS_OK; } static inline @@ -1765,7 +1768,7 @@ int clock_raw_value_from_ns_from_origin(const bt_clock_class *clock_class, } -enum bt_message_iterator_status +enum bt_message_iterator_seek_ns_from_origin_status bt_self_component_port_input_message_iterator_seek_ns_from_origin( struct bt_self_component_port_input_message_iterator *iterator, int64_t ns_from_origin) @@ -1801,14 +1804,13 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( status = iterator->methods.seek_ns_from_origin(iterator, ns_from_origin); BT_LOGD("User method returned: status=%s", - bt_message_iterator_status_string(status)); - BT_ASSERT_POST(status == BT_MESSAGE_ITERATOR_STATUS_OK || - status == BT_MESSAGE_ITERATOR_STATUS_ERROR || - status == BT_MESSAGE_ITERATOR_STATUS_NOMEM || - status == BT_MESSAGE_ITERATOR_STATUS_AGAIN, + bt_common_func_status_string(status)); + BT_ASSERT_POST(status == BT_FUNC_STATUS_OK || + status == BT_FUNC_STATUS_ERROR || + status == BT_FUNC_STATUS_MEMORY_ERROR || + status == BT_FUNC_STATUS_AGAIN, "Unexpected status: %![iter-]+i, status=%s", - iterator, - bt_common_self_message_iterator_status_string(status)); + iterator, bt_common_func_status_string(status)); } else { /* * The iterator doesn't know how to seek to a particular time. We will @@ -1820,20 +1822,19 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( iterator); status = iterator->methods.seek_beginning(iterator); BT_LOGD("User method returned: status=%s", - bt_message_iterator_status_string(status)); - BT_ASSERT_POST(status == BT_MESSAGE_ITERATOR_STATUS_OK || - status == BT_MESSAGE_ITERATOR_STATUS_ERROR || - status == BT_MESSAGE_ITERATOR_STATUS_NOMEM || - status == BT_MESSAGE_ITERATOR_STATUS_AGAIN, + bt_common_func_status_string(status)); + BT_ASSERT_POST(status == BT_FUNC_STATUS_OK || + status == BT_FUNC_STATUS_ERROR || + status == BT_FUNC_STATUS_MEMORY_ERROR || + status == BT_FUNC_STATUS_AGAIN, "Unexpected status: %![iter-]+i, status=%s", - iterator, - bt_common_self_message_iterator_status_string(status)); + iterator, bt_common_func_status_string(status)); switch (status) { - case BT_MESSAGE_ITERATOR_STATUS_OK: + case BT_FUNC_STATUS_OK: break; - case BT_MESSAGE_ITERATOR_STATUS_ERROR: - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: + case BT_FUNC_STATUS_ERROR: + case BT_FUNC_STATUS_MEMORY_ERROR: + case BT_FUNC_STATUS_AGAIN: goto end; default: abort(); @@ -1854,15 +1855,15 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( stream_states = create_auto_seek_stream_states(); if (!stream_states) { BT_LOGE_STR("Failed to allocate one GHashTable."); - status = BT_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } status = find_message_ge_ns_from_origin(iterator, ns_from_origin, stream_states); switch (status) { - case BT_MESSAGE_ITERATOR_STATUS_OK: - case BT_MESSAGE_ITERATOR_STATUS_END: + case BT_FUNC_STATUS_OK: + case BT_FUNC_STATUS_END: { GHashTableIter iter; gpointer key, value; @@ -1885,7 +1886,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( if (clock_raw_value_from_ns_from_origin(clock_class, ns_from_origin, &raw_value) != 0) { BT_LIB_LOGW("Could not convert nanoseconds from origin to clock value: ns-from-origin=%" PRId64 ", %![cc-]+K", ns_from_origin, clock_class); - status = BT_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } @@ -1896,7 +1897,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( msg = bt_message_packet_beginning_create_with_default_clock_snapshot( (bt_self_message_iterator *) iterator, stream_state->packet, raw_value); if (!msg) { - status = BT_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -1907,7 +1908,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( msg = bt_message_stream_activity_beginning_create( (bt_self_message_iterator *) iterator, stream); if (!msg) { - status = BT_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -1920,7 +1921,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( msg = bt_message_stream_beginning_create( (bt_self_message_iterator *) iterator, stream); if (!msg) { - status = BT_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -1946,18 +1947,18 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( } /* - * `BT_MESSAGE_ITERATOR_STATUS_END` becomes - * `BT_MESSAGE_ITERATOR_STATUS_OK`: the next + * `BT_FUNC_STATUS_END` becomes + * `BT_FUNC_STATUS_OK`: the next * time this iterator's "next" method is called, * it will return - * `BT_MESSAGE_ITERATOR_STATUS_END`. + * `BT_FUNC_STATUS_END`. */ - status = BT_MESSAGE_ITERATOR_STATUS_OK; + status = BT_FUNC_STATUS_OK; break; } - case BT_MESSAGE_ITERATOR_STATUS_ERROR: - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: + case BT_FUNC_STATUS_ERROR: + case BT_FUNC_STATUS_MEMORY_ERROR: + case BT_FUNC_STATUS_AGAIN: goto end; default: abort(); @@ -2012,7 +2013,8 @@ bt_bool bt_port_output_message_iterator_can_seek_beginning( iterator)); } -enum bt_message_iterator_status bt_port_output_message_iterator_seek_ns_from_origin( +enum bt_message_iterator_seek_ns_from_origin_status +bt_port_output_message_iterator_seek_ns_from_origin( struct bt_port_output_message_iterator *iterator, int64_t ns_from_origin) { @@ -2022,7 +2024,8 @@ enum bt_message_iterator_status bt_port_output_message_iterator_seek_ns_from_ori ns_from_origin); } -enum bt_message_iterator_status bt_port_output_message_iterator_seek_beginning( +enum bt_message_iterator_seek_beginning_status +bt_port_output_message_iterator_seek_beginning( struct bt_port_output_message_iterator *iterator) { BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); diff --git a/src/lib/graph/message/iterator.h b/src/lib/graph/message/iterator.h index 36795bd0..d28a8810 100644 --- a/src/lib/graph/message/iterator.h +++ b/src/lib/graph/message/iterator.h @@ -28,7 +28,6 @@ #include "lib/object.h" #include #include -#include #include #include "common/assert.h" #include @@ -77,15 +76,15 @@ struct bt_message_iterator { GPtrArray *msgs; }; -typedef enum bt_self_message_iterator_status +typedef enum bt_component_class_message_iterator_next_method_status (*bt_self_component_port_input_message_iterator_next_method)( void *, bt_message_array_const, uint64_t, uint64_t *); -typedef enum bt_self_message_iterator_status +typedef enum bt_component_class_message_iterator_seek_ns_from_origin_method_status (*bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)( void *, int64_t); -typedef enum bt_self_message_iterator_status +typedef enum bt_component_class_message_iterator_seek_beginning_method_status (*bt_self_component_port_input_message_iterator_seek_beginning_method)( void *); diff --git a/src/lib/graph/query-executor.c b/src/lib/graph/query-executor.c index 59c44f7b..b3367b1a 100644 --- a/src/lib/graph/query-executor.c +++ b/src/lib/graph/query-executor.c @@ -37,6 +37,7 @@ #include "component-class.h" #include "query-executor.h" +#include "lib/func-status.h" static void bt_query_executor_destroy(struct bt_object *obj) @@ -67,18 +68,19 @@ end: return (void *) query_exec; } -enum bt_query_executor_status bt_query_executor_query( +enum bt_query_executor_query_status bt_query_executor_query( struct bt_query_executor *query_exec, const struct bt_component_class *comp_cls, const char *object, const struct bt_value *params, - bt_logging_level log_level, + enum bt_logging_level log_level, const struct bt_value **user_result) { - typedef enum bt_query_status (*method_t)(void *, const void *, - const void *, const void *, bt_logging_level, const void *); + typedef enum bt_component_class_query_method_status (*method_t)(void *, + const void *, const void *, const void *, enum bt_logging_level, + const void *); - enum bt_query_status status; - enum bt_query_executor_status exec_status; + enum bt_query_executor_query_status status; + enum bt_component_class_query_method_status query_status; method_t method = NULL; BT_ASSERT_PRE_NON_NULL(query_exec, "Query executor"); @@ -121,7 +123,7 @@ enum bt_query_executor_status bt_query_executor_query( /* Not an error: nothing to query */ BT_LIB_LOGD("Component class has no registered query method: " "%!+C", comp_cls); - exec_status = BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED; + status = BT_FUNC_STATUS_UNSUPPORTED; goto end; } @@ -131,30 +133,30 @@ enum bt_query_executor_status bt_query_executor_query( query_exec, comp_cls, object, params, bt_common_logging_level_string(log_level)); *user_result = NULL; - status = method((void *) comp_cls, query_exec, object, params, + query_status = method((void *) comp_cls, query_exec, object, params, log_level, user_result); BT_LIB_LOGD("User method returned: status=%s, %![res-]+v", - bt_query_status_string(status), *user_result); - BT_ASSERT_POST(status != BT_QUERY_STATUS_OK || *user_result, - "User method returned `BT_QUERY_STATUS_OK` without a result."); - exec_status = (int) status; + bt_common_func_status_string(query_status), *user_result); + BT_ASSERT_POST(query_status != BT_FUNC_STATUS_OK || *user_result, + "User method returned `BT_FUNC_STATUS_OK` without a result."); + status = (int) query_status; if (query_exec->canceled) { BT_OBJECT_PUT_REF_AND_RESET(*user_result); - exec_status = BT_QUERY_EXECUTOR_STATUS_CANCELED; + status = BT_FUNC_STATUS_CANCELED; goto end; } end: - return exec_status; + return status; } -enum bt_query_executor_status bt_query_executor_cancel( +enum bt_query_executor_cancel_status bt_query_executor_cancel( struct bt_query_executor *query_exec) { BT_ASSERT_PRE_NON_NULL(query_exec, "Query executor"); query_exec->canceled = BT_TRUE; BT_LOGI("Canceled query executor: addr=%p", query_exec); - return BT_QUERY_EXECUTOR_STATUS_OK; + return BT_FUNC_STATUS_OK; } bt_bool bt_query_executor_is_canceled(const struct bt_query_executor *query_exec) diff --git a/src/lib/graph/query-executor.h b/src/lib/graph/query-executor.h index 57951b72..875c26c0 100644 --- a/src/lib/graph/query-executor.h +++ b/src/lib/graph/query-executor.h @@ -33,49 +33,4 @@ struct bt_query_executor { bool canceled; }; -static inline const char *bt_query_status_string(enum bt_query_status status) -{ - switch (status) { - case BT_QUERY_STATUS_OK: - return "BT_QUERY_STATUS_OK"; - case BT_QUERY_STATUS_AGAIN: - return "BT_QUERY_STATUS_AGAIN"; - case BT_QUERY_STATUS_ERROR: - return "BT_QUERY_STATUS_ERROR"; - case BT_QUERY_STATUS_INVALID_OBJECT: - return "BT_QUERY_STATUS_INVALID_OBJECT"; - case BT_QUERY_STATUS_INVALID_PARAMS: - return "BT_QUERY_STATUS_INVALID_PARAMS"; - case BT_QUERY_STATUS_NOMEM: - return "BT_QUERY_STATUS_NOMEM"; - default: - return "(unknown)"; - } -}; - -static inline const char *bt_query_executor_status_string( - enum bt_query_executor_status status) -{ - switch (status) { - case BT_QUERY_EXECUTOR_STATUS_OK: - return "BT_QUERY_EXECUTOR_STATUS_OK"; - case BT_QUERY_EXECUTOR_STATUS_AGAIN: - return "BT_QUERY_EXECUTOR_STATUS_AGAIN"; - case BT_QUERY_EXECUTOR_STATUS_CANCELED: - return "BT_QUERY_EXECUTOR_STATUS_CANCELED"; - case BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED: - return "BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED"; - case BT_QUERY_EXECUTOR_STATUS_ERROR: - return "BT_QUERY_EXECUTOR_STATUS_ERROR"; - case BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT: - return "BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT"; - case BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS: - return "BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS"; - case BT_QUERY_EXECUTOR_STATUS_NOMEM: - return "BT_QUERY_EXECUTOR_STATUS_NOMEM"; - default: - return "(unknown)"; - } -}; - #endif /* BABELTRACE_GRAPH_QUERY_EXECUTOR_INTERNAL_H */ diff --git a/src/lib/plugin/plugin-so.c b/src/lib/plugin/plugin-so.c index 43055ac3..2ddecdb3 100644 --- a/src/lib/plugin/plugin-so.c +++ b/src/lib/plugin/plugin-so.c @@ -44,6 +44,8 @@ #include "plugin.h" #include "plugin-so.h" +#include "lib/func-status.h" +#include "common/common.h" #define NATIVE_PLUGIN_SUFFIX "." G_MODULE_SUFFIX #define NATIVE_PLUGIN_SUFFIX_LEN sizeof(NATIVE_PLUGIN_SUFFIX) @@ -102,21 +104,6 @@ void fini_comp_class_list(void) BT_LOGD_STR("Released references from all component classes to shared library handles."); } -static inline -const char *bt_self_plugin_status_string(enum bt_self_plugin_status status) -{ - switch (status) { - case BT_SELF_PLUGIN_STATUS_OK: - return "BT_SELF_PLUGIN_STATUS_OK"; - case BT_SELF_PLUGIN_STATUS_ERROR: - return "BT_SELF_PLUGIN_STATUS_ERROR"; - case BT_SELF_PLUGIN_STATUS_NOMEM: - return "BT_SELF_PLUGIN_STATUS_NOMEM"; - default: - return "(unknown)"; - } -} - static void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj) { @@ -174,18 +161,18 @@ void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj) } static -enum bt_plugin_status bt_plugin_so_shared_lib_handle_create( +int bt_plugin_so_shared_lib_handle_create( const char *path, struct bt_plugin_so_shared_lib_handle **shared_lib_handle) { - enum bt_plugin_status status = BT_PLUGIN_STATUS_OK; + int status = BT_FUNC_STATUS_OK; BT_ASSERT(shared_lib_handle); BT_LOGI("Creating shared library handle: path=\"%s\"", path); *shared_lib_handle = g_new0(struct bt_plugin_so_shared_lib_handle, 1); if (!*shared_lib_handle) { BT_LOGE_STR("Failed to allocate one shared library handle."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -199,7 +186,7 @@ enum bt_plugin_status bt_plugin_so_shared_lib_handle_create( (*shared_lib_handle)->path = g_string_new(path); if (!(*shared_lib_handle)->path) { BT_LOGE_STR("Failed to allocate a GString."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -215,14 +202,14 @@ enum bt_plugin_status bt_plugin_so_shared_lib_handle_create( BT_LOGI("Cannot open GModule: %s: path=\"%s\"", g_module_error(), path); BT_OBJECT_PUT_REF_AND_RESET(*shared_lib_handle); - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = BT_FUNC_STATUS_NOT_FOUND; goto end; } goto end; end: - BT_ASSERT(*shared_lib_handle || status != BT_PLUGIN_STATUS_OK); + BT_ASSERT(*shared_lib_handle || status != BT_FUNC_STATUS_OK); if (*shared_lib_handle) { BT_LOGI("Created shared library handle: path=\"%s\", addr=%p", path, *shared_lib_handle); @@ -275,7 +262,7 @@ void bt_plugin_so_destroy_spec_data(struct bt_plugin *plugin) * 6. Freeze the plugin object. */ static -enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, +int bt_plugin_so_init(struct bt_plugin *plugin, bool fail_on_load_error, const struct __bt_plugin_descriptor *descriptor, struct __bt_plugin_descriptor_attribute const * const *attrs_begin, @@ -332,7 +319,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, } methods; }; - enum bt_plugin_status status = BT_PLUGIN_STATUS_OK; + int status = BT_FUNC_STATUS_OK; struct __bt_plugin_descriptor_attribute const * const *cur_attr_ptr; struct __bt_plugin_component_class_descriptor const * const *cur_cc_descr_ptr; struct __bt_plugin_component_class_descriptor_attribute const * const *cur_cc_descr_attr_ptr; @@ -356,7 +343,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, sizeof(struct comp_class_full_descriptor)); if (!comp_class_full_descriptors) { BT_LOGE_STR("Failed to allocate a GArray."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -418,7 +405,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cur_attr->type); if (fail_on_load_error) { - status = BT_PLUGIN_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_LOADING_ERROR; goto end; } @@ -689,7 +676,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cur_cc_descr_attr->type); if (fail_on_load_error) { - status = BT_PLUGIN_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_LOADING_ERROR; goto end; } @@ -700,22 +687,22 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, /* Initialize plugin */ if (spec->init) { - enum bt_self_plugin_status init_status; + enum bt_plugin_init_func_status init_status; BT_LOGD_STR("Calling user's plugin initialization function."); init_status = spec->init((void *) plugin); BT_LOGD("User function returned: status=%s", - bt_self_plugin_status_string(init_status)); + bt_common_func_status_string(init_status)); if (init_status < 0) { BT_LOG_WRITE(fail_on_load_error ? BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG, "User's plugin initialization function failed: " "status=%s", - bt_self_plugin_status_string(init_status)); + bt_common_func_status_string(init_status)); if (fail_on_load_error) { - status = (int) init_status; + status = init_status; goto end; } } @@ -782,7 +769,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->descriptor->type); if (fail_on_load_error) { - status = BT_PLUGIN_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_LOADING_ERROR; goto end; } @@ -791,7 +778,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, if (!comp_class) { BT_LOGE_STR("Cannot create component class."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -800,7 +787,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, comp_class, cc_full_descr->description); if (ret) { BT_LOGE_STR("Cannot set component class's description."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } @@ -811,7 +798,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->help); if (ret) { BT_LOGE_STR("Cannot set component class's help string."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } @@ -825,7 +812,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.init); if (ret) { BT_LOGE_STR("Cannot set source component class's initialization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -837,7 +824,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.finalize); if (ret) { BT_LOGE_STR("Cannot set source component class's finalization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -849,7 +836,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.query); if (ret) { BT_LOGE_STR("Cannot set source component class's query method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -861,7 +848,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.output_port_connected); if (ret) { BT_LOGE_STR("Cannot set source component class's \"output port connected\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -873,7 +860,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.msg_iter_init); if (ret) { BT_LOGE_STR("Cannot set source component class's message iterator initialization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -885,7 +872,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.msg_iter_finalize); if (ret) { BT_LOGE_STR("Cannot set source component class's message iterator finalization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -897,7 +884,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.msg_iter_seek_ns_from_origin); if (ret) { BT_LOGE_STR("Cannot set source component class's message iterator \"seek nanoseconds from origin\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -909,7 +896,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.msg_iter_seek_beginning); if (ret) { BT_LOGE_STR("Cannot set source component class's message iterator \"seek beginning\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -921,7 +908,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin); if (ret) { BT_LOGE_STR("Cannot set source component class's message iterator \"can seek nanoseconds from origin\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -933,7 +920,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.source.msg_iter_can_seek_beginning); if (ret) { BT_LOGE_STR("Cannot set source component class's message iterator \"can seek beginning\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } @@ -947,7 +934,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.init); if (ret) { BT_LOGE_STR("Cannot set filter component class's initialization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -959,7 +946,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.finalize); if (ret) { BT_LOGE_STR("Cannot set filter component class's finalization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -971,7 +958,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.query); if (ret) { BT_LOGE_STR("Cannot set filter component class's query method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -983,7 +970,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.input_port_connected); if (ret) { BT_LOGE_STR("Cannot set filter component class's \"input port connected\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -995,7 +982,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.output_port_connected); if (ret) { BT_LOGE_STR("Cannot set filter component class's \"output port connected\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -1007,7 +994,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.msg_iter_init); if (ret) { BT_LOGE_STR("Cannot set filter component class's message iterator initialization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -1019,7 +1006,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.msg_iter_finalize); if (ret) { BT_LOGE_STR("Cannot set filter component class's message iterator finalization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -1031,7 +1018,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin); if (ret) { BT_LOGE_STR("Cannot set filter component class's message iterator \"seek nanoseconds from origin\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -1043,7 +1030,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.msg_iter_seek_beginning); if (ret) { BT_LOGE_STR("Cannot set filter component class's message iterator \"seek beginning\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -1055,7 +1042,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin); if (ret) { BT_LOGE_STR("Cannot set filter component class's message iterator \"can seek nanoseconds from origin\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -1067,7 +1054,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.filter.msg_iter_can_seek_beginning); if (ret) { BT_LOGE_STR("Cannot set filter component class's message iterator \"can seek beginning\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } @@ -1081,7 +1068,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.sink.init); if (ret) { BT_LOGE_STR("Cannot set sink component class's initialization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class); goto end; } @@ -1093,7 +1080,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.sink.finalize); if (ret) { BT_LOGE_STR("Cannot set sink component class's finalization method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class); goto end; } @@ -1105,7 +1092,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.sink.query); if (ret) { BT_LOGE_STR("Cannot set sink component class's query method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class); goto end; } @@ -1117,7 +1104,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.sink.input_port_connected); if (ret) { BT_LOGE_STR("Cannot set sink component class's \"input port connected\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class); goto end; } @@ -1129,7 +1116,7 @@ enum bt_plugin_status bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->methods.sink.graph_is_configured); if (ret) { BT_LOGE_STR("Cannot set sink component class's \"graph is configured\" method."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class); goto end; } @@ -1211,7 +1198,7 @@ size_t count_non_null_items_in_section(const void *begin, const void *end) } static -enum bt_plugin_status bt_plugin_so_create_all_from_sections( +int bt_plugin_so_create_all_from_sections( struct bt_plugin_so_shared_lib_handle *shared_lib_handle, bool fail_on_load_error, struct __bt_plugin_descriptor const * const *descriptors_begin, @@ -1224,7 +1211,7 @@ enum bt_plugin_status bt_plugin_so_create_all_from_sections( struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_end, struct bt_plugin_set **plugin_set_out) { - enum bt_plugin_status status = BT_PLUGIN_STATUS_OK; + int status = BT_FUNC_STATUS_OK; size_t descriptor_count; size_t attrs_count; size_t cc_descriptors_count; @@ -1255,12 +1242,11 @@ enum bt_plugin_status bt_plugin_so_create_all_from_sections( *plugin_set_out = bt_plugin_set_create(); if (!*plugin_set_out) { BT_LOGE_STR("Cannot create empty plugin set."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto error; } for (i = 0; i < descriptors_end - descriptors_begin; i++) { - enum bt_plugin_status status; const struct __bt_plugin_descriptor *descriptor = descriptors_begin[i]; struct bt_plugin *plugin; @@ -1280,7 +1266,7 @@ enum bt_plugin_status bt_plugin_so_create_all_from_sections( descriptor->major); if (fail_on_load_error) { - status = BT_PLUGIN_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_LOADING_ERROR; goto error; } else { continue; @@ -1290,7 +1276,7 @@ enum bt_plugin_status bt_plugin_so_create_all_from_sections( plugin = bt_plugin_so_create_empty(shared_lib_handle); if (!plugin) { BT_LOGE_STR("Cannot create empty shared library handle."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto error; } @@ -1303,7 +1289,7 @@ enum bt_plugin_status bt_plugin_so_create_all_from_sections( descriptor, attrs_begin, attrs_end, cc_descriptors_begin, cc_descriptors_end, cc_descr_attrs_begin, cc_descr_attrs_end); - if (status == BT_PLUGIN_STATUS_OK) { + if (status == BT_FUNC_STATUS_OK) { /* Add to plugin set */ bt_plugin_set_add_plugin(*plugin_set_out, plugin); BT_OBJECT_PUT_REF_AND_RESET(plugin); @@ -1325,7 +1311,7 @@ enum bt_plugin_status bt_plugin_so_create_all_from_sections( if ((*plugin_set_out)->plugins->len == 0) { BT_OBJECT_PUT_REF_AND_RESET(*plugin_set_out); - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = BT_FUNC_STATUS_NOT_FOUND; } goto end; @@ -1339,18 +1325,17 @@ end: } BT_HIDDEN -enum bt_plugin_status bt_plugin_so_create_all_from_static( - bool fail_on_load_error, +int bt_plugin_so_create_all_from_static(bool fail_on_load_error, struct bt_plugin_set **plugin_set_out) { - enum bt_plugin_status status; + int status; struct bt_plugin_so_shared_lib_handle *shared_lib_handle = NULL; BT_ASSERT(plugin_set_out); *plugin_set_out = NULL; status = bt_plugin_so_shared_lib_handle_create(NULL, &shared_lib_handle); - if (status != BT_PLUGIN_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { BT_ASSERT(!shared_lib_handle); goto end; } @@ -1368,7 +1353,7 @@ enum bt_plugin_status bt_plugin_so_create_all_from_static( __bt_get_begin_section_component_class_descriptor_attributes(), __bt_get_end_section_component_class_descriptor_attributes(), plugin_set_out); - BT_ASSERT((status == BT_PLUGIN_STATUS_OK && *plugin_set_out && + BT_ASSERT((status == BT_FUNC_STATUS_OK && *plugin_set_out && (*plugin_set_out)->plugins->len > 0) || !*plugin_set_out); end: @@ -1377,11 +1362,11 @@ end: } BT_HIDDEN -enum bt_plugin_status bt_plugin_so_create_all_from_file(const char *path, +int bt_plugin_so_create_all_from_file(const char *path, bool fail_on_load_error, struct bt_plugin_set **plugin_set_out) { size_t path_len; - enum bt_plugin_status status; + int status; struct __bt_plugin_descriptor const * const *descriptors_begin = NULL; struct __bt_plugin_descriptor const * const *descriptors_end = NULL; struct __bt_plugin_descriptor_attribute const * const *attrs_begin = NULL; @@ -1424,13 +1409,13 @@ enum bt_plugin_status bt_plugin_so_create_all_from_file(const char *path, if (!is_shared_object && !is_libtool_wrapper) { /* Name indicates this is not a plugin file; not an error */ BT_LOGI("File is not an SO plugin file: path=\"%s\"", path); - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = BT_FUNC_STATUS_NOT_FOUND; goto end; } status = bt_plugin_so_shared_lib_handle_create(path, &shared_lib_handle); - if (status != BT_PLUGIN_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { /* bt_plugin_so_shared_lib_handle_create() logs more details */ BT_ASSERT(!shared_lib_handle); BT_LOGE_STR("Cannot create shared library handle."); @@ -1450,7 +1435,7 @@ enum bt_plugin_status bt_plugin_so_create_all_from_file(const char *path, BT_LOGI("Cannot resolve plugin symbol: path=\"%s\", " "symbol=\"%s\"", path, "__bt_get_begin_section_plugin_descriptors"); - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = BT_FUNC_STATUS_NOT_FOUND; goto end; } @@ -1467,8 +1452,8 @@ enum bt_plugin_status bt_plugin_so_create_all_from_file(const char *path, "Cannot resolve plugin symbol: path=\"%s\", " "symbol=\"%s\"", path, "__bt_get_end_section_plugin_descriptors"); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? BT_FUNC_STATUS_LOADING_ERROR : + BT_FUNC_STATUS_NOT_FOUND; goto end; } @@ -1500,8 +1485,8 @@ enum bt_plugin_status bt_plugin_so_create_all_from_file(const char *path, path, "__bt_get_begin_section_plugin_descriptor_attributes", "__bt_get_end_section_plugin_descriptor_attributes", attrs_begin, attrs_end); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? BT_FUNC_STATUS_LOADING_ERROR : + BT_FUNC_STATUS_NOT_FOUND; goto end; } @@ -1533,8 +1518,8 @@ enum bt_plugin_status bt_plugin_so_create_all_from_file(const char *path, path, "__bt_get_begin_section_component_class_descriptors", "__bt_get_end_section_component_class_descriptors", cc_descriptors_begin, cc_descriptors_end); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? BT_FUNC_STATUS_LOADING_ERROR : + BT_FUNC_STATUS_NOT_FOUND; goto end; } @@ -1566,8 +1551,8 @@ enum bt_plugin_status bt_plugin_so_create_all_from_file(const char *path, path, "__bt_get_begin_section_component_class_descriptor_attributes", "__bt_get_end_section_component_class_descriptor_attributes", cc_descr_attrs_begin, cc_descr_attrs_end); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? BT_FUNC_STATUS_LOADING_ERROR : + BT_FUNC_STATUS_NOT_FOUND; goto end; } diff --git a/src/lib/plugin/plugin-so.h b/src/lib/plugin/plugin-so.h index a2259c8b..0ceb40a6 100644 --- a/src/lib/plugin/plugin-so.h +++ b/src/lib/plugin/plugin-so.h @@ -53,12 +53,11 @@ struct bt_plugin_so_spec_data { }; BT_HIDDEN -enum bt_plugin_status bt_plugin_so_create_all_from_file(const char *path, +int bt_plugin_so_create_all_from_file(const char *path, bool fail_on_load_error, struct bt_plugin_set **plugin_set_out); BT_HIDDEN -enum bt_plugin_status bt_plugin_so_create_all_from_static( - bool fail_on_load_error, +int bt_plugin_so_create_all_from_static(bool fail_on_load_error, struct bt_plugin_set **plugin_set_out); void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin, diff --git a/src/lib/plugin/plugin.c b/src/lib/plugin/plugin.c index 1cef5123..36059c4a 100644 --- a/src/lib/plugin/plugin.c +++ b/src/lib/plugin/plugin.c @@ -46,6 +46,7 @@ #include "plugin.h" #include "plugin-so.h" +#include "lib/func-status.h" #define PYTHON_PLUGIN_PROVIDER_FILENAME "libbabeltrace2-python-plugin-provider." G_MODULE_SUFFIX #define PYTHON_PLUGIN_PROVIDER_SYM_NAME bt_plugin_python_create_all_from_file @@ -57,7 +58,7 @@ #include static -enum bt_plugin_status (*bt_plugin_python_create_all_from_file_sym)( +int (*bt_plugin_python_create_all_from_file_sym)( const char *path, bool fail_on_load_error, struct bt_plugin_set **plugin_set_out) = bt_plugin_python_create_all_from_file; @@ -70,8 +71,8 @@ void init_python_plugin_provider(void) static GModule *python_plugin_provider_module; static -enum bt_plugin_status (*bt_plugin_python_create_all_from_file_sym)( - const char *path, bool fail_on_load_error, +int (*bt_plugin_python_create_all_from_file_sym)( + const char *path, bool fail_on_load_error, struct bt_plugin_set **plugin_set_out); static @@ -144,7 +145,7 @@ const struct bt_plugin *bt_plugin_set_borrow_plugin_by_index_const( return g_ptr_array_index(plugin_set->plugins, index); } -enum bt_plugin_status bt_plugin_find_all_from_static( +enum bt_plugin_find_all_from_static_status bt_plugin_find_all_from_static( bt_bool fail_on_load_error, const struct bt_plugin_set **plugin_set_out) { @@ -153,11 +154,11 @@ enum bt_plugin_status bt_plugin_find_all_from_static( (void *) plugin_set_out); } -enum bt_plugin_status bt_plugin_find_all_from_file(const char *path, - bt_bool fail_on_load_error, +enum bt_plugin_find_all_from_file_status bt_plugin_find_all_from_file( + const char *path, bt_bool fail_on_load_error, const struct bt_plugin_set **plugin_set_out) { - enum bt_plugin_status status; + enum bt_plugin_find_all_from_file_status status; BT_ASSERT_PRE_NON_NULL(path, "Path"); BT_ASSERT_PRE_NON_NULL(path, "Plugin set (output)"); @@ -166,7 +167,7 @@ enum bt_plugin_status bt_plugin_find_all_from_file(const char *path, /* Try shared object plugins */ status = bt_plugin_so_create_all_from_file(path, fail_on_load_error, (void *) plugin_set_out); - if (status == BT_PLUGIN_STATUS_OK) { + if (status == BT_FUNC_STATUS_OK) { BT_ASSERT(*plugin_set_out); BT_ASSERT((*plugin_set_out)->plugins->len > 0); goto end; @@ -175,7 +176,7 @@ enum bt_plugin_status bt_plugin_find_all_from_file(const char *path, goto end; } - BT_ASSERT(status == BT_PLUGIN_STATUS_NOT_FOUND); + BT_ASSERT(status == BT_FUNC_STATUS_NOT_FOUND); BT_ASSERT(!*plugin_set_out); /* Try Python plugins if support is available */ @@ -183,7 +184,7 @@ enum bt_plugin_status bt_plugin_find_all_from_file(const char *path, if (bt_plugin_python_create_all_from_file_sym) { status = bt_plugin_python_create_all_from_file_sym(path, fail_on_load_error, (void *) plugin_set_out); - if (status == BT_PLUGIN_STATUS_OK) { + if (status == BT_FUNC_STATUS_OK) { BT_ASSERT(*plugin_set_out); BT_ASSERT((*plugin_set_out)->plugins->len > 0); goto end; @@ -192,18 +193,18 @@ enum bt_plugin_status bt_plugin_find_all_from_file(const char *path, goto end; } - BT_ASSERT(status == BT_PLUGIN_STATUS_NOT_FOUND); + BT_ASSERT(status == BT_FUNC_STATUS_NOT_FOUND); BT_ASSERT(!*plugin_set_out); } end: - if (status == BT_PLUGIN_STATUS_OK) { + if (status == BT_FUNC_STATUS_OK) { BT_LOGI("Created %u plugins from file: " "path=\"%s\", count=%u, plugin-set-addr=%p", (*plugin_set_out)->plugins->len, path, (*plugin_set_out)->plugins->len, *plugin_set_out); - } else if (status == BT_PLUGIN_STATUS_NOT_FOUND) { + } else if (status == BT_FUNC_STATUS_NOT_FOUND) { BT_LOGI("Found no plugins in file: path=\"%s\"", path); } @@ -215,7 +216,7 @@ static void destroy_gstring(void *data) g_string_free(data, TRUE); } -enum bt_plugin_status bt_plugin_find(const char *plugin_name, +enum bt_plugin_find_status bt_plugin_find(const char *plugin_name, bt_bool fail_on_load_error, const struct bt_plugin **plugin_out) { const char *system_plugin_dir; @@ -225,7 +226,7 @@ enum bt_plugin_status bt_plugin_find(const char *plugin_name, const struct bt_plugin_set *plugin_set = NULL; GPtrArray *dirs = NULL; int ret; - enum bt_plugin_status status = BT_PLUGIN_STATUS_OK; + int status = BT_FUNC_STATUS_OK; size_t i, j; BT_ASSERT_PRE_NON_NULL(plugin_name, "Name"); @@ -235,7 +236,7 @@ enum bt_plugin_status bt_plugin_find(const char *plugin_name, dirs = g_ptr_array_new_with_free_func((GDestroyNotify) destroy_gstring); if (!dirs) { BT_LOGE_STR("Failed to allocate a GPtrArray."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -258,7 +259,7 @@ enum bt_plugin_status bt_plugin_find(const char *plugin_name, ret = bt_common_append_plugin_path_dirs(envvar, dirs); if (ret) { BT_LOGE_STR("Failed to append plugin path to array of directories."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } } @@ -269,7 +270,7 @@ enum bt_plugin_status bt_plugin_find(const char *plugin_name, if (!home_plugin_dir_str) { BT_LOGE_STR("Failed to allocate a GString."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -283,7 +284,7 @@ enum bt_plugin_status bt_plugin_find(const char *plugin_name, if (!system_plugin_dir_str) { BT_LOGE_STR("Failed to allocate a GString."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -311,14 +312,14 @@ enum bt_plugin_status bt_plugin_find(const char *plugin_name, if (status < 0) { BT_ASSERT(!plugin_set); goto end; - } else if (status == BT_PLUGIN_STATUS_NOT_FOUND) { + } else if (status == BT_FUNC_STATUS_NOT_FOUND) { BT_ASSERT(!plugin_set); BT_LOGI("No plugins found in directory: path=\"%s\"", dir->str); continue; } - BT_ASSERT(status == BT_PLUGIN_STATUS_OK); + BT_ASSERT(status == BT_FUNC_STATUS_OK); BT_ASSERT(plugin_set); for (j = 0; j < plugin_set->plugins->len; j++) { @@ -345,15 +346,13 @@ enum bt_plugin_status bt_plugin_find(const char *plugin_name, if (status < 0) { BT_ASSERT(!plugin_set); goto end; - } - - if (status == BT_PLUGIN_STATUS_NOT_FOUND) { + } else if (status == BT_FUNC_STATUS_NOT_FOUND) { BT_ASSERT(!plugin_set); BT_LOGI_STR("No plugins found in built-in plugins."); goto end; } - BT_ASSERT(status == BT_PLUGIN_STATUS_OK); + BT_ASSERT(status == BT_FUNC_STATUS_OK); BT_ASSERT(plugin_set); for (j = 0; j < plugin_set->plugins->len; j++) { @@ -370,7 +369,7 @@ enum bt_plugin_status bt_plugin_find(const char *plugin_name, } } - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = BT_FUNC_STATUS_NOT_FOUND; end: free(home_plugin_dir); @@ -380,10 +379,10 @@ end: g_ptr_array_free(dirs, TRUE); } - if (status == BT_PLUGIN_STATUS_OK) { + if (status == BT_FUNC_STATUS_OK) { BT_LIB_LOGI("Found plugin in standard directories and built-in plugins: " "%!+l", plugin); - } else if (status == BT_PLUGIN_STATUS_NOT_FOUND) { + } else if (status == BT_FUNC_STATUS_NOT_FOUND) { BT_LOGI("No plugin found in standard directories and built-in plugins: " "name=\"%s\"", plugin_name); } @@ -396,7 +395,7 @@ static struct { struct bt_plugin_set *plugin_set; bool recurse; bool fail_on_load_error; - enum bt_plugin_status status; + int status; } append_all_from_dir_info = { .lock = PTHREAD_MUTEX_INITIALIZER }; @@ -428,7 +427,7 @@ int nftw_append_all_from_dir(const char *file, bt_plugin_find_all_from_file(file, append_all_from_dir_info.fail_on_load_error, &plugins_from_file); - if (append_all_from_dir_info.status == BT_PLUGIN_STATUS_OK) { + if (append_all_from_dir_info.status == BT_FUNC_STATUS_OK) { size_t j; BT_ASSERT(plugins_from_file); @@ -460,7 +459,7 @@ int nftw_append_all_from_dir(const char *file, */ BT_ASSERT(!plugins_from_file); BT_ASSERT(append_all_from_dir_info.status == - BT_PLUGIN_STATUS_NOT_FOUND); + BT_FUNC_STATUS_NOT_FOUND); break; } case FTW_DNR: @@ -478,13 +477,12 @@ end: } static -enum bt_plugin_status bt_plugin_create_append_all_from_dir( - struct bt_plugin_set *plugin_set, const char *path, - bt_bool recurse, bt_bool fail_on_load_error) +int bt_plugin_create_append_all_from_dir(struct bt_plugin_set *plugin_set, + const char *path, bt_bool recurse, bt_bool fail_on_load_error) { int nftw_flags = FTW_PHYS; int ret; - enum bt_plugin_status status; + int status; struct stat sb; BT_ASSERT(plugin_set); @@ -503,14 +501,14 @@ enum bt_plugin_status bt_plugin_create_append_all_from_dir( BT_LOGW_ERRNO("Cannot open directory", ": path=\"%s\", recurse=%d", path, recurse); - status = BT_PLUGIN_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } pthread_mutex_lock(&append_all_from_dir_info.lock); append_all_from_dir_info.plugin_set = plugin_set; append_all_from_dir_info.recurse = recurse; - append_all_from_dir_info.status = BT_PLUGIN_STATUS_OK; + append_all_from_dir_info.status = BT_FUNC_STATUS_OK; append_all_from_dir_info.fail_on_load_error = fail_on_load_error; ret = nftw(path, nftw_append_all_from_dir, APPEND_ALL_FROM_DIR_NFDOPEN_MAX, nftw_flags); @@ -521,28 +519,29 @@ enum bt_plugin_status bt_plugin_create_append_all_from_dir( BT_LOGW_ERRNO("Failed to walk directory", ": path=\"%s\", recurse=%d", path, recurse); - status = BT_PLUGIN_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } - if (status == BT_PLUGIN_STATUS_NOT_FOUND) { + if (status == BT_FUNC_STATUS_NOT_FOUND) { /* * We're just appending in this function; even if * nothing was found, it's still okay from the caller's * perspective. */ - status = BT_PLUGIN_STATUS_OK; + status = BT_FUNC_STATUS_OK; } end: return status; } -enum bt_plugin_status bt_plugin_find_all_from_dir(const char *path, - bt_bool recurse, bt_bool fail_on_load_error, +enum bt_plugin_find_all_from_dir_status bt_plugin_find_all_from_dir( + const char *path, bt_bool recurse, bt_bool fail_on_load_error, const struct bt_plugin_set **plugin_set_out) { - enum bt_plugin_status status = BT_PLUGIN_STATUS_OK; + enum bt_plugin_find_all_from_dir_status status = + BT_FUNC_STATUS_OK; BT_ASSERT_PRE_NON_NULL(plugin_set_out, "Plugin set (output)"); BT_LOGI("Creating all plugins in directory: path=\"%s\", recurse=%d", @@ -550,13 +549,13 @@ enum bt_plugin_status bt_plugin_find_all_from_dir(const char *path, *plugin_set_out = bt_plugin_set_create(); if (!*plugin_set_out) { BT_LOGE_STR("Cannot create empty plugin set."); - status = BT_PLUGIN_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto error; } /* * Append found plugins to array (never returns - * `BT_PLUGIN_STATUS_NOT_FOUND`) + * `BT_FUNC_STATUS_NOT_FOUND`) */ status = bt_plugin_create_append_all_from_dir((void *) *plugin_set_out, path, recurse, fail_on_load_error); @@ -567,16 +566,16 @@ enum bt_plugin_status bt_plugin_find_all_from_dir(const char *path, */ BT_LOGW("Cannot append plugins found in directory: " "path=\"%s\", status=%s", - path, bt_plugin_status_string(status)); + path, bt_common_func_status_string(status)); goto error; } - BT_ASSERT(status == BT_PLUGIN_STATUS_OK); + BT_ASSERT(status == BT_FUNC_STATUS_OK); if ((*plugin_set_out)->plugins->len == 0) { /* Nothing was appended: not found */ BT_LOGI("No plugins found in directory: path=\"%s\"", path); - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -586,7 +585,7 @@ enum bt_plugin_status bt_plugin_find_all_from_dir(const char *path, goto end; error: - BT_ASSERT(status != BT_PLUGIN_STATUS_OK); + BT_ASSERT(status != BT_FUNC_STATUS_OK); BT_OBJECT_PUT_REF_AND_RESET(*plugin_set_out); end: diff --git a/src/lib/plugin/plugin.h b/src/lib/plugin/plugin.h index 46b2b117..202c69be 100644 --- a/src/lib/plugin/plugin.h +++ b/src/lib/plugin/plugin.h @@ -34,6 +34,7 @@ #include #include "plugin-so.h" +#include "lib/func-status.h" /* Protection: this file uses BT_LIB_LOG*() macros directly */ #ifndef BT_LIB_LOG_SUPPORTED @@ -87,25 +88,6 @@ struct bt_plugin_set { GPtrArray *plugins; }; -static inline -const char *bt_plugin_status_string(enum bt_plugin_status status) -{ - switch (status) { - case BT_PLUGIN_STATUS_OK: - return "BT_PLUGIN_STATUS_OK"; - case BT_PLUGIN_STATUS_NOT_FOUND: - return "BT_PLUGIN_STATUS_NOT_FOUND"; - case BT_PLUGIN_STATUS_ERROR: - return "BT_PLUGIN_STATUS_ERROR"; - case BT_PLUGIN_STATUS_LOADING_ERROR: - return "BT_PLUGIN_STATUS_LOADING_ERROR"; - case BT_PLUGIN_STATUS_NOMEM: - return "BT_PLUGIN_STATUS_NOMEM"; - default: - return "(unknown)"; - } -} - static inline const char *bt_plugin_type_string(enum bt_plugin_type type) { @@ -347,7 +329,7 @@ void bt_plugin_set_version(struct bt_plugin *plugin, unsigned int major, } static inline -enum bt_plugin_status bt_plugin_add_component_class( +int bt_plugin_add_component_class( struct bt_plugin *plugin, struct bt_component_class *comp_class) { GPtrArray *comp_classes; @@ -380,7 +362,7 @@ enum bt_plugin_status bt_plugin_add_component_class( BT_LIB_LOGD("Added component class to plugin: " "%![plugin-]+l, %![cc-]+C", plugin, comp_class); - return BT_PLUGIN_STATUS_OK; + return BT_FUNC_STATUS_OK; } static diff --git a/src/lib/trace-ir/clock-class.c b/src/lib/trace-ir/clock-class.c index e84a41b5..fdeef928 100644 --- a/src/lib/trace-ir/clock-class.c +++ b/src/lib/trace-ir/clock-class.c @@ -37,6 +37,7 @@ #include #include "lib/object.h" #include "common/assert.h" +#include "lib/func-status.h" #define BT_ASSERT_PRE_CLOCK_CLASS_HOT(_cc) \ BT_ASSERT_PRE_HOT((_cc), "Clock class", ": %!+K", (_cc)) @@ -136,7 +137,7 @@ const char *bt_clock_class_get_name(const struct bt_clock_class *clock_class) return clock_class->name.value; } -enum bt_clock_class_status bt_clock_class_set_name( +enum bt_clock_class_set_name_status bt_clock_class_set_name( struct bt_clock_class *clock_class, const char *name) { BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); @@ -145,7 +146,7 @@ enum bt_clock_class_status bt_clock_class_set_name( g_string_assign(clock_class->name.str, name); clock_class->name.value = clock_class->name.str->str; BT_LIB_LOGD("Set clock class's name: %!+K", clock_class); - return BT_CLOCK_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } const char *bt_clock_class_get_description( @@ -155,7 +156,7 @@ const char *bt_clock_class_get_description( return clock_class->description.value; } -enum bt_clock_class_status bt_clock_class_set_description( +enum bt_clock_class_set_description_status bt_clock_class_set_description( struct bt_clock_class *clock_class, const char *descr) { BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); @@ -165,7 +166,7 @@ enum bt_clock_class_status bt_clock_class_set_description( clock_class->description.value = clock_class->description.str->str; BT_LIB_LOGD("Set clock class's description: %!+K", clock_class); - return BT_CLOCK_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } uint64_t bt_clock_class_get_frequency(const struct bt_clock_class *clock_class) @@ -278,7 +279,8 @@ void _bt_clock_class_freeze(const struct bt_clock_class *clock_class) ((struct bt_clock_class *) clock_class)->frozen = 1; } -enum bt_clock_class_status bt_clock_class_cycles_to_ns_from_origin( +enum bt_clock_class_cycles_to_ns_from_origin_status +bt_clock_class_cycles_to_ns_from_origin( const struct bt_clock_class *clock_class, uint64_t cycles, int64_t *ns) { @@ -288,7 +290,7 @@ enum bt_clock_class_status bt_clock_class_cycles_to_ns_from_origin( BT_ASSERT_PRE_NON_NULL(ns, "Nanoseconds (output)"); ret = bt_util_ns_from_origin_clock_class(clock_class, cycles, ns); if (ret) { - ret = BT_CLOCK_CLASS_STATUS_OVERFLOW; + ret = BT_FUNC_STATUS_OVERFLOW; BT_LIB_LOGD("Cannot convert cycles to nanoseconds " "from origin for given clock class: " "value overflows the signed 64-bit integer range: " diff --git a/src/lib/trace-ir/clock-class.h b/src/lib/trace-ir/clock-class.h index 4cbf77ea..153456dd 100644 --- a/src/lib/trace-ir/clock-class.h +++ b/src/lib/trace-ir/clock-class.h @@ -37,6 +37,8 @@ #include #include +#include "lib/func-status.h" + struct bt_clock_class { struct bt_object base; @@ -113,7 +115,7 @@ int bt_clock_class_clock_value_from_ns_from_origin( return bt_common_clock_value_from_ns_from_origin(cc->offset_seconds, cc->offset_cycles, cc->frequency, ns_from_origin, - raw_value); + raw_value) ? BT_FUNC_STATUS_OVERFLOW : BT_FUNC_STATUS_OK; } #endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H */ diff --git a/src/lib/trace-ir/clock-snapshot.c b/src/lib/trace-ir/clock-snapshot.c index 944532a2..757e1cb8 100644 --- a/src/lib/trace-ir/clock-snapshot.c +++ b/src/lib/trace-ir/clock-snapshot.c @@ -34,6 +34,7 @@ #include #include "lib/object.h" #include "common/assert.h" +#include "lib/func-status.h" BT_HIDDEN void bt_clock_snapshot_destroy(struct bt_clock_snapshot *clock_snapshot) @@ -146,11 +147,12 @@ uint64_t bt_clock_snapshot_get_value( return clock_snapshot->value_cycles; } -enum bt_clock_snapshot_status bt_clock_snapshot_get_ns_from_origin( +enum bt_clock_snapshot_get_ns_from_origin_status +bt_clock_snapshot_get_ns_from_origin( const struct bt_clock_snapshot *clock_snapshot, int64_t *ret_value_ns) { - int ret = BT_CLOCK_SNAPSHOT_STATUS_OK; + int ret = BT_FUNC_STATUS_OK; BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot"); BT_ASSERT_PRE_NON_NULL(ret_value_ns, "Value (ns) (output)"); @@ -161,7 +163,7 @@ enum bt_clock_snapshot_status bt_clock_snapshot_get_ns_from_origin( BT_LIB_LOGD("Clock snapshot, once converted to nanoseconds from origin, " "overflows the signed 64-bit integer range: " "%![cs-]+k", clock_snapshot); - ret = BT_CLOCK_SNAPSHOT_STATUS_OVERFLOW; + ret = BT_FUNC_STATUS_OVERFLOW; goto end; } diff --git a/src/lib/trace-ir/event-class.c b/src/lib/trace-ir/event-class.c index 63a250bb..49ff7ff6 100644 --- a/src/lib/trace-ir/event-class.c +++ b/src/lib/trace-ir/event-class.c @@ -47,6 +47,7 @@ #include "stream-class.h" #include "trace.h" #include "utils.h" +#include "lib/func-status.h" #define BT_ASSERT_PRE_EVENT_CLASS_HOT(_ec) \ BT_ASSERT_PRE_HOT(((const struct bt_event_class *) (_ec)), \ @@ -193,7 +194,7 @@ const char *bt_event_class_get_name(const struct bt_event_class *event_class) return event_class->name.value; } -enum bt_event_class_status bt_event_class_set_name( +enum bt_event_class_set_name_status bt_event_class_set_name( struct bt_event_class *event_class, const char *name) { BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); @@ -202,7 +203,7 @@ enum bt_event_class_status bt_event_class_set_name( g_string_assign(event_class->name.str, name); event_class->name.value = event_class->name.str->str; BT_LIB_LOGD("Set event class's name: %!+E", event_class); - return BT_EVENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } uint64_t bt_event_class_get_id(const struct bt_event_class *event_class) @@ -239,7 +240,7 @@ const char *bt_event_class_get_emf_uri(const struct bt_event_class *event_class) return event_class->emf_uri.value; } -enum bt_event_class_status bt_event_class_set_emf_uri( +enum bt_event_class_set_emf_uri_status bt_event_class_set_emf_uri( struct bt_event_class *event_class, const char *emf_uri) { @@ -249,7 +250,7 @@ enum bt_event_class_status bt_event_class_set_emf_uri( g_string_assign(event_class->emf_uri.str, emf_uri); event_class->emf_uri.value = event_class->emf_uri.str->str; BT_LIB_LOGD("Set event class's EMF URI: %!+E", event_class); - return BT_EVENT_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } struct bt_stream_class *bt_event_class_borrow_stream_class( @@ -282,7 +283,8 @@ bt_event_class_borrow_specific_context_field_class( return event_class->specific_context_fc; } -enum bt_event_class_status bt_event_class_set_specific_context_field_class( +enum bt_event_class_set_field_class_status +bt_event_class_set_specific_context_field_class( struct bt_event_class *event_class, struct bt_field_class *field_class) { @@ -315,7 +317,7 @@ enum bt_event_class_status bt_event_class_set_specific_context_field_class( * bt_resolve_field_paths() can fail: anything else * would be because a precondition is not satisfied. */ - ret = BT_EVENT_CLASS_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -345,7 +347,8 @@ struct bt_field_class *bt_event_class_borrow_payload_field_class( return event_class->payload_fc; } -enum bt_event_class_status bt_event_class_set_payload_field_class( +enum bt_event_class_set_field_class_status +bt_event_class_set_payload_field_class( struct bt_event_class *event_class, struct bt_field_class *field_class) { @@ -379,7 +382,7 @@ enum bt_event_class_status bt_event_class_set_payload_field_class( * bt_resolve_field_paths() can fail: anything else * would be because a precondition is not satisfied. */ - ret = BT_EVENT_CLASS_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } diff --git a/src/lib/trace-ir/field-class.c b/src/lib/trace-ir/field-class.c index 3f658a51..30a1444c 100644 --- a/src/lib/trace-ir/field-class.c +++ b/src/lib/trace-ir/field-class.c @@ -44,6 +44,7 @@ #include "field.h" #include "field-path.h" #include "utils.h" +#include "lib/func-status.h" enum bt_field_class_type bt_field_class_get_type( const struct bt_field_class *fc) @@ -365,7 +366,7 @@ void bt_field_class_signed_enumeration_mapping_get_range_by_index( (uint64_t *) lower, (uint64_t *) upper); } -enum bt_field_class_status +enum bt_field_class_enumeration_get_mapping_labels_by_value_status bt_field_class_unsigned_enumeration_get_mapping_labels_by_value( const struct bt_field_class *fc, uint64_t value, bt_field_class_enumeration_mapping_label_array *label_array, @@ -402,10 +403,10 @@ bt_field_class_unsigned_enumeration_get_mapping_labels_by_value( *label_array = (void *) enum_fc->label_buf->pdata; *count = (uint64_t) enum_fc->label_buf->len; - return BT_FIELD_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_field_class_status +enum bt_field_class_enumeration_get_mapping_labels_by_value_status bt_field_class_signed_enumeration_get_mapping_labels_by_value( const struct bt_field_class *fc, int64_t value, bt_field_class_enumeration_mapping_label_array *label_array, @@ -442,15 +443,16 @@ bt_field_class_signed_enumeration_get_mapping_labels_by_value( *label_array = (void *) enum_fc->label_buf->pdata; *count = (uint64_t) enum_fc->label_buf->len; - return BT_FIELD_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } static inline -enum bt_field_class_status add_mapping_to_enumeration_field_class( +enum bt_field_class_enumeration_map_range_status +add_mapping_to_enumeration_field_class( struct bt_field_class *fc, const char *label, uint64_t lower, uint64_t upper) { - int ret = BT_FIELD_CLASS_STATUS_OK; + int ret = BT_FUNC_STATUS_OK; uint64_t i; struct bt_field_class_enumeration *enum_fc = (void *) fc; struct bt_field_class_enumeration_mapping *mapping = NULL; @@ -481,7 +483,7 @@ enum bt_field_class_status add_mapping_to_enumeration_field_class( finalize_enumeration_field_class_mapping(mapping); g_array_set_size(enum_fc->mappings, enum_fc->mappings->len - 1); - ret = BT_FIELD_CLASS_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -490,7 +492,7 @@ enum bt_field_class_status add_mapping_to_enumeration_field_class( finalize_enumeration_field_class_mapping(mapping); g_array_set_size(enum_fc->mappings, enum_fc->mappings->len - 1); - ret = BT_FIELD_CLASS_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } } @@ -510,7 +512,7 @@ end: return ret; } -enum bt_field_class_status bt_field_class_unsigned_enumeration_map_range( +enum bt_field_class_enumeration_map_range_status bt_field_class_unsigned_enumeration_map_range( struct bt_field_class *fc, const char *label, uint64_t range_lower, uint64_t range_upper) { @@ -535,7 +537,7 @@ enum bt_field_class_status bt_field_class_unsigned_enumeration_map_range( range_upper); } -enum bt_field_class_status bt_field_class_signed_enumeration_map_range( +enum bt_field_class_enumeration_map_range_status bt_field_class_signed_enumeration_map_range( struct bt_field_class *fc, const char *label, int64_t range_lower, int64_t range_upper) { @@ -722,11 +724,11 @@ end: } static -enum bt_field_class_status append_named_field_class_to_container_field_class( +int append_named_field_class_to_container_field_class( struct bt_field_class_named_field_class_container *container_fc, const char *name, struct bt_field_class *fc) { - int ret = BT_FIELD_CLASS_STATUS_OK; + int ret = BT_FUNC_STATUS_OK; struct bt_named_field_class *named_fc; GString *name_str; @@ -741,7 +743,7 @@ enum bt_field_class_status append_named_field_class_to_container_field_class( name_str = g_string_new(name); if (!name_str) { BT_LOGE_STR("Failed to allocate a GString."); - ret = BT_FIELD_CLASS_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -766,7 +768,8 @@ end: return ret; } -enum bt_field_class_status bt_field_class_structure_append_member( +enum bt_field_class_structure_append_member_status +bt_field_class_structure_append_member( struct bt_field_class *fc, const char *name, struct bt_field_class *member_fc) { @@ -946,7 +949,8 @@ end: return (void *) var_fc; } -enum bt_field_class_status bt_field_class_variant_set_selector_field_class( +enum bt_field_class_variant_set_selector_field_class_status +bt_field_class_variant_set_selector_field_class( struct bt_field_class *fc, struct bt_field_class *selector_fc) { @@ -960,10 +964,11 @@ enum bt_field_class_status bt_field_class_variant_set_selector_field_class( var_fc->selector_fc = selector_fc; bt_object_get_no_null_check(selector_fc); bt_field_class_freeze(selector_fc); - return BT_FIELD_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_field_class_status bt_field_class_variant_append_option( +enum bt_field_class_variant_append_option_status +bt_field_class_variant_append_option( struct bt_field_class *fc, const char *name, struct bt_field_class *option_fc) { @@ -1199,7 +1204,8 @@ end: return (void *) array_fc; } -enum bt_field_class_status bt_field_class_dynamic_array_set_length_field_class( +enum bt_field_class_dynamic_array_set_length_field_class_status +bt_field_class_dynamic_array_set_length_field_class( struct bt_field_class *fc, struct bt_field_class *length_fc) { @@ -1214,7 +1220,7 @@ enum bt_field_class_status bt_field_class_dynamic_array_set_length_field_class( array_fc->length_fc = length_fc; bt_object_get_no_null_check(length_fc); bt_field_class_freeze(length_fc); - return BT_FIELD_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } const struct bt_field_path * diff --git a/src/lib/trace-ir/field.c b/src/lib/trace-ir/field.c index 7dc4d90d..3f10d6ee 100644 --- a/src/lib/trace-ir/field.c +++ b/src/lib/trace-ir/field.c @@ -36,6 +36,7 @@ #include "field.h" #include "field-class.h" +#include "lib/func-status.h" static void reset_single_field(struct bt_field *field); @@ -559,7 +560,8 @@ void bt_field_real_set_value(struct bt_field *field, double value) bt_field_set_single(field, true); } -enum bt_field_status bt_field_unsigned_enumeration_get_mapping_labels( +enum bt_field_enumeration_get_mapping_labels_status +bt_field_unsigned_enumeration_get_mapping_labels( const struct bt_field *field, bt_field_class_enumeration_mapping_label_array *label_array, uint64_t *count) @@ -577,7 +579,8 @@ enum bt_field_status bt_field_unsigned_enumeration_get_mapping_labels( field->class, int_field->value.u, label_array, count); } -enum bt_field_status bt_field_signed_enumeration_get_mapping_labels( +enum bt_field_enumeration_get_mapping_labels_status +bt_field_signed_enumeration_get_mapping_labels( const struct bt_field *field, bt_field_class_enumeration_mapping_label_array *label_array, uint64_t *count) @@ -627,8 +630,8 @@ void clear_string_field(struct bt_field *field) bt_field_set_single(field, true); } -enum bt_field_status bt_field_string_set_value(struct bt_field *field, - const char *value) +enum bt_field_string_set_value_status bt_field_string_set_value( + struct bt_field *field, const char *value) { BT_ASSERT_PRE_NON_NULL(field, "Field"); BT_ASSERT_PRE_NON_NULL(value, "Value"); @@ -636,18 +639,19 @@ enum bt_field_status bt_field_string_set_value(struct bt_field *field, BT_ASSERT_PRE_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING, "Field"); clear_string_field(field); - return bt_field_string_append_with_length(field, value, + return (int) bt_field_string_append_with_length(field, value, (uint64_t) strlen(value)); } -enum bt_field_status bt_field_string_append(struct bt_field *field, const char *value) +enum bt_field_string_append_status bt_field_string_append( + struct bt_field *field, const char *value) { return bt_field_string_append_with_length(field, value, (uint64_t) strlen(value)); } -enum bt_field_status bt_field_string_append_with_length(struct bt_field *field, - const char *value, uint64_t length) +enum bt_field_string_append_status bt_field_string_append_with_length( + struct bt_field *field, const char *value, uint64_t length) { struct bt_field_string *string_field = (void *) field; char *data; @@ -675,17 +679,16 @@ enum bt_field_status bt_field_string_append_with_length(struct bt_field *field, ((char *) string_field->buf->data)[new_length] = '\0'; string_field->length = new_length; bt_field_set_single(field, true); - return BT_FIELD_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_field_status bt_field_string_clear(struct bt_field *field) +void bt_field_string_clear(struct bt_field *field) { BT_ASSERT_PRE_NON_NULL(field, "Field"); BT_ASSERT_PRE_FIELD_HOT(field, "Field"); BT_ASSERT_PRE_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING, "Field"); clear_string_field(field); - return BT_FIELD_STATUS_OK; } uint64_t bt_field_array_get_length(const struct bt_field *field) @@ -697,10 +700,10 @@ uint64_t bt_field_array_get_length(const struct bt_field *field) return array_field->length; } -enum bt_field_status bt_field_dynamic_array_set_length(struct bt_field *field, - uint64_t length) +enum bt_field_dynamic_array_set_length_status bt_field_dynamic_array_set_length( + struct bt_field *field, uint64_t length) { - int ret = BT_FIELD_STATUS_OK; + int ret = BT_FUNC_STATUS_OK; struct bt_field_array *array_field = (void *) field; BT_ASSERT_PRE_NON_NULL(field, "Field"); @@ -726,7 +729,7 @@ enum bt_field_status bt_field_dynamic_array_set_length(struct bt_field *field, "dynamic array field: " "index=%" PRIu64 ", " "%![array-field-]+f", i, field); - ret = BT_FIELD_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -861,7 +864,8 @@ const struct bt_field *bt_field_variant_borrow_selected_option_field_const( return borrow_variant_field_selected_option_field((void *) field); } -enum bt_field_status bt_field_variant_select_option_field( +enum bt_field_variant_select_option_field_status +bt_field_variant_select_option_field( struct bt_field *field, uint64_t index) { struct bt_field_variant *var_field = (void *) field; @@ -873,7 +877,7 @@ enum bt_field_status bt_field_variant_select_option_field( BT_ASSERT_PRE_VALID_INDEX(index, var_field->fields->len); var_field->selected_field = var_field->fields->pdata[index]; var_field->selected_index = index; - return BT_FIELD_STATUS_OK; + return BT_FUNC_STATUS_OK; } uint64_t bt_field_variant_get_selected_option_field_index( diff --git a/src/lib/trace-ir/packet.c b/src/lib/trace-ir/packet.c index a9c4ea9e..d32da65a 100644 --- a/src/lib/trace-ir/packet.c +++ b/src/lib/trace-ir/packet.c @@ -39,6 +39,7 @@ #include "stream-class.h" #include "stream.h" #include "trace.h" +#include "lib/func-status.h" #define BT_ASSERT_PRE_PACKET_HOT(_packet) \ BT_ASSERT_PRE_HOT((_packet), "Packet", ": %!+a", (_packet)) @@ -236,7 +237,8 @@ end: return (void *) packet; } -enum bt_packet_status bt_packet_move_context_field(struct bt_packet *packet, +enum bt_packet_move_context_field_status bt_packet_move_context_field( + struct bt_packet *packet, struct bt_packet_context_field *context_field) { struct bt_stream_class *stream_class; @@ -261,7 +263,7 @@ enum bt_packet_status bt_packet_move_context_field(struct bt_packet *packet, /* Move new field */ packet->context_field = field_wrapper; - return BT_PACKET_STATUS_OK; + return BT_FUNC_STATUS_OK; } void bt_packet_get_ref(const struct bt_packet *packet) diff --git a/src/lib/trace-ir/stream-class.c b/src/lib/trace-ir/stream-class.c index b1a528ef..7abea884 100644 --- a/src/lib/trace-ir/stream-class.c +++ b/src/lib/trace-ir/stream-class.c @@ -44,6 +44,7 @@ #include "stream-class.h" #include "trace.h" #include "utils.h" +#include "lib/func-status.h" #define BT_ASSERT_PRE_STREAM_CLASS_HOT(_sc) \ BT_ASSERT_PRE_HOT((_sc), "Stream class", ": %!+S", (_sc)) @@ -205,7 +206,7 @@ const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class) return stream_class->name.value; } -enum bt_stream_class_status bt_stream_class_set_name( +enum bt_stream_class_set_name_status bt_stream_class_set_name( struct bt_stream_class *stream_class, const char *name) { @@ -215,7 +216,7 @@ enum bt_stream_class_status bt_stream_class_set_name( g_string_assign(stream_class->name.str, name); stream_class->name.value = stream_class->name.str->str; BT_LIB_LOGD("Set stream class's name: %!+S", stream_class); - return BT_STREAM_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } uint64_t bt_stream_class_get_id(const struct bt_stream_class *stream_class) @@ -293,7 +294,8 @@ bt_stream_class_borrow_packet_context_field_class( return stream_class->packet_context_fc; } -enum bt_stream_class_status bt_stream_class_set_packet_context_field_class( +enum bt_stream_class_set_field_class_status +bt_stream_class_set_packet_context_field_class( struct bt_stream_class *stream_class, struct bt_field_class *field_class) { @@ -319,7 +321,7 @@ enum bt_stream_class_status bt_stream_class_set_packet_context_field_class( * bt_resolve_field_paths() can fail: anything else * would be because a precondition is not satisfied. */ - ret = BT_STREAM_CLASS_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -351,7 +353,7 @@ bt_stream_class_borrow_event_common_context_field_class( return stream_class->event_common_context_fc; } -enum bt_stream_class_status +enum bt_stream_class_set_field_class_status bt_stream_class_set_event_common_context_field_class( struct bt_stream_class *stream_class, struct bt_field_class *field_class) @@ -379,7 +381,7 @@ bt_stream_class_set_event_common_context_field_class( * bt_resolve_field_paths() can fail: anything else * would be because a precondition is not satisfied. */ - ret = BT_STREAM_CLASS_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -404,7 +406,8 @@ void _bt_stream_class_freeze(const struct bt_stream_class *stream_class) ((struct bt_stream_class *) stream_class)->frozen = true; } -enum bt_stream_class_status bt_stream_class_set_default_clock_class( +enum bt_stream_class_set_default_clock_class_status +bt_stream_class_set_default_clock_class( struct bt_stream_class *stream_class, struct bt_clock_class *clock_class) { @@ -417,7 +420,7 @@ enum bt_stream_class_status bt_stream_class_set_default_clock_class( bt_clock_class_freeze(clock_class); BT_LIB_LOGD("Set stream class's default clock class: %!+S", stream_class); - return BT_STREAM_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } struct bt_clock_class *bt_stream_class_borrow_default_clock_class( diff --git a/src/lib/trace-ir/stream.c b/src/lib/trace-ir/stream.c index 7eb8e9cf..19041437 100644 --- a/src/lib/trace-ir/stream.c +++ b/src/lib/trace-ir/stream.c @@ -40,6 +40,7 @@ #include "stream-class.h" #include "stream.h" #include "trace.h" +#include "lib/func-status.h" #define BT_ASSERT_PRE_STREAM_HOT(_stream) \ BT_ASSERT_PRE_HOT((_stream), "Stream", ": %!+s", (_stream)) @@ -206,7 +207,7 @@ const char *bt_stream_get_name(const struct bt_stream *stream) return stream->name.value; } -enum bt_stream_status bt_stream_set_name(struct bt_stream *stream, +enum bt_stream_set_name_status bt_stream_set_name(struct bt_stream *stream, const char *name) { BT_ASSERT_PRE_NON_NULL(stream, "Stream"); @@ -215,7 +216,7 @@ enum bt_stream_status bt_stream_set_name(struct bt_stream *stream, g_string_assign(stream->name.str, name); stream->name.value = stream->name.str->str; BT_LIB_LOGD("Set stream's name: %!+s", stream); - return BT_STREAM_STATUS_OK; + return BT_FUNC_STATUS_OK; } uint64_t bt_stream_get_id(const struct bt_stream *stream) diff --git a/src/lib/trace-ir/trace-class.c b/src/lib/trace-ir/trace-class.c index bd8ff19f..a78c42a0 100644 --- a/src/lib/trace-ir/trace-class.c +++ b/src/lib/trace-ir/trace-class.c @@ -54,6 +54,7 @@ #include "stream.h" #include "trace.h" #include "utils.h" +#include "lib/func-status.h" struct bt_trace_class_destruction_listener_elem { bt_trace_class_destruction_listener_func func; @@ -187,7 +188,7 @@ const char *bt_trace_class_get_name(const struct bt_trace_class *tc) return tc->name.value; } -enum bt_trace_class_status bt_trace_class_set_name( +enum bt_trace_class_set_name_status bt_trace_class_set_name( struct bt_trace_class *tc, const char *name) { BT_ASSERT_PRE_NON_NULL(tc, "Trace class"); @@ -196,7 +197,7 @@ enum bt_trace_class_status bt_trace_class_set_name( g_string_assign(tc->name.str, name); tc->name.value = tc->name.str->str; BT_LIB_LOGD("Set trace class's name: %!+T", tc); - return BT_TRACE_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } bt_uuid bt_trace_class_get_uuid(const struct bt_trace_class *tc) @@ -215,7 +216,7 @@ void bt_trace_class_set_uuid(struct bt_trace_class *tc, bt_uuid uuid) BT_LIB_LOGD("Set trace class's UUID: %!+T", tc); } -enum bt_trace_class_status bt_trace_class_add_destruction_listener( +enum bt_trace_class_add_listener_status bt_trace_class_add_destruction_listener( const struct bt_trace_class *_tc, bt_trace_class_destruction_listener_func listener, void *data, uint64_t *listener_id) @@ -253,7 +254,7 @@ enum bt_trace_class_status bt_trace_class_add_destruction_listener( BT_LIB_LOGD("Added trace class destruction listener: %![tc-]+T, " "listener-id=%" PRIu64, tc, i); - return BT_TRACE_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } BT_ASSERT_PRE_FUNC @@ -266,7 +267,7 @@ bool has_listener_id(const struct bt_trace_class *tc, uint64_t listener_id) listener_id))->func != NULL; } -enum bt_trace_class_status bt_trace_class_remove_destruction_listener( +enum bt_trace_class_remove_listener_status bt_trace_class_remove_destruction_listener( const struct bt_trace_class *_tc, uint64_t listener_id) { struct bt_trace_class *tc = (void *) _tc; @@ -286,7 +287,7 @@ enum bt_trace_class_status bt_trace_class_remove_destruction_listener( BT_LIB_LOGD("Removed trace class destruction listener: " "%![tc-]+T, listener-id=%" PRIu64, tc, listener_id); - return BT_TRACE_CLASS_STATUS_OK; + return BT_FUNC_STATUS_OK; } BT_ASSERT_FUNC @@ -300,7 +301,8 @@ bool trace_has_environment_entry(const struct bt_trace_class *tc, const char *na } static -enum bt_trace_class_status set_environment_entry(struct bt_trace_class *tc, +enum bt_trace_class_set_environment_entry_status set_environment_entry( + struct bt_trace_class *tc, const char *name, struct bt_value *value) { int ret; @@ -315,7 +317,7 @@ enum bt_trace_class_status set_environment_entry(struct bt_trace_class *tc, ret = bt_attributes_set_field_value(tc->environment, name, value); if (ret) { - ret = BT_TRACE_CLASS_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; BT_LIB_LOGE("Cannot set trace class's environment entry: " "%![tc-]+T, entry-name=\"%s\"", tc, name); } else { @@ -327,7 +329,8 @@ enum bt_trace_class_status set_environment_entry(struct bt_trace_class *tc, return ret; } -enum bt_trace_class_status bt_trace_class_set_environment_entry_string( +enum bt_trace_class_set_environment_entry_status +bt_trace_class_set_environment_entry_string( struct bt_trace_class *tc, const char *name, const char *value) { int ret; @@ -350,7 +353,8 @@ end: return ret; } -enum bt_trace_class_status bt_trace_class_set_environment_entry_integer( +enum bt_trace_class_set_environment_entry_status +bt_trace_class_set_environment_entry_integer( struct bt_trace_class *tc, const char *name, int64_t value) { int ret; @@ -360,7 +364,7 @@ enum bt_trace_class_status bt_trace_class_set_environment_entry_integer( value_obj = bt_value_signed_integer_create_init(value); if (!value_obj) { BT_LOGE_STR("Cannot create an integer value object."); - ret = BT_TRACE_CLASS_STATUS_NOMEM; + ret = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } diff --git a/src/lib/trace-ir/trace.c b/src/lib/trace-ir/trace.c index 3c030838..fdaa7bad 100644 --- a/src/lib/trace-ir/trace.c +++ b/src/lib/trace-ir/trace.c @@ -55,6 +55,7 @@ #include "trace-class.h" #include "trace.h" #include "utils.h" +#include "lib/func-status.h" struct bt_trace_destruction_listener_elem { bt_trace_destruction_listener_func func; @@ -191,7 +192,8 @@ const char *bt_trace_get_name(const struct bt_trace *trace) return trace->name.value; } -enum bt_trace_status bt_trace_set_name(struct bt_trace *trace, const char *name) +enum bt_trace_set_name_status bt_trace_set_name(struct bt_trace *trace, + const char *name) { BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(name, "Name"); @@ -199,7 +201,7 @@ enum bt_trace_status bt_trace_set_name(struct bt_trace *trace, const char *name) g_string_assign(trace->name.str, name); trace->name.value = trace->name.str->str; BT_LIB_LOGD("Set trace's name: %!+t", trace); - return BT_TRACE_STATUS_OK; + return BT_FUNC_STATUS_OK; } uint64_t bt_trace_get_stream_count(const struct bt_trace *trace) @@ -250,7 +252,7 @@ const struct bt_stream *bt_trace_borrow_stream_by_id_const( return bt_trace_borrow_stream_by_id((void *) trace, id); } -enum bt_trace_status bt_trace_add_destruction_listener( +enum bt_trace_add_listener_status bt_trace_add_destruction_listener( const struct bt_trace *c_trace, bt_trace_destruction_listener_func listener, void *data, uint64_t *listener_id) @@ -288,7 +290,7 @@ enum bt_trace_status bt_trace_add_destruction_listener( BT_LIB_LOGD("Added destruction listener: " "%![trace-]+t, " "listener-id=%" PRIu64, trace, i); - return BT_TRACE_STATUS_OK; + return BT_FUNC_STATUS_OK; } BT_ASSERT_PRE_FUNC @@ -301,7 +303,7 @@ bool has_listener_id(const struct bt_trace *trace, uint64_t listener_id) listener_id))->func != NULL; } -enum bt_trace_status bt_trace_remove_destruction_listener( +enum bt_trace_remove_listener_status bt_trace_remove_destruction_listener( const struct bt_trace *c_trace, uint64_t listener_id) { struct bt_trace *trace = (void *) c_trace; @@ -321,7 +323,7 @@ enum bt_trace_status bt_trace_remove_destruction_listener( BT_LIB_LOGD("Removed \"trace destruction listener: " "%![trace-]+t, listener-id=%" PRIu64, trace, listener_id); - return BT_TRACE_STATUS_OK; + return BT_FUNC_STATUS_OK; } BT_HIDDEN diff --git a/src/lib/value.c b/src/lib/value.c index ab265e01..285971d4 100644 --- a/src/lib/value.c +++ b/src/lib/value.c @@ -36,6 +36,7 @@ #include "lib/assert-pre.h" #include "lib/value.h" #include "common/assert.h" +#include "func-status.h" #define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base)) #define BT_VALUE_TO_INTEGER(_base) ((struct bt_value_integer *) (_base)) @@ -539,10 +540,9 @@ void bt_value_destroy(struct bt_object *obj) } BT_HIDDEN -enum bt_value_status _bt_value_freeze(const struct bt_value *c_object) +void _bt_value_freeze(const struct bt_value *c_object) { const struct bt_value *object = (void *) c_object; - enum bt_value_status ret = BT_VALUE_STATUS_OK; BT_ASSERT(object); @@ -554,7 +554,7 @@ enum bt_value_status _bt_value_freeze(const struct bt_value *c_object) freeze_funcs[object->type]((void *) object); end: - return ret; + return; } enum bt_value_type bt_value_get_type(const struct bt_value *object) @@ -855,7 +855,7 @@ const char *bt_value_string_get(const struct bt_value *string_obj) return BT_VALUE_TO_STRING(string_obj)->gstr->str; } -enum bt_value_status bt_value_string_set( +enum bt_value_string_set_status bt_value_string_set( struct bt_value *string_obj, const char *val) { BT_ASSERT_PRE_NON_NULL(string_obj, "Value object"); @@ -864,7 +864,7 @@ enum bt_value_status bt_value_string_set( g_string_assign(BT_VALUE_TO_STRING(string_obj)->gstr, val); BT_LOGT("Set string value's raw value: value-addr=%p, raw-value-addr=%p", string_obj, val); - return BT_VALUE_STATUS_OK; + return BT_FUNC_STATUS_OK; } uint64_t bt_value_array_get_size(const struct bt_value *array_obj) @@ -895,7 +895,7 @@ const struct bt_value *bt_value_array_borrow_element_by_index_const( (void *) array_obj, index); } -enum bt_value_status bt_value_array_append_element( +enum bt_value_array_append_element_status bt_value_array_append_element( struct bt_value *array_obj, struct bt_value *element_obj) { @@ -911,13 +911,13 @@ enum bt_value_status bt_value_array_append_element( BT_LOGT("Appended element to array value: array-value-addr=%p, " "element-value-addr=%p, new-size=%u", array_obj, element_obj, typed_array_obj->garray->len); - return BT_VALUE_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_value_status bt_value_array_append_bool_element( - struct bt_value *array_obj, bt_bool val) +enum bt_value_array_append_element_status +bt_value_array_append_bool_element(struct bt_value *array_obj, bt_bool val) { - enum bt_value_status ret; + enum bt_value_array_append_element_status ret; struct bt_value *bool_obj = NULL; bool_obj = bt_value_bool_create_init(val); @@ -927,10 +927,11 @@ enum bt_value_status bt_value_array_append_bool_element( return ret; } -enum bt_value_status bt_value_array_append_unsigned_integer_element( - struct bt_value *array_obj, uint64_t val) +enum bt_value_array_append_element_status +bt_value_array_append_unsigned_integer_element(struct bt_value *array_obj, + uint64_t val) { - enum bt_value_status ret; + enum bt_value_array_append_element_status ret; struct bt_value *integer_obj = NULL; integer_obj = bt_value_unsigned_integer_create_init(val); @@ -940,10 +941,11 @@ enum bt_value_status bt_value_array_append_unsigned_integer_element( return ret; } -enum bt_value_status bt_value_array_append_signed_integer_element( - struct bt_value *array_obj, int64_t val) +enum bt_value_array_append_element_status +bt_value_array_append_signed_integer_element(struct bt_value *array_obj, + int64_t val) { - enum bt_value_status ret; + enum bt_value_array_append_element_status ret; struct bt_value *integer_obj = NULL; integer_obj = bt_value_signed_integer_create_init(val); @@ -953,10 +955,10 @@ enum bt_value_status bt_value_array_append_signed_integer_element( return ret; } -enum bt_value_status bt_value_array_append_real_element( - struct bt_value *array_obj, double val) +enum bt_value_array_append_element_status +bt_value_array_append_real_element(struct bt_value *array_obj, double val) { - enum bt_value_status ret; + enum bt_value_array_append_element_status ret; struct bt_value *real_obj = NULL; real_obj = bt_value_real_create_init(val); @@ -966,10 +968,11 @@ enum bt_value_status bt_value_array_append_real_element( return ret; } -enum bt_value_status bt_value_array_append_string_element( - struct bt_value *array_obj, const char *val) +enum bt_value_array_append_element_status +bt_value_array_append_string_element(struct bt_value *array_obj, + const char *val) { - enum bt_value_status ret; + enum bt_value_array_append_element_status ret; struct bt_value *string_obj = NULL; string_obj = bt_value_string_create_init(val); @@ -979,10 +982,10 @@ enum bt_value_status bt_value_array_append_string_element( return ret; } -enum bt_value_status bt_value_array_append_empty_array_element( - struct bt_value *array_obj) +enum bt_value_array_append_element_status +bt_value_array_append_empty_array_element(struct bt_value *array_obj) { - enum bt_value_status ret; + enum bt_value_array_append_element_status ret; struct bt_value *empty_array_obj = NULL; empty_array_obj = bt_value_array_create(); @@ -992,10 +995,10 @@ enum bt_value_status bt_value_array_append_empty_array_element( return ret; } -enum bt_value_status bt_value_array_append_empty_map_element( - struct bt_value *array_obj) +enum bt_value_array_append_element_status +bt_value_array_append_empty_map_element(struct bt_value *array_obj) { - enum bt_value_status ret; + enum bt_value_array_append_element_status ret; struct bt_value *map_obj = NULL; map_obj = bt_value_map_create(); @@ -1005,8 +1008,8 @@ enum bt_value_status bt_value_array_append_empty_map_element( return ret; } -enum bt_value_status bt_value_array_set_element_by_index( - struct bt_value *array_obj, uint64_t index, +enum bt_value_array_set_element_by_index_status +bt_value_array_set_element_by_index(struct bt_value *array_obj, uint64_t index, struct bt_value *element_obj) { struct bt_value_array *typed_array_obj = @@ -1024,7 +1027,7 @@ enum bt_value_status bt_value_array_set_element_by_index( BT_LOGT("Set array value's element: array-value-addr=%p, " "index=%" PRIu64 ", element-value-addr=%p", array_obj, index, element_obj); - return BT_VALUE_STATUS_OK; + return BT_FUNC_STATUS_OK; } uint64_t bt_value_map_get_size(const struct bt_value *map_obj) @@ -1059,9 +1062,9 @@ bt_bool bt_value_map_has_entry(const struct bt_value *map_obj, const char *key) GUINT_TO_POINTER(g_quark_from_string(key))); } -enum bt_value_status bt_value_map_insert_entry( - struct bt_value *map_obj, - const char *key, struct bt_value *element_obj) +enum bt_value_map_insert_entry_status bt_value_map_insert_entry( + struct bt_value *map_obj, const char *key, + struct bt_value *element_obj) { BT_ASSERT_PRE_NON_NULL(map_obj, "Map value object"); BT_ASSERT_PRE_NON_NULL(key, "Key"); @@ -1074,13 +1077,13 @@ enum bt_value_status bt_value_map_insert_entry( BT_LOGT("Inserted value into map value: map-value-addr=%p, " "key=\"%s\", element-value-addr=%p", map_obj, key, element_obj); - return BT_VALUE_STATUS_OK; + return BT_FUNC_STATUS_OK; } -enum bt_value_status bt_value_map_insert_bool_entry( +enum bt_value_map_insert_entry_status bt_value_map_insert_bool_entry( struct bt_value *map_obj, const char *key, bt_bool val) { - enum bt_value_status ret; + enum bt_value_map_insert_entry_status ret; struct bt_value *bool_obj = NULL; bool_obj = bt_value_bool_create_init(val); @@ -1090,10 +1093,11 @@ enum bt_value_status bt_value_map_insert_bool_entry( return ret; } -enum bt_value_status bt_value_map_insert_unsigned_integer_entry( - struct bt_value *map_obj, const char *key, uint64_t val) +enum bt_value_map_insert_entry_status +bt_value_map_insert_unsigned_integer_entry(struct bt_value *map_obj, + const char *key, uint64_t val) { - enum bt_value_status ret; + enum bt_value_map_insert_entry_status ret; struct bt_value *integer_obj = NULL; integer_obj = bt_value_unsigned_integer_create_init(val); @@ -1103,10 +1107,11 @@ enum bt_value_status bt_value_map_insert_unsigned_integer_entry( return ret; } -enum bt_value_status bt_value_map_insert_signed_integer_entry( - struct bt_value *map_obj, const char *key, int64_t val) +enum bt_value_map_insert_entry_status +bt_value_map_insert_signed_integer_entry(struct bt_value *map_obj, + const char *key, int64_t val) { - enum bt_value_status ret; + enum bt_value_map_insert_entry_status ret; struct bt_value *integer_obj = NULL; integer_obj = bt_value_signed_integer_create_init(val); @@ -1116,10 +1121,10 @@ enum bt_value_status bt_value_map_insert_signed_integer_entry( return ret; } -enum bt_value_status bt_value_map_insert_real_entry( +enum bt_value_map_insert_entry_status bt_value_map_insert_real_entry( struct bt_value *map_obj, const char *key, double val) { - enum bt_value_status ret; + enum bt_value_map_insert_entry_status ret; struct bt_value *real_obj = NULL; real_obj = bt_value_real_create_init(val); @@ -1129,11 +1134,11 @@ enum bt_value_status bt_value_map_insert_real_entry( return ret; } -enum bt_value_status bt_value_map_insert_string_entry( +enum bt_value_map_insert_entry_status bt_value_map_insert_string_entry( struct bt_value *map_obj, const char *key, const char *val) { - enum bt_value_status ret; + enum bt_value_map_insert_entry_status ret; struct bt_value *string_obj = NULL; string_obj = bt_value_string_create_init(val); @@ -1143,10 +1148,11 @@ enum bt_value_status bt_value_map_insert_string_entry( return ret; } -enum bt_value_status bt_value_map_insert_empty_array_entry( +enum bt_value_map_insert_entry_status +bt_value_map_insert_empty_array_entry( struct bt_value *map_obj, const char *key) { - enum bt_value_status ret; + enum bt_value_map_insert_entry_status ret; struct bt_value *array_obj = NULL; array_obj = bt_value_array_create(); @@ -1156,10 +1162,10 @@ enum bt_value_status bt_value_map_insert_empty_array_entry( return ret; } -enum bt_value_status bt_value_map_insert_empty_map_entry( - struct bt_value *map_obj, const char *key) +enum bt_value_map_insert_entry_status +bt_value_map_insert_empty_map_entry(struct bt_value *map_obj, const char *key) { - enum bt_value_status ret; + enum bt_value_map_insert_entry_status ret; struct bt_value *empty_map_obj = NULL; empty_map_obj = bt_value_map_create(); @@ -1169,10 +1175,11 @@ enum bt_value_status bt_value_map_insert_empty_map_entry( return ret; } -enum bt_value_status bt_value_map_foreach_entry(struct bt_value *map_obj, - bt_value_map_foreach_entry_func func, void *data) +enum bt_value_map_foreach_entry_status bt_value_map_foreach_entry( + struct bt_value *map_obj, bt_value_map_foreach_entry_func func, + void *data) { - enum bt_value_status ret = BT_VALUE_STATUS_OK; + enum bt_value_map_foreach_entry_status ret = BT_FUNC_STATUS_OK; gpointer key, element_obj; GHashTableIter iter; struct bt_value_map *typed_map_obj = BT_VALUE_TO_MAP(map_obj); @@ -1189,7 +1196,7 @@ enum bt_value_status bt_value_map_foreach_entry(struct bt_value *map_obj, BT_LOGT("User canceled the loop: key=\"%s\", " "value-addr=%p, data=%p", key_str, element_obj, data); - ret = BT_VALUE_STATUS_CANCELED; + ret = BT_FUNC_STATUS_CANCELED; break; } } @@ -1197,17 +1204,17 @@ enum bt_value_status bt_value_map_foreach_entry(struct bt_value *map_obj, return ret; } -enum bt_value_status bt_value_map_foreach_entry_const( +enum bt_value_map_foreach_entry_const_status bt_value_map_foreach_entry_const( const struct bt_value *map_obj, bt_value_map_foreach_entry_const_func func, void *data) { - return bt_value_map_foreach_entry((void *) map_obj, + return (int) bt_value_map_foreach_entry((void *) map_obj, (bt_value_map_foreach_entry_func) func, data); } struct extend_map_element_data { struct bt_value *extended_obj; - enum bt_value_status status; + int status; }; static @@ -1220,7 +1227,7 @@ bt_bool extend_map_element(const char *key, /* Copy object which is to replace the current one */ extend_data->status = bt_value_copy(extension_obj_elem, - &extension_obj_elem_copy); + &extension_obj_elem_copy); if (extend_data->status) { BT_LOGE("Cannot copy map element: addr=%p", extension_obj_elem); @@ -1244,7 +1251,7 @@ bt_bool extend_map_element(const char *key, goto end; error: - BT_ASSERT(extend_data->status != BT_VALUE_STATUS_OK); + BT_ASSERT(extend_data->status != BT_FUNC_STATUS_OK); ret = BT_FALSE; end: @@ -1252,14 +1259,14 @@ end: return ret; } -enum bt_value_status bt_value_map_extend( +enum bt_value_map_extend_status bt_value_map_extend( const struct bt_value *base_map_obj, const struct bt_value *extension_obj, struct bt_value **extended_map_obj) { struct extend_map_element_data extend_data = { .extended_obj = NULL, - .status = BT_VALUE_STATUS_OK, + .status = BT_FUNC_STATUS_OK, }; BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object"); @@ -1313,10 +1320,10 @@ end: return extend_data.status; } -enum bt_value_status bt_value_copy(const struct bt_value *object, +enum bt_value_copy_status bt_value_copy(const struct bt_value *object, struct bt_value **copy_obj) { - enum bt_value_status status = BT_VALUE_STATUS_OK; + enum bt_value_copy_status status = BT_FUNC_STATUS_OK; BT_ASSERT_PRE_NON_NULL(object, "Value object"); BT_ASSERT_PRE_NON_NULL(copy_obj, "Value object copy (output)"); @@ -1326,7 +1333,7 @@ enum bt_value_status bt_value_copy(const struct bt_value *object, BT_LOGD("Copied value object: copy-value-addr=%p", copy_obj); } else { - status = BT_VALUE_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; *copy_obj = NULL; BT_LOGE_STR("Failed to copy value object."); } diff --git a/src/lib/value.h b/src/lib/value.h index 4230f44c..9a6355e9 100644 --- a/src/lib/value.h +++ b/src/lib/value.h @@ -70,7 +70,7 @@ struct bt_value_map { }; BT_HIDDEN -enum bt_value_status _bt_value_freeze(const struct bt_value *object); +void _bt_value_freeze(const struct bt_value *object); #ifdef BT_DEV_MODE # define bt_value_freeze _bt_value_freeze diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.c b/src/plugins/ctf/common/msg-iter/msg-iter.c index 938eae17..fe1d160d 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.c +++ b/src/plugins/ctf/common/msg-iter/msg-iter.c @@ -2116,7 +2116,6 @@ enum bt_bfcr_status bfcr_string_begin_cb( { bt_field *field = NULL; struct bt_msg_iter *notit = data; - int ret; BT_COMP_LOGT("String (beginning) function called from BFCR: " "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -2132,8 +2131,7 @@ enum bt_bfcr_status bfcr_string_begin_cb( BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc); BT_ASSERT(bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_STRING); - ret = bt_field_string_clear(field); - BT_ASSERT(ret == 0); + bt_field_string_clear(field); /* * Push on stack. Not a compound class per se, but we know that @@ -2245,13 +2243,10 @@ enum bt_bfcr_status bfcr_compound_begin_cb( struct ctf_field_class_array_base *array_fc = (void *) fc; if (array_fc->is_text) { - int ret; - BT_ASSERT(bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_STRING); notit->done_filling_string = false; - ret = bt_field_string_clear(field); - BT_ASSERT(ret == 0); + bt_field_string_clear(field); bt_bfcr_set_unsigned_int_cb(notit->bfcr, bfcr_unsigned_int_char_cb); } diff --git a/src/plugins/ctf/fs-sink/fs-sink-trace.c b/src/plugins/ctf/fs-sink/fs-sink-trace.c index c4539755..07d78f76 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-trace.c +++ b/src/plugins/ctf/fs-sink/fs-sink-trace.c @@ -566,7 +566,7 @@ struct fs_sink_trace *fs_sink_trace_create(struct fs_sink_comp *fs_sink, { int ret; struct fs_sink_trace *trace = g_new0(struct fs_sink_trace, 1); - bt_trace_status trace_status; + bt_trace_add_listener_status trace_status; if (!trace) { goto end; diff --git a/src/plugins/ctf/fs-sink/fs-sink.c b/src/plugins/ctf/fs-sink/fs-sink.c index d630e50d..7fabc65c 100644 --- a/src/plugins/ctf/fs-sink/fs-sink.c +++ b/src/plugins/ctf/fs-sink/fs-sink.c @@ -43,10 +43,11 @@ static const char * const in_port_name = "in"; static -bt_self_component_status ensure_output_dir_exists( +bt_component_class_init_method_status ensure_output_dir_exists( struct fs_sink_comp *fs_sink) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; int ret; ret = g_mkdir_with_parents(fs_sink->output_dir_path->str, 0755); @@ -55,7 +56,7 @@ bt_self_component_status ensure_output_dir_exists( "Cannot create directories for output directory", ": output-dir-path=\"%s\"", fs_sink->output_dir_path->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto end; } @@ -64,22 +65,24 @@ end: } static -bt_self_component_status configure_component(struct fs_sink_comp *fs_sink, +bt_component_class_init_method_status +configure_component(struct fs_sink_comp *fs_sink, const bt_value *params) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; const bt_value *value; value = bt_value_map_borrow_entry_value_const(params, "path"); if (!value) { BT_COMP_LOGE_STR("Missing mandatory `path` parameter."); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto end; } if (!bt_value_is_string(value)) { BT_COMP_LOGE_STR("`path` parameter: expecting a string."); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto end; } @@ -90,7 +93,7 @@ bt_self_component_status configure_component(struct fs_sink_comp *fs_sink, if (value) { if (!bt_value_is_bool(value)) { BT_COMP_LOGE_STR("`assume-single-trace` parameter: expecting a boolean."); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto end; } @@ -102,7 +105,7 @@ bt_self_component_status configure_component(struct fs_sink_comp *fs_sink, if (value) { if (!bt_value_is_bool(value)) { BT_COMP_LOGE_STR("`ignore-discarded-events` parameter: expecting a boolean."); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto end; } @@ -115,7 +118,7 @@ bt_self_component_status configure_component(struct fs_sink_comp *fs_sink, if (value) { if (!bt_value_is_bool(value)) { BT_COMP_LOGE_STR("`ignore-discarded-packets` parameter: expecting a boolean."); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto end; } @@ -128,7 +131,7 @@ bt_self_component_status configure_component(struct fs_sink_comp *fs_sink, if (value) { if (!bt_value_is_bool(value)) { BT_COMP_LOGE_STR("`quiet` parameter: expecting a boolean."); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto end; } @@ -165,11 +168,13 @@ end: } BT_HIDDEN -bt_self_component_status ctf_fs_sink_init( +bt_component_class_init_method_status ctf_fs_sink_init( bt_self_component_sink *self_comp_sink, const bt_value *params, void *init_method_data) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; + bt_self_component_add_port_status add_port_status; struct fs_sink_comp *fs_sink = NULL; bt_self_component *self_comp = bt_self_component_sink_as_self_component(self_comp_sink); @@ -180,7 +185,7 @@ bt_self_component_status ctf_fs_sink_init( if (!fs_sink) { BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp, "Failed to allocate one CTF FS sink structure."); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -188,7 +193,7 @@ bt_self_component_status ctf_fs_sink_init( fs_sink->self_comp = self_comp; fs_sink->output_dir_path = g_string_new(NULL); status = configure_component(fs_sink, params); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { /* configure_component() logs errors */ goto end; } @@ -198,12 +203,12 @@ bt_self_component_status ctf_fs_sink_init( G_FILE_TEST_EXISTS)) { BT_COMP_LOGE("Single trace mode, but output path exists: " "output-path=\"%s\"", fs_sink->output_dir_path->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto end; } status = ensure_output_dir_exists(fs_sink); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { /* ensure_output_dir_exists() logs errors */ goto end; } @@ -212,20 +217,27 @@ bt_self_component_status ctf_fs_sink_init( NULL, (GDestroyNotify) fs_sink_trace_destroy); if (!fs_sink->traces) { BT_COMP_LOGE_STR("Failed to allocate one GHashTable."); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto end; } - status = bt_self_component_sink_add_input_port(self_comp_sink, - in_port_name, NULL, NULL); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + add_port_status = bt_self_component_sink_add_input_port( + self_comp_sink, in_port_name, NULL, NULL); + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto end; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + goto end; + default: + break; } bt_self_component_set_data(self_comp, fs_sink); end: - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { destroy_fs_sink_comp(fs_sink); } @@ -269,11 +281,12 @@ end: } static inline -bt_self_component_status handle_event_msg(struct fs_sink_comp *fs_sink, - const bt_message *msg) +bt_component_class_sink_consume_method_status handle_event_msg( + struct fs_sink_comp *fs_sink, const bt_message *msg) { int ret; - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; const bt_event *ir_event = bt_message_event_borrow_event_const(msg); const bt_stream *ir_stream = bt_event_borrow_stream_const(ir_event); struct fs_sink_stream *stream; @@ -282,14 +295,14 @@ bt_self_component_status handle_event_msg(struct fs_sink_comp *fs_sink, stream = borrow_stream(fs_sink, ir_stream); if (G_UNLIKELY(!stream)) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } ret = try_translate_event_class_trace_ir_to_ctf_ir(fs_sink, stream->sc, bt_event_borrow_class_const(ir_event), &ec); if (ret) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -302,7 +315,7 @@ bt_self_component_status handle_event_msg(struct fs_sink_comp *fs_sink, ret = fs_sink_stream_write_event(stream, cs, ir_event, ec); if (G_UNLIKELY(ret)) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -311,11 +324,12 @@ end: } static inline -bt_self_component_status handle_packet_beginning_msg( +bt_component_class_sink_consume_method_status handle_packet_beginning_msg( struct fs_sink_comp *fs_sink, const bt_message *msg) { int ret; - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; const bt_packet *ir_packet = bt_message_packet_beginning_borrow_packet_const(msg); const bt_stream *ir_stream = bt_packet_borrow_stream_const(ir_packet); @@ -324,7 +338,7 @@ bt_self_component_status handle_packet_beginning_msg( stream = borrow_stream(fs_sink, ir_stream); if (G_UNLIKELY(!stream)) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -388,7 +402,7 @@ bt_self_component_status handle_packet_beginning_msg( bt_trace_get_name( bt_stream_borrow_trace_const(ir_stream)), stream->trace->path->str, stream->file_name->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } } @@ -434,7 +448,7 @@ bt_self_component_status handle_packet_beginning_msg( bt_trace_get_name( bt_stream_borrow_trace_const(ir_stream)), stream->trace->path->str, stream->file_name->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -453,7 +467,7 @@ bt_self_component_status handle_packet_beginning_msg( bt_trace_get_name( bt_stream_borrow_trace_const(ir_stream)), stream->trace->path->str, stream->file_name->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -474,7 +488,7 @@ bt_self_component_status handle_packet_beginning_msg( bt_trace_get_name( bt_stream_borrow_trace_const(ir_stream)), stream->trace->path->str, stream->file_name->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } } @@ -489,7 +503,7 @@ bt_self_component_status handle_packet_beginning_msg( ret = fs_sink_stream_open_packet(stream, cs, ir_packet); if (ret) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -498,11 +512,12 @@ end: } static inline -bt_self_component_status handle_packet_end_msg( +bt_component_class_sink_consume_method_status handle_packet_end_msg( struct fs_sink_comp *fs_sink, const bt_message *msg) { int ret; - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; const bt_packet *ir_packet = bt_message_packet_end_borrow_packet_const(msg); const bt_stream *ir_stream = bt_packet_borrow_stream_const(ir_packet); @@ -511,7 +526,7 @@ bt_self_component_status handle_packet_end_msg( stream = borrow_stream(fs_sink, ir_stream); if (G_UNLIKELY(!stream)) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -563,14 +578,14 @@ bt_self_component_status handle_packet_end_msg( bt_trace_get_name( bt_stream_borrow_trace_const(ir_stream)), stream->trace->path->str, stream->file_name->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } } ret = fs_sink_stream_close_packet(stream, cs); if (ret) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -587,10 +602,11 @@ end: } static inline -bt_self_component_status handle_stream_beginning_msg( +bt_component_class_sink_consume_method_status handle_stream_beginning_msg( struct fs_sink_comp *fs_sink, const bt_message *msg) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; const bt_stream *ir_stream = bt_message_stream_beginning_borrow_stream_const(msg); const bt_stream_class *ir_sc = @@ -615,7 +631,7 @@ bt_self_component_status handle_stream_beginning_msg( "stream-name=\"%s\"", ir_stream, bt_stream_get_id(ir_stream), bt_stream_get_name(ir_stream)); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -635,13 +651,13 @@ bt_self_component_status handle_stream_beginning_msg( "stream-name=\"%s\"", ir_stream, bt_stream_get_id(ir_stream), bt_stream_get_name(ir_stream)); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } stream = borrow_stream(fs_sink, ir_stream); if (!stream) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -657,17 +673,18 @@ end: } static inline -bt_self_component_status handle_stream_end_msg(struct fs_sink_comp *fs_sink, - const bt_message *msg) +bt_component_class_sink_consume_method_status handle_stream_end_msg( + struct fs_sink_comp *fs_sink, const bt_message *msg) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; const bt_stream *ir_stream = bt_message_stream_end_borrow_stream_const(msg); struct fs_sink_stream *stream; stream = borrow_stream(fs_sink, ir_stream); if (!stream) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -689,10 +706,11 @@ end: } static inline -bt_self_component_status handle_discarded_events_msg( +bt_component_class_sink_consume_method_status handle_discarded_events_msg( struct fs_sink_comp *fs_sink, const bt_message *msg) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; const bt_stream *ir_stream = bt_message_discarded_events_borrow_stream_const(msg); struct fs_sink_stream *stream; @@ -702,7 +720,7 @@ bt_self_component_status handle_discarded_events_msg( stream = borrow_stream(fs_sink, ir_stream); if (!stream) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -727,7 +745,7 @@ bt_self_component_status handle_discarded_events_msg( bt_trace_get_name( bt_stream_borrow_trace_const(ir_stream)), stream->trace->path->str, stream->file_name->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -750,7 +768,7 @@ bt_self_component_status handle_discarded_events_msg( bt_trace_get_name( bt_stream_borrow_trace_const(ir_stream)), stream->trace->path->str, stream->file_name->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -796,10 +814,11 @@ end: } static inline -bt_self_component_status handle_discarded_packets_msg( +bt_component_class_sink_consume_method_status handle_discarded_packets_msg( struct fs_sink_comp *fs_sink, const bt_message *msg) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; const bt_stream *ir_stream = bt_message_discarded_packets_borrow_stream_const(msg); struct fs_sink_stream *stream; @@ -809,7 +828,7 @@ bt_self_component_status handle_discarded_packets_msg( stream = borrow_stream(fs_sink, ir_stream); if (!stream) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -834,7 +853,7 @@ bt_self_component_status handle_discarded_packets_msg( bt_trace_get_name( bt_stream_borrow_trace_const(ir_stream)), stream->trace->path->str, stream->file_name->str); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -896,11 +915,13 @@ void put_messages(bt_message_array_const msgs, uint64_t count) } BT_HIDDEN -bt_self_component_status ctf_fs_sink_consume(bt_self_component_sink *self_comp) +bt_component_class_sink_consume_method_status ctf_fs_sink_consume( + bt_self_component_sink *self_comp) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; struct fs_sink_comp *fs_sink; - bt_message_iterator_status it_status; + bt_message_iterator_next_status next_status; uint64_t msg_count = 0; bt_message_array_const msgs; @@ -910,15 +931,15 @@ bt_self_component_status ctf_fs_sink_consume(bt_self_component_sink *self_comp) BT_ASSERT(fs_sink->upstream_iter); /* Consume messages */ - it_status = bt_self_component_port_input_message_iterator_next( + next_status = bt_self_component_port_input_message_iterator_next( fs_sink->upstream_iter, &msgs, &msg_count); - if (it_status < 0) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + if (next_status < 0) { + status = (int) next_status; goto end; } - switch (it_status) { - case BT_MESSAGE_ITERATOR_STATUS_OK: + switch (next_status) { + case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK: { uint64_t i; @@ -970,7 +991,7 @@ bt_self_component_status ctf_fs_sink_consume(bt_self_component_sink *self_comp) BT_MESSAGE_PUT_REF_AND_RESET(msgs[i]); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK) { BT_COMP_LOGE("Failed to handle message: " "generated CTF traces could be incomplete: " "output-dir-path=\"%s\"", @@ -981,18 +1002,18 @@ bt_self_component_status ctf_fs_sink_consume(bt_self_component_sink *self_comp) break; } - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - status = BT_SELF_COMPONENT_STATUS_AGAIN; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN; break; - case BT_MESSAGE_ITERATOR_STATUS_END: + case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: /* TODO: Finalize all traces (should already be done?) */ - status = BT_SELF_COMPONENT_STATUS_END; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END; break; - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - status = BT_SELF_COMPONENT_STATUS_NOMEM; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR; break; - case BT_MESSAGE_ITERATOR_STATUS_ERROR: - status = BT_SELF_COMPONENT_STATUS_NOMEM; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR; break; default: break; @@ -1001,7 +1022,7 @@ bt_self_component_status ctf_fs_sink_consume(bt_self_component_sink *self_comp) goto end; error: - BT_ASSERT(status != BT_SELF_COMPONENT_STATUS_OK); + BT_ASSERT(status != BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK); put_messages(msgs, msg_count); end: @@ -1009,10 +1030,11 @@ end: } BT_HIDDEN -bt_self_component_status ctf_fs_sink_graph_is_configured( +bt_component_class_sink_graph_is_configured_method_status ctf_fs_sink_graph_is_configured( bt_self_component_sink *self_comp) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_graph_is_configured_method_status status = + BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK; struct fs_sink_comp *fs_sink = bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); @@ -1021,7 +1043,7 @@ bt_self_component_status ctf_fs_sink_graph_is_configured( bt_self_component_sink_borrow_input_port_by_name( self_comp, in_port_name)); if (!fs_sink->upstream_iter) { - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_ERROR; goto end; } diff --git a/src/plugins/ctf/fs-sink/fs-sink.h b/src/plugins/ctf/fs-sink/fs-sink.h index e59e1249..d1c95c78 100644 --- a/src/plugins/ctf/fs-sink/fs-sink.h +++ b/src/plugins/ctf/fs-sink/fs-sink.h @@ -66,17 +66,17 @@ struct fs_sink_comp { }; BT_HIDDEN -bt_self_component_status ctf_fs_sink_init( +bt_component_class_init_method_status ctf_fs_sink_init( bt_self_component_sink *component, const bt_value *params, void *init_method_data); BT_HIDDEN -bt_self_component_status ctf_fs_sink_consume( +bt_component_class_sink_consume_method_status ctf_fs_sink_consume( bt_self_component_sink *component); BT_HIDDEN -bt_self_component_status ctf_fs_sink_graph_is_configured( +bt_component_class_sink_graph_is_configured_method_status ctf_fs_sink_graph_is_configured( bt_self_component_sink *component); BT_HIDDEN diff --git a/src/plugins/ctf/fs-src/data-stream-file.c b/src/plugins/ctf/fs-src/data-stream-file.c index 18db1d0c..880eb852 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.c +++ b/src/plugins/ctf/fs-src/data-stream-file.c @@ -719,22 +719,22 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file) } BT_HIDDEN -bt_self_message_iterator_status ctf_fs_ds_file_next( +bt_component_class_message_iterator_next_method_status ctf_fs_ds_file_next( struct ctf_fs_ds_file *ds_file, bt_message **msg) { enum bt_msg_iter_status msg_iter_status; - bt_self_message_iterator_status status; + bt_component_class_message_iterator_next_method_status status; msg_iter_status = bt_msg_iter_get_next_message( ds_file->msg_iter, ds_file->pc_msg_iter, msg); switch (msg_iter_status) { case BT_MSG_ITER_STATUS_EOF: - status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; break; case BT_MSG_ITER_STATUS_OK: - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; break; case BT_MSG_ITER_STATUS_AGAIN: /* @@ -746,7 +746,7 @@ bt_self_message_iterator_status ctf_fs_ds_file_next( case BT_MSG_ITER_STATUS_INVAL: case BT_MSG_ITER_STATUS_ERROR: default: - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; break; } return status; diff --git a/src/plugins/ctf/fs-src/data-stream-file.h b/src/plugins/ctf/fs-src/data-stream-file.h index 50f91b36..622f6d42 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.h +++ b/src/plugins/ctf/fs-src/data-stream-file.h @@ -103,7 +103,7 @@ BT_HIDDEN void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream); BT_HIDDEN -bt_self_message_iterator_status ctf_fs_ds_file_next( +bt_component_class_message_iterator_next_method_status ctf_fs_ds_file_next( struct ctf_fs_ds_file *ds_file, bt_message **msg); diff --git a/src/plugins/ctf/fs-src/fs.c b/src/plugins/ctf/fs-src/fs.c index b100680f..da5a1eb6 100644 --- a/src/plugins/ctf/fs-src/fs.c +++ b/src/plugins/ctf/fs-src/fs.c @@ -103,11 +103,11 @@ void set_msg_iter_emits_stream_beginning_end_messages( } static -bt_self_message_iterator_status ctf_fs_iterator_next_one( +bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next_one( struct ctf_fs_msg_iter_data *msg_iter_data, const bt_message **out_msg) { - bt_self_message_iterator_status status; + bt_component_class_message_iterator_next_method_status status; BT_ASSERT(msg_iter_data->ds_file); @@ -116,11 +116,11 @@ bt_self_message_iterator_status ctf_fs_iterator_next_one( status = ctf_fs_ds_file_next(msg_iter_data->ds_file, &msg); switch (status) { - case BT_SELF_MESSAGE_ITERATOR_STATUS_OK: + case BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK: *out_msg = msg; msg = NULL; goto end; - case BT_SELF_MESSAGE_ITERATOR_STATUS_END: + case BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END: { int ret; @@ -142,7 +142,7 @@ bt_self_message_iterator_status ctf_fs_iterator_next_one( */ ret = msg_iter_data_set_current_ds_file(msg_iter_data); if (ret) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -159,20 +159,21 @@ end: } BT_HIDDEN -bt_self_message_iterator_status ctf_fs_iterator_next( +bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next( bt_self_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; struct ctf_fs_msg_iter_data *msg_iter_data = bt_self_message_iterator_get_data(iterator); uint64_t i = 0; - while (i < capacity && status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + while (i < capacity && + status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { status = ctf_fs_iterator_next_one(msg_iter_data, &msgs[i]); - if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { i++; } } @@ -180,17 +181,17 @@ bt_self_message_iterator_status ctf_fs_iterator_next( if (i > 0) { /* * Even if ctf_fs_iterator_next_one() returned something - * else than BT_SELF_MESSAGE_ITERATOR_STATUS_OK, we + * else than BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK, we * accumulated message objects in the output * message array, so we need to return - * BT_SELF_MESSAGE_ITERATOR_STATUS_OK so that they are + * BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK so that they are * transfered to downstream. This other status occurs * again the next time muxer_msg_iter_do_next() is * called, possibly without any accumulated * message, in which case we'll return it. */ *count = i; - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; } return status; @@ -215,17 +216,17 @@ end: } BT_HIDDEN -bt_self_message_iterator_status ctf_fs_iterator_seek_beginning( - bt_self_message_iterator *it) +bt_component_class_message_iterator_seek_beginning_method_status +ctf_fs_iterator_seek_beginning(bt_self_message_iterator *it) { struct ctf_fs_msg_iter_data *msg_iter_data = bt_self_message_iterator_get_data(it); - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_seek_beginning_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; BT_ASSERT(msg_iter_data); if (ctf_fs_iterator_reset(msg_iter_data)) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_ERROR; } return status; @@ -239,15 +240,15 @@ void ctf_fs_iterator_finalize(bt_self_message_iterator *it) } BT_HIDDEN -bt_self_message_iterator_status ctf_fs_iterator_init( +bt_component_class_message_iterator_init_method_status ctf_fs_iterator_init( bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp_src, bt_self_component_port_output *self_port) { struct ctf_fs_port_data *port_data; struct ctf_fs_msg_iter_data *msg_iter_data = NULL; - bt_self_message_iterator_status ret = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_init_method_status ret = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK; bt_logging_level log_level; bt_self_component *self_comp; @@ -259,7 +260,7 @@ bt_self_message_iterator_status ctf_fs_iterator_init( self_comp = port_data->ctf_fs->self_comp; msg_iter_data = g_new0(struct ctf_fs_msg_iter_data, 1); if (!msg_iter_data) { - ret = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -273,19 +274,19 @@ bt_self_message_iterator_status ctf_fs_iterator_init( self_comp); if (!msg_iter_data->msg_iter) { BT_COMP_LOGE_STR("Cannot create a CTF message iterator."); - ret = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } msg_iter_data->ds_file_group = port_data->ds_file_group; if (ctf_fs_iterator_reset(msg_iter_data)) { - ret = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR; goto error; } bt_self_message_iterator_set_data(self_msg_iter, msg_iter_data); - if (ret != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (ret != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK) { goto error; } @@ -1962,30 +1963,32 @@ end: } BT_HIDDEN -bt_self_component_status ctf_fs_init( +bt_component_class_init_method_status ctf_fs_init( bt_self_component_source *self_comp, const bt_value *params, __attribute__((unused)) void *init_method_data) { struct ctf_fs_component *ctf_fs; - bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status ret = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; ctf_fs = ctf_fs_create(self_comp, params); if (!ctf_fs) { - ret = BT_SELF_COMPONENT_STATUS_ERROR; + ret = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; } return ret; } BT_HIDDEN -bt_query_status ctf_fs_query( +bt_component_class_query_method_status ctf_fs_query( bt_self_component_class_source *comp_class, const bt_query_executor *query_exec, const char *object, const bt_value *params, bt_logging_level log_level, const bt_value **result) { - bt_query_status status = BT_QUERY_STATUS_OK; + bt_component_class_query_method_status status = + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK; if (!strcmp(object, "metadata-info")) { status = metadata_info_query(comp_class, params, log_level, @@ -1995,7 +1998,7 @@ bt_query_status ctf_fs_query( result); } else { BT_LOGE("Unknown query object `%s`", object); - status = BT_QUERY_STATUS_INVALID_OBJECT; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_OBJECT; goto end; } end: diff --git a/src/plugins/ctf/fs-src/fs.h b/src/plugins/ctf/fs-src/fs.h index 8819f018..b52e1796 100644 --- a/src/plugins/ctf/fs-src/fs.h +++ b/src/plugins/ctf/fs-src/fs.h @@ -205,7 +205,7 @@ struct ctf_fs_msg_iter_data { }; BT_HIDDEN -bt_self_component_status ctf_fs_init( +bt_component_class_init_method_status ctf_fs_init( bt_self_component_source *source, const bt_value *params, void *init_method_data); @@ -213,7 +213,7 @@ BT_HIDDEN void ctf_fs_finalize(bt_self_component_source *component); BT_HIDDEN -bt_query_status ctf_fs_query( +bt_component_class_query_method_status ctf_fs_query( bt_self_component_class_source *comp_class, const bt_query_executor *query_exec, const char *object, const bt_value *params, @@ -221,7 +221,7 @@ bt_query_status ctf_fs_query( const bt_value **result); BT_HIDDEN -bt_self_message_iterator_status ctf_fs_iterator_init( +bt_component_class_message_iterator_init_method_status ctf_fs_iterator_init( bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port); @@ -230,13 +230,13 @@ BT_HIDDEN void ctf_fs_iterator_finalize(bt_self_message_iterator *it); BT_HIDDEN -bt_self_message_iterator_status ctf_fs_iterator_next( +bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next( bt_self_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); BT_HIDDEN -bt_self_message_iterator_status ctf_fs_iterator_seek_beginning( +bt_component_class_message_iterator_seek_beginning_method_status ctf_fs_iterator_seek_beginning( bt_self_message_iterator *message_iterator); /* Create and initialize a new, empty ctf_fs_component. */ diff --git a/src/plugins/ctf/fs-src/query.c b/src/plugins/ctf/fs-src/query.c index 8e91ba36..6cfe5b4f 100644 --- a/src/plugins/ctf/fs-src/query.c +++ b/src/plugins/ctf/fs-src/query.c @@ -47,12 +47,13 @@ struct range { }; BT_HIDDEN -bt_query_status metadata_info_query( +bt_component_class_query_method_status metadata_info_query( bt_self_component_class_source *comp_class, const bt_value *params, bt_logging_level log_level, const bt_value **user_result) { - bt_query_status status = BT_QUERY_STATUS_OK; + bt_component_class_query_method_status status = + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK; bt_value *result = NULL; const bt_value *path_value = NULL; char *metadata_text = NULL; @@ -65,7 +66,7 @@ bt_query_status metadata_info_query( result = bt_value_map_create(); if (!result) { - status = BT_QUERY_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -73,20 +74,20 @@ bt_query_status metadata_info_query( if (!bt_value_is_map(params)) { BT_LOGE_STR("Query parameters is not a map value object."); - status = BT_QUERY_STATUS_INVALID_PARAMS; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS; goto error; } path_value = bt_value_map_borrow_entry_value_const(params, "path"); if (!path_value) { BT_LOGE_STR("Mandatory `path` parameter missing"); - status = BT_QUERY_STATUS_INVALID_PARAMS; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS; goto error; } if (!bt_value_is_string(path_value)) { BT_LOGE_STR("`path` parameter is required to be a string value"); - status = BT_QUERY_STATUS_INVALID_PARAMS; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS; goto error; } @@ -176,7 +177,7 @@ error: result = NULL; if (status >= 0) { - status = BT_QUERY_STATUS_ERROR; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR; } end: @@ -199,7 +200,7 @@ int add_range(bt_value *info, struct range *range, const char *range_name) { int ret = 0; - bt_value_status status; + bt_value_map_insert_entry_status status; bt_value *range_map = NULL; if (!range->set) { @@ -215,21 +216,21 @@ int add_range(bt_value *info, struct range *range, status = bt_value_map_insert_signed_integer_entry(range_map, "begin", range->begin_ns); - if (status != BT_VALUE_STATUS_OK) { + if (status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } status = bt_value_map_insert_signed_integer_entry(range_map, "end", range->end_ns); - if (status != BT_VALUE_STATUS_OK) { + if (status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } status = bt_value_map_insert_entry(info, range_name, range_map); - if (status != BT_VALUE_STATUS_OK) { + if (status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } @@ -243,12 +244,12 @@ static int add_stream_ids(bt_value *info, struct ctf_fs_ds_file_group *ds_file_group) { int ret = 0; - bt_value_status status; + bt_value_map_insert_entry_status status; if (ds_file_group->stream_id != UINT64_C(-1)) { status = bt_value_map_insert_unsigned_integer_entry(info, "id", ds_file_group->stream_id); - if (status != BT_VALUE_STATUS_OK) { + if (status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } @@ -256,7 +257,7 @@ int add_stream_ids(bt_value *info, struct ctf_fs_ds_file_group *ds_file_group) status = bt_value_map_insert_unsigned_integer_entry(info, "class-id", ds_file_group->sc->id); - if (status != BT_VALUE_STATUS_OK) { + if (status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } @@ -271,7 +272,8 @@ int populate_stream_info(struct ctf_fs_ds_file_group *group, { int ret = 0; size_t file_idx; - bt_value_status status; + bt_value_map_insert_entry_status insert_status; + bt_value_array_append_element_status append_status; bt_value *file_paths; struct ctf_fs_ds_index_entry *first_ds_index_entry, *last_ds_index_entry; gchar *port_name = NULL; @@ -287,9 +289,9 @@ int populate_stream_info(struct ctf_fs_ds_file_group *group, g_ptr_array_index(group->ds_file_infos, file_idx); - status = bt_value_array_append_string_element(file_paths, + append_status = bt_value_array_append_string_element(file_paths, info->path->str); - if (status != BT_VALUE_STATUS_OK) { + if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) { ret = -1; goto end; } @@ -329,9 +331,9 @@ int populate_stream_info(struct ctf_fs_ds_file_group *group, goto end; } - status = bt_value_map_insert_entry(group_info, "paths", + insert_status = bt_value_map_insert_entry(group_info, "paths", file_paths); - if (status != BT_VALUE_STATUS_OK) { + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } @@ -347,9 +349,9 @@ int populate_stream_info(struct ctf_fs_ds_file_group *group, goto end; } - status = bt_value_map_insert_string_entry(group_info, "port-name", - port_name); - if (status != BT_VALUE_STATUS_OK) { + insert_status = bt_value_map_insert_string_entry(group_info, + "port-name", port_name); + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } @@ -364,7 +366,8 @@ int populate_trace_info(const struct ctf_fs_trace *trace, bt_value *trace_info) { int ret = 0; size_t group_idx; - bt_value_status status; + bt_value_map_insert_entry_status insert_status; + bt_value_array_append_element_status append_status; bt_value *file_groups = NULL; struct range trace_range = { .begin_ns = INT64_MAX, @@ -389,15 +392,15 @@ int populate_trace_info(const struct ctf_fs_trace *trace, bt_value *trace_info) goto end; } - status = bt_value_map_insert_string_entry(trace_info, "name", + insert_status = bt_value_map_insert_string_entry(trace_info, "name", trace->name->str); - if (status != BT_VALUE_STATUS_OK) { + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } - status = bt_value_map_insert_string_entry(trace_info, "path", + insert_status = bt_value_map_insert_string_entry(trace_info, "path", trace->path->str); - if (status != BT_VALUE_STATUS_OK) { + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } @@ -422,9 +425,10 @@ int populate_trace_info(const struct ctf_fs_trace *trace, bt_value *trace_info) goto end; } - status = bt_value_array_append_element(file_groups, group_info); + append_status = bt_value_array_append_element(file_groups, + group_info); bt_value_put_ref(group_info); - if (status != BT_VALUE_STATUS_OK) { + if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) { goto end; } @@ -456,10 +460,10 @@ int populate_trace_info(const struct ctf_fs_trace *trace, bt_value *trace_info) } } - status = bt_value_map_insert_entry(trace_info, "streams", + insert_status = bt_value_map_insert_entry(trace_info, "streams", file_groups); BT_VALUE_PUT_REF_AND_RESET(file_groups); - if (status != BT_VALUE_STATUS_OK) { + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { ret = -1; goto end; } @@ -470,13 +474,14 @@ end: } BT_HIDDEN -bt_query_status trace_info_query( +bt_component_class_query_method_status trace_info_query( bt_self_component_class_source *comp_class, const bt_value *params, bt_logging_level log_level, const bt_value **user_result) { struct ctf_fs_component *ctf_fs = NULL; - bt_query_status status = BT_QUERY_STATUS_OK; + bt_component_class_query_method_status status = + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK; bt_value *result = NULL; const bt_value *paths_value = NULL; int ret = 0; @@ -486,7 +491,7 @@ bt_query_status trace_info_query( if (!bt_value_is_map(params)) { BT_LOGE("Query parameters is not a map value object."); - status = BT_QUERY_STATUS_INVALID_PARAMS; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS; goto error; } @@ -496,7 +501,7 @@ bt_query_status trace_info_query( } if (!read_src_fs_parameters(params, &paths_value, ctf_fs)) { - status = BT_QUERY_STATUS_INVALID_PARAMS; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS; goto error; } @@ -506,14 +511,14 @@ bt_query_status trace_info_query( result = bt_value_array_create(); if (!result) { - status = BT_QUERY_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_MEMORY_ERROR; goto error; } for (i = 0; i < ctf_fs->traces->len; i++) { struct ctf_fs_trace *trace; bt_value *trace_info; - bt_value_status status; + bt_value_array_append_element_status append_status; trace = g_ptr_array_index(ctf_fs->traces, i); BT_ASSERT(trace); @@ -530,9 +535,10 @@ bt_query_status trace_info_query( goto error; } - status = bt_value_array_append_element(result, trace_info); + append_status = bt_value_array_append_element(result, + trace_info); bt_value_put_ref(trace_info); - if (status != BT_VALUE_STATUS_OK) { + if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) { goto error; } } @@ -544,7 +550,7 @@ error: result = NULL; if (status >= 0) { - status = BT_QUERY_STATUS_ERROR; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR; } end: diff --git a/src/plugins/ctf/fs-src/query.h b/src/plugins/ctf/fs-src/query.h index 89e31838..50ad5870 100644 --- a/src/plugins/ctf/fs-src/query.h +++ b/src/plugins/ctf/fs-src/query.h @@ -29,13 +29,13 @@ #include BT_HIDDEN -bt_query_status metadata_info_query( +bt_component_class_query_method_status metadata_info_query( bt_self_component_class_source *comp_class, const bt_value *params, bt_logging_level log_level, const bt_value **result); BT_HIDDEN -bt_query_status trace_info_query( +bt_component_class_query_method_status trace_info_query( bt_self_component_class_source *comp_class, const bt_value *params, bt_logging_level log_level, const bt_value **result); diff --git a/src/plugins/ctf/lttng-live/lttng-live.c b/src/plugins/ctf/lttng-live/lttng-live.c index af886143..09442307 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.c +++ b/src/plugins/ctf/lttng-live/lttng-live.c @@ -1139,12 +1139,12 @@ void put_messages(bt_message_array_const msgs, uint64_t count) } BT_HIDDEN -bt_self_message_iterator_status lttng_live_msg_iter_next( +bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next( bt_self_message_iterator *self_msg_it, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_self_message_iterator_status status; + bt_component_class_message_iterator_next_method_status status; struct lttng_live_msg_iter *lttng_live_msg_iter = bt_self_message_iterator_get_data(self_msg_it); struct lttng_live_component *lttng_live = @@ -1170,7 +1170,7 @@ bt_self_message_iterator_status lttng_live_msg_iter_next( if (lttng_live_msg_iter->sessions->len == 0) { if (lttng_live->params.sess_not_found_act != SESSION_NOT_FOUND_ACTION_CONTINUE) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; goto no_session; } else { /* @@ -1179,7 +1179,7 @@ bt_self_message_iterator_status lttng_live_msg_iter_next( * requested session name. */ if (lttng_live_create_viewer_session(lttng_live_msg_iter)) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto no_session; } } @@ -1303,21 +1303,21 @@ end: * now. On the next call we return again if there are * still no new message to send. */ - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; } else { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN; } break; case LTTNG_LIVE_ITERATOR_STATUS_END: - status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; break; case LTTNG_LIVE_ITERATOR_STATUS_NOMEM: - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; break; case LTTNG_LIVE_ITERATOR_STATUS_ERROR: case LTTNG_LIVE_ITERATOR_STATUS_INVAL: case LTTNG_LIVE_ITERATOR_STATUS_UNSUPPORTED: - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; /* Put all existing messages on error. */ put_messages(msgs, *count); break; @@ -1330,15 +1330,15 @@ no_session: } BT_HIDDEN -bt_self_message_iterator_status lttng_live_msg_iter_init( +bt_component_class_message_iterator_init_method_status lttng_live_msg_iter_init( bt_self_message_iterator *self_msg_it, bt_self_component_source *self_comp_src, bt_self_component_port_output *self_port) { - bt_self_message_iterator_status ret = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_init_method_status ret = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK; bt_self_component *self_comp = - bt_self_component_source_as_self_component(self_comp_src); + bt_self_component_source_as_self_component(self_comp_src); struct lttng_live_component *lttng_live; struct lttng_live_msg_iter *lttng_live_msg_iter; bt_logging_level log_level; @@ -1355,7 +1355,7 @@ bt_self_message_iterator_status lttng_live_msg_iter_init( lttng_live_msg_iter = g_new0(struct lttng_live_msg_iter, 1); if (!lttng_live_msg_iter) { - ret = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR; goto end; } @@ -1414,17 +1414,19 @@ bt_self_message_iterator_status lttng_live_msg_iter_init( goto end; error: - ret = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR; lttng_live_msg_iter_destroy(lttng_live_msg_iter); end: return ret; } static -bt_query_status lttng_live_query_list_sessions(const bt_value *params, - const bt_value **result, bt_logging_level log_level) +bt_component_class_query_method_status lttng_live_query_list_sessions( + const bt_value *params, const bt_value **result, + bt_logging_level log_level) { - bt_query_status status = BT_QUERY_STATUS_OK; + bt_component_class_query_method_status status = + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK; const bt_value *url_value = NULL; const char *url; struct live_viewer_connection *viewer_connection = NULL; @@ -1433,14 +1435,14 @@ bt_query_status lttng_live_query_list_sessions(const bt_value *params, url_value = bt_value_map_borrow_entry_value_const(params, URL_PARAM); if (!url_value) { BT_COMP_LOGW("Mandatory `%s` parameter missing", URL_PARAM); - status = BT_QUERY_STATUS_INVALID_PARAMS; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS; goto error; } if (!bt_value_is_string(url_value)) { BT_COMP_LOGW("`%s` parameter is required to be a string value", URL_PARAM); - status = BT_QUERY_STATUS_INVALID_PARAMS; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_PARAMS; goto error; } @@ -1453,7 +1455,7 @@ bt_query_status lttng_live_query_list_sessions(const bt_value *params, status = live_viewer_connection_list_sessions(viewer_connection, result); - if (status != BT_QUERY_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK) { goto error; } @@ -1463,7 +1465,7 @@ error: BT_VALUE_PUT_REF_AND_RESET(*result); if (status >= 0) { - status = BT_QUERY_STATUS_ERROR; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR; } end: @@ -1474,12 +1476,14 @@ end: } BT_HIDDEN -bt_query_status lttng_live_query(bt_self_component_class_source *comp_class, +bt_component_class_query_method_status lttng_live_query( + bt_self_component_class_source *comp_class, const bt_query_executor *query_exec, const char *object, const bt_value *params, bt_logging_level log_level, const bt_value **result) { - bt_query_status status = BT_QUERY_STATUS_OK; + bt_component_class_query_method_status status = + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK; bt_self_component *self_comp = NULL; if (strcmp(object, "sessions") == 0) { @@ -1487,7 +1491,7 @@ bt_query_status lttng_live_query(bt_self_component_class_source *comp_class, log_level); } else { BT_COMP_LOGW("Unknown query object `%s`", object); - status = BT_QUERY_STATUS_INVALID_OBJECT; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_INVALID_OBJECT; goto end; } @@ -1599,32 +1603,41 @@ end: } BT_HIDDEN -bt_self_component_status lttng_live_component_init( +bt_component_class_init_method_status lttng_live_component_init( bt_self_component_source *self_comp_src, const bt_value *params, __attribute__((unused)) void *init_method_data) { struct lttng_live_component *lttng_live; - bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status ret = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; bt_self_component *self_comp = bt_self_component_source_as_self_component(self_comp_src); bt_logging_level log_level = bt_component_get_logging_level( bt_self_component_as_component(self_comp)); + bt_self_component_add_port_status add_port_status; lttng_live = lttng_live_component_create(params, log_level, self_comp); if (!lttng_live) { - ret = BT_SELF_COMPONENT_STATUS_NOMEM; + ret = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } if (lttng_live_graph_is_canceled(lttng_live)) { - ret = BT_SELF_COMPONENT_STATUS_END; + ret = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto error; } - ret = bt_self_component_source_add_output_port(self_comp_src, "out", - NULL, NULL); - if (ret != BT_SELF_COMPONENT_STATUS_OK) { + add_port_status = bt_self_component_source_add_output_port( + self_comp_src, "out", NULL, NULL); + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + ret = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; + goto error; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + ret = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; + default: + break; } bt_self_component_set_data(self_comp, lttng_live); diff --git a/src/plugins/ctf/lttng-live/lttng-live.h b/src/plugins/ctf/lttng-live/lttng-live.h index f003d627..62e1e752 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.h +++ b/src/plugins/ctf/lttng-live/lttng-live.h @@ -257,11 +257,11 @@ enum lttng_live_iterator_status { LTTNG_LIVE_ITERATOR_STATUS_UNSUPPORTED = -4, }; -bt_self_component_status lttng_live_component_init( +bt_component_class_init_method_status lttng_live_component_init( bt_self_component_source *self_comp, const bt_value *params, void *init_method_data); -bt_query_status lttng_live_query( +bt_component_class_query_method_status lttng_live_query( bt_self_component_class_source *comp_class, const bt_query_executor *query_exec, const char *object, const bt_value *params, @@ -270,12 +270,12 @@ bt_query_status lttng_live_query( void lttng_live_component_finalize(bt_self_component_source *component); -bt_self_message_iterator_status lttng_live_msg_iter_next( +bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next( bt_self_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); -bt_self_message_iterator_status lttng_live_msg_iter_init( +bt_component_class_message_iterator_init_method_status lttng_live_msg_iter_init( bt_self_message_iterator *self_msg_it, bt_self_component_source *self_comp, bt_self_component_port_output *self_port); diff --git a/src/plugins/ctf/lttng-live/viewer-connection.c b/src/plugins/ctf/lttng-live/viewer-connection.c index 57271b2a..0badf75b 100644 --- a/src/plugins/ctf/lttng-live/viewer-connection.c +++ b/src/plugins/ctf/lttng-live/viewer-connection.c @@ -395,7 +395,8 @@ int list_append_session(bt_value *results, struct live_viewer_connection *viewer_connection) { int ret = 0; - bt_value_status ret_status; + bt_value_map_insert_entry_status insert_status; + bt_value_array_append_element_status append_status; bt_value *map = NULL; GString *url = NULL; bool found = false; @@ -431,8 +432,8 @@ int list_append_session(bt_value *results, g_string_append_c(url, '/'); g_string_append(url, session->session_name); - ret_status = bt_value_map_insert_string_entry(map, "url", url->str); - if (ret_status != BT_VALUE_STATUS_OK) { + insert_status = bt_value_map_insert_string_entry(map, "url", url->str); + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { BT_COMP_LOGE_STR("Error inserting \"url\" entry."); ret = -1; goto end; @@ -442,9 +443,9 @@ int list_append_session(bt_value *results, * key = "target-hostname", * value = , */ - ret_status = bt_value_map_insert_string_entry(map, "target-hostname", + insert_status = bt_value_map_insert_string_entry(map, "target-hostname", session->hostname); - if (ret_status != BT_VALUE_STATUS_OK) { + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { BT_COMP_LOGE_STR("Error inserting \"target-hostname\" entry."); ret = -1; goto end; @@ -454,9 +455,9 @@ int list_append_session(bt_value *results, * key = "session-name", * value = , */ - ret_status = bt_value_map_insert_string_entry(map, "session-name", + insert_status = bt_value_map_insert_string_entry(map, "session-name", session->session_name); - if (ret_status != BT_VALUE_STATUS_OK) { + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { BT_COMP_LOGE_STR("Error inserting \"session-name\" entry."); ret = -1; goto end; @@ -469,9 +470,9 @@ int list_append_session(bt_value *results, { uint32_t live_timer = be32toh(session->live_timer); - ret_status = bt_value_map_insert_signed_integer_entry( + insert_status = bt_value_map_insert_signed_integer_entry( map, "timer-us", live_timer); - if (ret_status != BT_VALUE_STATUS_OK) { + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { BT_COMP_LOGE_STR("Error inserting \"timer-us\" entry."); ret = -1; goto end; @@ -485,9 +486,9 @@ int list_append_session(bt_value *results, { uint32_t streams = be32toh(session->streams); - ret_status = bt_value_map_insert_signed_integer_entry(map, + insert_status = bt_value_map_insert_signed_integer_entry(map, "stream-count", streams); - if (ret_status != BT_VALUE_STATUS_OK) { + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { BT_COMP_LOGE_STR("Error inserting \"stream-count\" entry."); ret = -1; goto end; @@ -501,17 +502,17 @@ int list_append_session(bt_value *results, { uint32_t clients = be32toh(session->clients); - ret_status = bt_value_map_insert_signed_integer_entry(map, + insert_status = bt_value_map_insert_signed_integer_entry(map, "client-count", clients); - if (ret_status != BT_VALUE_STATUS_OK) { + if (insert_status != BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK) { BT_COMP_LOGE_STR("Error inserting \"client-count\" entry."); ret = -1; goto end; } } - ret_status = bt_value_array_append_element(results, map); - if (ret_status != BT_VALUE_STATUS_OK) { + append_status = bt_value_array_append_element(results, map); + if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) { BT_COMP_LOGE_STR("Error appending map to results."); ret = -1; } @@ -561,11 +562,12 @@ end: */ BT_HIDDEN -bt_query_status live_viewer_connection_list_sessions( +bt_component_class_query_method_status live_viewer_connection_list_sessions( struct live_viewer_connection *viewer_connection, const bt_value **user_result) { - bt_query_status status = BT_QUERY_STATUS_OK; + bt_component_class_query_method_status status = + BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK; bt_value *result = NULL; struct lttng_viewer_cmd cmd; struct lttng_viewer_list_sessions list; @@ -579,7 +581,7 @@ bt_query_status live_viewer_connection_list_sessions( result = bt_value_array_create(); if (!result) { BT_COMP_LOGE("Error creating array"); - status = BT_QUERY_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -590,7 +592,7 @@ bt_query_status live_viewer_connection_list_sessions( ret_len = lttng_live_send(viewer_connection, &cmd, sizeof(cmd)); if (ret_len == BT_SOCKET_ERROR) { BT_COMP_LOGE("Error sending cmd: %s", bt_socket_errormsg()); - status = BT_QUERY_STATUS_ERROR; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR; goto error; } BT_ASSERT(ret_len == sizeof(cmd)); @@ -598,12 +600,12 @@ bt_query_status live_viewer_connection_list_sessions( ret_len = lttng_live_recv(viewer_connection, &list, sizeof(list)); if (ret_len == 0) { BT_COMP_LOGI("Remote side has closed connection"); - status = BT_QUERY_STATUS_ERROR; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR; goto error; } if (ret_len == BT_SOCKET_ERROR) { BT_COMP_LOGE("Error receiving session list: %s", bt_socket_errormsg()); - status = BT_QUERY_STATUS_ERROR; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR; goto error; } BT_ASSERT(ret_len == sizeof(list)); @@ -616,12 +618,12 @@ bt_query_status live_viewer_connection_list_sessions( sizeof(lsession)); if (ret_len == 0) { BT_COMP_LOGI("Remote side has closed connection"); - status = BT_QUERY_STATUS_ERROR; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR; goto error; } if (ret_len == BT_SOCKET_ERROR) { BT_COMP_LOGE("Error receiving session: %s", bt_socket_errormsg()); - status = BT_QUERY_STATUS_ERROR; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR; goto error; } BT_ASSERT(ret_len == sizeof(lsession)); @@ -629,7 +631,7 @@ bt_query_status live_viewer_connection_list_sessions( lsession.session_name[LTTNG_VIEWER_NAME_MAX - 1] = '\0'; if (list_append_session(result, viewer_connection->url, &lsession, viewer_connection)) { - status = BT_QUERY_STATUS_ERROR; + status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR; goto error; } } diff --git a/src/plugins/ctf/lttng-live/viewer-connection.h b/src/plugins/ctf/lttng-live/viewer-connection.h index 8d2aef6e..549a9003 100644 --- a/src/plugins/ctf/lttng-live/viewer-connection.h +++ b/src/plugins/ctf/lttng-live/viewer-connection.h @@ -91,7 +91,7 @@ struct live_viewer_connection * live_viewer_connection_create( void live_viewer_connection_destroy( struct live_viewer_connection *conn); -bt_query_status live_viewer_connection_list_sessions( +bt_component_class_query_method_status live_viewer_connection_list_sessions( struct live_viewer_connection *viewer_connection, const bt_value **user_result); diff --git a/src/plugins/lttng-utils/debug-info/debug-info.c b/src/plugins/lttng-utils/debug-info/debug-info.c index 06c8a9b1..80f96e7b 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.c +++ b/src/plugins/lttng-utils/debug-info/debug-info.c @@ -571,7 +571,7 @@ void debug_info_destroy(struct debug_info *debug_info) { bt_logging_level log_level; bt_self_component *self_comp; - bt_trace_status status; + bt_trace_remove_listener_status remove_listener_status; if (!debug_info) { goto end; } @@ -583,9 +583,10 @@ void debug_info_destroy(struct debug_info *debug_info) g_hash_table_destroy(debug_info->vpid_to_proc_dbg_info_src); } - status = bt_trace_remove_destruction_listener(debug_info->input_trace, + remove_listener_status = bt_trace_remove_destruction_listener( + debug_info->input_trace, debug_info->destruction_listener_id); - if (status != BT_TRACE_STATUS_OK) { + if (remove_listener_status != BT_TRACE_REMOVE_LISTENER_STATUS_OK) { BT_COMP_LOGE("Trace destruction listener removal failed."); } @@ -949,34 +950,36 @@ void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src, bool full_path, bt_field *curr_field, bt_logging_level log_level, bt_self_component *self_comp) { - bt_field_status status; + bt_field_string_set_value_status set_status; + bt_field_string_append_status append_status; BT_ASSERT(bt_field_get_class_type(curr_field) == BT_FIELD_CLASS_TYPE_STRING); if (dbg_info_src) { if (full_path) { - status = bt_field_string_set_value(curr_field, - dbg_info_src->bin_path); + set_status = bt_field_string_set_value(curr_field, + dbg_info_src->bin_path); } else { - status = bt_field_string_set_value(curr_field, - dbg_info_src->short_bin_path); + set_status = bt_field_string_set_value(curr_field, + dbg_info_src->short_bin_path); } - if (status != BT_FIELD_STATUS_OK) { + if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { BT_COMP_LOGE("Cannot set path component of \"bin\" " "curr_field field's value: str-fc-addr=%p", curr_field); } - status = bt_field_string_append(curr_field, dbg_info_src->bin_loc); - if (status != BT_FIELD_STATUS_OK) { + append_status = bt_field_string_append(curr_field, + dbg_info_src->bin_loc); + if (append_status != BT_FIELD_STRING_APPEND_STATUS_OK) { BT_COMP_LOGE("Cannot set bin location component of \"bin\" " "curr_field field's value: str-fc-addr=%p", curr_field); } } else { - status = bt_field_string_set_value(curr_field, ""); - if (status != BT_FIELD_STATUS_OK) { + set_status = bt_field_string_set_value(curr_field, ""); + if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { BT_COMP_LOGE("Cannot set \"bin\" curr_field field's value: " "str-fc-addr=%p", curr_field); } @@ -988,17 +991,17 @@ void fill_debug_info_func_field(struct debug_info_source *dbg_info_src, bt_field *curr_field, bt_logging_level log_level, bt_self_component *self_comp) { - bt_field_status status; + bt_field_string_set_value_status status; BT_ASSERT(bt_field_get_class_type(curr_field) == BT_FIELD_CLASS_TYPE_STRING); if (dbg_info_src && dbg_info_src->func) { status = bt_field_string_set_value(curr_field, - dbg_info_src->func); + dbg_info_src->func); } else { status = bt_field_string_set_value(curr_field, ""); } - if (status != BT_FIELD_STATUS_OK) { + if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { BT_COMP_LOGE("Cannot set \"func\" curr_field field's value: " "str-fc-addr=%p", curr_field); } @@ -1010,41 +1013,43 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src, bt_logging_level log_level, bt_self_component *self_comp) { - bt_field_status status; + bt_field_string_set_value_status set_status; + bt_field_string_append_status append_status; BT_ASSERT(bt_field_get_class_type(curr_field) == BT_FIELD_CLASS_TYPE_STRING); if (dbg_info_src && dbg_info_src->src_path) { if (full_path) { - status = bt_field_string_set_value(curr_field, + set_status = bt_field_string_set_value(curr_field, dbg_info_src->src_path); } else { - status = bt_field_string_set_value(curr_field, + set_status = bt_field_string_set_value(curr_field, dbg_info_src->short_src_path); } - if (status != BT_FIELD_STATUS_OK) { + if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { BT_COMP_LOGE("Cannot set path component of \"src\" " "curr_field field's value: str-fc-addr=%p", curr_field); } - status = bt_field_string_append(curr_field, ":"); - if (status != BT_FIELD_STATUS_OK) { + append_status = bt_field_string_append(curr_field, ":"); + if (append_status != BT_FIELD_STRING_APPEND_STATUS_OK) { BT_COMP_LOGE("Cannot set colon component of \"src\" " "curr_field field's value: str-fc-addr=%p", curr_field); } - status = bt_field_string_append(curr_field, dbg_info_src->line_no); - if (status != BT_FIELD_STATUS_OK) { + append_status = bt_field_string_append(curr_field, + dbg_info_src->line_no); + if (append_status != BT_FIELD_STRING_APPEND_STATUS_OK) { BT_COMP_LOGE("Cannot set line number component of \"src\" " "curr_field field's value: str-fc-addr=%p", curr_field); } } else { - status = bt_field_string_set_value(curr_field, ""); - if (status != BT_FIELD_STATUS_OK) { + set_status = bt_field_string_set_value(curr_field, ""); + if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { BT_COMP_LOGE("Cannot set \"src\" curr_field field's value: " "str-fc-addr=%p", curr_field); } @@ -1055,7 +1060,7 @@ static void fill_debug_info_field_empty(bt_field *debug_info_field, bt_logging_level log_level, bt_self_component *self_comp) { - bt_field_status status; + bt_field_string_set_value_status status; bt_field *bin_field, *func_field, *src_field; BT_ASSERT(bt_field_get_class_type(debug_info_field) == @@ -1076,19 +1081,19 @@ void fill_debug_info_field_empty(bt_field *debug_info_field, BT_FIELD_CLASS_TYPE_STRING); status = bt_field_string_set_value(bin_field, ""); - if (status != BT_FIELD_STATUS_OK) { + if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { BT_COMP_LOGE("Cannot set \"bin\" bin_field field's value: " "str-fc-addr=%p", bin_field); } status = bt_field_string_set_value(func_field, ""); - if (status != BT_FIELD_STATUS_OK) { + if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { BT_COMP_LOGE("Cannot set \"func\" func_field field's value: " "str-fc-addr=%p", func_field); } status = bt_field_string_set_value(src_field, ""); - if (status != BT_FIELD_STATUS_OK) { + if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { BT_COMP_LOGE("Cannot set \"src\" src_field field's value: " "str-fc-addr=%p", src_field); } @@ -1806,13 +1811,15 @@ int init_from_params(struct debug_info_component *debug_info_component, } BT_HIDDEN -bt_self_component_status debug_info_comp_init( +bt_component_class_init_method_status debug_info_comp_init( bt_self_component_filter *self_comp_flt, const bt_value *params, __attribute__((unused)) void *init_method_data) { int ret; struct debug_info_component *debug_info_comp; - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; + bt_self_component_add_port_status add_port_status; bt_self_component *self_comp = bt_self_component_filter_as_self_component(self_comp_flt); bt_logging_level log_level = bt_component_get_logging_level( @@ -1832,16 +1839,30 @@ bt_self_component_status debug_info_comp_init( debug_info_comp->self_comp = self_comp; bt_self_component_set_data(self_comp, debug_info_comp); - status = bt_self_component_filter_add_input_port(self_comp_flt, "in", - NULL, NULL); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + add_port_status = bt_self_component_filter_add_input_port( + self_comp_flt, "in", NULL, NULL); + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; + goto error; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; + default: + break; } - status = bt_self_component_filter_add_output_port(self_comp_flt, "out", - NULL, NULL); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + add_port_status = bt_self_component_filter_add_output_port( + self_comp_flt, "out", NULL, NULL); + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; + goto error; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; + default: + break; } ret = init_from_params(debug_info_comp, params); @@ -1858,8 +1879,8 @@ error: destroy_debug_info_comp(debug_info_comp); bt_self_component_set_data(self_comp, NULL); - if (status == BT_SELF_COMPONENT_STATUS_OK) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + if (status == BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; } end: return status; @@ -1882,22 +1903,22 @@ void debug_info_comp_finalize(bt_self_component_filter *self_comp_flt) } BT_HIDDEN -bt_self_message_iterator_status debug_info_msg_iter_next( +bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next( bt_self_message_iterator *self_msg_iter, const bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { bt_self_component_port_input_message_iterator *upstream_iterator = NULL; - bt_message_iterator_status upstream_iterator_ret_status; + bt_message_iterator_next_status upstream_iterator_ret_status; struct debug_info_msg_iter *debug_info_msg_iter; struct debug_info_component *debug_info = NULL; - bt_self_message_iterator_status status; + bt_component_class_message_iterator_next_method_status status; bt_self_component *self_comp = NULL; bt_message_array_const input_msgs; const bt_message *out_message; uint64_t curr_msg_idx, i; - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; self_comp = bt_self_message_iterator_borrow_component(self_msg_iter); BT_ASSERT(self_comp); @@ -1914,13 +1935,14 @@ bt_self_message_iterator_status debug_info_msg_iter_next( upstream_iterator_ret_status = bt_self_component_port_input_message_iterator_next( upstream_iterator, &input_msgs, count); - if (upstream_iterator_ret_status != BT_MESSAGE_ITERATOR_STATUS_OK) { + if (upstream_iterator_ret_status != + BT_MESSAGE_ITERATOR_NEXT_STATUS_OK) { /* - * No messages were returned. Not necessarily an error. Convert - * the upstream message iterator status to a self status. + * No messages were returned. Not necessarily an error. + * Convert the upstream message iterator status to a + * self status. */ - status = bt_common_message_iterator_status_to_self( - upstream_iterator_ret_status); + status = (int) upstream_iterator_ret_status; goto end; } @@ -1932,7 +1954,7 @@ bt_self_message_iterator_status debug_info_msg_iter_next( for (curr_msg_idx = 0; curr_msg_idx < *count; curr_msg_idx++) { out_message = handle_message(debug_info_msg_iter, - input_msgs[curr_msg_idx]); + input_msgs[curr_msg_idx]); if (!out_message) { goto handle_msg_error; } @@ -1956,7 +1978,8 @@ handle_msg_error: bt_message_put_ref(msgs[i]); } - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; + end: return status; } @@ -1989,12 +2012,13 @@ end: } BT_HIDDEN -bt_self_message_iterator_status debug_info_msg_iter_init( +bt_component_class_message_iterator_init_method_status debug_info_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp_flt, bt_self_component_port_output *self_port) { - bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_init_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK; struct bt_self_component_port_input *input_port = NULL; bt_self_component_port_input_message_iterator *upstream_iterator = NULL; struct debug_info_msg_iter *debug_info_msg_iter = NULL; @@ -2009,13 +2033,13 @@ bt_self_message_iterator_status debug_info_msg_iter_init( input_port = bt_self_component_filter_borrow_input_port_by_name( self_comp_flt, "in"); if (!input_port) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR; goto error; } debug_info_msg_iter = g_new0(struct debug_info_msg_iter, 1); if (!debug_info_msg_iter) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -2026,7 +2050,7 @@ bt_self_message_iterator_status debug_info_msg_iter_init( upstream_iterator = bt_self_component_port_input_message_iterator_create( input_port); if (!upstream_iterator) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -2038,7 +2062,7 @@ bt_self_message_iterator_status debug_info_msg_iter_init( g_direct_hash, g_direct_equal, (GDestroyNotify) NULL, (GDestroyNotify) debug_info_destroy); if (!debug_info_msg_iter->debug_info_map) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -2051,13 +2075,13 @@ bt_self_message_iterator_status debug_info_msg_iter_init( debug_info_msg_iter->ir_maps = trace_ir_maps_create(self_comp, debug_info_field_name, log_level); if (!debug_info_msg_iter->ir_maps) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache, log_level); if (ret) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -2068,6 +2092,7 @@ bt_self_message_iterator_status debug_info_msg_iter_init( error: debug_info_msg_iter_destroy(debug_info_msg_iter); + end: return status; } @@ -2085,27 +2110,31 @@ bt_bool debug_info_msg_iter_can_seek_beginning( } BT_HIDDEN -bt_self_message_iterator_status debug_info_msg_iter_seek_beginning( +bt_component_class_message_iterator_seek_beginning_method_status debug_info_msg_iter_seek_beginning( bt_self_message_iterator *self_msg_iter) { struct debug_info_msg_iter *debug_info_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); - bt_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_seek_beginning_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; + bt_message_iterator_seek_beginning_status seek_beg_status; BT_ASSERT(debug_info_msg_iter); /* Ask the upstream component to seek to the beginning. */ - status = bt_self_component_port_input_message_iterator_seek_beginning( + seek_beg_status = bt_self_component_port_input_message_iterator_seek_beginning( debug_info_msg_iter->msg_iter); - if (status != BT_MESSAGE_ITERATOR_STATUS_OK) { + if (seek_beg_status != BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_OK) { + status = (int) seek_beg_status; goto end; } /* Clear this iterator data. */ trace_ir_maps_clear(debug_info_msg_iter->ir_maps); g_hash_table_remove_all(debug_info_msg_iter->debug_info_map); + end: - return bt_common_message_iterator_status_to_self(status); + return status; } BT_HIDDEN diff --git a/src/plugins/lttng-utils/debug-info/debug-info.h b/src/plugins/lttng-utils/debug-info/debug-info.h index c5237924..fb50f60f 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.h +++ b/src/plugins/lttng-utils/debug-info/debug-info.h @@ -35,7 +35,7 @@ #define IP_FIELD_NAME "ip" BT_HIDDEN -bt_self_component_status debug_info_comp_init( +bt_component_class_init_method_status debug_info_comp_init( bt_self_component_filter *self_comp, const bt_value *params, void *init_method_data); @@ -43,13 +43,13 @@ BT_HIDDEN void debug_info_comp_finalize(bt_self_component_filter *self_comp); BT_HIDDEN -bt_self_message_iterator_status debug_info_msg_iter_init( +bt_component_class_message_iterator_init_method_status debug_info_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp, bt_self_component_port_output *self_port); BT_HIDDEN -bt_self_message_iterator_status debug_info_msg_iter_next( +bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next( bt_self_message_iterator *self_msg_iter, const bt_message_array_const msgs, uint64_t capacity, uint64_t *count); @@ -59,7 +59,7 @@ bt_bool debug_info_msg_iter_can_seek_beginning( bt_self_message_iterator *message_iterator); BT_HIDDEN -bt_self_message_iterator_status debug_info_msg_iter_seek_beginning( +bt_component_class_message_iterator_seek_beginning_method_status debug_info_msg_iter_seek_beginning( bt_self_message_iterator *message_iterator); BT_HIDDEN diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c index 8516a989..39cb9fb7 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c @@ -39,19 +39,18 @@ BT_HIDDEN void copy_trace_content(const bt_trace *in_trace, bt_trace *out_trace, bt_logging_level log_level, bt_self_component *self_comp) { - bt_trace_status status; + bt_trace_set_name_status status; const char *trace_name; BT_COMP_LOGD("Copying content of trace: in-t-addr=%p, out-t-addr=%p", in_trace, out_trace); - trace_name = bt_trace_get_name(in_trace); /* Copy the trace name. */ if (trace_name) { status = bt_trace_set_name(out_trace, trace_name); - if (status != BT_TRACE_STATUS_OK) { + if (status != BT_TRACE_SET_NAME_STATUS_OK) { BT_COMP_LOGE("Cannot set trace's name: trace-addr=%p, name=\"%s\"", - out_trace, trace_name); + out_trace, trace_name); goto end; } } @@ -67,7 +66,7 @@ void copy_stream_content(const bt_stream *in_stream, bt_stream *out_stream, bt_logging_level log_level, bt_self_component *self_comp) { const char *stream_name; - bt_stream_status status; + bt_stream_set_name_status status; BT_COMP_LOGD("Copying content of stream: in-s-addr=%p, out-s-addr=%p", in_stream, out_stream); @@ -75,7 +74,7 @@ void copy_stream_content(const bt_stream *in_stream, bt_stream *out_stream, stream_name = bt_stream_get_name(in_stream); if (stream_name) { status = bt_stream_set_name(out_stream, stream_name); - if (status != BT_STREAM_STATUS_OK) { + if (status != BT_STREAM_SET_NAME_STATUS_OK) { BT_COMP_LOGE("Cannot set stream's name: stream-addr=%p, " "name=%s", out_stream, stream_name); goto end; @@ -185,8 +184,9 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field, case BT_FIELD_CLASS_TYPE_STRING: { const char *str = bt_field_string_get_value(in_field); - bt_field_status status = bt_field_string_set_value(out_field, str); - if (status != BT_FIELD_STATUS_OK) { + bt_field_string_set_value_status status = + bt_field_string_set_value(out_field, str); + if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) { BT_COMP_LOGE("Cannot set string field's value: " "str-field-addr=%p, str=%s" PRId64, out_field, str); @@ -237,14 +237,15 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field, const bt_field *in_element_field; bt_field *out_element_field; uint64_t i, array_len; - bt_field_status status; + bt_field_dynamic_array_set_length_status set_len_status; array_len = bt_field_array_get_length(in_field); if (in_fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY) { - status = bt_field_dynamic_array_set_length(out_field, - array_len); - if (status != BT_FIELD_STATUS_OK) { + set_len_status = bt_field_dynamic_array_set_length( + out_field, array_len); + if (set_len_status != + BT_FIELD_DYNAMIC_ARRAY_SET_LENGTH_STATUS_OK) { BT_COMP_LOGE("Cannot set dynamic array field's " "length field: field-addr=%p, " "length=%" PRIu64, out_field, array_len); @@ -254,10 +255,10 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field, for (i = 0; i < array_len; i++) { in_element_field = bt_field_array_borrow_element_field_by_index_const( - in_field, i); + in_field, i); out_element_field = bt_field_array_borrow_element_field_by_index( - out_field, i); + out_field, i); copy_field_content(in_element_field, out_element_field, log_level, self_comp); } @@ -265,7 +266,7 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field, } case BT_FIELD_CLASS_TYPE_VARIANT: { - bt_field_status status; + bt_field_variant_select_option_field_status sel_opt_status; uint64_t in_selected_option_idx; const bt_field *in_option_field; bt_field *out_option_field; @@ -273,9 +274,10 @@ void copy_field_content(const bt_field *in_field, bt_field *out_field, in_selected_option_idx = bt_field_variant_get_selected_option_field_index( in_field); - status = bt_field_variant_select_option_field(out_field, + sel_opt_status = bt_field_variant_select_option_field(out_field, in_selected_option_idx); - if (status != BT_FIELD_STATUS_OK) { + if (sel_opt_status != + BT_FIELD_VARIANT_SELECT_OPTION_FIELD_STATUS_OK) { BT_COMP_LOGE("Cannot select variant field's option field: " "var-field-addr=%p, opt-index=%" PRId64, out_field, in_selected_option_idx); diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c index 408bab51..1f50c304 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.c @@ -551,7 +551,8 @@ error: BT_HIDDEN void trace_ir_data_maps_destroy(struct trace_ir_data_maps *maps) { - bt_trace_status status; + bt_trace_remove_listener_status status; + if (!maps) { return; } @@ -569,8 +570,8 @@ void trace_ir_data_maps_destroy(struct trace_ir_data_maps *maps) } status = bt_trace_remove_destruction_listener(maps->input_trace, - maps->destruction_listener_id); - if (status != BT_TRACE_STATUS_OK) { + maps->destruction_listener_id); + if (status != BT_TRACE_REMOVE_LISTENER_STATUS_OK) { BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG, maps->log_level, maps->self_comp, "Trace destruction listener removal failed."); @@ -582,7 +583,8 @@ void trace_ir_data_maps_destroy(struct trace_ir_data_maps *maps) BT_HIDDEN void trace_ir_metadata_maps_destroy(struct trace_ir_metadata_maps *maps) { - bt_trace_class_status status; + bt_trace_class_remove_listener_status status; + if (!maps) { return; } @@ -611,9 +613,10 @@ void trace_ir_metadata_maps_destroy(struct trace_ir_metadata_maps *maps) bt_trace_class_put_ref(maps->output_trace_class); } - status = bt_trace_class_remove_destruction_listener(maps->input_trace_class, - maps->destruction_listener_id); - if (status != BT_TRACE_CLASS_STATUS_OK) { + status = bt_trace_class_remove_destruction_listener( + maps->input_trace_class, + maps->destruction_listener_id); + if (status != BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_OK) { BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG, maps->log_level, maps->self_comp, "Trace destruction listener removal failed."); diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c index 698d47b9..353cfb10 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c @@ -72,7 +72,7 @@ int copy_trace_class_content(const bt_trace_class *in_trace_class, for (i = 0; i < env_field_count; i++) { const char *value_name; const bt_value *value = NULL; - bt_trace_class_status trace_class_status; + bt_trace_class_set_environment_entry_status set_env_status; bt_trace_class_borrow_environment_entry_by_index_const( in_trace_class, i, &value_name, &value); @@ -85,13 +85,13 @@ int copy_trace_class_content(const bt_trace_class *in_trace_class, BT_ASSERT(value); if (bt_value_is_signed_integer(value)) { - trace_class_status = + set_env_status = bt_trace_class_set_environment_entry_integer( out_trace_class, value_name, bt_value_signed_integer_get( value)); } else if (bt_value_is_string(value)) { - trace_class_status = + set_env_status = bt_trace_class_set_environment_entry_string( out_trace_class, value_name, bt_value_string_get(value)); @@ -99,7 +99,8 @@ int copy_trace_class_content(const bt_trace_class *in_trace_class, abort(); } - if (trace_class_status != BT_TRACE_CLASS_STATUS_OK) { + if (set_env_status != + BT_TRACE_CLASS_SET_ENVIRONMENT_ENTRY_STATUS_OK) { ret = -1; goto error; } @@ -116,7 +117,6 @@ int copy_clock_class_content(const bt_clock_class *in_clock_class, bt_clock_class *out_clock_class, bt_logging_level log_level, bt_self_component *self_comp) { - bt_clock_class_status status; const char *clock_class_name, *clock_class_description; int64_t seconds; uint64_t cycles; @@ -129,8 +129,8 @@ int copy_clock_class_content(const bt_clock_class *in_clock_class, clock_class_name = bt_clock_class_get_name(in_clock_class); if (clock_class_name) { - status = bt_clock_class_set_name(out_clock_class, clock_class_name); - if (status != BT_CLOCK_CLASS_STATUS_OK) { + if (bt_clock_class_set_name(out_clock_class, clock_class_name) + != BT_CLOCK_CLASS_SET_NAME_STATUS_OK) { BT_COMP_LOGE("Error setting clock class' name cc-addr=%p, name=%p", out_clock_class, clock_class_name); out_clock_class = NULL; @@ -142,9 +142,9 @@ int copy_clock_class_content(const bt_clock_class *in_clock_class, clock_class_description = bt_clock_class_get_description(in_clock_class); if (clock_class_description) { - status = bt_clock_class_set_description(out_clock_class, - clock_class_description); - if (status != BT_CLOCK_CLASS_STATUS_OK) { + if (bt_clock_class_set_description(out_clock_class, + clock_class_description) != + BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK) { BT_COMP_LOGE("Error setting clock class' description cc-addr=%p, " "name=%p", out_clock_class, clock_class_description); out_clock_class = NULL; @@ -236,7 +236,6 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps, bt_clock_class *out_clock_class; const bt_field_class *in_packet_context_fc, *in_common_context_fc; bt_field_class *out_packet_context_fc, *out_common_context_fc; - bt_stream_class_status status; const char *in_name; int ret = 0; bt_logging_level log_level = ir_maps->log_level; @@ -284,8 +283,8 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps, in_name = bt_stream_class_get_name(in_stream_class); if (in_name) { - status = bt_stream_class_set_name(out_stream_class, in_name); - if (status != BT_STREAM_CLASS_STATUS_OK) { + if (bt_stream_class_set_name(out_stream_class, in_name) != + BT_STREAM_CLASS_SET_NAME_STATUS_OK) { BT_COMP_LOGE("Error set stream class name: out-sc-addr=%p, " "name=%s", out_stream_class, in_name); ret = -1; @@ -320,9 +319,9 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps, goto error; } - status = bt_stream_class_set_packet_context_field_class( - out_stream_class, out_packet_context_fc); - if (status != BT_STREAM_CLASS_STATUS_OK) { + if (bt_stream_class_set_packet_context_field_class( + out_stream_class, out_packet_context_fc) != + BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_OK) { BT_COMP_LOGE("Error setting stream class' packet context " "field class: sc-addr=%p, packet-fc-addr=%p", out_stream_class, out_packet_context_fc); @@ -356,9 +355,9 @@ int copy_stream_class_content(struct trace_ir_maps *ir_maps, goto error; } - status = bt_stream_class_set_event_common_context_field_class( - out_stream_class, out_common_context_fc); - if (status != BT_STREAM_CLASS_STATUS_OK) { + if (bt_stream_class_set_event_common_context_field_class( + out_stream_class, out_common_context_fc) != + BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_OK) { BT_COMP_LOGE("Error setting stream class' packet context " "field class: sc-addr=%p, packet-fc-addr=%p", out_stream_class, out_common_context_fc); @@ -383,7 +382,6 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps, const char *in_event_class_name, *in_emf_uri; bt_property_availability prop_avail; bt_event_class_log_level ec_log_level; - bt_event_class_status status; bt_field_class *out_specific_context_fc, *out_payload_fc; const bt_field_class *in_event_specific_context, *in_event_payload; int ret = 0; @@ -396,8 +394,9 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps, /* Copy event class name. */ in_event_class_name = bt_event_class_get_name(in_event_class); if (in_event_class_name) { - status = bt_event_class_set_name(out_event_class, in_event_class_name); - if (status != BT_EVENT_CLASS_STATUS_OK) { + if (bt_event_class_set_name(out_event_class, + in_event_class_name) != + BT_EVENT_CLASS_SET_NAME_STATUS_OK) { BT_COMP_LOGE("Error setting event class' name: ec-addr=%p, " "name=%s", out_event_class, in_event_class_name); ret = -1; @@ -416,8 +415,8 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps, /* Copy event class emf uri. */ in_emf_uri = bt_event_class_get_emf_uri(in_event_class); if (in_emf_uri) { - status = bt_event_class_set_emf_uri(out_event_class, in_emf_uri); - if (status != BT_EVENT_CLASS_STATUS_OK) { + if (bt_event_class_set_emf_uri(out_event_class, in_emf_uri) != + BT_EVENT_CLASS_SET_EMF_URI_STATUS_OK) { BT_COMP_LOGE("Error setting event class' emf uri: ec-addr=%p, " "emf uri=%s", out_event_class, in_emf_uri); ret = -1; @@ -451,9 +450,9 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps, * Add the output specific context to the output event * class. */ - status = bt_event_class_set_specific_context_field_class( - out_event_class, out_specific_context_fc); - if (status != BT_EVENT_CLASS_STATUS_OK) { + if (bt_event_class_set_specific_context_field_class( + out_event_class, out_specific_context_fc) != + BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_OK) { BT_COMP_LOGE("Error setting event class' specific context " "field class: ec-addr=%p, ctx-fc-addr=%p", out_event_class, out_specific_context_fc); @@ -482,9 +481,9 @@ int copy_event_class_content(struct trace_ir_maps *ir_maps, } /* Add the output payload to the output event class. */ - status = bt_event_class_set_payload_field_class( - out_event_class, out_payload_fc); - if (status != BT_EVENT_CLASS_STATUS_OK) { + if (bt_event_class_set_payload_field_class( + out_event_class, out_payload_fc) != + BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_OK) { BT_COMP_LOGE("Error setting event class' payload " "field class: ec-addr=%p, payload-fc-addr=%p", out_event_class, out_payload_fc); @@ -506,7 +505,6 @@ int copy_event_common_context_field_class_content( const bt_field_class *in_field_class, bt_field_class *out_field_class) { - bt_field_class_status status; bt_field_class *debug_field_class = NULL, *bin_field_class = NULL, *func_field_class = NULL, *src_field_class = NULL; int ret = 0; @@ -567,9 +565,9 @@ int copy_event_common_context_field_class_content( goto error; } - status = bt_field_class_structure_append_member( - debug_field_class, "bin", bin_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { + if (bt_field_class_structure_append_member( + debug_field_class, "bin", bin_field_class) != + BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) { BT_COMP_LOGE_STR("Failed to add a field to debug_info " "struct: field=bin."); ret = -1; @@ -577,9 +575,9 @@ int copy_event_common_context_field_class_content( } BT_FIELD_CLASS_PUT_REF_AND_RESET(bin_field_class); - status = bt_field_class_structure_append_member( - debug_field_class, "func", func_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { + if (bt_field_class_structure_append_member( + debug_field_class, "func", func_field_class) != + BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) { BT_COMP_LOGE_STR("Failed to add a field to debug_info " "struct: field=func."); ret = -1; @@ -587,9 +585,9 @@ int copy_event_common_context_field_class_content( } BT_FIELD_CLASS_PUT_REF_AND_RESET(func_field_class); - status = bt_field_class_structure_append_member( - debug_field_class, "src", src_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { + if (bt_field_class_structure_append_member( + debug_field_class, "src", src_field_class) != + BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) { BT_COMP_LOGE_STR("Failed to add a field to debug_info " "struct: field=src."); ret = -1; @@ -598,10 +596,9 @@ int copy_event_common_context_field_class_content( BT_FIELD_CLASS_PUT_REF_AND_RESET(src_field_class); /*Add the filled debug-info field class to the common context. */ - status = bt_field_class_structure_append_member(out_field_class, - debug_info_fc_name, - debug_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { + if (bt_field_class_structure_append_member(out_field_class, + debug_info_fc_name, debug_field_class) != + BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) { BT_COMP_LOGE_STR("Failed to add debug_info field to " "event common context."); ret = -1; diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c index e1a13788..c3f80a94 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c @@ -228,7 +228,6 @@ int field_class_unsigned_enumeration_copy( */ for (range_index = 0; range_index < range_count; range_index++) { uint64_t lower, upper; - bt_field_class_status status; bt_field_class_unsigned_enumeration_mapping_get_range_by_index( u_mapping, range_index, &lower, &upper); @@ -237,10 +236,9 @@ int field_class_unsigned_enumeration_copy( label, lower, upper); /* Add the label and its range to the copy field class. */ - status = bt_field_class_unsigned_enumeration_map_range( - out_field_class, label, lower, upper); - - if (status != BT_FIELD_CLASS_STATUS_OK) { + if (bt_field_class_unsigned_enumeration_map_range( + out_field_class, label, lower, upper) != + BT_FIELD_CLASS_ENUMERATION_MAP_RANGE_STATUS_OK) { BT_COMP_LOGE_STR("Failed to add range to unsigned " "enumeration."); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_field_class); @@ -300,7 +298,6 @@ int field_class_signed_enumeration_copy( */ for (range_index = 0; range_index < range_count; range_index++) { int64_t lower, upper; - bt_field_class_status status; bt_field_class_signed_enumeration_mapping_get_range_by_index( i_mapping, range_index, &lower, &upper); @@ -309,9 +306,9 @@ int field_class_signed_enumeration_copy( label, lower, upper); /* Add the label and its range to the copy field class. */ - status = bt_field_class_signed_enumeration_map_range( - out_field_class, label, lower, upper); - if (status != BT_FIELD_CLASS_STATUS_OK) { + if (bt_field_class_signed_enumeration_map_range( + out_field_class, label, lower, upper) != + BT_FIELD_CLASS_ENUMERATION_MAP_RANGE_STATUS_OK) { BT_COMP_LOGE_STR("Failed to add range to signed " "enumeration."); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_field_class); @@ -355,7 +352,6 @@ int field_class_structure_copy( bt_field_class *out_field_class) { uint64_t i, struct_member_count; - bt_field_class_status status; int ret = 0; BT_COMP_LOGD("Copying content of structure field class: " @@ -398,9 +394,9 @@ int field_class_structure_copy( goto error; } - status = bt_field_class_structure_append_member(out_field_class, - member_name, out_member_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { + if (bt_field_class_structure_append_member(out_field_class, + member_name, out_member_field_class) != + BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK) { BT_COMP_LOGE("Cannot append structure field class's field: " "index=%" PRId64 ", " "field-fc-addr=%p, field-name=\"%s\"", @@ -457,7 +453,6 @@ int field_class_variant_copy( const bt_field_class *option_fc; const char *option_name; bt_field_class *out_option_field_class; - bt_field_class_status status; const bt_field_class_variant_option *option; option = bt_field_class_variant_borrow_option_by_index_const( @@ -480,10 +475,10 @@ int field_class_variant_copy( goto error; } - status = bt_field_class_variant_append_option( + if (bt_field_class_variant_append_option( out_field_class, option_name, - out_option_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { + out_option_field_class) != + BT_FIELD_CLASS_VARIANT_APPEND_OPTION_STATUS_OK) { BT_COMP_LOGE_STR("Cannot append option to variant field class'"); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class); ret = -1; @@ -524,7 +519,6 @@ int field_class_dynamic_array_copy( { const bt_field_class *len_fc; const bt_field_path *len_fp; - bt_field_class_status status; bt_field_class *out_len_field_class; int ret = 0; @@ -549,9 +543,9 @@ int field_class_dynamic_array_copy( goto error; } - status = bt_field_class_dynamic_array_set_length_field_class( - out_field_class, out_len_field_class); - if (status != BT_FIELD_CLASS_STATUS_OK) { + if (bt_field_class_dynamic_array_set_length_field_class( + out_field_class, out_len_field_class) != + BT_FIELD_CLASS_DYNAMIC_ARRAY_SET_LENGTH_FIELD_CLASS_STATUS_OK) { BT_COMP_LOGE_STR("Cannot set dynamic array field class' " "length field class."); BT_FIELD_CLASS_PUT_REF_AND_RESET(out_len_field_class); diff --git a/src/plugins/text/details/details.c b/src/plugins/text/details/details.c index 105a6767..37951910 100644 --- a/src/plugins/text/details/details.c +++ b/src/plugins/text/details/details.c @@ -387,22 +387,34 @@ void log_configuration(bt_self_component_sink *comp, } BT_HIDDEN -bt_self_component_status details_init(bt_self_component_sink *comp, +bt_component_class_init_method_status details_init(bt_self_component_sink *comp, const bt_value *params, __attribute__((unused)) void *init_method_data) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; + bt_self_component_add_port_status add_port_status; struct details_comp *details_comp = NULL; - status = bt_self_component_sink_add_input_port(comp, in_port_name, - NULL, NULL); - if (status != BT_SELF_COMPONENT_STATUS_OK) { - goto error; + add_port_status = bt_self_component_sink_add_input_port(comp, + in_port_name, NULL, NULL); + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_OK: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; + break; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; + break; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + break; + default: + abort(); } details_comp = create_details_comp(comp); if (!details_comp) { - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -417,8 +429,8 @@ bt_self_component_status details_init(bt_self_component_sink *comp, goto end; error: - if (status == BT_SELF_COMPONENT_STATUS_OK) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + if (status == BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; } destroy_details_comp(details_comp); @@ -428,10 +440,11 @@ end: } BT_HIDDEN -bt_self_component_status details_graph_is_configured( - bt_self_component_sink *comp) +bt_component_class_sink_graph_is_configured_method_status +details_graph_is_configured(bt_self_component_sink *comp) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_graph_is_configured_method_status status = + BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK; bt_self_component_port_input_message_iterator *iterator; struct details_comp *details_comp; bt_self_component_port_input *in_port; @@ -445,7 +458,7 @@ bt_self_component_status details_graph_is_configured( bt_self_component_port_input_as_port_input(in_port)))) { BT_COMP_LOGE("Single input port is not connected: " "port-name=\"%s\"", in_port_name); - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_ERROR; goto end; } @@ -453,7 +466,7 @@ bt_self_component_status details_graph_is_configured( bt_self_component_sink_borrow_input_port_by_name(comp, in_port_name)); if (!iterator) { - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -465,13 +478,15 @@ end: } BT_HIDDEN -bt_self_component_status details_consume(bt_self_component_sink *comp) +bt_component_class_sink_consume_method_status +details_consume(bt_self_component_sink *comp) { - bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status ret = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; bt_message_array_const msgs; uint64_t count; struct details_comp *details_comp; - bt_message_iterator_status it_ret; + bt_message_iterator_next_status next_status; uint64_t i; details_comp = bt_self_component_get_data( @@ -480,11 +495,11 @@ bt_self_component_status details_consume(bt_self_component_sink *comp) BT_ASSERT(details_comp->msg_iter); /* Consume messages */ - it_ret = bt_self_component_port_input_message_iterator_next( + next_status = bt_self_component_port_input_message_iterator_next( details_comp->msg_iter, &msgs, &count); - switch (it_ret) { - case BT_MESSAGE_ITERATOR_STATUS_OK: - ret = BT_SELF_COMPONENT_STATUS_OK; + switch (next_status) { + case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK: + ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; for (i = 0; i < count; i++) { int print_ret = details_write_message(details_comp, @@ -496,7 +511,7 @@ bt_self_component_status details_consume(bt_self_component_sink *comp) bt_message_put_ref(msgs[i]); } - ret = BT_SELF_COMPONENT_STATUS_ERROR; + ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } @@ -512,17 +527,17 @@ bt_self_component_status details_consume(bt_self_component_sink *comp) } break; - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - ret = BT_SELF_COMPONENT_STATUS_AGAIN; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN: + ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN; goto end; - case BT_MESSAGE_ITERATOR_STATUS_END: - ret = BT_SELF_COMPONENT_STATUS_END; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: + ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END; goto end; - case BT_MESSAGE_ITERATOR_STATUS_ERROR: - ret = BT_SELF_COMPONENT_STATUS_ERROR; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR: + ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - ret = BT_SELF_COMPONENT_STATUS_NOMEM; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR: + ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR; goto end; default: abort(); diff --git a/src/plugins/text/details/details.h b/src/plugins/text/details/details.h index 6bc124bc..f475c9d0 100644 --- a/src/plugins/text/details/details.h +++ b/src/plugins/text/details/details.h @@ -161,7 +161,7 @@ struct details_comp { }; BT_HIDDEN -bt_self_component_status details_init( +bt_component_class_init_method_status details_init( bt_self_component_sink *component, const bt_value *params, void *init_method_data); @@ -169,11 +169,11 @@ BT_HIDDEN void details_finalize(bt_self_component_sink *component); BT_HIDDEN -bt_self_component_status details_graph_is_configured( +bt_component_class_sink_graph_is_configured_method_status details_graph_is_configured( bt_self_component_sink *comp); BT_HIDDEN -bt_self_component_status details_consume(bt_self_component_sink *component); +bt_component_class_sink_consume_method_status details_consume(bt_self_component_sink *component); BT_HIDDEN void details_destroy_details_trace_class_meta( diff --git a/src/plugins/text/details/write.c b/src/plugins/text/details/write.c index 3601d45c..3ea4d41c 100644 --- a/src/plugins/text/details/write.c +++ b/src/plugins/text/details/write.c @@ -1385,7 +1385,7 @@ end: static void write_time(struct details_write_ctx *ctx, const bt_clock_snapshot *cs) { - bt_clock_snapshot_status status; + bt_clock_snapshot_get_ns_from_origin_status cs_status; int64_t ns_from_origin; char buf[32]; @@ -1398,8 +1398,8 @@ void write_time(struct details_write_ctx *ctx, const bt_clock_snapshot *cs) color_bold(ctx), color_fg_blue(ctx), buf, color_reset(ctx), ctx->details_comp->cfg.compact ? "" : " cycles"); - status = bt_clock_snapshot_get_ns_from_origin(cs, &ns_from_origin); - if (status == BT_CLOCK_SNAPSHOT_STATUS_OK) { + cs_status = bt_clock_snapshot_get_ns_from_origin(cs, &ns_from_origin); + if (cs_status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OK) { format_int(buf, ns_from_origin, 10); g_string_append_printf(ctx->str, "%s %s%s%s%s%s", ctx->details_comp->cfg.compact ? "" : ",", diff --git a/src/plugins/text/dmesg/dmesg.c b/src/plugins/text/dmesg/dmesg.c index 3392e3ed..12413b38 100644 --- a/src/plugins/text/dmesg/dmesg.c +++ b/src/plugins/text/dmesg/dmesg.c @@ -375,21 +375,40 @@ void destroy_dmesg_component(struct dmesg_component *dmesg_comp) } static -bt_self_component_status create_port( +bt_component_class_init_method_status create_port( bt_self_component_source *self_comp) { - return bt_self_component_source_add_output_port(self_comp, + bt_component_class_init_method_status status; + bt_self_component_add_port_status add_port_status; + + add_port_status = bt_self_component_source_add_output_port(self_comp, "out", NULL, NULL); + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_OK: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; + break; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; + break; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + break; + default: + abort(); + } + + return status; } BT_HIDDEN -bt_self_component_status dmesg_init( +bt_component_class_init_method_status dmesg_init( bt_self_component_source *self_comp_src, bt_value *params, void *init_method_data) { int ret = 0; struct dmesg_component *dmesg_comp = g_new0(struct dmesg_component, 1); - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; bt_self_component *self_comp = bt_self_component_source_as_self_component(self_comp_src); const bt_component *comp = bt_self_component_as_component(self_comp); @@ -427,7 +446,7 @@ bt_self_component_status dmesg_init( } status = create_port(self_comp_src); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { goto error; } @@ -440,7 +459,7 @@ error: bt_self_component_set_data(self_comp, NULL); if (status >= 0) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; } end: @@ -580,12 +599,7 @@ int fill_event_payload_from_line(struct dmesg_component *dmesg_comp, len--; } - ret = bt_field_string_clear(str_field); - if (ret) { - BT_COMP_LOGE_STR("Cannot clear string field object."); - goto error; - } - + bt_field_string_clear(str_field); ret = bt_field_string_append_with_length(str_field, line, len); if (ret) { BT_COMP_LOGE("Cannot append value to string field object: " @@ -660,7 +674,7 @@ void destroy_dmesg_msg_iter(struct dmesg_msg_iter *dmesg_msg_iter) BT_HIDDEN -bt_self_message_iterator_status dmesg_msg_iter_init( +bt_component_class_message_iterator_init_method_status dmesg_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port) @@ -669,8 +683,8 @@ bt_self_message_iterator_status dmesg_msg_iter_init( bt_self_component_source_as_self_component(self_comp)); struct dmesg_msg_iter *dmesg_msg_iter = g_new0(struct dmesg_msg_iter, 1); - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_init_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK; if (!dmesg_msg_iter) { BT_COMP_LOGE_STR("Failed to allocate on dmesg message iterator structure."); @@ -700,7 +714,7 @@ error: destroy_dmesg_msg_iter(dmesg_msg_iter); bt_self_message_iterator_set_data(self_msg_iter, NULL); if (status >= 0) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR; } end: @@ -716,21 +730,21 @@ void dmesg_msg_iter_finalize( } static -bt_self_message_iterator_status dmesg_msg_iter_next_one( +bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next_one( struct dmesg_msg_iter *dmesg_msg_iter, bt_message **msg) { ssize_t len; struct dmesg_component *dmesg_comp; - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; BT_ASSERT(dmesg_msg_iter); dmesg_comp = dmesg_msg_iter->dmesg_comp; BT_ASSERT(dmesg_comp); if (dmesg_msg_iter->state == STATE_DONE) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; goto end; } @@ -749,14 +763,13 @@ bt_self_message_iterator_status dmesg_msg_iter_next_one( &dmesg_msg_iter->linebuf_len, dmesg_msg_iter->fp); if (len < 0) { if (errno == EINVAL) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; } else if (errno == ENOMEM) { - status = - BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; } else { if (dmesg_msg_iter->state == STATE_EMIT_STREAM_BEGINNING) { /* Stream did not even begin */ - status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; goto end; } else { /* End current packet now */ @@ -857,7 +870,7 @@ handle_state: if (!*msg) { BT_COMP_LOGE("Cannot create message: dmesg-comp-addr=%p", dmesg_comp); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; } end: @@ -865,7 +878,7 @@ end: } BT_HIDDEN -bt_self_message_iterator_status dmesg_msg_iter_next( +bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) @@ -873,18 +886,18 @@ bt_self_message_iterator_status dmesg_msg_iter_next( struct dmesg_msg_iter *dmesg_msg_iter = bt_self_message_iterator_get_data( self_msg_iter); - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; uint64_t i = 0; while (i < capacity && - status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { bt_message *priv_msg = NULL; status = dmesg_msg_iter_next_one(dmesg_msg_iter, &priv_msg); msgs[i] = priv_msg; - if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { i++; } } @@ -903,7 +916,7 @@ bt_self_message_iterator_status dmesg_msg_iter_next( * message, in which case we'll return it. */ *count = i; - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; } return status; @@ -921,7 +934,8 @@ bt_bool dmesg_msg_iter_can_seek_beginning( } BT_HIDDEN -bt_self_message_iterator_status dmesg_msg_iter_seek_beginning( +bt_component_class_message_iterator_seek_beginning_method_status +dmesg_msg_iter_seek_beginning( bt_self_message_iterator *self_msg_iter) { struct dmesg_msg_iter *dmesg_msg_iter = @@ -932,5 +946,5 @@ bt_self_message_iterator_status dmesg_msg_iter_seek_beginning( BT_MESSAGE_PUT_REF_AND_RESET(dmesg_msg_iter->tmp_event_msg); dmesg_msg_iter->last_clock_value = 0; dmesg_msg_iter->state = STATE_EMIT_STREAM_BEGINNING; - return BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; } diff --git a/src/plugins/text/dmesg/dmesg.h b/src/plugins/text/dmesg/dmesg.h index fd29d7a5..45656bf1 100644 --- a/src/plugins/text/dmesg/dmesg.h +++ b/src/plugins/text/dmesg/dmesg.h @@ -28,7 +28,7 @@ #include BT_HIDDEN -bt_self_component_status dmesg_init( +bt_component_class_init_method_status dmesg_init( bt_self_component_source *self_comp, const bt_value *params, void *init_method_data); @@ -36,7 +36,7 @@ BT_HIDDEN void dmesg_finalize(bt_self_component_source *self_comp); BT_HIDDEN -bt_self_message_iterator_status dmesg_msg_iter_init( +bt_component_class_message_iterator_init_method_status dmesg_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port); @@ -46,7 +46,7 @@ void dmesg_msg_iter_finalize( bt_self_message_iterator *self_msg_iter); BT_HIDDEN -bt_self_message_iterator_status dmesg_msg_iter_next( +bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); @@ -56,7 +56,7 @@ bt_bool dmesg_msg_iter_can_seek_beginning( bt_self_message_iterator *message_iterator); BT_HIDDEN -bt_self_message_iterator_status dmesg_msg_iter_seek_beginning( +bt_component_class_message_iterator_seek_beginning_method_status dmesg_msg_iter_seek_beginning( bt_self_message_iterator *message_iterator); #endif /* BABELTRACE_PLUGIN_TEXT_DMESG_DMESG_H */ diff --git a/src/plugins/text/pretty/pretty.c b/src/plugins/text/pretty/pretty.c index b17426c2..0a85530e 100644 --- a/src/plugins/text/pretty/pretty.c +++ b/src/plugins/text/pretty/pretty.c @@ -124,24 +124,25 @@ void pretty_finalize(bt_self_component_sink *comp) } static -bt_self_component_status handle_message( +bt_component_class_message_iterator_next_method_status handle_message( struct pretty_component *pretty, const bt_message *message) { - bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_message_iterator_next_method_status ret = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; BT_ASSERT(pretty); switch (bt_message_get_type(message)) { case BT_MESSAGE_TYPE_EVENT: if (pretty_print_event(pretty, message)) { - ret = BT_SELF_COMPONENT_STATUS_ERROR; + ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; } break; case BT_MESSAGE_TYPE_DISCARDED_EVENTS: case BT_MESSAGE_TYPE_DISCARDED_PACKETS: if (pretty_print_discarded_items(pretty, message)) { - ret = BT_SELF_COMPONENT_STATUS_ERROR; + ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; } break; default: @@ -152,10 +153,11 @@ bt_self_component_status handle_message( } BT_HIDDEN -bt_self_component_status pretty_graph_is_configured( - bt_self_component_sink *comp) +bt_component_class_sink_graph_is_configured_method_status +pretty_graph_is_configured(bt_self_component_sink *comp) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_graph_is_configured_method_status status = + BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK; struct pretty_component *pretty; pretty = bt_self_component_get_data( @@ -166,49 +168,47 @@ bt_self_component_status pretty_graph_is_configured( bt_self_component_sink_borrow_input_port_by_name(comp, in_port_name)); if (!pretty->iterator) { - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; } return status; } BT_HIDDEN -bt_self_component_status pretty_consume( +bt_component_class_sink_consume_method_status pretty_consume( bt_self_component_sink *comp) { - bt_self_component_status ret; + bt_component_class_sink_consume_method_status ret; bt_message_array_const msgs; bt_self_component_port_input_message_iterator *it; struct pretty_component *pretty = bt_self_component_get_data( bt_self_component_sink_as_self_component(comp)); - bt_message_iterator_status it_ret; + bt_message_iterator_next_status next_status; uint64_t count = 0; uint64_t i = 0; it = pretty->iterator; - it_ret = bt_self_component_port_input_message_iterator_next(it, + next_status = bt_self_component_port_input_message_iterator_next(it, &msgs, &count); - switch (it_ret) { - case BT_MESSAGE_ITERATOR_STATUS_OK: + switch (next_status) { + case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK: break; - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - ret = BT_SELF_COMPONENT_STATUS_NOMEM; - goto end; - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - ret = BT_SELF_COMPONENT_STATUS_AGAIN; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR: + case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN: + ret = (int) next_status; goto end; - case BT_MESSAGE_ITERATOR_STATUS_END: - ret = BT_SELF_COMPONENT_STATUS_END; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: + ret = (int) next_status; BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET( pretty->iterator); goto end; default: - ret = BT_SELF_COMPONENT_STATUS_ERROR; + ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; } - BT_ASSERT(it_ret == BT_MESSAGE_ITERATOR_STATUS_OK); + BT_ASSERT(next_status == BT_MESSAGE_ITERATOR_NEXT_STATUS_OK); for (i = 0; i < count; i++) { ret = handle_message(pretty, msgs[i]); @@ -235,18 +235,14 @@ int add_params_to_map(bt_value *plugin_opt_map) for (i = 0; i < BT_ARRAY_SIZE(plugin_options); i++) { const char *key = plugin_options[i]; - bt_value_status status; - - status = bt_value_map_insert_entry(plugin_opt_map, key, - bt_value_null); - switch (status) { - case BT_VALUE_STATUS_OK: - break; - default: + + if (bt_value_map_insert_entry(plugin_opt_map, key, + bt_value_null) < 0) { ret = -1; goto end; } } + end: return ret; } @@ -340,7 +336,6 @@ static int apply_params(struct pretty_component *pretty, const bt_value *params) { int ret = 0; - bt_value_status status; bool value, found; char *str = NULL; @@ -354,15 +349,12 @@ int apply_params(struct pretty_component *pretty, const bt_value *params) goto end; } /* Report unknown parameters. */ - status = bt_value_map_foreach_entry_const(params, - check_param_exists, pretty); - switch (status) { - case BT_VALUE_STATUS_OK: - break; - default: + if (bt_value_map_foreach_entry_const(params, + check_param_exists, pretty) < 0) { ret = -1; goto end; } + /* Known parameters. */ pretty->options.color = PRETTY_COLOR_OPT_AUTO; if (bt_value_map_has_entry(params, "color")) { @@ -636,23 +628,23 @@ void init_stream_packet_context_quarks(void) } BT_HIDDEN -bt_self_component_status pretty_init( - bt_self_component_sink *comp, - const bt_value *params, +bt_component_class_init_method_status pretty_init( + bt_self_component_sink *comp, const bt_value *params, __attribute__((unused)) void *init_method_data) { - bt_self_component_status ret; + bt_component_class_init_method_status ret = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; struct pretty_component *pretty = create_pretty(); if (!pretty) { - ret = BT_SELF_COMPONENT_STATUS_NOMEM; + ret = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto end; } - ret = bt_self_component_sink_add_input_port(comp, in_port_name, - NULL, NULL); - if (ret != BT_SELF_COMPONENT_STATUS_OK) { - goto end; + if (bt_self_component_sink_add_input_port(comp, + in_port_name, NULL, NULL) < 0) { + ret = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + goto error; } pretty->out = stdout; @@ -665,7 +657,7 @@ bt_self_component_status pretty_init( pretty->last_real_timestamp = -1ULL; if (apply_params(pretty, params)) { - ret = BT_SELF_COMPONENT_STATUS_ERROR; + ret = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto error; } diff --git a/src/plugins/text/pretty/pretty.h b/src/plugins/text/pretty/pretty.h index 72203df2..f038643a 100644 --- a/src/plugins/text/pretty/pretty.h +++ b/src/plugins/text/pretty/pretty.h @@ -106,17 +106,16 @@ extern GQuark stream_packet_context_quarks[STREAM_PACKET_CONTEXT_QUARKS_LEN]; BT_HIDDEN -bt_self_component_status pretty_init( - bt_self_component_sink *component, - const bt_value *params, +bt_component_class_init_method_status pretty_init( + bt_self_component_sink *component, const bt_value *params, void *init_method_data); BT_HIDDEN -bt_self_component_status pretty_consume( +bt_component_class_sink_consume_method_status pretty_consume( bt_self_component_sink *component); BT_HIDDEN -bt_self_component_status pretty_graph_is_configured( +bt_component_class_sink_graph_is_configured_method_status pretty_graph_is_configured( bt_self_component_sink *component); BT_HIDDEN diff --git a/src/plugins/utils/counter/counter.c b/src/plugins/utils/counter/counter.c index f8561e76..db269e78 100644 --- a/src/plugins/utils/counter/counter.c +++ b/src/plugins/utils/counter/counter.c @@ -137,18 +137,20 @@ void counter_finalize(bt_self_component_sink *comp) } BT_HIDDEN -bt_self_component_status counter_init( +bt_component_class_init_method_status counter_init( bt_self_component_sink *component, const bt_value *params, __attribute__((unused)) void *init_method_data) { - bt_self_component_status ret; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; + bt_self_component_add_port_status add_port_status; struct counter *counter = g_new0(struct counter, 1); const bt_value *step = NULL; const bt_value *hide_zero = NULL; if (!counter) { - ret = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -156,10 +158,17 @@ bt_self_component_status counter_init( bt_self_component_sink_as_self_component(component); counter->log_level = bt_component_get_logging_level( bt_self_component_as_component(counter->self_comp)); - ret = bt_self_component_sink_add_input_port(component, + add_port_status = bt_self_component_sink_add_input_port(component, "in", NULL, NULL); - if (ret != BT_SELF_COMPONENT_STATUS_OK) { + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto error; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + goto error; + default: + break; } counter->last_printed_total = -1ULL; @@ -195,17 +204,22 @@ bt_self_component_status counter_init( error: destroy_private_counter_data(counter); - ret = BT_SELF_COMPONENT_STATUS_ERROR; + + if (status == BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; + } end: - return ret; + return status; } BT_HIDDEN -bt_self_component_status counter_graph_is_configured( +bt_component_class_sink_graph_is_configured_method_status +counter_graph_is_configured( bt_self_component_sink *comp) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_graph_is_configured_method_status status = + BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK; struct counter *counter; bt_self_component_port_input_message_iterator *iterator; @@ -216,7 +230,7 @@ bt_self_component_status counter_graph_is_configured( bt_self_component_sink_borrow_input_port_by_name(comp, in_port_name)); if (!iterator) { - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -228,12 +242,13 @@ end: } BT_HIDDEN -bt_self_component_status counter_consume( +bt_component_class_sink_consume_method_status counter_consume( bt_self_component_sink *comp) { - bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; struct counter *counter; - bt_message_iterator_status it_ret; + bt_message_iterator_next_status next_status; uint64_t msg_count; bt_message_array_const msgs; @@ -243,20 +258,20 @@ bt_self_component_status counter_consume( if (G_UNLIKELY(!counter->msg_iter)) { try_print_last(counter); - ret = BT_SELF_COMPONENT_STATUS_END; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END; goto end; } /* Consume messages */ - it_ret = bt_self_component_port_input_message_iterator_next( + next_status = bt_self_component_port_input_message_iterator_next( counter->msg_iter, &msgs, &msg_count); - if (it_ret < 0) { - ret = BT_SELF_COMPONENT_STATUS_ERROR; + if (next_status < 0) { + status = (int) next_status; goto end; } - switch (it_ret) { - case BT_MESSAGE_ITERATOR_STATUS_OK: + switch (next_status) { + case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK: { uint64_t i; @@ -302,18 +317,18 @@ bt_self_component_status counter_consume( bt_message_put_ref(msg); } - ret = BT_SELF_COMPONENT_STATUS_OK; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; break; } - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - ret = BT_SELF_COMPONENT_STATUS_AGAIN; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN; goto end; - case BT_MESSAGE_ITERATOR_STATUS_END: + case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: try_print_last(counter); - ret = BT_SELF_COMPONENT_STATUS_END; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END; goto end; - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - ret = BT_SELF_COMPONENT_STATUS_NOMEM; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR; goto end; default: break; @@ -322,5 +337,5 @@ bt_self_component_status counter_consume( try_print_count(counter, msg_count); end: - return ret; + return status; } diff --git a/src/plugins/utils/counter/counter.h b/src/plugins/utils/counter/counter.h index 48135ef3..3d8b8b6e 100644 --- a/src/plugins/utils/counter/counter.h +++ b/src/plugins/utils/counter/counter.h @@ -53,7 +53,7 @@ struct counter { }; BT_HIDDEN -bt_self_component_status counter_init( +bt_component_class_init_method_status counter_init( bt_self_component_sink *component, const bt_value *params, void *init_method_data); @@ -61,10 +61,10 @@ BT_HIDDEN void counter_finalize(bt_self_component_sink *component); BT_HIDDEN -bt_self_component_status counter_graph_is_configured( +bt_component_class_sink_graph_is_configured_method_status counter_graph_is_configured( bt_self_component_sink *component); BT_HIDDEN -bt_self_component_status counter_consume(bt_self_component_sink *component); +bt_component_class_sink_consume_method_status counter_consume(bt_self_component_sink *component); #endif /* BABELTRACE_PLUGINS_UTILS_COUNTER_H */ diff --git a/src/plugins/utils/dummy/dummy.c b/src/plugins/utils/dummy/dummy.c index a2a35cb9..a5516cc6 100644 --- a/src/plugins/utils/dummy/dummy.c +++ b/src/plugins/utils/dummy/dummy.c @@ -48,23 +48,32 @@ void dummy_finalize(bt_self_component_sink *comp) } BT_HIDDEN -bt_self_component_status dummy_init( +bt_component_class_init_method_status dummy_init( bt_self_component_sink *component, const bt_value *params, __attribute__((unused)) void *init_method_data) { - bt_self_component_status ret; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; + bt_self_component_add_port_status add_port_status; struct dummy *dummy = g_new0(struct dummy, 1); if (!dummy) { - ret = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto end; } - ret = bt_self_component_sink_add_input_port(component, + add_port_status = bt_self_component_sink_add_input_port(component, "in", NULL, NULL); - if (ret != BT_SELF_COMPONENT_STATUS_OK) { + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto error; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + goto error; + default: + break; } bt_self_component_set_data( @@ -75,14 +84,15 @@ error: destroy_private_dummy_data(dummy); end: - return ret; + return status; } BT_HIDDEN -bt_self_component_status dummy_graph_is_configured( +bt_component_class_sink_graph_is_configured_method_status dummy_graph_is_configured( bt_self_component_sink *comp) { - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_graph_is_configured_method_status status = + BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK; struct dummy *dummy; bt_self_component_port_input_message_iterator *iterator; @@ -93,7 +103,7 @@ bt_self_component_status dummy_graph_is_configured( bt_self_component_sink_borrow_input_port_by_name(comp, in_port_name)); if (!iterator) { - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -105,14 +115,15 @@ end: } BT_HIDDEN -bt_self_component_status dummy_consume( +bt_component_class_sink_consume_method_status dummy_consume( bt_self_component_sink *component) { - bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_sink_consume_method_status status = + BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; bt_message_array_const msgs; uint64_t count; struct dummy *dummy; - bt_message_iterator_status it_ret; + bt_message_iterator_next_status next_status; uint64_t i; dummy = bt_self_component_get_data( @@ -120,38 +131,38 @@ bt_self_component_status dummy_consume( BT_ASSERT(dummy); if (G_UNLIKELY(!dummy->msg_iter)) { - ret = BT_SELF_COMPONENT_STATUS_END; + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END; goto end; } /* Consume one message */ - it_ret = bt_self_component_port_input_message_iterator_next( + next_status = bt_self_component_port_input_message_iterator_next( dummy->msg_iter, &msgs, &count); - switch (it_ret) { - case BT_MESSAGE_ITERATOR_STATUS_OK: - ret = BT_SELF_COMPONENT_STATUS_OK; + switch (next_status) { + case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; for (i = 0; i < count; i++) { bt_message_put_ref(msgs[i]); } break; - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - ret = BT_SELF_COMPONENT_STATUS_AGAIN; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN; goto end; - case BT_MESSAGE_ITERATOR_STATUS_END: - ret = BT_SELF_COMPONENT_STATUS_END; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END; goto end; - case BT_MESSAGE_ITERATOR_STATUS_ERROR: - ret = BT_SELF_COMPONENT_STATUS_ERROR; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR; goto end; - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - ret = BT_SELF_COMPONENT_STATUS_NOMEM; + case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR; goto end; default: break; } end: - return ret; + return status; } diff --git a/src/plugins/utils/dummy/dummy.h b/src/plugins/utils/dummy/dummy.h index 2b05f6cf..c5ab55ae 100644 --- a/src/plugins/utils/dummy/dummy.h +++ b/src/plugins/utils/dummy/dummy.h @@ -33,7 +33,7 @@ struct dummy { }; BT_HIDDEN -bt_self_component_status dummy_init( +bt_component_class_init_method_status dummy_init( bt_self_component_sink *component, const bt_value *params, void *init_method_data); @@ -41,11 +41,11 @@ BT_HIDDEN void dummy_finalize(bt_self_component_sink *component); BT_HIDDEN -bt_self_component_status dummy_graph_is_configured( +bt_component_class_sink_graph_is_configured_method_status dummy_graph_is_configured( bt_self_component_sink *comp); BT_HIDDEN -bt_self_component_status dummy_consume( +bt_component_class_sink_consume_method_status dummy_consume( bt_self_component_sink *component); #endif /* BABELTRACE_PLUGINS_UTILS_DUMMY_H */ diff --git a/src/plugins/utils/muxer/muxer.c b/src/plugins/utils/muxer/muxer.c index 0d641235..d47ad6e0 100644 --- a/src/plugins/utils/muxer/muxer.c +++ b/src/plugins/utils/muxer/muxer.c @@ -184,30 +184,31 @@ end: } static -bt_self_component_status add_available_input_port( +bt_self_component_add_port_status add_available_input_port( bt_self_component_filter *self_comp) { struct muxer_comp *muxer_comp = bt_self_component_get_data( bt_self_component_filter_as_self_component(self_comp)); - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_self_component_add_port_status status = + BT_SELF_COMPONENT_ADD_PORT_STATUS_OK; GString *port_name = NULL; BT_ASSERT(muxer_comp); port_name = g_string_new("in"); if (!port_name) { BT_COMP_LOGE_STR("Failed to allocate a GString."); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR; goto end; } g_string_append_printf(port_name, "%u", muxer_comp->next_port_num); status = bt_self_component_filter_add_input_port( self_comp, port_name->str, NULL, NULL); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { BT_COMP_LOGE("Cannot add input port to muxer component: " "port-name=\"%s\", comp-addr=%p, status=%s", port_name->str, self_comp, - bt_self_component_status_string(status)); + bt_common_func_status_string(status)); goto end; } @@ -226,7 +227,7 @@ end: } static -bt_self_component_status create_output_port( +bt_self_component_add_port_status create_output_port( bt_self_component_filter *self_comp) { return bt_self_component_filter_add_output_port( @@ -326,12 +327,14 @@ end: } BT_HIDDEN -bt_self_component_status muxer_init( +bt_component_class_init_method_status muxer_init( bt_self_component_filter *self_comp_flt, const bt_value *params, void *init_data) { int ret; - bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; + bt_self_component_add_port_status add_port_status; bt_self_component *self_comp = bt_self_component_filter_as_self_component(self_comp_flt); struct muxer_comp *muxer_comp = g_new0(struct muxer_comp, 1); @@ -360,21 +363,35 @@ bt_self_component_status muxer_init( } bt_self_component_set_data(self_comp, muxer_comp); - status = add_available_input_port(self_comp_flt); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + add_port_status = add_available_input_port(self_comp_flt); + if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { BT_COMP_LOGE("Cannot ensure that at least one muxer component's input port is available: " "muxer-comp-addr=%p, status=%s", muxer_comp, - bt_self_component_status_string(status)); + bt_common_func_status_string(add_port_status)); + if (add_port_status == + BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR) { + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + } else { + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; + } + goto error; } - status = create_output_port(self_comp_flt); - if (status) { + add_port_status = create_output_port(self_comp_flt); + if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { BT_COMP_LOGE("Cannot create muxer component's output port: " "muxer-comp-addr=%p, status=%s", muxer_comp, - bt_self_component_status_string(status)); + bt_common_func_status_string(add_port_status)); + if (add_port_status == + BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR) { + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + } else { + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; + } + goto error; } @@ -388,8 +405,8 @@ error: destroy_muxer_comp(muxer_comp); bt_self_component_set_data(self_comp, NULL); - if (status == BT_SELF_COMPONENT_STATUS_OK) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + if (status == BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; } end: @@ -442,14 +459,14 @@ end: } static -bt_self_message_iterator_status muxer_upstream_msg_iter_next( +bt_component_class_message_iterator_next_method_status muxer_upstream_msg_iter_next( struct muxer_upstream_msg_iter *muxer_upstream_msg_iter, bool *is_ended) { struct muxer_comp *muxer_comp = muxer_upstream_msg_iter->muxer_comp; - bt_self_message_iterator_status status; - bt_message_iterator_status input_port_iter_status; + bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_next_status input_port_iter_status; bt_message_array_const msgs; uint64_t i; uint64_t count; @@ -461,10 +478,11 @@ bt_self_message_iterator_status muxer_upstream_msg_iter_next( input_port_iter_status = bt_self_component_port_input_message_iterator_next( muxer_upstream_msg_iter->msg_iter, &msgs, &count); BT_COMP_LOGD("Upstream message iterator's \"next\" method returned: " - "status=%s", bt_message_iterator_status_string(input_port_iter_status)); + "status=%s", + bt_common_func_status_string(input_port_iter_status)); switch (input_port_iter_status) { - case BT_MESSAGE_ITERATOR_STATUS_OK: + case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK: /* * Message iterator's current message is * valid: it must be considered for muxing operations. @@ -482,30 +500,30 @@ bt_self_message_iterator_status muxer_upstream_msg_iter_next( g_queue_push_tail(muxer_upstream_msg_iter->msgs, (void *) msgs[i]); } - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; break; - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN: /* * Message iterator's current message is not * valid anymore. Return - * BT_MESSAGE_ITERATOR_STATUS_AGAIN immediately. + * BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN immediately. */ - status = BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN; break; - case BT_MESSAGE_ITERATOR_STATUS_END: /* Fall-through. */ + case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: /* Fall-through. */ /* * Message iterator reached the end: release it. It * won't be considered again to find the youngest * message. */ *is_ended = true; - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; break; default: /* Error or unsupported status code */ BT_COMP_LOGE("Error or unsupported status code: " "status-code=%d", input_port_iter_status); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; break; } @@ -891,7 +909,7 @@ end: * the youngest, and sets *ts_ns to its time. */ static -bt_self_message_iterator_status +bt_component_class_message_iterator_next_method_status muxer_msg_iter_youngest_upstream_msg_iter( struct muxer_comp *muxer_comp, struct muxer_msg_iter *muxer_msg_iter, @@ -901,8 +919,8 @@ muxer_msg_iter_youngest_upstream_msg_iter( size_t i; int ret; int64_t youngest_ts_ns = INT64_MAX; - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; BT_ASSERT(muxer_comp); BT_ASSERT(muxer_msg_iter); @@ -941,7 +959,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( * validate_new_stream_clock_class() logs * errors. */ - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } } else if (G_UNLIKELY(bt_message_get_type(msg) == @@ -954,7 +972,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( bt_clock_snapshot_borrow_clock_class_const(cs)); if (ret) { /* validate_clock_class() logs errors */ - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } } @@ -964,7 +982,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( if (ret) { /* get_msg_ts_ns() logs errors */ *muxer_upstream_msg_iter = NULL; - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -977,7 +995,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( } if (!*muxer_upstream_msg_iter) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; *ts_ns = INT64_MIN; } @@ -986,14 +1004,15 @@ end: } static -bt_self_message_iterator_status validate_muxer_upstream_msg_iter( +bt_component_class_message_iterator_next_method_status +validate_muxer_upstream_msg_iter( struct muxer_upstream_msg_iter *muxer_upstream_msg_iter, bool *is_ended) { struct muxer_comp *muxer_comp = muxer_upstream_msg_iter->muxer_comp; - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; BT_COMP_LOGD("Validating muxer's upstream message iterator wrapper: " "muxer-upstream-msg-iter-wrap-addr=%p", @@ -1017,12 +1036,13 @@ end: } static -bt_self_message_iterator_status validate_muxer_upstream_msg_iters( +bt_component_class_message_iterator_next_method_status +validate_muxer_upstream_msg_iters( struct muxer_msg_iter *muxer_msg_iter) { struct muxer_comp *muxer_comp = muxer_msg_iter->muxer_comp; - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; size_t i; BT_COMP_LOGD("Validating muxer's upstream message iterator wrappers: " @@ -1038,7 +1058,7 @@ bt_self_message_iterator_status validate_muxer_upstream_msg_iters( status = validate_muxer_upstream_msg_iter( muxer_upstream_msg_iter, &is_ended); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { if (status < 0) { BT_COMP_LOGE("Cannot validate muxer's upstream message iterator wrapper: " "muxer-msg-iter-addr=%p, " @@ -1086,17 +1106,17 @@ end: } static inline -bt_self_message_iterator_status muxer_msg_iter_do_next_one( +bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next_one( struct muxer_comp *muxer_comp, struct muxer_msg_iter *muxer_msg_iter, const bt_message **msg) { - bt_self_message_iterator_status status; + bt_component_class_message_iterator_next_method_status status; struct muxer_upstream_msg_iter *muxer_upstream_msg_iter = NULL; int64_t next_return_ts; status = validate_muxer_upstream_msg_iters(muxer_msg_iter); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { /* validate_muxer_upstream_msg_iters() logs details */ goto end; } @@ -1110,15 +1130,15 @@ bt_self_message_iterator_status muxer_msg_iter_do_next_one( status = muxer_msg_iter_youngest_upstream_msg_iter(muxer_comp, muxer_msg_iter, &muxer_upstream_msg_iter, &next_return_ts); - if (status < 0 || status == BT_SELF_MESSAGE_ITERATOR_STATUS_END) { + if (status < 0 || status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END) { if (status < 0) { BT_COMP_LOGE("Cannot find the youngest upstream message iterator wrapper: " "status=%s", - bt_common_self_message_iterator_status_string(status)); + bt_common_func_status_string(status)); } else { BT_COMP_LOGD("Cannot find the youngest upstream message iterator wrapper: " "status=%s", - bt_common_self_message_iterator_status_string(status)); + bt_common_func_status_string(status)); } goto end; @@ -1130,7 +1150,7 @@ bt_self_message_iterator_status muxer_msg_iter_do_next_one( "last-returned-ts=%" PRId64, muxer_msg_iter, next_return_ts, muxer_msg_iter->last_returned_ts_ns); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1139,7 +1159,7 @@ bt_self_message_iterator_status muxer_msg_iter_do_next_one( "muxer-upstream-msg-iter-wrap-addr=%p, " "ts=%" PRId64, muxer_msg_iter, muxer_upstream_msg_iter, next_return_ts); - BT_ASSERT(status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK); + BT_ASSERT(status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK); BT_ASSERT(muxer_upstream_msg_iter); /* @@ -1155,20 +1175,20 @@ end: } static -bt_self_message_iterator_status muxer_msg_iter_do_next( +bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next( struct muxer_comp *muxer_comp, struct muxer_msg_iter *muxer_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; uint64_t i = 0; - while (i < capacity && status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + while (i < capacity && status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { status = muxer_msg_iter_do_next_one(muxer_comp, muxer_msg_iter, &msgs[i]); - if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { i++; } } @@ -1187,7 +1207,7 @@ bt_self_message_iterator_status muxer_msg_iter_do_next( * message, in which case we'll return it. */ *count = i; - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; } return status; @@ -1281,15 +1301,15 @@ end: } BT_HIDDEN -bt_self_message_iterator_status muxer_msg_iter_init( +bt_component_class_message_iterator_init_method_status muxer_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp, bt_self_component_port_output *port) { struct muxer_comp *muxer_comp = NULL; struct muxer_msg_iter *muxer_msg_iter = NULL; - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_init_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK; int ret; muxer_comp = bt_self_component_get_data( @@ -1357,7 +1377,7 @@ bt_self_message_iterator_status muxer_msg_iter_init( error: destroy_muxer_msg_iter(muxer_msg_iter); bt_self_message_iterator_set_data(self_msg_iter, NULL); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR; end: muxer_comp->initializing_muxer_msg_iter = false; @@ -1387,12 +1407,12 @@ void muxer_msg_iter_finalize(bt_self_message_iterator *self_msg_iter) } BT_HIDDEN -bt_self_message_iterator_status muxer_msg_iter_next( +bt_component_class_message_iterator_next_method_status muxer_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_self_message_iterator_status status; + bt_component_class_message_iterator_next_method_status status; struct muxer_msg_iter *muxer_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); bt_self_component *self_comp = NULL; @@ -1416,35 +1436,41 @@ bt_self_message_iterator_status muxer_msg_iter_next( "comp-addr=%p, muxer-comp-addr=%p, muxer-msg-iter-addr=%p, " "msg-iter-addr=%p, status=%s", self_comp, muxer_comp, muxer_msg_iter, self_msg_iter, - bt_common_self_message_iterator_status_string(status)); + bt_common_func_status_string(status)); } else { BT_COMP_LOGT("Returning from muxer component's message iterator's \"next\" method: " "status=%s", - bt_common_self_message_iterator_status_string(status)); + bt_common_func_status_string(status)); } return status; } BT_HIDDEN -bt_self_component_status muxer_input_port_connected( +bt_component_class_port_connected_method_status muxer_input_port_connected( bt_self_component_filter *self_comp, bt_self_component_port_input *self_port, const bt_port_output *other_port) { - bt_self_component_status status; + bt_component_class_port_connected_method_status status = + BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_OK; + bt_self_component_add_port_status add_port_status; struct muxer_comp *muxer_comp = bt_self_component_get_data( bt_self_component_filter_as_self_component(self_comp)); - status = add_available_input_port(self_comp); - if (status) { - /* - * Only way to report an error later since this - * method does not return anything. - */ + add_port_status = add_available_input_port(self_comp); + if (add_port_status) { BT_COMP_LOGE("Cannot add one muxer component's input port: " "status=%s", - bt_self_component_status_string(status)); + bt_common_func_status_string(status)); + + if (add_port_status == + BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR) { + status = BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_MEMORY_ERROR; + } else { + status = BT_COMPONENT_CLASS_PORT_CONNECTED_METHOD_STATUS_ERROR; + } + goto end; } @@ -1499,12 +1525,14 @@ end: } BT_HIDDEN -bt_self_message_iterator_status muxer_msg_iter_seek_beginning( +bt_component_class_message_iterator_seek_beginning_method_status muxer_msg_iter_seek_beginning( bt_self_message_iterator *self_msg_iter) { struct muxer_msg_iter *muxer_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); - bt_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_seek_beginning_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; + bt_message_iterator_seek_beginning_status seek_beg_status; uint64_t i; /* Seek all ended upstream iterators first */ @@ -1513,9 +1541,10 @@ bt_self_message_iterator_status muxer_msg_iter_seek_beginning( struct muxer_upstream_msg_iter *upstream_msg_iter = muxer_msg_iter->ended_muxer_upstream_msg_iters->pdata[i]; - status = bt_self_component_port_input_message_iterator_seek_beginning( + seek_beg_status = bt_self_component_port_input_message_iterator_seek_beginning( upstream_msg_iter->msg_iter); - if (status != BT_MESSAGE_ITERATOR_STATUS_OK) { + if (seek_beg_status != BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_OK) { + status = (int) seek_beg_status; goto end; } @@ -1528,9 +1557,10 @@ bt_self_message_iterator_status muxer_msg_iter_seek_beginning( struct muxer_upstream_msg_iter *upstream_msg_iter = muxer_msg_iter->active_muxer_upstream_msg_iters->pdata[i]; - status = bt_self_component_port_input_message_iterator_seek_beginning( + seek_beg_status = bt_self_component_port_input_message_iterator_seek_beginning( upstream_msg_iter->msg_iter); - if (status != BT_MESSAGE_ITERATOR_STATUS_OK) { + if (seek_beg_status != BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_OK) { + status = (int) seek_beg_status; goto end; } @@ -1555,5 +1585,5 @@ bt_self_message_iterator_status muxer_msg_iter_seek_beginning( MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ANY; end: - return (bt_self_message_iterator_status) status; + return status; } diff --git a/src/plugins/utils/muxer/muxer.h b/src/plugins/utils/muxer/muxer.h index 43b4d52b..95faf568 100644 --- a/src/plugins/utils/muxer/muxer.h +++ b/src/plugins/utils/muxer/muxer.h @@ -29,7 +29,7 @@ #include "common/macros.h" BT_HIDDEN -bt_self_component_status muxer_init( +bt_component_class_init_method_status muxer_init( bt_self_component_filter *self_comp, const bt_value *params, void *init_data); @@ -37,7 +37,7 @@ BT_HIDDEN void muxer_finalize(bt_self_component_filter *self_comp); BT_HIDDEN -bt_self_message_iterator_status muxer_msg_iter_init( +bt_component_class_message_iterator_init_method_status muxer_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp, bt_self_component_port_output *self_port); @@ -47,13 +47,13 @@ void muxer_msg_iter_finalize( bt_self_message_iterator *self_msg_iter); BT_HIDDEN -bt_self_message_iterator_status muxer_msg_iter_next( +bt_component_class_message_iterator_next_method_status muxer_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); BT_HIDDEN -bt_self_component_status muxer_input_port_connected( +bt_component_class_port_connected_method_status muxer_input_port_connected( bt_self_component_filter *comp, bt_self_component_port_input *self_port, const bt_port_output *other_port); @@ -63,7 +63,7 @@ bt_bool muxer_msg_iter_can_seek_beginning( bt_self_message_iterator *message_iterator); BT_HIDDEN -bt_self_message_iterator_status muxer_msg_iter_seek_beginning( +bt_component_class_message_iterator_seek_beginning_method_status muxer_msg_iter_seek_beginning( bt_self_message_iterator *message_iterator); #endif /* BABELTRACE_PLUGINS_UTILS_MUXER_H */ diff --git a/src/plugins/utils/trimmer/trimmer.c b/src/plugins/utils/trimmer/trimmer.c index 218f7788..91402204 100644 --- a/src/plugins/utils/trimmer/trimmer.c +++ b/src/plugins/utils/trimmer/trimmer.c @@ -435,7 +435,7 @@ int init_trimmer_comp_from_params(struct trimmer_comp *trimmer_comp, if (set_bound_from_param(trimmer_comp, "begin", value, &trimmer_comp->begin, trimmer_comp->is_gmt)) { /* set_bound_from_param() logs errors */ - ret = BT_SELF_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } } else { @@ -448,7 +448,7 @@ int init_trimmer_comp_from_params(struct trimmer_comp *trimmer_comp, if (set_bound_from_param(trimmer_comp, "end", value, &trimmer_comp->end, trimmer_comp->is_gmt)) { /* set_bound_from_param() logs errors */ - ret = BT_SELF_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } } else { @@ -466,37 +466,54 @@ end: return ret; } -bt_self_component_status trimmer_init(bt_self_component_filter *self_comp_flt, +bt_component_class_init_method_status trimmer_init( + bt_self_component_filter *self_comp_flt, const bt_value *params, void *init_data) { int ret; - bt_self_component_status status; + bt_component_class_init_method_status status = + BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; + bt_self_component_add_port_status add_port_status; struct trimmer_comp *trimmer_comp = create_trimmer_comp(); bt_self_component *self_comp = bt_self_component_filter_as_self_component(self_comp_flt); if (!trimmer_comp) { - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; goto error; } trimmer_comp->log_level = bt_component_get_logging_level( bt_self_component_as_component(self_comp)); trimmer_comp->self_comp = self_comp; - status = bt_self_component_filter_add_input_port( + add_port_status = bt_self_component_filter_add_input_port( self_comp_flt, in_port_name, NULL, NULL); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto error; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + goto error; + default: + break; } - status = bt_self_component_filter_add_output_port( + add_port_status = bt_self_component_filter_add_output_port( self_comp_flt, "out", NULL, NULL); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + switch (add_port_status) { + case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto error; + case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR: + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR; + goto error; + default: + break; } ret = init_trimmer_comp_from_params(trimmer_comp, params); if (ret) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; goto error; } @@ -504,8 +521,8 @@ bt_self_component_status trimmer_init(bt_self_component_filter *self_comp_flt, goto end; error: - if (status == BT_SELF_COMPONENT_STATUS_OK) { - status = BT_SELF_COMPONENT_STATUS_ERROR; + if (status == BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) { + status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR; } if (trimmer_comp) { @@ -544,18 +561,18 @@ void destroy_trimmer_iterator_stream_state( } BT_HIDDEN -bt_self_message_iterator_status trimmer_msg_iter_init( +bt_component_class_message_iterator_init_method_status trimmer_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp, bt_self_component_port_output *port) { - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_init_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK; struct trimmer_iterator *trimmer_it; trimmer_it = g_new0(struct trimmer_iterator, 1); if (!trimmer_it) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -581,13 +598,13 @@ bt_self_message_iterator_status trimmer_msg_iter_init( bt_self_component_filter_borrow_input_port_by_name( self_comp, in_port_name)); if (!trimmer_it->upstream_iter) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR; goto end; } trimmer_it->output_messages = g_queue_new(); if (!trimmer_it->output_messages) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -595,7 +612,7 @@ bt_self_message_iterator_status trimmer_msg_iter_init( g_direct_equal, NULL, (GDestroyNotify) destroy_trimmer_iterator_stream_state); if (!trimmer_it->stream_states) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -603,7 +620,7 @@ bt_self_message_iterator_status trimmer_msg_iter_init( bt_self_message_iterator_set_data(self_msg_iter, trimmer_it); end: - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK && trimmer_it) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK && trimmer_it) { destroy_trimmer_iterator(trimmer_it); } @@ -792,11 +809,12 @@ end: } static -bt_self_message_iterator_status state_set_trimmer_iterator_bounds( +bt_component_class_message_iterator_next_method_status +state_set_trimmer_iterator_bounds( struct trimmer_iterator *trimmer_it) { - bt_message_iterator_status upstream_iter_status = - BT_MESSAGE_ITERATOR_STATUS_OK; + bt_message_iterator_next_status upstream_iter_status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; struct trimmer_comp *trimmer_comp = trimmer_it->trimmer_comp; bt_message_array_const msgs; uint64_t count = 0; @@ -811,7 +829,7 @@ bt_self_message_iterator_status state_set_trimmer_iterator_bounds( upstream_iter_status = bt_self_component_port_input_message_iterator_next( trimmer_it->upstream_iter, &msgs, &count); - if (upstream_iter_status != BT_MESSAGE_ITERATOR_STATUS_OK) { + if (upstream_iter_status != BT_MESSAGE_ITERATOR_NEXT_STATUS_OK) { goto end; } @@ -868,19 +886,20 @@ found: error: put_messages(msgs, count); - upstream_iter_status = BT_MESSAGE_ITERATOR_STATUS_ERROR; + upstream_iter_status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; end: return (int) upstream_iter_status; } static -bt_self_message_iterator_status state_seek_initially( +bt_component_class_message_iterator_next_method_status state_seek_initially( struct trimmer_iterator *trimmer_it) { struct trimmer_comp *trimmer_comp = trimmer_it->trimmer_comp; - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; BT_ASSERT(trimmer_it->begin.is_set); @@ -888,7 +907,7 @@ bt_self_message_iterator_status state_seek_initially( if (!bt_self_component_port_input_message_iterator_can_seek_beginning( trimmer_it->upstream_iter)) { BT_COMP_LOGE_STR("Cannot make upstream message iterator initially seek its beginning."); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -901,7 +920,7 @@ bt_self_message_iterator_status state_seek_initially( BT_COMP_LOGE("Cannot make upstream message iterator initially seek: " "seek-ns-from-origin=%" PRId64, trimmer_it->begin.ns_from_origin); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -909,7 +928,7 @@ bt_self_message_iterator_status state_seek_initially( trimmer_it->upstream_iter, trimmer_it->begin.ns_from_origin); } - if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { trimmer_it->state = TRIMMER_ITERATOR_STATE_TRIM; } @@ -945,11 +964,12 @@ int clock_raw_value_from_ns_from_origin(const bt_clock_class *clock_class, } static inline -bt_self_message_iterator_status end_stream(struct trimmer_iterator *trimmer_it, +bt_component_class_message_iterator_next_method_status +end_stream(struct trimmer_iterator *trimmer_it, struct trimmer_iterator_stream_state *sstate) { - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; uint64_t raw_value; const bt_clock_class *clock_class; int ret; @@ -978,7 +998,7 @@ bt_self_message_iterator_status end_stream(struct trimmer_iterator *trimmer_it, ret = clock_raw_value_from_ns_from_origin(clock_class, trimmer_it->end.ns_from_origin, &raw_value); if (ret) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -986,7 +1006,7 @@ bt_self_message_iterator_status end_stream(struct trimmer_iterator *trimmer_it, trimmer_it->self_msg_iter, sstate->cur_packet, raw_value); if (!msg) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1009,7 +1029,7 @@ bt_self_message_iterator_status end_stream(struct trimmer_iterator *trimmer_it, msg = bt_message_stream_activity_end_create( trimmer_it->self_msg_iter, sstate->stream); if (!msg) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1032,7 +1052,7 @@ bt_self_message_iterator_status end_stream(struct trimmer_iterator *trimmer_it, ret = clock_raw_value_from_ns_from_origin(clock_class, sstate->stream_act_end_ns_from_origin, &raw_value); if (ret) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1046,7 +1066,7 @@ bt_self_message_iterator_status end_stream(struct trimmer_iterator *trimmer_it, msg = bt_message_stream_end_create(trimmer_it->self_msg_iter, sstate->stream); if (!msg) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1065,11 +1085,11 @@ end: } static inline -bt_self_message_iterator_status end_iterator_streams( +bt_component_class_message_iterator_next_method_status end_iterator_streams( struct trimmer_iterator *trimmer_it) { - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; GHashTableIter iter; gpointer key, sstate; @@ -1103,14 +1123,15 @@ end: } static inline -bt_self_message_iterator_status create_stream_beginning_activity_message( +bt_component_class_message_iterator_next_method_status +create_stream_beginning_activity_message( struct trimmer_iterator *trimmer_it, const bt_stream *stream, const bt_clock_class *clock_class, bt_message **msg) { bt_message *local_msg; - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; BT_ASSERT(msg); BT_ASSERT(!trimmer_it->begin.is_infinite); @@ -1118,7 +1139,7 @@ bt_self_message_iterator_status create_stream_beginning_activity_message( local_msg = bt_message_stream_activity_beginning_create( trimmer_it->self_msg_iter, stream); if (!local_msg) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1129,7 +1150,7 @@ bt_self_message_iterator_status create_stream_beginning_activity_message( ret = clock_raw_value_from_ns_from_origin(clock_class, trimmer_it->begin.ns_from_origin, &raw_value); if (ret) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; bt_message_put_ref(local_msg); goto end; } @@ -1161,13 +1182,14 @@ end: * `reached_end`. */ static inline -bt_self_message_iterator_status handle_message_with_stream_state( +bt_component_class_message_iterator_next_method_status +handle_message_with_stream_state( struct trimmer_iterator *trimmer_it, const bt_message *msg, struct trimmer_iterator_stream_state *sstate, int64_t ns_from_origin, bool *reached_end) { - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; bt_message_type msg_type = bt_message_get_type(msg); int ret; @@ -1245,7 +1267,7 @@ bt_self_message_iterator_status handle_message_with_stream_state( if (bt_clock_snapshot_get_ns_from_origin(end_cs, &end_ns_from_origin)) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1277,7 +1299,7 @@ bt_self_message_iterator_status handle_message_with_stream_state( ret = clock_raw_value_from_ns_from_origin(clock_class, trimmer_it->end.ns_from_origin, &end_raw_value); if (ret) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1300,7 +1322,7 @@ bt_self_message_iterator_status handle_message_with_stream_state( } if (!new_msg) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1385,7 +1407,7 @@ bt_self_message_iterator_status handle_message_with_stream_state( } else if (sstate->stream_act_end_ns_from_origin < trimmer_it->end.ns_from_origin) { status = end_stream(trimmer_it, sstate); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { goto end; } @@ -1400,7 +1422,7 @@ bt_self_message_iterator_status handle_message_with_stream_state( end: /* We release the message's reference whatever the outcome */ bt_message_put_ref(msg); - return BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; } /* @@ -1416,11 +1438,11 @@ end: * `reached_end`. */ static inline -bt_self_message_iterator_status handle_message( +bt_component_class_message_iterator_next_method_status handle_message( struct trimmer_iterator *trimmer_it, const bt_message *msg, bool *reached_end) { - bt_self_message_iterator_status status; + bt_component_class_message_iterator_next_method_status status; const bt_stream *stream = NULL; int64_t ns_from_origin = INT64_MIN; bool skip; @@ -1491,7 +1513,7 @@ bt_self_message_iterator_status handle_message( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1511,7 +1533,7 @@ bt_self_message_iterator_status handle_message( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1524,7 +1546,7 @@ bt_self_message_iterator_status handle_message( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1537,7 +1559,7 @@ bt_self_message_iterator_status handle_message( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1550,14 +1572,14 @@ bt_self_message_iterator_status handle_message( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } sstate = g_new0(struct trimmer_iterator_stream_state, 1); if (!sstate) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1571,7 +1593,7 @@ bt_self_message_iterator_status handle_message( /* Retrieve the message's time */ ret = get_msg_ns_from_origin(msg, &ns_from_origin, &skip); if (G_UNLIKELY(ret)) { - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1596,7 +1618,7 @@ bt_self_message_iterator_status handle_message( *reached_end = true; } else { push_message(trimmer_it, msg); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; msg = NULL; } } @@ -1628,17 +1650,17 @@ void fill_message_array_from_output_messages( } static inline -bt_self_message_iterator_status state_ending( +bt_component_class_message_iterator_next_method_status state_ending( struct trimmer_iterator *trimmer_it, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; if (g_queue_is_empty(trimmer_it->output_messages)) { trimmer_it->state = TRIMMER_ITERATOR_STATE_ENDED; - status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; goto end; } @@ -1650,12 +1672,13 @@ end: } static inline -bt_self_message_iterator_status state_trim(struct trimmer_iterator *trimmer_it, +bt_component_class_message_iterator_next_method_status +state_trim(struct trimmer_iterator *trimmer_it, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; bt_message_array_const my_msgs; uint64_t my_count; uint64_t i; @@ -1664,10 +1687,10 @@ bt_self_message_iterator_status state_trim(struct trimmer_iterator *trimmer_it, while (g_queue_is_empty(trimmer_it->output_messages)) { status = (int) bt_self_component_port_input_message_iterator_next( trimmer_it->upstream_iter, &my_msgs, &my_count); - if (G_UNLIKELY(status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK)) { - if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_END) { + if (G_UNLIKELY(status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK)) { + if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END) { status = end_iterator_streams(trimmer_it); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { goto end; } @@ -1693,7 +1716,7 @@ bt_self_message_iterator_status state_trim(struct trimmer_iterator *trimmer_it, my_msgs[i] = NULL; if (G_UNLIKELY(status != - BT_SELF_MESSAGE_ITERATOR_STATUS_OK)) { + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK)) { put_messages(my_msgs, my_count); goto end; } @@ -1732,50 +1755,50 @@ end: } BT_HIDDEN -bt_self_message_iterator_status trimmer_msg_iter_next( +bt_component_class_message_iterator_next_method_status trimmer_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { struct trimmer_iterator *trimmer_it = bt_self_message_iterator_get_data(self_msg_iter); - bt_self_message_iterator_status status = - BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_component_class_message_iterator_next_method_status status = + BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; BT_ASSERT(trimmer_it); if (G_LIKELY(trimmer_it->state == TRIMMER_ITERATOR_STATE_TRIM)) { status = state_trim(trimmer_it, msgs, capacity, count); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { goto end; } } else { switch (trimmer_it->state) { case TRIMMER_ITERATOR_STATE_SET_BOUNDS_NS_FROM_ORIGIN: status = state_set_trimmer_iterator_bounds(trimmer_it); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { goto end; } status = state_seek_initially(trimmer_it); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { goto end; } status = state_trim(trimmer_it, msgs, capacity, count); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { goto end; } break; case TRIMMER_ITERATOR_STATE_SEEK_INITIALLY: status = state_seek_initially(trimmer_it); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { goto end; } status = state_trim(trimmer_it, msgs, capacity, count); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { goto end; } @@ -1783,13 +1806,13 @@ bt_self_message_iterator_status trimmer_msg_iter_next( case TRIMMER_ITERATOR_STATE_ENDING: status = state_ending(trimmer_it, msgs, capacity, count); - if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { goto end; } break; case TRIMMER_ITERATOR_STATE_ENDED: - status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; + status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; break; default: abort(); diff --git a/src/plugins/utils/trimmer/trimmer.h b/src/plugins/utils/trimmer/trimmer.h index 46ac8a38..c29a89f4 100644 --- a/src/plugins/utils/trimmer/trimmer.h +++ b/src/plugins/utils/trimmer/trimmer.h @@ -35,17 +35,17 @@ BT_HIDDEN void trimmer_finalize(bt_self_component_filter *self_comp); BT_HIDDEN -bt_self_component_status trimmer_init(bt_self_component_filter *self_comp, +bt_component_class_init_method_status trimmer_init(bt_self_component_filter *self_comp, const bt_value *params, void *init_data); BT_HIDDEN -bt_self_message_iterator_status trimmer_msg_iter_init( +bt_component_class_message_iterator_init_method_status trimmer_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp, bt_self_component_port_output *port); BT_HIDDEN -bt_self_message_iterator_status trimmer_msg_iter_next( +bt_component_class_message_iterator_next_method_status trimmer_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); diff --git a/src/python-plugin-provider/python-plugin-provider.c b/src/python-plugin-provider/python-plugin-provider.c index 40435f1d..a2d136a9 100644 --- a/src/python-plugin-provider/python-plugin-provider.c +++ b/src/python-plugin-provider/python-plugin-provider.c @@ -164,10 +164,10 @@ void fini_python(void) { } static -enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, +int bt_plugin_from_python_plugin_info(PyObject *plugin_info, bool fail_on_load_error, bt_plugin **plugin_out) { - enum bt_plugin_status status = BT_PLUGIN_STATUS_OK; + int status = __BT_FUNC_STATUS_OK; PyObject *py_name = NULL; PyObject *py_author = NULL; PyObject *py_description = NULL; @@ -191,8 +191,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG, "Cannot find `name` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -202,8 +202,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG, "Cannot find `author` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -213,8 +213,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG, "Cannot find `desciption` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -224,8 +224,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG, "Cannot find `license` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -235,8 +235,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG, "Cannot find `version` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -247,8 +247,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG, "Cannot find `comp_class_addrs` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -260,8 +260,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, "Cannot decode Python plugin name string: " "py-plugin-info-addr=%p", plugin_info); status = fail_on_load_error ? - BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } } else { @@ -270,8 +270,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LOG_WARN : BT_LOG_INFO, BT_LOG_TAG, "Plugin name is not a string: " "py-plugin-info-addr=%p", plugin_info); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -283,8 +283,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, "Cannot decode Python plugin author string: " "py-plugin-info-addr=%p", plugin_info); status = fail_on_load_error ? - BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } } @@ -297,8 +297,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, "Cannot decode Python plugin description string: " "py-plugin-info-addr=%p", plugin_info); status = fail_on_load_error ? - BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } } @@ -311,8 +311,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, "Cannot decode Python plugin license string: " "py-plugin-info-addr=%p", plugin_info); status = fail_on_load_error ? - BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } } @@ -346,8 +346,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, "Invalid Python plugin version format: " "py-plugin-info-addr=%p", plugin_info); status = fail_on_load_error ? - BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } } @@ -365,8 +365,8 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, "Cannot decode Python plugin version's extra string: " "py-plugin-info-addr=%p", plugin_info); status = fail_on_load_error ? - BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } } @@ -376,7 +376,7 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, *plugin_out = bt_plugin_create_empty(BT_PLUGIN_TYPE_PYTHON); if (!*plugin_out) { BT_LOGE_STR("Cannot create empty plugin object."); - status = BT_PLUGIN_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto error; } @@ -416,7 +416,7 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, plugin_info, i); if (fail_on_load_error) { - status = BT_PLUGIN_STATUS_LOADING_ERROR; + status = __BT_FUNC_STATUS_LOADING_ERROR; goto error; } @@ -446,7 +446,7 @@ enum bt_plugin_status bt_plugin_from_python_plugin_info(PyObject *plugin_info, goto end; error: - BT_ASSERT(status != BT_PLUGIN_STATUS_OK); + BT_ASSERT(status != __BT_FUNC_STATUS_OK); print_python_traceback(fail_on_load_error ? BT_LOG_WARN : BT_LOG_INFO); pyerr_clear(); BT_OBJECT_PUT_REF_AND_RESET(*plugin_out); @@ -462,14 +462,14 @@ end: } G_MODULE_EXPORT -enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, +int bt_plugin_python_create_all_from_file(const char *path, bool fail_on_load_error, struct bt_plugin_set **plugin_set_out) { bt_plugin *plugin = NULL; PyObject *py_plugin_info = NULL; gchar *basename = NULL; size_t path_len; - enum bt_plugin_status status = BT_PLUGIN_STATUS_OK; + int status = __BT_FUNC_STATUS_OK; BT_ASSERT(path); @@ -479,7 +479,7 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, * here because we already know Python cannot be fully * initialized. */ - status = BT_PLUGIN_STATUS_ERROR; + status = __BT_FUNC_STATUS_ERROR; goto error; } else if (python_state == PYTHON_STATE_WONT_INITIALIZE) { /* @@ -487,7 +487,7 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, * Python plugins are disabled, so it's simply not * found. */ - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -500,7 +500,7 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, PYTHON_PLUGIN_FILE_EXT, PYTHON_PLUGIN_FILE_EXT_LEN) != 0) { BT_LOGI("Skipping non-Python file: path=\"%s\"", path); - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -508,7 +508,7 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, basename = g_path_get_basename(path); if (!basename) { BT_LOGE("Cannot get path's basename: path=\"%s\"", path); - status = BT_PLUGIN_STATUS_ERROR; + status = __BT_FUNC_STATUS_ERROR; goto error; } @@ -516,7 +516,7 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, PYTHON_PLUGIN_FILE_PREFIX_LEN) != 0) { BT_LOGI("Skipping Python file not starting with `%s`: " "path=\"%s\"", PYTHON_PLUGIN_FILE_PREFIX, path); - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -535,7 +535,7 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, * Python plugins are disabled, so it's simply not * found. */ - status = BT_PLUGIN_STATUS_NOT_FOUND; + status = __BT_FUNC_STATUS_NOT_FOUND; goto error; } else if (python_state != PYTHON_STATE_FULLY_INITIALIZED) { /* @@ -544,7 +544,7 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, * attributes from them. */ BT_LOGE("Failed to initialize Python interpreter."); - status = BT_PLUGIN_STATUS_ERROR; + status = __BT_FUNC_STATUS_ERROR; goto error; } @@ -564,8 +564,8 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, print_python_traceback(fail_on_load_error ? BT_LOG_WARN : BT_LOG_INFO); PyErr_Clear(); - status = fail_on_load_error ? BT_PLUGIN_STATUS_LOADING_ERROR : - BT_PLUGIN_STATUS_NOT_FOUND; + status = fail_on_load_error ? __BT_FUNC_STATUS_LOADING_ERROR : + __BT_FUNC_STATUS_NOT_FOUND; goto error; } @@ -585,18 +585,18 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, path, py_plugin_info); BT_ASSERT(!plugin); goto error; - } else if (status == BT_PLUGIN_STATUS_NOT_FOUND) { + } else if (status == __BT_FUNC_STATUS_NOT_FOUND) { BT_ASSERT(!plugin); goto error; } - BT_ASSERT(status == BT_PLUGIN_STATUS_OK); + BT_ASSERT(status == __BT_FUNC_STATUS_OK); BT_ASSERT(plugin); bt_plugin_set_path(plugin, path); *plugin_set_out = bt_plugin_set_create(); if (!*plugin_set_out) { BT_LOGE_STR("Cannot create empty plugin set."); - status = BT_PLUGIN_STATUS_NOMEM; + status = __BT_FUNC_STATUS_MEMORY_ERROR; goto error; } @@ -607,7 +607,7 @@ enum bt_plugin_status bt_plugin_python_create_all_from_file(const char *path, goto end; error: - BT_ASSERT(status != BT_PLUGIN_STATUS_OK); + BT_ASSERT(status != __BT_FUNC_STATUS_OK); BT_OBJECT_PUT_REF_AND_RESET(*plugin_set_out); end: diff --git a/tests/bindings/python/bt2/test_clock_class.py b/tests/bindings/python/bt2/test_clock_class.py index b741be4a..1f395912 100644 --- a/tests/bindings/python/bt2/test_clock_class.py +++ b/tests/bindings/python/bt2/test_clock_class.py @@ -179,7 +179,7 @@ class ClockClassTestCase(unittest.TestCase): return comp_self._create_clock_class(frequency=1000) cc = run_in_component_init(f) - with self.assertRaises(OverflowError): + with self.assertRaises(bt2.OverflowError): cc.cycles_to_ns_from_origin(2**63) def test_create_uuid(self): @@ -277,7 +277,7 @@ class ClockSnapshotTestCase(unittest.TestCase): self._msg.default_clock_snapshot.ns_from_origin, ns_from_origin) def test_ns_from_origin_overflow(self): - with self.assertRaises(OverflowError): + with self.assertRaises(bt2.OverflowError): self._msg_clock_overflow.default_clock_snapshot.ns_from_origin def test_eq_int(self): diff --git a/tests/bindings/python/bt2/test_graph.py b/tests/bindings/python/bt2/test_graph.py index 9b82b791..3ec32e62 100644 --- a/tests/bindings/python/bt2/test_graph.py +++ b/tests/bindings/python/bt2/test_graph.py @@ -178,7 +178,7 @@ class GraphTestCase(unittest.TestCase): self._graph.cancel() self.assertTrue(self._graph.is_canceled) - # Test that Graph.run() raises bt2.GraphCanceled if the graph gets canceled + # Test that Graph.run() raises bt2.Canceled if the graph gets canceled # during execution. def test_cancel_while_running(self): class MyIter(_MyIter): @@ -208,7 +208,7 @@ class GraphTestCase(unittest.TestCase): up = graph.add_component(MySource, 'down') down = graph.add_component(MySink, 'up') graph.connect_ports(up.output_ports['out'], down.input_ports['in']) - with self.assertRaises(bt2.GraphCanceled): + with self.assertRaises(bt2.Canceled): graph.run() def test_run(self): diff --git a/tests/bindings/python/bt2/test_query_executor.py b/tests/bindings/python/bt2/test_query_executor.py index f72a1b6e..30e5a2c9 100644 --- a/tests/bindings/python/bt2/test_query_executor.py +++ b/tests/bindings/python/bt2/test_query_executor.py @@ -106,9 +106,9 @@ class QueryExecutorTestCase(unittest.TestCase): @classmethod def _query(cls, query_exec, obj, params, log_level): - raise bt2.InvalidQueryObject + raise bt2.InvalidObject - with self.assertRaises(bt2.InvalidQueryObject): + with self.assertRaises(bt2.InvalidObject): res = bt2.QueryExecutor().query(MySink, 'obj', [17, 23]) def test_query_logging_level_invalid_type(self): @@ -142,9 +142,9 @@ class QueryExecutorTestCase(unittest.TestCase): @classmethod def _query(cls, query_exec, obj, params, log_level): - raise bt2.InvalidQueryParams + raise bt2.InvalidParams - with self.assertRaises(bt2.InvalidQueryParams): + with self.assertRaises(bt2.InvalidParams): res = bt2.QueryExecutor().query(MySink, 'obj', [17, 23]) def test_query_try_again(self): @@ -177,5 +177,5 @@ class QueryExecutorTestCase(unittest.TestCase): query_exec = bt2.QueryExecutor() query_exec.cancel() - with self.assertRaises(bt2.QueryExecutorCanceled): + with self.assertRaises(bt2.Canceled): res = query_exec.query(MySink, 'obj', [17, 23]) diff --git a/tests/lib/plugin.c b/tests/lib/plugin.c index 0bee0447..1f0d783a 100644 --- a/tests/lib/plugin.c +++ b/tests/lib/plugin.c @@ -67,7 +67,7 @@ static void test_minimal(const char *plugin_dir) const bt_plugin_set *plugin_set = NULL; const bt_plugin *plugin; char *minimal_path = get_test_plugin_path(plugin_dir, "minimal"); - bt_plugin_status status; + bt_plugin_find_all_from_file_status status; BT_ASSERT(minimal_path); diag("minimal plugin test below"); @@ -75,7 +75,7 @@ static void test_minimal(const char *plugin_dir) reset_test_plugin_env_vars(); status = bt_plugin_find_all_from_file(minimal_path, BT_FALSE, &plugin_set); - ok(status == BT_PLUGIN_STATUS_OK, + ok(status == BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_OK, "bt_plugin_find_all_from_file() succeeds with a valid file"); ok(plugin_set, "bt_plugin_find_all_from_file() returns a plugin set"); @@ -128,18 +128,18 @@ static void test_sfs(const char *plugin_dir) const bt_value *res_params; bt_graph *graph; const char *object_str; - bt_graph_status graph_ret; + bt_graph_add_component_status graph_ret; bt_query_executor *query_exec = bt_query_executor_create(); int ret; - bt_plugin_status status; + bt_plugin_find_all_from_file_status status; BT_ASSERT(query_exec); BT_ASSERT(sfs_path); diag("sfs plugin test below"); status = bt_plugin_find_all_from_file(sfs_path, BT_FALSE, &plugin_set); - BT_ASSERT(status == BT_PLUGIN_STATUS_OK && plugin_set && - bt_plugin_set_get_plugin_count(plugin_set) == 1); + BT_ASSERT(status == BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_OK && + plugin_set && bt_plugin_set_get_plugin_count(plugin_set) == 1); plugin = bt_plugin_set_borrow_plugin_by_index_const(plugin_set, 0); ok(bt_plugin_get_version(plugin, &major, &minor, &patch, &extra) == BT_PROPERTY_AVAILABILITY_AVAILABLE, @@ -202,7 +202,7 @@ static void test_sfs(const char *plugin_dir) BT_ASSERT(graph); graph_ret = bt_graph_add_sink_component(graph, sink_comp_class, "the-sink", NULL, BT_LOGGING_LEVEL_NONE, &sink_component); - ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component, + ok(graph_ret == BT_GRAPH_ADD_COMPONENT_STATUS_OK && sink_component, "bt_graph_add_sink_component() still works after the plugin object is destroyed"); BT_COMPONENT_SINK_PUT_REF_AND_RESET(sink_component); bt_graph_put_ref(graph); @@ -217,19 +217,19 @@ static void test_sfs(const char *plugin_dir) static void test_create_all_from_dir(const char *plugin_dir) { const bt_plugin_set *plugin_set; - bt_plugin_status status; + bt_plugin_find_all_from_dir_status status; diag("create from all test below"); status = bt_plugin_find_all_from_dir(NON_EXISTING_PATH, BT_FALSE, BT_FALSE, &plugin_set); - ok(status == BT_PLUGIN_STATUS_ERROR, + ok(status == BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_ERROR, "bt_plugin_find_all_from_dir() fails with an invalid path"); plugin_set = NULL; status = bt_plugin_find_all_from_dir(plugin_dir, BT_FALSE, BT_FALSE, &plugin_set); - ok(status == BT_PLUGIN_STATUS_OK, + ok(status == BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_OK, "bt_plugin_find_all_from_dir() succeeds with a valid path"); ok(plugin_set, "bt_plugin_find_all_from_dir() returns a plugin set with a valid path"); @@ -247,10 +247,10 @@ static void test_find(const char *plugin_dir) int ret; const bt_plugin *plugin; char *plugin_path; - bt_plugin_status status; + bt_plugin_find_status status; ok(bt_plugin_find(NON_EXISTING_PATH, BT_FALSE, &plugin) == - BT_PLUGIN_STATUS_NOT_FOUND, + BT_PLUGIN_FIND_STATUS_NOT_FOUND, "bt_plugin_find() returns BT_PLUGIN_STATUS_NOT_FOUND with an unknown plugin name"); ret = asprintf(&plugin_path, "%s" G_SEARCHPATH_SEPARATOR_S G_DIR_SEPARATOR_S "ec1d09e5-696c-442e-b1c3-f9c6cf7f5958" @@ -263,7 +263,7 @@ static void test_find(const char *plugin_dir) g_setenv("BABELTRACE_PLUGIN_PATH", plugin_path, 1); plugin = NULL; status = bt_plugin_find("test_minimal", BT_FALSE, &plugin); - ok(status == BT_PLUGIN_STATUS_OK, + ok(status == BT_PLUGIN_FIND_STATUS_OK, "bt_plugin_find() succeeds with a plugin name it can find"); ok(plugin, "bt_plugin_find() returns a plugin object"); ok(strcmp(bt_plugin_get_author(plugin), "Janine Sutto") == 0, diff --git a/tests/lib/test-plugin-plugins/minimal.c b/tests/lib/test-plugin-plugins/minimal.c index 6c63d632..c3e7f226 100644 --- a/tests/lib/test-plugin-plugins/minimal.c +++ b/tests/lib/test-plugin-plugins/minimal.c @@ -19,10 +19,10 @@ #include #include -static bt_self_plugin_status plugin_init(bt_self_plugin *plugin) +static bt_plugin_init_func_status plugin_init(bt_self_plugin *plugin) { g_setenv("BT_TEST_PLUGIN_INIT_CALLED", "1", 1); - return BT_SELF_PLUGIN_STATUS_OK; + return BT_PLUGIN_INIT_FUNC_STATUS_OK; } static void plugin_exit(void) diff --git a/tests/lib/test-plugin-plugins/sfs.c b/tests/lib/test-plugin-plugins/sfs.c index d9ef11ff..6e0e0a4b 100644 --- a/tests/lib/test-plugin-plugins/sfs.c +++ b/tests/lib/test-plugin-plugins/sfs.c @@ -18,26 +18,28 @@ #include #include "common/assert.h" -static bt_self_component_status sink_consume( +static bt_component_class_sink_consume_method_status sink_consume( bt_self_component_sink *self_comp) { - return BT_SELF_COMPONENT_STATUS_OK; + return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; } -static bt_self_message_iterator_status src_dummy_iterator_init_method( +static bt_component_class_message_iterator_init_method_status +src_dummy_iterator_init_method( bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port) { - return BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK; } -static bt_self_message_iterator_status flt_dummy_iterator_init_method( +static bt_component_class_message_iterator_init_method_status +flt_dummy_iterator_init_method( bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp, bt_self_component_port_output *self_port) { - return BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK; } static void dummy_iterator_finalize_method( @@ -45,15 +47,16 @@ static void dummy_iterator_finalize_method( { } -static bt_self_message_iterator_status dummy_iterator_next_method( +static bt_component_class_message_iterator_next_method_status +dummy_iterator_next_method( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - return BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; } -static bt_query_status flt_query_method( +static bt_component_class_query_method_status flt_query_method( bt_self_component_class_filter *component_class, const bt_query_executor *query_exec, const char *object, const bt_value *params, @@ -73,7 +76,7 @@ static bt_query_status flt_query_method( iret = bt_value_array_append_element(res, val); BT_ASSERT(iret == 0); bt_value_put_ref(val); - return BT_QUERY_STATUS_OK; + return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK; } BT_PLUGIN_MODULE(); diff --git a/tests/lib/test_trace_ir_ref.c b/tests/lib/test_trace_ir_ref.c index 53eaca01..5051fa6d 100644 --- a/tests/lib/test_trace_ir_ref.c +++ b/tests/lib/test_trace_ir_ref.c @@ -442,21 +442,21 @@ static void test_example_scenario(bt_self_component_source *self_comp) } static -bt_self_component_status src_init( +bt_component_class_init_method_status src_init( bt_self_component_source *self_comp, const bt_value *params, void *init_method_data) { test_example_scenario(self_comp); - return BT_SELF_COMPONENT_STATUS_OK; + return BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK; } static -bt_self_message_iterator_status src_iter_next( +bt_component_class_message_iterator_next_method_status src_iter_next( bt_self_message_iterator *self_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - return BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; } static void test_example_scenario_in_graph(void) diff --git a/tests/plugins/src.ctf.fs/query/test_query_trace_info.py b/tests/plugins/src.ctf.fs/query/test_query_trace_info.py index b3924640..0698975a 100644 --- a/tests/plugins/src.ctf.fs/query/test_query_trace_info.py +++ b/tests/plugins/src.ctf.fs/query/test_query_trace_info.py @@ -96,28 +96,28 @@ class QueryTraceInfoClockOffsetTestCase(unittest.TestCase): self._check(trace, -2000000002) def test_clock_class_offset_s_wrong_type(self): - with self.assertRaises(bt2.InvalidQueryParams): + with self.assertRaises(bt2.InvalidParams): self._executor.query(self._fs, 'trace-info', { 'paths': self._paths, 'clock-class-offset-s': "2", }) def test_clock_class_offset_s_wrong_type_none(self): - with self.assertRaises(bt2.InvalidQueryParams): + with self.assertRaises(bt2.InvalidParams): self._executor.query(self._fs, 'trace-info', { 'paths': self._paths, 'clock-class-offset-s': None, }) def test_clock_class_offset_ns_wrong_type(self): - with self.assertRaises(bt2.InvalidQueryParams): + with self.assertRaises(bt2.InvalidParams): self._executor.query(self._fs, 'trace-info', { 'paths': self._paths, 'clock-class-offset-ns': "2", }) def test_clock_class_offset_ns_wrong_type_none(self): - with self.assertRaises(bt2.InvalidQueryParams): + with self.assertRaises(bt2.InvalidParams): self._executor.query(self._fs, 'trace-info', { 'paths': self._paths, 'clock-class-offset-ns': None, -- 2.34.1