From: Simon Marchi Date: Wed, 24 Jul 2019 03:08:17 +0000 (-0400) Subject: lib: make default query implementation return INVALID_OBJECT, remove UNSUPPORTED... X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=2c1d3e9111d8f1b55361b9b880350c2680c90093 lib: make default query implementation return INVALID_OBJECT, remove UNSUPPORTED status Queries against component classes that don't implement the query method currently return a special UNSUPPORTED status. There is however no need for a different status than the one a query method returns when it doesn't know about the object, INVALID_OBJECT. Make the default implemention of "query" return INVALID_OBJECT, and remove any trace of UNSUPPORTED, including in the Python bindings. Change-Id: I43f59ef749f3803a832a1ad14e640d03424b3420 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/1755 Reviewed-by: Philippe Proulx Tested-by: jenkins --- diff --git a/include/babeltrace2/babeltrace.h b/include/babeltrace2/babeltrace.h index 4d092636..62a75bf5 100644 --- a/include/babeltrace2/babeltrace.h +++ b/include/babeltrace2/babeltrace.h @@ -164,7 +164,6 @@ #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 #undef __BT_IN_BABELTRACE_H #undef __BT_UPCAST diff --git a/include/babeltrace2/func-status.h b/include/babeltrace2/func-status.h index 619dad02..c817b388 100644 --- a/include/babeltrace2/func-status.h +++ b/include/babeltrace2/func-status.h @@ -81,11 +81,6 @@ # define __BT_FUNC_STATUS_AGAIN 11 #endif -/* Unsupported operation */ -#ifndef __BT_FUNC_STATUS_UNSUPPORTED -# define __BT_FUNC_STATUS_UNSUPPORTED 95 -#endif - /* Object is canceled */ #ifndef __BT_FUNC_STATUS_CANCELED # define __BT_FUNC_STATUS_CANCELED 125 diff --git a/include/babeltrace2/graph/query-executor.h b/include/babeltrace2/graph/query-executor.h index 67bc74a5..332bd62b 100644 --- a/include/babeltrace2/graph/query-executor.h +++ b/include/babeltrace2/graph/query-executor.h @@ -40,7 +40,6 @@ 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, diff --git a/src/bindings/python/bt2/bt2/__init__.py.in b/src/bindings/python/bt2/bt2/__init__.py.in index bf36b459..7d63b697 100644 --- a/src/bindings/python/bt2/bt2/__init__.py.in +++ b/src/bindings/python/bt2/bt2/__init__.py.in @@ -85,10 +85,6 @@ class OverflowError(OverflowError): pass -class Unsupported(Exception): - pass - - class TryAgain(Exception): pass 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 12a4fa04..ed939937 100644 --- a/src/bindings/python/bt2/bt2/native_bt_component_class.i +++ b/src/bindings/python/bt2/bt2/native_bt_component_class.i @@ -100,7 +100,6 @@ 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_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_bt2_cc_init_from_bt2(void) @@ -133,9 +132,6 @@ void bt_bt2_cc_init_from_bt2(void) 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 @@ -404,9 +400,6 @@ int py_exc_to_status(bt_self_component_class *self_component_class, } 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 { /* Unknown exception: convert to general error */ log_exception_and_maybe_append_error(BT_LOG_WARNING, true, diff --git a/src/bindings/python/bt2/bt2/utils.py b/src/bindings/python/bt2/bt2/utils.py index 5cbbb89b..bd4dd7a9 100644 --- a/src/bindings/python/bt2/bt2/utils.py +++ b/src/bindings/python/bt2/bt2/utils.py @@ -171,10 +171,5 @@ def _handle_func_status(status, msg=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/cli/babeltrace2.c b/src/cli/babeltrace2.c index 2c90fc0e..0eeb8770 100644 --- a/src/cli/babeltrace2.c +++ b/src/cli/babeltrace2.c @@ -209,9 +209,6 @@ int query(struct bt_config *cfg, const bt_component_class *comp_cls, case BT_QUERY_EXECUTOR_QUERY_STATUS_INVALID_PARAMS: *fail_reason = "invalid query parameters"; goto error; - case BT_QUERY_EXECUTOR_QUERY_STATUS_UNSUPPORTED: - *fail_reason = "unsupported action"; - goto error; case BT_QUERY_EXECUTOR_QUERY_STATUS_MEMORY_ERROR: *fail_reason = "not enough memory"; goto error; diff --git a/src/common/common.h b/src/common/common.h index 5849101b..5156e1b0 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -619,8 +619,6 @@ const char *bt_common_func_status_string(int status) 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: diff --git a/src/lib/func-status.h b/src/lib/func-status.h index 64ed19bc..f5132851 100644 --- a/src/lib/func-status.h +++ b/src/lib/func-status.h @@ -39,7 +39,6 @@ #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 #endif /* BABELTRACE_FUNC_STATUS_INTERNAL_H */ diff --git a/src/lib/graph/query-executor.c b/src/lib/graph/query-executor.c index e381917e..3a00c9b8 100644 --- a/src/lib/graph/query-executor.c +++ b/src/lib/graph/query-executor.c @@ -124,7 +124,7 @@ enum bt_query_executor_query_status bt_query_executor_query( /* Not an error: nothing to query */ BT_LIB_LOGD("Component class has no registered query method: " "%!+C", comp_cls); - status = BT_FUNC_STATUS_UNSUPPORTED; + status = BT_FUNC_STATUS_INVALID_OBJECT; goto end; }