const char *arg;
struct bt_config_connection *cfg_connection;
- ret = bt_value_string_get(arg_value, &arg);
- BT_ASSERT(ret == 0);
+ arg = bt_value_string_get(arg_value);
cfg_connection = cfg_connection_from_arg(arg);
if (!cfg_connection) {
snprintf(error_buf, error_buf_size, "Cannot parse --connect option's argument:\n %s\n",
goto end;
}
- ret = bt_value_string_get(str_obj, &suffix);
- if (ret) {
- printf_err("Unexpected error\n");
- goto end;
- }
+ suffix = bt_value_string_get(str_obj);
g_string_assign(tmpstr, prefix);
g_string_append(tmpstr, "-");
GString *cur_param_key = NULL;
char error_buf[256] = { 0 };
long retry_duration = -1;
+ enum bt_value_status status;
struct poptOption run_long_options[] = {
{ "base-params", 'b', POPT_ARG_STRING, NULL, OPT_BASE_PARAMS, NULL, NULL },
{ "component", 'c', POPT_ARG_STRING, NULL, OPT_COMPONENT, NULL, NULL },
BT_ASSERT(cur_base_params);
bt_object_put_ref(cur_cfg_comp->params);
- cur_cfg_comp->params = bt_value_copy(
+ status = bt_value_copy(
+ &cur_cfg_comp->params,
bt_value_borrow_from_private(cur_base_params));
- if (!cur_cfg_comp->params) {
+ if (status != BT_VALUE_STATUS_OK) {
print_err_oom();
goto error;
}
goto error;
}
- params_to_set = bt_value_map_extend(
+ status = bt_value_map_extend(¶ms_to_set,
bt_value_borrow_from_private(cur_cfg_comp->params),
bt_value_borrow_from_private(params));
BT_OBJECT_PUT_REF_AND_RESET(params);
- if (!params_to_set) {
+ if (status != BT_VALUE_STATUS_OK) {
printf_err("Cannot extend current component parameters with --params option's argument:\n %s\n",
arg);
goto error;
goto end;
}
for (i = 0; i < len; i++) {
- int ret;
struct bt_value *arg_value =
bt_value_array_borrow_element_by_index(run_args, i);
const char *arg;
BT_ASSERT(arg_value);
- ret = bt_value_string_get(arg_value, &arg);
- BT_ASSERT(ret == 0);
+ arg = bt_value_string_get(arg_value);
BT_ASSERT(arg);
argv[i + 1] = arg;
}
}
BT_ASSERT(bt_value_is_string(elem));
- if (bt_value_string_get(elem, &arg)) {
- goto error;
- }
-
+ arg = bt_value_string_get(elem);
ret = bt_private_value_array_append_string_element(run_args, arg);
if (ret) {
print_err_oom();
{
int ret = 0;
GList *leftover;
+ enum bt_value_status status;
for (leftover = leftovers; leftover != NULL;
leftover = g_list_next(leftover)) {
* this is where the unique path goes.
*/
BT_OBJECT_PUT_REF_AND_RESET(impl_args->extra_params);
- impl_args->extra_params =
- bt_value_copy(bt_value_borrow_from_private(
+ status = bt_value_copy(&impl_args->extra_params,
+ bt_value_borrow_from_private(
base_implicit_ctf_input_args->extra_params));
- if (!impl_args->extra_params) {
+ if (status != BT_VALUE_STATUS_OK) {
print_err_oom();
destroy_implicit_component_args(impl_args);
goto error;
const char *arg_to_print;
BT_ASSERT(arg_value);
- ret = bt_value_string_get(arg_value, &arg);
- BT_ASSERT(ret == 0);
+ arg = bt_value_string_get(arg_value);
if (print_run_args) {
quoted = bt_common_shell_quote(arg, true);
* Extracts the various paths from the string arg, delimited by ':',
* and appends them to the array value object plugin_paths.
*/
-enum bt_value_status bt_config_append_plugin_paths(
+int bt_config_append_plugin_paths(
struct bt_private_value *plugin_paths, const char *arg)
{
- enum bt_value_status status = BT_VALUE_STATUS_OK;
+ int ret = 0;
GPtrArray *dirs = g_ptr_array_new_with_free_func(destroy_gstring);
- int ret;
size_t i;
if (!dirs) {
- status = BT_VALUE_STATUS_ERROR;
+ ret = -1;
goto end;
}
ret = bt_common_append_plugin_path_dirs(arg, dirs);
if (ret) {
- status = BT_VALUE_STATUS_ERROR;
+ ret = -1;
goto end;
}
for (i = 0; i < dirs->len; i++) {
GString *dir = g_ptr_array_index(dirs, i);
- status = bt_private_value_array_append_string_element(
+ ret = bt_private_value_array_append_string_element(
plugin_paths, dir->str);
- if (status != BT_VALUE_STATUS_OK) {
- break;
+ if (ret != BT_VALUE_STATUS_OK) {
+ ret = -1;
+ goto end;
}
}
end:
g_ptr_array_free(dirs, TRUE);
- return status;
+ return ret;
}
void bt_config_connection_destroy(struct bt_config_connection *connection)
return bt_object_get_ref(g_ptr_array_index(array, index));
}
-enum bt_value_status bt_config_append_plugin_paths(
- struct bt_private_value *plugin_paths, const char *arg);
+int bt_config_append_plugin_paths(struct bt_private_value *plugin_paths,
+ const char *arg);
void bt_config_connection_destroy(struct bt_config_connection *connection);
const char *str_val;
int size;
int i;
- enum bt_value_status status;
if (!value) {
return;
bt_common_color_reset());
break;
case BT_VALUE_TYPE_BOOL:
- status = bt_value_bool_get(value, &bool_val);
- if (status != BT_VALUE_STATUS_OK) {
- goto error;
- }
+ bool_val = bt_value_bool_get(value);
fprintf(fp, "%s%s%s%s\n", bt_common_color_bold(),
bt_common_color_fg_cyan(), bool_val ? "yes" : "no",
bt_common_color_reset());
break;
case BT_VALUE_TYPE_INTEGER:
- status = bt_value_integer_get(value, &int_val);
- if (status != BT_VALUE_STATUS_OK) {
- goto error;
- }
+ int_val = bt_value_integer_get(value);
fprintf(fp, "%s%s%" PRId64 "%s\n", bt_common_color_bold(),
bt_common_color_fg_red(), int_val,
bt_common_color_reset());
break;
case BT_VALUE_TYPE_REAL:
- status = bt_value_real_get(value, &dbl_val);
- if (status != BT_VALUE_STATUS_OK) {
- goto error;
- }
+ dbl_val = bt_value_real_get(value);
fprintf(fp, "%s%s%lf%s\n", bt_common_color_bold(),
bt_common_color_fg_red(), dbl_val,
bt_common_color_reset());
break;
case BT_VALUE_TYPE_STRING:
- status = bt_value_string_get(value, &str_val);
- if (status != BT_VALUE_STATUS_OK) {
- goto error;
- }
+ str_val = bt_value_string_get(value);
fprintf(fp, "%s%s%s%s\n", bt_common_color_bold(),
bt_common_color_fg_green(), str_val,
bt_common_color_reset());
struct bt_value *plugin_path_value = NULL;
const char *plugin_path;
struct bt_plugin_set *plugin_set;
- enum bt_value_status status;
plugin_path_value = bt_value_array_borrow_element_by_index(
plugin_paths, i);
- status = bt_value_string_get(plugin_path_value, &plugin_path);
- if (status != BT_VALUE_STATUS_OK) {
- BT_LOGD_STR("Cannot get plugin path string.");
- continue;
- }
+ plugin_path = bt_value_string_get(plugin_path_value);
/*
* Skip this if the directory does not exist because
BT_LOGE_STR("Unexpected empty array \"url\" entry.");
goto error;
}
- ret = bt_value_string_get(v, &url_text);
- BT_ASSERT(ret == 0);
+ url_text = bt_value_string_get(v);
fprintf(out_stream, "%s", url_text);
v = bt_value_map_borrow_entry_value(map, "timer-us");
if (!v) {
BT_LOGE_STR("Unexpected empty array \"timer-us\" entry.");
goto error;
}
- ret = bt_value_integer_get(v, &timer_us);
- BT_ASSERT(ret == 0);
+ timer_us = bt_value_integer_get(v);
fprintf(out_stream, " (timer = %" PRIu64 ", ", timer_us);
v = bt_value_map_borrow_entry_value(map, "stream-count");
if (!v) {
BT_LOGE_STR("Unexpected empty array \"stream-count\" entry.");
goto error;
}
- ret = bt_value_integer_get(v, &streams);
- BT_ASSERT(ret == 0);
+ streams = bt_value_integer_get(v);
fprintf(out_stream, "%" PRIu64 " stream(s), ", streams);
v = bt_value_map_borrow_entry_value(map, "client-count");
if (!v) {
BT_LOGE_STR("Unexpected empty array \"client-count\" entry.");
goto error;
}
- ret = bt_value_integer_get(v, &clients);
- BT_ASSERT(ret == 0);
+ clients = bt_value_integer_get(v);
fprintf(out_stream, "%" PRIu64 " client(s) connected)\n", clients);
}
goto end;
}
- ret = bt_value_string_get(metadata_text_value, &metadata_text);
- BT_ASSERT(ret == 0);
+ metadata_text = bt_value_string_get(metadata_text_value);
if (cfg->cmd_data.print_ctf_metadata.output_path->len > 0) {
out_stream =
goto error;
}
- value_status = bt_value_string_get(component_path_value, &path);
- if (value_status != BT_VALUE_STATUS_OK) {
- BT_LOGD("Cannot get path string value: component-name=%s",
- cfg_comp->instance_name->str);
- ret = -1;
- goto error;
- }
-
+ path = bt_value_string_get(component_path_value);
query_params = bt_private_value_map_create();
if (!query_params) {
BT_LOGE_STR("Cannot create query parameters.");
goto error;
}
- value_status = bt_value_integer_get(intersection_begin, &begin);
- if (value_status != BT_VALUE_STATUS_OK) {
- ret = -1;
- BT_LOGD_STR("Cannot retrieve value of intersection-range-ns \'begin\' field from query result.");
- goto error;
- }
-
- value_status = bt_value_integer_get(intersection_end, &end);
- if (value_status != BT_VALUE_STATUS_OK) {
- ret = -1;
- BT_LOGD_STR("Cannot retrieve value of intersection-range-ns \'end\' field from query result.");
- goto error;
- }
+ begin = bt_value_integer_get(intersection_begin);
+ end = bt_value_integer_get(intersection_end);
if (begin < 0 || end < 0 || end < begin) {
BT_LOGW("Invalid trace stream intersection values: "
goto error;
}
- value_status = bt_value_string_get(stream_path_value,
- &stream_path);
- if (value_status != BT_VALUE_STATUS_OK) {
- ret = -1;
- goto error;
- }
-
+ stream_path = bt_value_string_get(stream_path_value);
port_id->port_name = strdup(stream_path);
if (!port_id->port_name) {
ret = -1;
extern struct bt_private_value *bt_private_value_bool_create_init(bt_bool val);
-extern enum bt_value_status bt_private_value_bool_set(struct bt_private_value *bool_obj,
+extern void bt_private_value_bool_set(struct bt_private_value *bool_obj,
bt_bool val);
extern struct bt_private_value *bt_private_value_integer_create(void);
-extern struct bt_private_value *bt_private_value_integer_create_init(int64_t val);
+extern struct bt_private_value *bt_private_value_integer_create_init(
+ int64_t val);
-extern enum bt_value_status bt_private_integer_bool_set(
+extern void bt_private_value_integer_set(
struct bt_private_value *integer_obj, int64_t val);
extern struct bt_private_value *bt_private_value_real_create(void);
extern struct bt_private_value *bt_private_value_real_create_init(double val);
-extern enum bt_value_status bt_private_value_real_set(
+extern void bt_private_value_real_set(
struct bt_private_value *real_obj, double val);
extern struct bt_private_value *bt_private_value_string_create(void);
-extern struct bt_private_value *bt_private_value_string_create_init(const char *val);
+extern struct bt_private_value *bt_private_value_string_create_init(
+ const char *val);
-extern enum bt_value_status bt_private_value_string_set(struct bt_private_value *string_obj,
+extern enum bt_value_status bt_private_value_string_set(
+ struct bt_private_value *string_obj,
const char *val);
extern struct bt_private_value *bt_private_value_array_create(void);
const struct bt_private_value *array_obj, uint64_t index);
extern enum bt_value_status bt_private_value_array_append_element(
- struct bt_private_value *array_obj, struct bt_value *element_obj);
+ struct bt_private_value *array_obj,
+ struct bt_value *element_obj);
extern enum bt_value_status bt_private_value_array_append_bool_element(
- struct bt_private_value *array_obj, bt_bool val);
+ struct bt_private_value *array_obj,
+ bt_bool val);
extern enum bt_value_status bt_private_value_array_append_integer_element(
- struct bt_private_value *array_obj, int64_t val);
+ struct bt_private_value *array_obj,
+ int64_t val);
extern enum bt_value_status bt_private_value_array_append_real_element(
- struct bt_private_value *array_obj, double val);
+ struct bt_private_value *array_obj,
+ double val);
extern enum bt_value_status bt_private_value_array_append_string_element(
struct bt_private_value *array_obj, const char *val);
const struct bt_private_value *map_obj, const char *key);
typedef bt_bool (* bt_private_value_map_foreach_entry_cb)(const char *key,
- struct bt_private_value *object, void *data);
+ struct bt_private_value *object, void *data);
extern enum bt_value_status bt_private_value_map_foreach_entry(
const struct bt_private_value *map_obj,
struct bt_private_value *map_obj, const char *key, double val);
extern enum bt_value_status bt_private_value_map_insert_string_entry(
- struct bt_private_value *map_obj, const char *key, const char *val);
+ struct bt_private_value *map_obj, const char *key,
+ const char *val);
extern enum bt_value_status bt_private_value_map_insert_empty_array_entry(
struct bt_private_value *map_obj, const char *key);
*/
enum bt_value_status {
/// Operation canceled.
- BT_VALUE_STATUS_CANCELED = -3,
+ BT_VALUE_STATUS_CANCELED = 125,
- /// General error.
- BT_VALUE_STATUS_ERROR = -1,
+ /// Cannot allocate memory.
+ BT_VALUE_STATUS_NOMEM = -12,
/// Okay, no error.
- BT_VALUE_STATUS_OK = 0,
+ BT_VALUE_STATUS_OK = 0,
};
struct bt_value;
return bt_value_get_type(object) == BT_VALUE_TYPE_MAP;
}
-extern struct bt_private_value *bt_value_copy(const struct bt_value *object);
+extern enum bt_value_status bt_value_copy(struct bt_private_value **copy,
+ const struct bt_value *object);
extern bt_bool bt_value_compare(const struct bt_value *object_a,
const struct bt_value *object_b);
-extern enum bt_value_status bt_value_bool_get(
- const struct bt_value *bool_obj, bt_bool *val);
+extern bt_bool bt_value_bool_get(const struct bt_value *bool_obj);
-extern enum bt_value_status bt_value_integer_get(
- const struct bt_value *integer_obj, int64_t *val);
+extern int64_t bt_value_integer_get(const struct bt_value *integer_obj);
-extern enum bt_value_status bt_value_real_get(
- const struct bt_value *real_obj, double *val);
+extern double bt_value_real_get(const struct bt_value *real_obj);
-extern enum bt_value_status bt_value_string_get(
- const struct bt_value *string_obj, const char **val);
+extern const char *bt_value_string_get(const struct bt_value *string_obj);
-extern int64_t bt_value_array_get_size(const struct bt_value *array_obj);
+extern uint64_t bt_value_array_get_size(const struct bt_value *array_obj);
-extern bt_bool bt_value_array_is_empty(const struct bt_value *array_obj);
+static inline
+bt_bool bt_value_array_is_empty(const struct bt_value *array_obj)
+{
+ return bt_value_array_get_size(array_obj) == 0;
+}
extern struct bt_value *bt_value_array_borrow_element_by_index(
const struct bt_value *array_obj, uint64_t index);
-extern int64_t bt_value_map_get_size(const struct bt_value *map_obj);
+extern uint64_t bt_value_map_get_size(const struct bt_value *map_obj);
-extern bt_bool bt_value_map_is_empty(const struct bt_value *map_obj);
+static inline
+bt_bool bt_value_map_is_empty(const struct bt_value *map_obj)
+{
+ return bt_value_map_get_size(map_obj) == 0;
+}
extern struct bt_value *bt_value_map_borrow_entry_value(
const struct bt_value *map_obj, const char *key);
extern bt_bool bt_value_map_has_entry(const struct bt_value *map_obj,
const char *key);
-extern struct bt_private_value *bt_value_map_extend(
+extern enum bt_value_status bt_value_map_extend(
+ struct bt_private_value **extended_map_obj,
struct bt_value *base_map_obj,
struct bt_value *extension_map_obj);
const char *bt_ctf_attributes_get_field_name(struct bt_private_value *attr_obj,
uint64_t index)
{
- int rc;
const char *ret = NULL;
struct bt_private_value *attr_field_obj = NULL;
struct bt_private_value *attr_field_name_obj = NULL;
goto end;
}
- rc = bt_value_string_get(
- bt_value_borrow_from_private(attr_field_name_obj), &ret);
- if (rc) {
- BT_LOGE("Cannot get raw value from string value: value-addr=%p",
- attr_field_name_obj);
- ret = NULL;
- }
+ ret = bt_value_string_get(
+ bt_value_borrow_from_private(attr_field_name_obj));
end:
return ret;
}
for (i = 0; i < attr_size; ++i) {
- int ret;
const char *field_name;
value_obj = bt_private_value_array_borrow_element_by_index(attr_obj, i);
goto error;
}
- ret = bt_value_string_get(
- bt_value_borrow_from_private(attr_field_name_obj),
- &field_name);
- if (ret) {
- BT_LOGE("Cannot get raw value from string value: value-addr=%p",
- attr_field_name_obj);
- goto error;
- }
+ field_name = bt_value_string_get(
+ bt_value_borrow_from_private(attr_field_name_obj));
if (!strcmp(field_name, name)) {
break;
bt_value_borrow_from_private(env_field_value_obj))) {
case BT_VALUE_TYPE_INTEGER:
{
- int ret;
int64_t int_value;
- ret = bt_value_integer_get(
+ int_value = bt_value_integer_get(
bt_value_borrow_from_private(
- env_field_value_obj), &int_value);
- BT_ASSERT(ret == 0);
+ env_field_value_obj));
g_string_append_printf(context->string,
"\t%s = %" PRId64 ";\n", entry_name,
int_value);
}
case BT_VALUE_TYPE_STRING:
{
- int ret;
const char *str_value;
char *escaped_str = NULL;
- ret = bt_value_string_get(
+ str_value = bt_value_string_get(
bt_value_borrow_from_private(
- env_field_value_obj), &str_value);
- BT_ASSERT(ret == 0);
+ env_field_value_obj));
escaped_str = g_strescape(str_value, NULL);
if (!escaped_str) {
BT_LOGE("Cannot escape string: string=\"%s\"",
switch (bt_value_get_type(value)) {
case BT_VALUE_TYPE_BOOL:
{
- bt_bool val;
+ bt_bool val = bt_value_bool_get(value);
- (void) bt_value_bool_get(value, &val);
BUF_APPEND(", %svalue=%d", PRFIELD(val));
break;
}
case BT_VALUE_TYPE_INTEGER:
{
- int64_t val;
+ int64_t val = bt_value_integer_get(value);
- (void) bt_value_integer_get(value, &val);
BUF_APPEND(", %svalue=%" PRId64, PRFIELD(val));
break;
}
case BT_VALUE_TYPE_REAL:
{
- double val;
+ double val = bt_value_real_get(value);
- (void) bt_value_real_get(value, &val);
BUF_APPEND(", %svalue=%f", PRFIELD(val));
break;
}
case BT_VALUE_TYPE_STRING:
{
- const char *val;
+ const char *val = bt_value_string_get(value);
- (void) bt_value_string_get(value, &val);
BUF_APPEND(", %spartial-value=\"%.32s\"", PRFIELD(val));
break;
}
const char *bt_attributes_get_field_name(struct bt_private_value *attr_obj,
uint64_t index)
{
- int rc;
const char *ret = NULL;
struct bt_private_value *attr_field_obj = NULL;
struct bt_private_value *attr_field_name_obj = NULL;
goto end;
}
- rc = bt_value_string_get(
- bt_value_borrow_from_private(attr_field_name_obj), &ret);
- if (rc) {
- BT_LOGE("Cannot get raw value from string value: value-addr=%p",
- attr_field_name_obj);
- ret = NULL;
- }
+ ret = bt_value_string_get(
+ bt_value_borrow_from_private(attr_field_name_obj));
end:
return ret;
}
for (i = 0; i < attr_size; ++i) {
- int ret;
const char *field_name;
value_obj = bt_private_value_array_borrow_element_by_index(
goto error;
}
- ret = bt_value_string_get(
- bt_value_borrow_from_private(attr_field_name_obj),
- &field_name);
- if (ret) {
- BT_LOGE("Cannot get raw value from string value: value-addr=%p",
- attr_field_name_obj);
- goto error;
- }
+ field_name = bt_value_string_get(
+ bt_value_borrow_from_private(attr_field_name_obj));
if (!strcmp(field_name, name)) {
break;
};
struct bt_value *bt_value_null = &bt_value_null_instance;
-struct bt_private_value *bt_private_value_null = (void *) &bt_value_null_instance;
+struct bt_private_value *bt_private_value_null =
+ (void *) &bt_value_null_instance;
struct bt_value_bool {
struct bt_value base;
static
struct bt_private_value *bt_value_bool_copy(const struct bt_value *bool_obj)
{
- return bt_private_value_bool_create_init(BT_VALUE_TO_BOOL(bool_obj)->value);
+ return bt_private_value_bool_create_init(
+ BT_VALUE_TO_BOOL(bool_obj)->value);
}
static
}
for (i = 0; i < typed_array_obj->garray->len; ++i) {
- struct bt_private_value *element_obj_copy;
- struct bt_value *element_obj = bt_value_array_borrow_element_by_index(
- array_obj, i);
+ struct bt_private_value *element_obj_copy = NULL;
+ struct bt_value *element_obj =
+ bt_value_array_borrow_element_by_index(
+ array_obj, i);
BT_ASSERT(element_obj);
BT_LOGD("Copying array value's element: element-addr=%p, "
"index=%d", element_obj, i);
- element_obj_copy = bt_value_copy(element_obj);
- if (!element_obj_copy) {
+ ret = bt_value_copy(&element_obj_copy, element_obj);
+ if (ret) {
BT_LOGE("Cannot copy array value's element: "
"array-addr=%p, index=%d",
array_obj, i);
goto end;
}
+ BT_ASSERT(element_obj_copy);
ret = bt_private_value_array_append_element(copy_obj,
(void *) element_obj_copy);
BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
GHashTableIter iter;
gpointer key, element_obj;
struct bt_private_value *copy_obj;
- struct bt_private_value *element_obj_copy;
+ struct bt_private_value *element_obj_copy = NULL;
struct bt_value_map *typed_map_obj;
BT_LOGD("Copying map value: addr=%p", map_obj);
BT_ASSERT(key_str);
BT_LOGD("Copying map value's element: element-addr=%p, "
"key=\"%s\"", element_obj, key_str);
- element_obj_copy = bt_value_copy(element_obj);
- if (!element_obj_copy) {
+ ret = bt_value_copy(&element_obj_copy, element_obj);
+ if (ret) {
BT_LOGE("Cannot copy map value's element: "
"map-addr=%p, key=\"%s\"",
map_obj, key_str);
goto end;
}
+ BT_ASSERT(element_obj_copy);
ret = bt_private_value_map_insert_entry(copy_obj, key_str,
(void *) element_obj_copy);
BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
gpointer key, element_obj_a;
const struct bt_value_map *map_obj_a = BT_VALUE_TO_MAP(object_a);
- if (bt_value_map_get_size(object_a) != bt_value_map_get_size(object_b)) {
+ if (bt_value_map_get_size(object_a) !=
+ bt_value_map_get_size(object_b)) {
BT_LOGV("Map values are different: size mismatch "
"value-a-addr=%p, value-b-addr=%p, "
"value-a-size=%" PRId64 ", value-b-size=%" PRId64,
return (void *) BT_VALUE_FROM_CONCRETE(map_obj);
}
-enum bt_value_status bt_value_bool_get(const struct bt_value *bool_obj,
- bt_bool *val)
+bt_bool bt_value_bool_get(const struct bt_value *bool_obj)
{
BT_ASSERT_PRE_NON_NULL(bool_obj, "Value object");
- BT_ASSERT_PRE_NON_NULL(val, "Raw value");
BT_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_VALUE_TYPE_BOOL);
- *val = BT_VALUE_TO_BOOL(bool_obj)->value;
- return BT_VALUE_STATUS_OK;
+ return BT_VALUE_TO_BOOL(bool_obj)->value;
}
-enum bt_value_status bt_private_value_bool_set(struct bt_private_value *bool_obj,
- bt_bool val)
+void bt_private_value_bool_set(struct bt_private_value *bool_obj, bt_bool val)
{
BT_ASSERT_PRE_NON_NULL(bool_obj, "Value object");
BT_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_VALUE_TYPE_BOOL);
BT_VALUE_TO_BOOL(bool_obj)->value = val;
BT_LOGV("Set boolean value's raw value: value-addr=%p, value=%d",
bool_obj, val);
- return BT_VALUE_STATUS_OK;
}
-enum bt_value_status bt_value_integer_get(const struct bt_value *integer_obj,
- int64_t *val)
+int64_t bt_value_integer_get(const struct bt_value *integer_obj)
{
BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object");
- BT_ASSERT_PRE_NON_NULL(val, "Raw value");
BT_ASSERT_PRE_VALUE_IS_TYPE(integer_obj, BT_VALUE_TYPE_INTEGER);
- *val = BT_VALUE_TO_INTEGER(integer_obj)->value;
- return BT_VALUE_STATUS_OK;
+ return BT_VALUE_TO_INTEGER(integer_obj)->value;
}
-enum bt_value_status bt_private_integer_bool_set(struct bt_private_value *integer_obj,
+void bt_private_value_integer_set(struct bt_private_value *integer_obj,
int64_t val)
{
BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object");
BT_VALUE_TO_INTEGER(integer_obj)->value = val;
BT_LOGV("Set integer value's raw value: value-addr=%p, value=%" PRId64,
integer_obj, val);
- return BT_VALUE_STATUS_OK;
}
-enum bt_value_status bt_value_real_get(const struct bt_value *real_obj,
- double *val)
+double bt_value_real_get(const struct bt_value *real_obj)
{
BT_ASSERT_PRE_NON_NULL(real_obj, "Value object");
- BT_ASSERT_PRE_NON_NULL(val, "Raw value");
BT_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_VALUE_TYPE_REAL);
- *val = BT_VALUE_TO_REAL(real_obj)->value;
- return BT_VALUE_STATUS_OK;
+ return BT_VALUE_TO_REAL(real_obj)->value;
}
-enum bt_value_status bt_private_value_real_set(struct bt_private_value *real_obj,
- double val)
+void bt_private_value_real_set(struct bt_private_value *real_obj, double val)
{
BT_ASSERT_PRE_NON_NULL(real_obj, "Value object");
BT_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_VALUE_TYPE_REAL);
BT_VALUE_TO_REAL(real_obj)->value = val;
BT_LOGV("Set real number value's raw value: value-addr=%p, value=%f",
real_obj, val);
- return BT_VALUE_STATUS_OK;
}
-enum bt_value_status bt_value_string_get(const struct bt_value *string_obj,
- const char **val)
+const char *bt_value_string_get(const struct bt_value *string_obj)
{
BT_ASSERT_PRE_NON_NULL(string_obj, "Value object");
- BT_ASSERT_PRE_NON_NULL(val, "Raw value");
BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_VALUE_TYPE_STRING);
- *val = BT_VALUE_TO_STRING(string_obj)->gstr->str;
- return BT_VALUE_STATUS_OK;
+ return BT_VALUE_TO_STRING(string_obj)->gstr->str;
}
-enum bt_value_status bt_private_value_string_set(struct bt_private_value *string_obj,
- const char *val)
+enum bt_value_status bt_private_value_string_set(
+ struct bt_private_value *string_obj, const char *val)
{
BT_ASSERT_PRE_NON_NULL(string_obj, "Value object");
- BT_ASSERT_PRE_NON_NULL(val, "Raw value");
BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_VALUE_TYPE_STRING);
BT_ASSERT_PRE_VALUE_HOT(string_obj, "Value object");
g_string_assign(BT_VALUE_TO_STRING(string_obj)->gstr, val);
return BT_VALUE_STATUS_OK;
}
-int64_t bt_value_array_get_size(const struct bt_value *array_obj)
+uint64_t bt_value_array_get_size(const struct bt_value *array_obj)
{
BT_ASSERT_PRE_NON_NULL(array_obj, "Value object");
BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
- return (int64_t) BT_VALUE_TO_ARRAY(array_obj)->garray->len;
-}
-
-bt_bool bt_value_array_is_empty(const struct bt_value *array_obj)
-{
- return bt_value_array_get_size(array_obj) == 0;
+ return (uint64_t) BT_VALUE_TO_ARRAY(array_obj)->garray->len;
}
struct bt_value *bt_value_array_borrow_element_by_index(
return BT_VALUE_STATUS_OK;
}
-int64_t bt_value_map_get_size(const struct bt_value *map_obj)
+uint64_t bt_value_map_get_size(const struct bt_value *map_obj)
{
BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
- return (int64_t) g_hash_table_size(BT_VALUE_TO_MAP(map_obj)->ght);
-}
-
-bt_bool bt_value_map_is_empty(const struct bt_value *map_obj)
-{
- return bt_value_map_get_size(map_obj) == 0;
+ return (uint64_t) g_hash_table_size(BT_VALUE_TO_MAP(map_obj)->ght);
}
struct bt_value *bt_value_map_borrow_entry_value(const struct bt_value *map_obj,
}
enum bt_value_status bt_private_value_map_insert_string_entry(
- struct bt_private_value *map_obj, const char *key, const char *val)
+ struct bt_private_value *map_obj, const char *key,
+ const char *val)
{
enum bt_value_status ret;
struct bt_private_value *string_obj = NULL;
struct extend_map_element_data {
struct bt_private_value *extended_obj;
- bt_bool got_error;
+ enum bt_value_status status;
};
static
struct bt_value *extension_obj_elem, void *data)
{
bt_bool ret = BT_TRUE;
-
struct extend_map_element_data *extend_data = data;
+ struct bt_private_value *extension_obj_elem_copy = NULL;
/* Copy object which is to replace the current one */
- struct bt_private_value *extension_obj_elem_copy =
- bt_value_copy(extension_obj_elem);
+ extend_data->status = bt_value_copy(&extension_obj_elem_copy,
+ extension_obj_elem);
+ if (extend_data->status) {
+ BT_LOGE("Cannot copy map element: addr=%p",
+ extension_obj_elem);
+ goto error;
+ }
+
+ BT_ASSERT(extension_obj_elem_copy);
/* Replace in extended object */
- if (bt_private_value_map_insert_entry(extend_data->extended_obj, key,
- (void *) extension_obj_elem_copy)) {
+ extend_data->status = bt_private_value_map_insert_entry(
+ extend_data->extended_obj, key,
+ (void *) extension_obj_elem_copy);
+ if (extend_data->status) {
BT_LOGE("Cannot replace value in extended value: key=\"%s\", "
"extended-value-addr=%p, element-value-addr=%p",
key, extend_data->extended_obj,
goto end;
error:
+ BT_ASSERT(extend_data->status != BT_VALUE_STATUS_OK);
ret = BT_FALSE;
- extend_data->got_error = BT_TRUE;
end:
BT_OBJECT_PUT_REF_AND_RESET(extension_obj_elem_copy);
return ret;
}
-struct bt_private_value *bt_value_map_extend(struct bt_value *base_map_obj,
+enum bt_value_status bt_value_map_extend(
+ struct bt_private_value **extended_map_obj,
+ struct bt_value *base_map_obj,
struct bt_value *extension_obj)
{
- struct bt_private_value *extended_obj = NULL;
- struct extend_map_element_data extend_data = { 0 };
+ struct extend_map_element_data extend_data = {
+ .extended_obj = NULL,
+ .status = BT_VALUE_STATUS_OK,
+ };
BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object");
BT_ASSERT_PRE_NON_NULL(extension_obj, "Extension value object");
+ BT_ASSERT_PRE_NON_NULL(extended_map_obj,
+ "Extended value object (output)");
BT_ASSERT_PRE_VALUE_IS_TYPE(base_map_obj, BT_VALUE_TYPE_MAP);
BT_ASSERT_PRE_VALUE_IS_TYPE(extension_obj, BT_VALUE_TYPE_MAP);
BT_LOGD("Extending map value: base-value-addr=%p, extension-value-addr=%p",
base_map_obj, extension_obj);
+ *extended_map_obj = NULL;
/* Create copy of base map object to start with */
- extended_obj = bt_value_copy(base_map_obj);
- if (!extended_obj) {
+ extend_data.status = bt_value_copy(extended_map_obj, base_map_obj);
+ if (extend_data.status) {
BT_LOGE("Cannot copy base value: base-value-addr=%p",
base_map_obj);
goto error;
}
+ BT_ASSERT(extended_map_obj);
+
/*
* For each key in the extension map object, replace this key
* in the copied map object.
*/
- extend_data.extended_obj = extended_obj;
+ extend_data.extended_obj = *extended_map_obj;
if (bt_value_map_foreach_entry(extension_obj, extend_map_element,
&extend_data)) {
goto error;
}
- if (extend_data.got_error) {
+ if (extend_data.status) {
BT_LOGE("Failed to successfully iterate on the extension object's elements: "
"extension-value-addr=%p", extension_obj);
goto error;
}
BT_LOGD("Extended map value: extended-value-addr=%p",
- extended_obj);
+ *extended_map_obj);
goto end;
error:
- BT_OBJECT_PUT_REF_AND_RESET(extended_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(*extended_map_obj);
+ *extended_map_obj = NULL;
end:
- return (void *) extended_obj;
+ return extend_data.status;
}
-struct bt_private_value *bt_value_copy(const struct bt_value *object)
+enum bt_value_status bt_value_copy(struct bt_private_value **copy_obj,
+ const struct bt_value *object)
{
- struct bt_private_value *copy_obj = NULL;
+ enum bt_value_status status = BT_VALUE_STATUS_OK;
BT_ASSERT_PRE_NON_NULL(object, "Value object");
+ BT_ASSERT_PRE_NON_NULL(copy_obj, "Value object copy (output)");
BT_LOGD("Copying value object: addr=%p", object);
- copy_obj = copy_funcs[object->type](object);
- if (copy_obj) {
+ *copy_obj = copy_funcs[object->type](object);
+ if (*copy_obj) {
BT_LOGD("Copied value object: copy-value-addr=%p",
copy_obj);
} else {
+ status = BT_VALUE_STATUS_NOMEM;
+ *copy_obj = NULL;
BT_LOGE_STR("Failed to copy value object.");
}
- return (void *) copy_obj;
+ return status;
}
bt_bool bt_value_compare(const struct bt_value *object_a,
if (!value) {
goto end;
}
- status = bt_value_bool_get(value, &bool_val);
- if (status != BT_VALUE_STATUS_OK) {
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end;
- }
+ bool_val = bt_value_bool_get(value);
*option = (bool) bool_val;
if (found) {
struct bt_value *value = NULL;
const char *path_param;
enum bt_component_status ret;
- enum bt_value_status value_ret;
ctf_fs = g_new0(struct ctf_fs_component, 1);
if (!ctf_fs) {
goto error;
}
- value_ret = bt_value_string_get(value, &path_param);
- BT_ASSERT(value_ret == BT_VALUE_STATUS_OK);
+ path_param = bt_value_string_get(value);
value = bt_value_map_borrow_entry_value(params, "clock-class-offset-s");
if (value) {
if (!bt_value_is_integer(value)) {
BT_LOGE("clock-class-offset-s should be an integer");
goto error;
}
- value_ret = bt_value_integer_get(value,
- &ctf_fs->metadata_config.clock_class_offset_s);
- BT_ASSERT(value_ret == BT_VALUE_STATUS_OK);
+ ctf_fs->metadata_config.clock_class_offset_s = bt_value_integer_get(value);
}
value = bt_value_map_borrow_entry_value(params, "clock-class-offset-ns");
BT_LOGE("clock-class-offset-ns should be an integer");
goto error;
}
- value_ret = bt_value_integer_get(value,
- &ctf_fs->metadata_config.clock_class_offset_ns);
- BT_ASSERT(value_ret == BT_VALUE_STATUS_OK);
+ ctf_fs->metadata_config.clock_class_offset_ns = bt_value_integer_get(value);
}
ctf_fs->port_data = g_ptr_array_new_with_free_func(port_data_destroy);
}
path_value = bt_value_map_borrow_entry_value(params, "path");
- ret = bt_value_string_get(path_value, &path);
- if (ret) {
- BT_LOGE_STR("Cannot get `path` string parameter.");
- query_ret.status = BT_QUERY_STATUS_INVALID_PARAMS;
- goto error;
- }
+ path = bt_value_string_get(path_value);
BT_ASSERT(path);
metadata_fp = ctf_fs_metadata_open_file(path);
}
path_value = bt_value_map_borrow_entry_value(params, "path");
- ret = bt_value_string_get(path_value, &path);
- if (ret) {
- BT_LOGE("Cannot get `path` string parameter.");
- query_ret.status = BT_QUERY_STATUS_INVALID_PARAMS;
- goto error;
- }
+ path = bt_value_string_get(path_value);
normalized_path = bt_common_normalize_path(path, NULL);
if (!normalized_path) {
BT_LOGW("Mandatory \"url\" parameter missing");
goto error;
}
- ret = bt_value_string_get(value, &url);
- if (ret != BT_VALUE_STATUS_OK) {
- BT_LOGW("\"url\" parameter is required to be a string value");
- goto error;
- }
+ url = bt_value_string_get(value);
lttng_live->url = g_string_new(url);
if (!lttng_live->url) {
goto error;
ret = BT_VALUE_STATUS_ERROR;
goto end;
}
- ret = bt_value_string_get(hostname, &hostname_str);
- if (ret != BT_VALUE_STATUS_OK) {
- goto end;
- }
- ret = bt_value_string_get(session_name, &session_name_str);
- if (ret != BT_VALUE_STATUS_OK) {
- goto end;
- }
+ hostname_str = bt_value_string_get(hostname);
+ session_name_str = bt_value_string_get(session_name);
if (!strcmp(session->hostname, hostname_str)
&& !strcmp(session->session_name,
ret = BT_VALUE_STATUS_ERROR;
goto end;
}
- ret = bt_value_integer_get(btval, &val);
- if (ret != BT_VALUE_STATUS_OK) {
- goto end;
- }
+ val = bt_value_integer_get(btval);
/* sum */
val += streams;
ret = bt_private_integer_bool_set(btval, val);
ret = BT_VALUE_STATUS_ERROR;
goto end;
}
- ret = bt_value_integer_get(btval, &val);
- if (ret != BT_VALUE_STATUS_OK) {
- goto end;
- }
+ val = bt_value_integer_get(btval);
/* max */
val = max_t(int64_t, clients, val);
ret = bt_private_integer_bool_set(btval, val);
if (!field) {
goto end;
}
- ret = bt_value_string_get(field, &str_value);
- BT_ASSERT(ret == BT_VALUE_STATUS_OK);
+ str_value = bt_value_string_get(field);
/* Domain not ust, no debug info */
if (strcmp(str_value, "ust") != 0) {
if (!field) {
goto end;
}
- ret = bt_value_string_get(field, &str_value);
- BT_ASSERT(ret == BT_VALUE_STATUS_OK);
+ str_value = bt_value_string_get(field);
/* Tracer_name not lttng-ust, no debug info */
if (strcmp(str_value, "lttng-ust") != 0) {
enum bt_value_status value_ret;
const char *tmp;
- value_ret = bt_value_string_get(value, &tmp);
- if (value_ret) {
- ret = BT_COMPONENT_STATUS_INVALID;
- BT_LOGE_STR("Failed to retrieve debug-info-field-name value. "
- "Expecting a string.");
- }
+ tmp = bt_value_string_get(value);
strcpy(debug_info_component->arg_debug_info_field_name, tmp);
bt_object_put_ref(value);
} else {
if (value) {
enum bt_value_status value_ret;
- value_ret = bt_value_string_get(value,
- &debug_info_component->arg_debug_dir);
- if (value_ret) {
- ret = BT_COMPONENT_STATUS_INVALID;
- BT_LOGE_STR("Failed to retrieve debug-info-dir value. "
- "Expecting a string.");
- }
+ debug_info_component->arg_debug_dir = bt_value_string_get(value);
}
bt_object_put_ref(value);
if (ret != BT_COMPONENT_STATUS_OK) {
if (value) {
enum bt_value_status value_ret;
- value_ret = bt_value_string_get(value,
- &debug_info_component->arg_target_prefix);
- if (value_ret) {
- ret = BT_COMPONENT_STATUS_INVALID;
- BT_LOGE_STR("Failed to retrieve target-prefix value. "
- "Expecting a string.");
- }
+ debug_info_component->arg_target_prefix = bt_value_string_get(value);
}
bt_object_put_ref(value);
if (ret != BT_COMPONENT_STATUS_OK) {
enum bt_value_status value_ret;
bt_bool bool_val;
- value_ret = bt_value_bool_get(value,
- &bool_val);
- if (value_ret) {
- ret = BT_COMPONENT_STATUS_INVALID;
- BT_LOGE_STR("Failed to retrieve full-path value. "
- "Expecting a boolean.");
- }
+ bool_val = bt_value_bool_get(value);
debug_info_component->arg_full_path = bool_val;
}
goto error;
}
- ret = bt_value_bool_get(no_timestamp,
- &dmesg_comp->params.no_timestamp);
- BT_ASSERT(ret == 0);
+ dmesg_comp->params.no_timestamp =
+ bt_value_bool_get(no_timestamp);
}
path = bt_value_map_borrow_entry_value(params, "path");
goto error;
}
- ret = bt_value_string_get(path, &path_str);
- BT_ASSERT(ret == 0);
+ path_str = bt_value_string_get(path);
g_string_assign(dmesg_comp->params.path, path_str);
} else {
dmesg_comp->params.read_from_stdin = true;
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
struct bt_value *value = NULL;
- enum bt_value_status status;
const char *str;
value = bt_value_map_borrow_entry_value(params, key);
if (bt_value_is_null(value)) {
goto end;
}
- status = bt_value_string_get(value, &str);
- switch (status) {
- case BT_VALUE_STATUS_OK:
- break;
- default:
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end;
- }
+ str = bt_value_string_get(value);
*option = g_strdup(str);
+
end:
return ret;
}
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
struct bt_value *value = NULL;
- enum bt_value_status status;
bt_bool bool_val;
value = bt_value_map_borrow_entry_value(params, key);
if (!value) {
goto end;
}
- status = bt_value_bool_get(value, &bool_val);
- switch (status) {
- case BT_VALUE_STATUS_OK:
- break;
- default:
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end;
- }
+ bool_val = bt_value_bool_get(value);
*option = (bool) bool_val;
if (found) {
*found = true;
goto end;
}
- status = bt_value_string_get(color_value, &color);
- if (status) {
- warn_wrong_color_param(pretty);
+ color = bt_value_string_get(color_value);
+
+ if (strcmp(color, "never") == 0) {
+ pretty->options.color = PRETTY_COLOR_OPT_NEVER;
+ } else if (strcmp(color, "auto") == 0) {
+ pretty->options.color = PRETTY_COLOR_OPT_AUTO;
+ } else if (strcmp(color, "always") == 0) {
+ pretty->options.color = PRETTY_COLOR_OPT_ALWAYS;
} else {
- if (strcmp(color, "never") == 0) {
- pretty->options.color = PRETTY_COLOR_OPT_NEVER;
- } else if (strcmp(color, "auto") == 0) {
- pretty->options.color = PRETTY_COLOR_OPT_AUTO;
- } else if (strcmp(color, "always") == 0) {
- pretty->options.color = PRETTY_COLOR_OPT_ALWAYS;
- } else {
- warn_wrong_color_param(pretty);
- }
+ warn_wrong_color_param(pretty);
}
}
if (print_names) {
print_name_equal(pretty, "trace:hostname");
}
- if (bt_value_string_get(hostname_str, &str)
- == BT_VALUE_STATUS_OK) {
- g_string_append(pretty->string, str);
- }
+ str = bt_value_string_get(hostname_str);
+ g_string_append(pretty->string, str);
dom_print = 1;
}
}
} else if (dom_print) {
g_string_append(pretty->string, ":");
}
- if (bt_value_string_get(domain_str, &str)
- == BT_VALUE_STATUS_OK) {
- g_string_append(pretty->string, str);
- }
+ str = bt_value_string_get(domain_str);
+ g_string_append(pretty->string, str);
dom_print = 1;
}
}
} else if (dom_print) {
g_string_append(pretty->string, ":");
}
- if (bt_value_string_get(procname_str, &str)
- == BT_VALUE_STATUS_OK) {
- g_string_append(pretty->string, str);
- }
-
+ str = bt_value_string_get(procname_str);
+ g_string_append(pretty->string, str);
dom_print = 1;
}
}
} else if (dom_print) {
g_string_append(pretty->string, ":");
}
- if (bt_value_integer_get(vpid_value, &value)
- == BT_VALUE_STATUS_OK) {
- g_string_append_printf(pretty->string, "(%" PRId64 ")", value);
- }
-
+ value = bt_value_integer_get(vpid_value);
+ g_string_append_printf(pretty->string,
+ "(%" PRId64 ")", value);
dom_print = 1;
}
}
if (step && bt_value_is_integer(step)) {
int64_t val;
- (void) bt_value_integer_get(step, &val);
-
+ val = bt_value_integer_get(step);
if (val >= 0) {
counter->step = (uint64_t) val;
}
if (hide_zero && bt_value_is_bool(hide_zero)) {
bt_bool val;
- (void) bt_value_bool_get(hide_zero, &val);
+ val = bt_value_bool_get(hide_zero);
counter->hide_zero = (bool) val;
}
goto error;
}
- real_params = bt_value_map_extend(
+ ret = bt_value_map_extend(&real_params,
bt_value_borrow_from_private(default_params), params);
- if (!real_params) {
+ if (ret) {
BT_LOGE("Cannot extend default parameters map value: "
"muxer-comp-addr=%p, def-params-addr=%p, "
"params-addr=%p", muxer_comp, default_params,
goto error;
}
- ret = bt_value_bool_get(assume_absolute_clock_classes, &bool_val);
- BT_ASSERT(ret == 0);
+ bool_val = bt_value_bool_get(assume_absolute_clock_classes);
muxer_comp->assume_absolute_clock_classes = (bool) bool_val;
BT_LOGD("Configured muxer component: muxer-comp-addr=%p, "
"assume-absolute-clock-classes=%d",
if (value) {
enum bt_value_status value_ret;
- value_ret = bt_value_bool_get(value, &gmt);
- if (value_ret) {
- ret = BT_COMPONENT_STATUS_INVALID;
- BT_LOGE_STR("Failed to retrieve clock-gmt value. Expecting a boolean");
- }
+ gmt = bt_value_bool_get(value);
}
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
#include <string.h>
#include "tap/tap.h"
-#define NR_TESTS 158
+#define NR_TESTS 147
static
void test_null(void)
static
void test_bool(void)
{
- int ret;
bt_bool value;
struct bt_private_value *priv_obj;
struct bt_value *obj;
"bt_private_value_bool_create() returns a boolean value object");
value = BT_TRUE;
- ret = bt_value_bool_get(obj, &value);
- ok(!ret && !value, "default boolean value object value is BT_FALSE");
+ value = bt_value_bool_get(obj);
+ ok(!value, "default boolean value object value is BT_FALSE");
- BT_ASSERT(!bt_private_value_bool_set(priv_obj, BT_FALSE));
- ret = bt_private_value_bool_set(priv_obj, BT_TRUE);
- ok(!ret, "bt_private_value_bool_set() succeeds");
- ret = bt_value_bool_get(obj, &value);
- ok(!ret && value, "bt_private_value_bool_set() works");
+ bt_private_value_bool_set(priv_obj, BT_FALSE);
+ bt_private_value_bool_set(priv_obj, BT_TRUE);
+ value = bt_value_bool_get(obj);
+ ok(value, "bt_private_value_bool_set() works");
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
pass("putting an existing boolean value object does not cause a crash")
obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_bool(obj),
"bt_private_value_bool_create_init() returns a boolean value object");
- ret = bt_value_bool_get(obj, &value);
- ok(!ret && value,
+ value = bt_value_bool_get(obj);
+ ok(value,
"bt_private_value_bool_create_init() sets the appropriate initial value");
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
static
void test_integer(void)
{
- int ret;
int64_t value;
struct bt_private_value *priv_obj;
struct bt_value *obj;
"bt_private_value_integer_create() returns an integer value object");
value = 1961;
- ret = bt_value_integer_get(obj, &value);
- ok(!ret && value == 0, "default integer value object value is 0");
+ value = bt_value_integer_get(obj);
+ ok(value == 0, "default integer value object value is 0");
- ret = bt_private_integer_bool_set(priv_obj, -98765);
- ok(!ret, "bt_private_integer_bool_set() succeeds");
- ret = bt_value_integer_get(obj, &value);
- ok(!ret && value == -98765, "bt_private_integer_bool_set() works");
+ bt_private_value_integer_set(priv_obj, -98765);
+ value = bt_value_integer_get(obj);
+ ok(value == -98765, "bt_private_integer_bool_set() works");
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
pass("putting an existing integer value object does not cause a crash")
obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_integer(obj),
"bt_private_value_integer_create_init() returns an integer value object");
- ret = bt_value_integer_get(obj, &value);
- ok(!ret && value == 321456987,
+ value = bt_value_integer_get(obj);
+ ok(value == 321456987,
"bt_private_value_integer_create_init() sets the appropriate initial value");
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
static
void test_real(void)
{
- int ret;
double value;
struct bt_private_value *priv_obj;
struct bt_value *obj;
"bt_private_value_real_create() returns a real number value object");
value = 17.34;
- ret = bt_value_real_get(obj, &value);
- ok(!ret && value == 0.,
+ value = bt_value_real_get(obj);
+ ok(value == 0.,
"default real number value object value is 0");
- ret = bt_private_value_real_set(priv_obj, -3.1416);
- ok(!ret, "bt_private_value_real_set() succeeds");
- ret = bt_value_real_get(obj, &value);
- ok(!ret && value == -3.1416, "bt_private_value_real_set() works");
+ bt_private_value_real_set(priv_obj, -3.1416);
+ value = bt_value_real_get(obj);
+ ok(value == -3.1416, "bt_private_value_real_set() works");
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
pass("putting an existing real number value object does not cause a crash")
obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_real(obj),
"bt_private_value_real_create_init() returns a real number value object");
- ret = bt_value_real_get(obj, &value);
- ok(!ret && value == 33.1649758,
+ value = bt_value_real_get(obj);
+ ok(value == 33.1649758,
"bt_private_value_real_create_init() sets the appropriate initial value");
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
static
void test_string(void)
{
- int ret;
const char *value;
struct bt_private_value *priv_obj;
struct bt_value *obj;
ok(obj && bt_value_is_string(obj),
"bt_private_value_string_create() returns a string value object");
- ret = bt_value_string_get(obj, &value);
- ok(!ret && value && !strcmp(value, ""),
+ value = bt_value_string_get(obj);
+ ok(value && !strcmp(value, ""),
"default string value object value is \"\"");
- ret = bt_private_value_string_set(priv_obj, "hello worldz");
- ok(!ret, "bt_private_value_string_set() succeeds");
- ret = bt_value_string_get(obj, &value);
- ok(!ret && value && !strcmp(value, "hello worldz"),
+ bt_private_value_string_set(priv_obj, "hello worldz");
+ value = bt_value_string_get(obj);
+ ok(value && !strcmp(value, "hello worldz"),
"bt_value_string_get() works");
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
obj = bt_value_borrow_from_private(priv_obj);
ok(obj && bt_value_is_string(obj),
"bt_private_value_string_create_init() returns a string value object");
- ret = bt_value_string_get(obj, &value);
- ok(!ret && value && !strcmp(value, "initial value"),
+ value = bt_value_string_get(obj);
+ ok(value && !strcmp(value, "initial value"),
"bt_private_value_string_create_init() sets the appropriate initial value");
BT_OBJECT_PUT_REF_AND_RESET(priv_obj);
obj = bt_value_array_borrow_element_by_index(array_obj, 0);
ok(obj && bt_value_is_integer(obj),
"bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (integer)");
- ret = bt_value_integer_get(obj, &int_value);
- ok(!ret && int_value == 345,
+ int_value = bt_value_integer_get(obj);
+ ok(int_value == 345,
"bt_value_array_borrow_element_by_index() returns an value object with the appropriate value (integer)");
obj = bt_value_array_borrow_element_by_index(array_obj, 1);
ok(obj && bt_value_is_real(obj),
"bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (real number)");
- ret = bt_value_real_get(obj, &real_value);
- ok(!ret && real_value == -17.45,
+ real_value = bt_value_real_get(obj);
+ ok(real_value == -17.45,
"bt_value_array_borrow_element_by_index() returns an value object with the appropriate value (real number)");
obj = bt_value_array_borrow_element_by_index(array_obj, 2);
ok(obj && bt_value_is_bool(obj),
"bt_value_array_borrow_element_by_index() returns an value object with the appropriate type (boolean)");
- ret = bt_value_bool_get(obj, &bool_value);
- ok(!ret && bool_value,
+ bool_value = bt_value_bool_get(obj);
+ ok(bool_value,
"bt_value_array_borrow_element_by_index() returns an value object with the appropriate value (boolean)");
obj = bt_value_array_borrow_element_by_index(array_obj, 3);
ok(obj == bt_value_null,
obj = bt_value_array_borrow_element_by_index(array_obj, 2);
ok(obj && bt_value_is_integer(obj),
"bt_value_array_set_element_by_index() inserts an value object with the appropriate type");
- ret = bt_value_integer_get(obj, &int_value);
+ int_value = bt_value_integer_get(obj);
BT_ASSERT(!ret);
ok(int_value == 1001,
"bt_value_array_set_element_by_index() inserts an value object with the appropriate value");
obj = bt_value_array_borrow_element_by_index(array_obj, 4);
ok(obj && bt_value_is_bool(obj),
"bt_private_value_array_append_bool_element() appends a boolean value object");
- ret = bt_value_bool_get(obj, &bool_value);
- ok(!ret && !bool_value,
+ bool_value = bt_value_bool_get(obj);
+ ok(!bool_value,
"bt_private_value_array_append_bool_element() appends the appropriate value");
obj = bt_value_array_borrow_element_by_index(array_obj, 5);
ok(obj && bt_value_is_integer(obj),
"bt_private_value_array_append_integer_element() appends an integer value object");
- ret = bt_value_integer_get(obj, &int_value);
- ok(!ret && int_value == 98765,
+ int_value = bt_value_integer_get(obj);
+ ok(int_value == 98765,
"bt_private_value_array_append_integer_element() appends the appropriate value");
obj = bt_value_array_borrow_element_by_index(array_obj, 6);
ok(obj && bt_value_is_real(obj),
"bt_private_value_array_append_real_element() appends a real number value object");
- ret = bt_value_real_get(obj, &real_value);
- ok(!ret && real_value == 2.49578,
+ real_value = bt_value_real_get(obj);
+ ok(real_value == 2.49578,
"bt_private_value_array_append_real_element() appends the appropriate value");
obj = bt_value_array_borrow_element_by_index(array_obj, 7);
ok(obj && bt_value_is_string(obj),
"bt_private_value_array_append_string_element() appends a string value object");
- ret = bt_value_string_get(obj, &string_value);
+ string_value = bt_value_string_get(obj);
ok(!ret && string_value && !strcmp(string_value, "bt_value"),
"bt_private_value_array_append_string_element() appends the appropriate value");
obj = bt_value_array_borrow_element_by_index(array_obj, 8);
bt_bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
void *data)
{
- int ret;
struct map_foreach_checklist *checklist = data;
if (!strcmp(key, "bt_bool")) {
} else {
bt_bool val = BT_FALSE;
- ret = bt_value_bool_get(object, &val);
- ok(!ret, "test_map_foreach_cb_check(): success getting \"bt_bool\" value");
+ val = bt_value_bool_get(object);
if (val) {
pass("test_map_foreach_cb_check(): \"bt_bool\" value object has the right value");
} else {
int64_t val = 0;
- ret = bt_value_integer_get(object, &val);
- ok(!ret, "test_map_foreach_cb_check(): success getting \"int\" value");
+ val = bt_value_integer_get(object);
if (val == 19457) {
pass("test_map_foreach_cb_check(): \"int\" value object has the right value");
} else {
double val = 0;
- ret = bt_value_real_get(object, &val);
- ok(!ret, "test_map_foreach_cb_check(): success getting \"real\" value");
+ val = bt_value_real_get(object);
if (val == 5.444) {
pass("test_map_foreach_cb_check(): \"real\" value object has the right value");
} else {
bt_bool val = BT_FALSE;
- ret = bt_value_bool_get(object, &val);
- ok(!ret, "test_map_foreach_cb_check(): success getting \"bool2\" value");
+ val = bt_value_bool_get(object);
if (val) {
pass("test_map_foreach_cb_check(): \"bool2\" value object has the right value");
} else {
int64_t val = 0;
- ret = bt_value_integer_get(object, &val);
- ok(!ret, "test_map_foreach_cb_check(): success getting \"int2\" value");
+ val = bt_value_integer_get(object);
if (val == 98765) {
pass("test_map_foreach_cb_check(): \"int2\" value object has the right value");
} else {
double val = 0;
- ret = bt_value_real_get(object, &val);
- ok(!ret, "test_map_foreach_cb_check(): success getting \"real2\" value");
+ val = bt_value_real_get(object);
if (val == -49.0001) {
pass("test_map_foreach_cb_check(): \"real2\" value object has the right value");
} else {
const char *val;
- ret = bt_value_string_get(object, &val);
- ok(!ret, "test_map_foreach_cb_check(): success getting \"string2\" value");
+ val = bt_value_string_get(object);
if (val && !strcmp(val, "bt_value")) {
pass("test_map_foreach_cb_check(): \"string2\" value object has the right value");
obj = bt_value_map_borrow_entry_value(map_obj, "real");
ok(obj && bt_value_is_real(obj),
"bt_value_map_borrow_entry_value() returns an value object with the appropriate type (real)");
- ret = bt_value_real_get(obj, &real_value);
- ok(!ret && real_value == 5.444,
+ real_value = bt_value_real_get(obj);
+ ok(real_value == 5.444,
"bt_value_map_borrow_entry_value() returns an value object with the appropriate value (real)");
obj = bt_value_map_borrow_entry_value(map_obj, "int");
ok(obj && bt_value_is_integer(obj),
"bt_value_map_borrow_entry_value() returns an value object with the appropriate type (integer)");
- ret = bt_value_integer_get(obj, &int_value);
- ok(!ret && int_value == 19457,
+ int_value = bt_value_integer_get(obj);
+ ok(int_value == 19457,
"bt_value_map_borrow_entry_value() returns an value object with the appropriate value (integer)");
obj = bt_value_map_borrow_entry_value(map_obj, "null");
ok(obj && bt_value_is_null(obj),
obj = bt_value_map_borrow_entry_value(map_obj, "bt_bool");
ok(obj && bt_value_is_bool(obj),
"bt_value_map_borrow_entry_value() returns an value object with the appropriate type (boolean)");
- ret = bt_value_bool_get(obj, &bool_value);
- ok(!ret && bool_value,
+ bool_value = bt_value_bool_get(obj);
+ ok(bool_value,
"bt_value_map_borrow_entry_value() returns an value object with the appropriate value (boolean)");
ret = bt_private_value_map_insert_bool_entry(priv_map_obj, "bool2",
bt_value_borrow_from_private(string_obj));
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- map_copy_obj = bt_value_copy(bt_value_borrow_from_private(map_obj));
- ok(map_copy_obj,
+ status = bt_value_copy(&map_copy_obj,
+ bt_value_borrow_from_private(map_obj));
+ ok(status == BT_VALUE_STATUS_OK && map_copy_obj,
"bt_value_copy() succeeds");
ok(map_obj != map_copy_obj,
status = bt_private_value_map_insert_real_entry(extension_map,
"project", -404);
BT_ASSERT(status == BT_VALUE_STATUS_OK);
- extended_map = bt_value_map_extend(
+ status = bt_value_map_extend(
+ &extended_map,
bt_value_borrow_from_private(base_map),
bt_value_borrow_from_private(extension_map));
- ok(extended_map, "bt_value_map_extend() succeeds");
+ ok(status == BT_VALUE_STATUS_OK &&
+ extended_map, "bt_value_map_extend() succeeds");
ok(bt_value_map_get_size(
bt_value_borrow_from_private(extended_map)) == 5,
"bt_value_map_extend() returns a map object with the correct size");
/* Test bt_ctf_trace_get_environment_field_value */
obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 1);
- ret = bt_value_integer_get(obj, &ret_int64_t);
- ok(!ret && ret_int64_t == -164973,
+ ret_int64_t = bt_value_integer_get(obj);
+ ok(ret_int64_t == -164973,
"bt_ctf_trace_get_environment_field_value succeeds in getting an integer value");
BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 2);
- ret = bt_value_string_get(obj, &ret_string);
- ok(!ret && ret_string && !strcmp(ret_string, "oh yeah"),
+ ret_string = bt_value_string_get(obj);
+ ok(ret_string && !strcmp(ret_string, "oh yeah"),
"bt_ctf_trace_get_environment_field_value succeeds in getting a string value");
BT_OBJECT_PUT_REF_AND_RESET(obj);
"bt_ctf_trace_get_environment_field_value_by_name returns NULL or an unknown field name");
obj = bt_ctf_trace_get_environment_field_value_by_name(trace,
"test_env_str");
- ret = bt_value_string_get(obj, &ret_string);
- ok(!ret && ret_string && !strcmp(ret_string, "oh yeah"),
+ ret_string = bt_value_string_get(obj);
+ ok(ret_string && !strcmp(ret_string, "oh yeah"),
"bt_ctf_trace_get_environment_field_value_by_name succeeds in getting an existing field");
BT_OBJECT_PUT_REF_AND_RESET(obj);
ok(bt_ctf_trace_get_environment_field_count(trace) == 3,
"bt_ctf_trace_set_environment_field_integer with an existing key does not increase the environment size");
obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 1);
- ret = bt_value_integer_get(obj, &ret_int64_t);
- ok(!ret && ret_int64_t == 654321,
+ ret_int64_t = bt_value_integer_get(obj);
+ ok(ret_int64_t == 654321,
"bt_ctf_trace_get_environment_field_value successfully replaces an existing field");
BT_OBJECT_PUT_REF_AND_RESET(obj);
struct bt_value *res_params;
struct bt_graph *graph;
const char *object_str;
- enum bt_value_status value_ret;
enum bt_graph_status graph_ret;
struct bt_query_executor *query_exec = bt_query_executor_create();
int ret;
BT_ASSERT(bt_value_is_array(results) && bt_value_array_get_size(results) == 2);
object = bt_value_array_borrow_element_by_index(results, 0);
BT_ASSERT(object && bt_value_is_string(object));
- value_ret = bt_value_string_get(object, &object_str);
- BT_ASSERT(value_ret == BT_VALUE_STATUS_OK);
+ object_str = bt_value_string_get(object);
ok(strcmp(object_str, "get-something") == 0,
"bt_component_class_query() receives the expected object name");
res_params = bt_value_array_borrow_element_by_index(results, 1);