BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END};
static bt_component_class_query_method_status
-lttng_live_query_list_sessions(const bt2::ConstMapValue params, const bt_value **result,
+lttng_live_query_list_sessions(const bt2::ConstMapValue params, bt2::Value::Shared& result,
const bt2c::Logger& logger)
{
bt_component_class_query_method_status status;
goto end;
error:
- BT_VALUE_PUT_REF_AND_RESET(*result);
-
if (status >= 0) {
status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
}
}
static bt_component_class_query_method_status
-lttng_live_query_support_info(const bt2::ConstMapValue params, const bt_value **result,
+lttng_live_query_support_info(const bt2::ConstMapValue params, bt2::Value::Shared& result,
const bt2c::Logger& logger)
{
bt_component_class_query_method_status status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK;
/* Used by the logging macros */
__attribute__((unused)) bt_self_component *self_comp = NULL;
- *result = NULL;
const auto typeValue = params["type"];
if (!typeValue) {
BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "Missing expected `type` parameter.");
}
create_result:
- *result = bt_value_real_create_init(weight);
- if (!*result) {
- status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_MEMORY_ERROR;
- goto error;
- }
-
+ result = bt2::RealValue::create(weight);
goto end;
error:
status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_ERROR;
}
- BT_ASSERT(!*result);
+ BT_ASSERT(!result);
end:
return status;
bt2::PrivateQueryExecutor {priv_query_exec},
"PLUGIN/SRC.CTF.LTTNG-LIVE/QUERY"};
const bt2::ConstMapValue paramsObj(params);
+ bt2::Value::Shared resultObj;
if (strcmp(object, "sessions") == 0) {
- status = lttng_live_query_list_sessions(paramsObj, result, logger);
+ status = lttng_live_query_list_sessions(paramsObj, resultObj, logger);
} else if (strcmp(object, "babeltrace.support-info") == 0) {
- status = lttng_live_query_support_info(paramsObj, result, logger);
+ status = lttng_live_query_support_info(paramsObj, resultObj, logger);
} else {
BT_CPPLOGI_SPEC(logger, "Unknown query object `{}`", object);
- status = BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_UNKNOWN_OBJECT;
- goto end;
+ return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_UNKNOWN_OBJECT;
+ }
+
+ if (status == BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK) {
+ *result = resultObj.release().libObjPtr();
}
-end:
return status;
} catch (const std::bad_alloc&) {
return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_MEMORY_ERROR;