From b189a968258bcf286f022208b71849f8194828bb Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 23 Jul 2019 22:49:46 -0400 Subject: [PATCH] lib: remove LOADING_ERROR status Remove the LOADING_ERROR status, use ERROR instead. It's not so useful to return a separate kind of error, now that we have a way to communicate detailed error causes. Change-Id: I45682b12748fdf8a8466211323dd8563f01d423b Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/1754 Reviewed-by: Philippe Proulx Tested-by: jenkins --- include/babeltrace2/babeltrace.h | 1 - include/babeltrace2/func-status.h | 5 ---- include/babeltrace2/plugin/plugin-const.h | 4 --- src/bindings/python/bt2/bt2/__init__.py.in | 4 --- src/bindings/python/bt2/bt2/utils.py | 5 ---- src/common/common.h | 2 -- src/lib/func-status.h | 1 - src/lib/plugin/plugin-so.c | 16 +++++----- .../python-plugin-provider.c | 30 +++++++++---------- 9 files changed, 23 insertions(+), 45 deletions(-) diff --git a/include/babeltrace2/babeltrace.h b/include/babeltrace2/babeltrace.h index 4c77aa27..4d092636 100644 --- a/include/babeltrace2/babeltrace.h +++ b/include/babeltrace2/babeltrace.h @@ -159,7 +159,6 @@ #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 diff --git a/include/babeltrace2/func-status.h b/include/babeltrace2/func-status.h index 3970be67..619dad02 100644 --- a/include/babeltrace2/func-status.h +++ b/include/babeltrace2/func-status.h @@ -56,11 +56,6 @@ # define __BT_FUNC_STATUS_MEMORY_ERROR -12 #endif -/* Plugin loading error */ -#ifndef __BT_FUNC_STATUS_LOADING_ERROR -# define __BT_FUNC_STATUS_LOADING_ERROR -2 -#endif - /* General error */ #ifndef __BT_FUNC_STATUS_ERROR # define __BT_FUNC_STATUS_ERROR -1 diff --git a/include/babeltrace2/plugin/plugin-const.h b/include/babeltrace2/plugin/plugin-const.h index 892e3550..11a6a01f 100644 --- a/include/babeltrace2/plugin/plugin-const.h +++ b/include/babeltrace2/plugin/plugin-const.h @@ -41,7 +41,6 @@ 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; @@ -52,7 +51,6 @@ 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; @@ -64,7 +62,6 @@ 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; @@ -76,7 +73,6 @@ 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; diff --git a/src/bindings/python/bt2/bt2/__init__.py.in b/src/bindings/python/bt2/bt2/__init__.py.in index 4ceb37d1..bf36b459 100644 --- a/src/bindings/python/bt2/bt2/__init__.py.in +++ b/src/bindings/python/bt2/bt2/__init__.py.in @@ -105,10 +105,6 @@ class Canceled(Exception): pass -class _LoadingError(_Error): - pass - - class _ListenerHandle: def __init__(self, listener_id, obj): self._listener_id = listener_id diff --git a/src/bindings/python/bt2/bt2/utils.py b/src/bindings/python/bt2/bt2/utils.py index bb8d1b32..5cbbb89b 100644 --- a/src/bindings/python/bt2/bt2/utils.py +++ b/src/bindings/python/bt2/bt2/utils.py @@ -156,11 +156,6 @@ def _handle_func_status(status, msg=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 diff --git a/src/common/common.h b/src/common/common.h index e4c775e5..5849101b 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -609,8 +609,6 @@ const char *bt_common_func_status_string(int status) 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: diff --git a/src/lib/func-status.h b/src/lib/func-status.h index c1ed154d..64ed19bc 100644 --- a/src/lib/func-status.h +++ b/src/lib/func-status.h @@ -34,7 +34,6 @@ #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 diff --git a/src/lib/plugin/plugin-so.c b/src/lib/plugin/plugin-so.c index b9ef8005..ae795598 100644 --- a/src/lib/plugin/plugin-so.c +++ b/src/lib/plugin/plugin-so.c @@ -406,7 +406,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, NULL, descriptor->name, cur_attr->type_name, cur_attr->type); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } else { BT_LIB_LOGW( @@ -683,7 +683,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, cur_cc_descr_attr->comp_class_descriptor->type), cur_cc_descr_attr->type_name, cur_cc_descr_attr->type); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } else { BT_LIB_LOGW( @@ -796,7 +796,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, descriptor->name, cc_full_descr->descriptor->name, cc_full_descr->descriptor->type); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } else { BT_LIB_LOGW( @@ -1332,7 +1332,7 @@ int bt_plugin_so_create_all_from_sections( BT_LIB_LOGW_APPEND_CAUSE( "Unknown ABI major version: abi-major=%d", descriptor->major); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; goto error; } else { BT_LIB_LOGW( @@ -1522,7 +1522,7 @@ int 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 = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot resolve plugin symbol: path=\"%s\", " @@ -1562,7 +1562,7 @@ int 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 = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Found section start or end symbol, but not both: " @@ -1606,7 +1606,7 @@ int 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 = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Found section start or end symbol, but not both: " @@ -1650,7 +1650,7 @@ int 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 = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Found section start or end symbol, but not both: " diff --git a/src/python-plugin-provider/python-plugin-provider.c b/src/python-plugin-provider/python-plugin-provider.c index 765035e2..43a4cf04 100644 --- a/src/python-plugin-provider/python-plugin-provider.c +++ b/src/python-plugin-provider/python-plugin-provider.c @@ -250,7 +250,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot find `name` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot find `name` attribute in Python plugin info object: " @@ -268,7 +268,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot find `author` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot find `author` attribute in Python plugin info object: " @@ -286,7 +286,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot find `description` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot find `description` attribute in Python plugin info object: " @@ -304,7 +304,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot find `license` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot find `license` attribute in Python plugin info object: " @@ -322,7 +322,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot find `version` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot find `version` attribute in Python plugin info object: " @@ -341,7 +341,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot find `comp_class_addrs` attribute in Python plugin info object: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot find `comp_class_addrs` attribute in Python plugin info object: " @@ -360,7 +360,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot decode Python plugin name string: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot decode Python plugin name string: " @@ -377,7 +377,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Plugin name is not a string: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Plugin name is not a string: " @@ -396,7 +396,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot decode Python plugin author string: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot decode Python plugin author string: " @@ -416,7 +416,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot decode Python plugin description string: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot decode Python plugin description string: " @@ -436,7 +436,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot decode Python plugin license string: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot decode Python plugin license string: " @@ -477,7 +477,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Invalid Python plugin version format: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Invalid Python plugin version format: " @@ -502,7 +502,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, BT_LIB_LOGW_APPEND_CAUSE( "Cannot decode Python plugin version's extra string: " "py-plugin-info-addr=%p", plugin_info); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot decode Python plugin version's extra string: " @@ -558,7 +558,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info, "Component class address is not an integer in Python plugin info object: " "py-plugin-info-addr=%p, index=%zu", plugin_info, i); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Component class address is not an integer in Python plugin info object: " @@ -700,7 +700,7 @@ int bt_plugin_python_create_all_from_file(const char *path, append_python_traceback_error_cause(); BT_LIB_LOGW_APPEND_CAUSE( "Cannot load Python plugin: path=\"%s\"", path); - status = BT_FUNC_STATUS_LOADING_ERROR; + status = BT_FUNC_STATUS_ERROR; } else { BT_LIB_LOGW( "Cannot load Python plugin: path=\"%s\"", path); -- 2.34.1