bt2: normalize the code to use some commonly used patterns
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_trace_class.i.h
index f508ffb0cb7d0759c4b288719a9994b1b36c704f..f51d619fdfd70f75f5864c3a20bfe230cc03a2c1 100644 (file)
@@ -36,14 +36,16 @@ trace_class_destroyed_listener(const bt_trace_class *trace_class, void *py_calla
        }
 
        py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_class_ptr);
-       if (py_res) {
-               BT_ASSERT(py_res == Py_None);
-       } else {
+       if (!py_res) {
                loge_exception_append_cause(
                        "Trace class's destruction listener (Python)",
                        BT_LOG_OUTPUT_LEVEL);
+               goto end;
        }
 
+       BT_ASSERT(py_res == Py_None);
+
+end:
        Py_DECREF(py_trace_class_ptr);
        Py_XDECREF(py_res);
 }
@@ -57,6 +59,7 @@ int bt_bt2_trace_class_add_destruction_listener(
 
        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_FUNC_STATUS_OK) {
This page took 0.024042 seconds and 4 git commands to generate.