lib: make `bt_attributes_get_count()` return uint64_t
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 24 Oct 2019 14:14:20 +0000 (10:14 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Oct 2019 19:14:53 +0000 (15:14 -0400)
This function cannot return a negative number and cannot fail as it uses
the `bt_value_array_get_length()` function.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I1dfb06ffceaab9ef1c1ab6fa11041a2c3ddeb464
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2248
Tested-by: jenkins <jenkins@lttng.org>
src/lib/trace-ir/attributes.c
src/lib/trace-ir/attributes.h
src/lib/trace-ir/trace.c

index ce58e28982e758b91089487fe5b182dcc63938e0..8f03c799a79aa1b590a2432499e12d739ce71edd 100644 (file)
@@ -77,7 +77,7 @@ void bt_attributes_destroy(struct bt_value *attr_obj)
 }
 
 BT_HIDDEN
-int64_t bt_attributes_get_count(const struct bt_value *attr_obj)
+uint64_t bt_attributes_get_count(const struct bt_value *attr_obj)
 {
        return bt_value_array_get_length(attr_obj);
 }
index 60b46d428f9c77b30a92f2d628197fdcc77328a9..6f52d18bb07ffbad953a23607c6055de72c814e9 100644 (file)
@@ -39,7 +39,7 @@ BT_HIDDEN
 void bt_attributes_destroy(struct bt_value *attr_obj);
 
 BT_HIDDEN
-int64_t bt_attributes_get_count(const struct bt_value *attr_obj);
+uint64_t bt_attributes_get_count(const struct bt_value *attr_obj);
 
 BT_HIDDEN
 const char *bt_attributes_get_field_name(const struct bt_value *attr_obj,
index 1536feaf6c3b4e77e720703acc188d042651c21e..7a61040125a55d496e7d6878b4256b603afb6e06 100644 (file)
@@ -332,12 +332,8 @@ end:
 
 uint64_t bt_trace_get_environment_entry_count(const struct bt_trace *trace)
 {
-       int64_t ret;
-
        BT_ASSERT_PRE_DEV_NON_NULL(trace, "Trace");
-       ret = bt_attributes_get_count(trace->environment);
-       BT_ASSERT(ret >= 0);
-       return (uint64_t) ret;
+       return bt_attributes_get_count(trace->environment);
 }
 
 void bt_trace_borrow_environment_entry_by_index_const(
This page took 0.027807 seconds and 4 git commands to generate.