lib: make default query implementation return INVALID_OBJECT, remove UNSUPPORTED...
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 24 Jul 2019 03:08:17 +0000 (23:08 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 04:18:54 +0000 (00:18 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1755
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
include/babeltrace2/babeltrace.h
include/babeltrace2/func-status.h
include/babeltrace2/graph/query-executor.h
src/bindings/python/bt2/bt2/__init__.py.in
src/bindings/python/bt2/bt2/native_bt_component_class.i
src/bindings/python/bt2/bt2/utils.py
src/cli/babeltrace2.c
src/common/common.h
src/lib/func-status.h
src/lib/graph/query-executor.c

index 4d09263608381707f8fe7104da60d45e95d392b8..62a75bf5310d4de88c87170d74bfb7cf64322c15 100644 (file)
 #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
index 619dad02f1a6370cf1734a927e76f7fb632934b9..c817b38842a7fdad7fb5d188a17b588342abaa69 100644 (file)
 # 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
index 67bc74a57462160d0e9a62cfe7ea82d29ca009bc..332bd62b340223f349031cde25ee64512fe6222a 100644 (file)
@@ -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,
index bf36b459517055fe8a68526eca8db84fd0881d5b..7d63b697d88bdda6378b669e582485f92391b8ca 100644 (file)
@@ -85,10 +85,6 @@ class OverflowError(OverflowError):
     pass
 
 
-class Unsupported(Exception):
-    pass
-
-
 class TryAgain(Exception):
     pass
 
index 12a4fa0453b5ff559c24b8ce136a2ee17df1384b..ed939937e6cade034a4665ff1b2c0adb82f45460 100644 (file)
@@ -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,
index 5cbbb89b2ed55983aceaa7bb8100552c3294e3e0..bd4dd7a9406c3749dc1e5865d98e6f560326769e 100644 (file)
@@ -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
index 2c90fc0e69ae545b87d823fb23045b2b461d18bc..0eeb8770d4707d218f141045ce9562c88cc978ad 100644 (file)
@@ -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;
index 5849101b578aaf6d59cccb83de0746df04ab8913..5156e1b0be565312ddcaac487f75102e5f59f40a 100644 (file)
@@ -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:
index 64ed19bc614be73580a803b13236dc8cba6b0295..f51328514c6cadee25e72e3f354da07e96336aca 100644 (file)
@@ -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 */
index e381917e3ceb7fae0850246dac9136192b3da705..3a00c9b80985abe0af2e4cf2a4f6a96a3d3b0d54 100644 (file)
@@ -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;
        }
 
This page took 0.029526 seconds and 4 git commands to generate.