Standardize *get_*_count() functions
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 26 Apr 2017 21:30:51 +0000 (17:30 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:41 +0000 (12:57 -0400)
All "count" functions now return the count as an `int64_t` value,
returning -1 on error.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
35 files changed:
cli/babeltrace.c
include/babeltrace/ctf-ir/attributes-internal.h
include/babeltrace/ctf-ir/event-class.h
include/babeltrace/ctf-ir/field-path.h
include/babeltrace/ctf-ir/field-types-internal.h
include/babeltrace/ctf-ir/field-types.h
include/babeltrace/ctf-ir/fields.h
include/babeltrace/ctf-ir/stream-class.h
include/babeltrace/ctf-ir/trace.h
include/babeltrace/ctf-ir/visitor-internal.h
include/babeltrace/ctf-writer/serialize-internal.h
include/babeltrace/graph/clock-class-priority-map.h
include/babeltrace/graph/component-filter.h
include/babeltrace/graph/component-internal.h
include/babeltrace/graph/component-sink.h
include/babeltrace/graph/component-source.h
include/babeltrace/mmap-align-internal.h
include/babeltrace/plugin/plugin.h
include/babeltrace/values.h
lib/ctf-ir/attributes.c
lib/ctf-ir/event-class.c
lib/ctf-ir/field-path.c
lib/ctf-ir/field-types.c
lib/ctf-ir/stream-class.c
lib/ctf-ir/trace.c
lib/graph/clock-class-priority-map.c
lib/graph/component.c
lib/graph/filter.c
lib/graph/graph.c
lib/graph/sink.c
lib/graph/source.c
lib/plugin/plugin.c
lib/values.c
plugins/utils/muxer/muxer.c
tests/plugins/test-utils-muxer.c

index 821772e191b048a2b444da3018e94444eb8b885d..1a699909b1447bf7d54b7b9f1583ffc9c3a95b5c 100644 (file)
@@ -629,8 +629,8 @@ end:
 static
 void add_to_loaded_plugins(struct bt_plugin_set *plugin_set)
 {
-       int i;
-       int count;
+       int64_t i;
+       int64_t count;
 
        count = bt_plugin_set_get_plugin_count(plugin_set);
        assert(count >= 0);
@@ -864,7 +864,7 @@ static int cmd_help(struct bt_config *cfg)
        printf("  %sComponent classes%s: %d\n",
                        bt_common_color_bold(),
                        bt_common_color_reset(),
-                       bt_plugin_get_component_class_count(plugin));
+                       (int) bt_plugin_get_component_class_count(plugin));
 
 
        if (cfg->cmd_data.help.cfg_component->type !=
index b6a15a8c97e68b31775350b0e08a8eb746dc1652..fc82e7296e78812ef8e7a75accb8ac0e97876508 100644 (file)
@@ -42,7 +42,7 @@ BT_HIDDEN
 void bt_ctf_attributes_destroy(struct bt_value *attr_obj);
 
 BT_HIDDEN
-int bt_ctf_attributes_get_count(struct bt_value *attr_obj);
+int64_t bt_ctf_attributes_get_count(struct bt_value *attr_obj);
 
 BT_HIDDEN
 const char *bt_ctf_attributes_get_field_name(struct bt_value *attr_obj,
index 16fbcfb3e93158f80ce8359f29fb61c608cc8704..627919671fcab6117a8c557c0eeef84ab1926a31 100644 (file)
@@ -241,7 +241,7 @@ extern int bt_ctf_event_class_set_id(
 @sa bt_ctf_event_class_get_attribute_value(): Returns the value of
        the attribute of a given event class at a given index.
 */
-extern int bt_ctf_event_class_get_attribute_count(
+extern int64_t bt_ctf_event_class_get_attribute_count(
                struct bt_ctf_event_class *event_class);
 
 /**
@@ -482,7 +482,7 @@ bt_ctf_field_type_structure_get_field_count().
 @prenotnull{event_class}
 @postrefcountsame{event_class}
 */
-extern int bt_ctf_event_class_get_field_count(
+extern int64_t bt_ctf_event_class_get_field_count(
                struct bt_ctf_event_class *event_class);
 
 /**
index 7b009828c547e0e22946783667f79f19ea31bf39..e53b50f13c156ce09bbefb7108999949fd5831b6 100644 (file)
@@ -28,6 +28,7 @@
  * http://www.efficios.com/ctf
  */
 
+#include <stdint.h>
 #include <babeltrace/ctf-ir/field-types.h>
 
 #ifdef __cplusplus
@@ -109,7 +110,7 @@ extern enum bt_ctf_scope bt_ctf_field_path_get_root_scope(
 @prenotnull{field_path}
 @postrefcountsame{field_path}
 */
-extern int bt_ctf_field_path_get_index_count(
+extern int64_t bt_ctf_field_path_get_index_count(
                const struct bt_ctf_field_path *field_path);
 
 /**
index 129446bd9f20ffddc6ad1b29ddf218c62737c866..f54e859bb56c8dc8d2f8444a48e041805e2770b1 100644 (file)
@@ -27,6 +27,7 @@
  * SOFTWARE.
  */
 
+#include <stdint.h>
 #include <babeltrace/ctf-writer/event-types.h>
 #include <babeltrace/ctf-writer/event-fields.h>
 #include <babeltrace/ctf-writer/writer.h>
@@ -214,7 +215,7 @@ int bt_ctf_field_type_sequence_set_element_type(struct bt_ctf_field_type *array,
                struct bt_ctf_field_type *element_type);
 
 BT_HIDDEN
-int bt_ctf_field_type_get_field_count(struct bt_ctf_field_type *type);
+int64_t bt_ctf_field_type_get_field_count(struct bt_ctf_field_type *type);
 
 BT_HIDDEN
 struct bt_ctf_field_type *bt_ctf_field_type_get_field_at_index(
index 06c77379ae786da78c7af0a27b6d4b940e858db2..3e35a8d04fa6135f5243b307f6d45782afb4f1af 100644 (file)
@@ -1336,7 +1336,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type(
 @preisenumft{enum_field_type}
 @postrefcountsame{enum_field_type}
 */
-extern int bt_ctf_field_type_enumeration_get_mapping_count(
+extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
                struct bt_ctf_field_type *enum_field_type);
 
 /**
@@ -1921,7 +1921,7 @@ extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
 @preisstructft{struct_field_type}
 @postrefcountsame{struct_field_type}
 */
-extern int bt_ctf_field_type_structure_get_field_count(
+extern int64_t bt_ctf_field_type_structure_get_field_count(
                struct bt_ctf_field_type *struct_field_type);
 
 /**
@@ -2400,7 +2400,7 @@ extern struct bt_ctf_field_path *bt_ctf_field_type_variant_get_tag_field_path(
 @preisvarft{variant_field_type}
 @postrefcountsame{variant_field_type}
 */
-extern int bt_ctf_field_type_variant_get_field_count(
+extern int64_t bt_ctf_field_type_variant_get_field_count(
                struct bt_ctf_field_type *variant_field_type);
 
 /**
index 8578b5185d151d11a3b9032e8891c981896b98b8..abdc3dd1593f7d6bffcdf3231046d7e648ba3723 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <stdint.h>
 #include <stddef.h>
+#include <babeltrace/ctf-ir/field-types.h>
 
 #ifdef __cplusplus
 extern "C" {
index 2111ca1f8af985edf86ecec35bf23500e5843350..dc7b35d6ec436fd99005919ad06d19ac054bb87e 100644 (file)
@@ -474,7 +474,7 @@ extern int bt_ctf_stream_class_set_event_context_type(
 @prenotnull{stream_class}
 @postrefcountsame{stream_class}
 */
-extern int bt_ctf_stream_class_get_event_class_count(
+extern int64_t bt_ctf_stream_class_get_event_class_count(
                struct bt_ctf_stream_class *stream_class);
 
 /**
index a9e4fa89e1bc6cd76e7eab6e5aee87c78c704878..16cec454542d7b95c62b3fe2a24616f90d3df512 100644 (file)
@@ -293,7 +293,7 @@ extern int bt_ctf_trace_set_native_byte_order(struct bt_ctf_trace *trace_class,
 @prenotnull{trace_class}
 @postrefcountsame{trace_class}
 */
-extern int bt_ctf_trace_get_environment_field_count(
+extern int64_t bt_ctf_trace_get_environment_field_count(
                struct bt_ctf_trace *trace_class);
 
 /**
@@ -548,7 +548,8 @@ extern int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace *trace_class,
 @prenotnull{trace_class}
 @postrefcountsame{trace_class}
 */
-extern int bt_ctf_trace_get_clock_class_count(struct bt_ctf_trace *trace_class);
+extern int64_t bt_ctf_trace_get_clock_class_count(
+               struct bt_ctf_trace *trace_class);
 
 /**
 @brief  Returns the CTF IR clock class at index \p index in the CTF
@@ -645,7 +646,8 @@ extern int bt_ctf_trace_add_clock_class(struct bt_ctf_trace *trace_class,
 @prenotnull{trace_class}
 @postrefcountsame{trace_class}
 */
-extern int bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace_class);
+extern int64_t bt_ctf_trace_get_stream_class_count(
+               struct bt_ctf_trace *trace_class);
 
 /**
 @brief  Returns the stream class at index \p index in the CTF IR trace
@@ -742,7 +744,7 @@ extern int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace_class,
 @prenotnull{trace_class}
 @postrefcountsame{trace_class}
 */
-extern int bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace_class);
+extern int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace_class);
 
 /**
 @brief  Returns the stream at index \p index in the CTF IR trace
index e37172e1680daddbfb62143ffc7323e75a251feb..7e5e634b1e22f4e3d388df70b26bccdd5a22aa65 100644 (file)
@@ -31,7 +31,7 @@
 #include <babeltrace/babeltrace-internal.h>
 
 typedef void *(*bt_child_accessor)(void *object, int index);
-typedef int (*bt_child_count_accessor)(void *object);
+typedef int64_t (*bt_child_count_accessor)(void *object);
 typedef int (*bt_child_visitor)(void *object, bt_ctf_visitor visitor,
                void *data);
 
index 15ced8debe823b0f048b2cf93ff3284eb3e0a098..6095ae646da6d54df0fc393f89b83c2b86ebb10c 100644 (file)
@@ -110,7 +110,7 @@ char *bt_ctf_stream_pos_get_addr(struct bt_ctf_stream_pos *pos)
 {
        /* Only makes sense to get the address after aligning on CHAR_BIT */
        assert(!(pos->offset % CHAR_BIT));
-       return mmap_align_addr(pos->base_mma) +
+       return ((char *) mmap_align_addr(pos->base_mma)) +
                pos->mmap_base_offset + (pos->offset / CHAR_BIT);
 }
 
index 95d3168ba0cecc975921d4388ea3b7d9ddc07f4e..f810a4436d80fb819f773bbbc2823ddc56997c55 100644 (file)
@@ -109,7 +109,7 @@ extern struct bt_clock_class_priority_map *bt_clock_class_priority_map_create();
 @prenotnull{clock_class_priority_map}
 @postrefcountsame{clock_class_priority_map}
 */
-extern int bt_clock_class_priority_map_get_clock_class_count(
+extern int64_t bt_clock_class_priority_map_get_clock_class_count(
                struct bt_clock_class_priority_map *clock_class_priority_map);
 
 /**
index f9e681f39aaec1d2a6d56c2a7a33f5765e921504..557432d87c5e0451d05dbab0b51d76d221553950 100644 (file)
@@ -37,8 +37,8 @@ extern "C" {
 struct bt_port;
 struct bt_component;
 
-extern enum bt_component_status bt_component_filter_get_input_port_count(
-               struct bt_component *component, uint64_t *count);
+extern int64_t bt_component_filter_get_input_port_count(
+               struct bt_component *component);
 extern struct bt_port *bt_component_filter_get_input_port(
                struct bt_component *component, const char *name);
 extern struct bt_port *bt_component_filter_get_input_port_at_index(
@@ -46,8 +46,8 @@ extern struct bt_port *bt_component_filter_get_input_port_at_index(
 extern struct bt_port *bt_component_filter_get_default_input_port(
                struct bt_component *component);
 
-extern enum bt_component_status bt_component_filter_get_output_port_count(
-               struct bt_component *component, uint64_t *count);
+extern int64_t bt_component_filter_get_output_port_count(
+               struct bt_component *component);
 extern struct bt_port *bt_component_filter_get_output_port(
                struct bt_component *component, const char *name);
 extern struct bt_port *bt_component_filter_get_output_port_at_index(
index 27b03b09595520b5e19598b0dffcec0473735b8c..ae08b8b7ddfd61f71d4738210691dc787915cf8d 100644 (file)
@@ -106,10 +106,10 @@ void bt_component_set_graph(struct bt_component *component,
                struct bt_graph *graph);
 
 BT_HIDDEN
-uint64_t bt_component_get_input_port_count(struct bt_component *comp);
+int64_t bt_component_get_input_port_count(struct bt_component *comp);
 
 BT_HIDDEN
-uint64_t bt_component_get_output_port_count(struct bt_component *comp);
+int64_t bt_component_get_output_port_count(struct bt_component *comp);
 
 BT_HIDDEN
 struct bt_port *bt_component_get_input_port_at_index(struct bt_component *comp,
index 3bbfbb11e665dcdec968771d804806dc0b2e63a0..3c462bffe56e6327cd0fc129d00b746b22317bc4 100644 (file)
@@ -36,8 +36,8 @@ extern "C" {
 struct bt_component;
 struct bt_notification;
 
-extern enum bt_component_status bt_component_sink_get_input_port_count(
-               struct bt_component *component, uint64_t *count);
+extern int64_t bt_component_sink_get_input_port_count(
+               struct bt_component *component);
 extern struct bt_port *bt_component_sink_get_input_port(
                struct bt_component *component, const char *name);
 extern struct bt_port *bt_component_sink_get_input_port_at_index(
index 165ba0d248e5ed17b4bce3a2e06fc5dfe9c77bc1..24a8c0069b47bb968f7f9f09550f918293b532b8 100644 (file)
@@ -37,8 +37,8 @@ extern "C" {
 struct bt_component;
 struct bt_notification_iterator;
 
-extern enum bt_component_status bt_component_source_get_output_port_count(
-               struct bt_component *component, uint64_t *count);
+extern int64_t bt_component_source_get_output_port_count(
+               struct bt_component *component);
 extern struct bt_port *bt_component_source_get_output_port(
                struct bt_component *component, const char *name);
 extern struct bt_port *bt_component_source_get_output_port_at_index(
index ccb0e1f44039a2d7dd21375e584b45a083aa7070..d89affb592884a67f64507eee31c0493043891ae 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <babeltrace/align-internal.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <sys/mman.h>
 
 /*
@@ -71,7 +72,7 @@ struct mmap_align *mmap_align(size_t length, int prot,
                free(mma);
                return MAP_FAILED;
        }
-       mma->addr = mma->page_aligned_addr + (offset - page_aligned_offset);
+       mma->addr = ((uint8_t *) mma->page_aligned_addr) + (offset - page_aligned_offset);
        return mma;
 }
 
index 0e0bc8da54068df2fba76327ed2826e3a2b8b8f2..64192b3d3a0a9ec19b26a8c76d0df9a48d24810a 100644 (file)
@@ -28,6 +28,7 @@
  * SOFTWARE.
  */
 
+#include <stdint.h>
 #include <stddef.h>
 #include <stdbool.h>
 #include <babeltrace/graph/component-class.h>
@@ -109,7 +110,7 @@ extern enum bt_plugin_status bt_plugin_get_version(struct bt_plugin *plugin,
                unsigned int *major, unsigned int *minor, unsigned int *patch,
                const char **extra);
 
-extern int bt_plugin_get_component_class_count(struct bt_plugin *plugin);
+extern int64_t bt_plugin_get_component_class_count(struct bt_plugin *plugin);
 
 extern struct bt_component_class *bt_plugin_get_component_class(
                struct bt_plugin *plugin, size_t index);
@@ -120,7 +121,7 @@ struct bt_component_class *bt_plugin_get_component_class_by_name_and_type(
                enum bt_component_class_type type);
 
 extern
-int bt_plugin_set_get_plugin_count(struct bt_plugin_set *plugin_set);
+int64_t bt_plugin_set_get_plugin_count(struct bt_plugin_set *plugin_set);
 
 extern
 struct bt_plugin *bt_plugin_set_get_plugin(struct bt_plugin_set *plugin_set,
index 03c0024fdbc2afaf758cb9db8709afd2e1bd9656..bc9669ce36a2f25158f8c2065bc444272e3df3b4 100644 (file)
@@ -181,7 +181,7 @@ enum bt_value_status {
        BT_VALUE_STATUS_CANCELLED =     -3,
 
        /* -22 for compatibility with -EINVAL */
-       /// Invalid arguments.
+       /// Invalid argument.
        BT_VALUE_STATUS_INVAL =         -22,
 
        /// General error.
@@ -843,7 +843,7 @@ extern struct bt_value *bt_value_array_create(void);
 @sa bt_value_array_is_empty(): Checks whether or not a given array
        value object is empty.
 */
-extern int bt_value_array_size(const struct bt_value *array_obj);
+extern int64_t bt_value_array_size(const struct bt_value *array_obj);
 
 /**
 @brief Checks whether or not the array value object \p array_obj
@@ -879,7 +879,7 @@ extern bool bt_value_array_is_empty(const struct bt_value *array_obj);
 @postrefcountsame{array_obj}
 */
 extern struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
-               size_t index);
+               uint64_t index);
 
 /**
 @brief Appends the value object \p element_obj to the array value
@@ -1076,7 +1076,7 @@ extern enum bt_value_status bt_value_array_append_empty_map(
 @postrefcountsame{array_obj}
 */
 extern enum bt_value_status bt_value_array_set(struct bt_value *array_obj,
-               size_t index, struct bt_value *element_obj);
+               uint64_t index, struct bt_value *element_obj);
 
 /** @} */
 
@@ -1111,7 +1111,7 @@ extern struct bt_value *bt_value_map_create(void);
 @sa bt_value_map_is_empty(): Checks whether or not a given map value
        object is empty.
 */
-extern int bt_value_map_size(const struct bt_value *map_obj);
+extern int64_t bt_value_map_size(const struct bt_value *map_obj);
 
 /**
 @brief Checks whether or not the map value object \p map_obj is empty.
index c6e8a232e885bc0c35fd08de3848a18ee87d6a3f..0ea3cfd7cc5a4e32ca05b37d8c0701caf5f709b7 100644 (file)
@@ -58,7 +58,7 @@ void bt_ctf_attributes_destroy(struct bt_value *attr_obj)
 }
 
 BT_HIDDEN
-int bt_ctf_attributes_get_count(struct bt_value *attr_obj)
+int64_t bt_ctf_attributes_get_count(struct bt_value *attr_obj)
 {
        return bt_value_array_size(attr_obj);
 }
index 0cef19353f1f972cc7fbb86d5f43c6bb93e12a16..c50e39bfa1b8a121bc8e89b2bd1944c14efc2af4 100644 (file)
@@ -262,10 +262,10 @@ end:
        return ret;
 }
 
-int bt_ctf_event_class_get_attribute_count(
+int64_t bt_ctf_event_class_get_attribute_count(
                struct bt_ctf_event_class *event_class)
 {
-       int ret = 0;
+       int64_t ret = 0;
 
        if (!event_class) {
                ret = -1;
@@ -400,10 +400,10 @@ end:
        return ret;
 }
 
-int bt_ctf_event_class_get_field_count(
+int64_t bt_ctf_event_class_get_field_count(
                struct bt_ctf_event_class *event_class)
 {
-       int ret;
+       int64_t ret;
 
        if (!event_class) {
                ret = -1;
@@ -577,8 +577,8 @@ BT_HIDDEN
 int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
                struct metadata_context *context)
 {
-       int i;
-       int count;
+       int64_t i;
+       int64_t count;
        int ret = 0;
        struct bt_value *attr_value = NULL;
 
index 6c0b248af0ce222632a9957834ab8d3cc8f8c4e5..a3d42352709410dce141511fbe3b3d46a1b18526 100644 (file)
@@ -29,6 +29,7 @@
 #include <babeltrace/ctf-ir/field-path-internal.h>
 #include <babeltrace/ctf-ir/field-path.h>
 #include <limits.h>
+#include <stdint.h>
 #include <glib.h>
 
 static
@@ -111,10 +112,10 @@ end:
        return scope;
 }
 
-int bt_ctf_field_path_get_index_count(
+int64_t bt_ctf_field_path_get_index_count(
                const struct bt_ctf_field_path *field_path)
 {
-       int ret = -1;
+       int64_t ret = -1;
 
        if (!field_path) {
                goto end;
index b29d9947d7cc763d118e9b95ca122e297e0536ef..442aff0e9e2b2b8c990ce3e1ac83dcab130f4114 100644 (file)
@@ -590,8 +590,8 @@ int bt_ctf_field_type_structure_validate(struct bt_ctf_field_type *type)
 {
        int ret = 0;
        struct bt_ctf_field_type *child_type = NULL;
-       int field_count = bt_ctf_field_type_structure_get_field_count(type);
-       int i;
+       int64_t field_count = bt_ctf_field_type_structure_get_field_count(type);
+       int64_t i;
 
        if (field_count < 0) {
                ret = -1;
@@ -660,13 +660,13 @@ static
 int bt_ctf_field_type_variant_validate(struct bt_ctf_field_type *type)
 {
        int ret = 0;
-       int field_count;
+       int64_t field_count;
        struct bt_ctf_field_type *child_type = NULL;
        struct bt_ctf_field_type_variant *variant =
                container_of(type, struct bt_ctf_field_type_variant,
                        parent);
-       int i;
-       int tag_mappings_count;
+       int64_t i;
+       int64_t tag_mappings_count;
 
        if (variant->tag_name->len == 0 || !variant->tag) {
                ret = -1;
@@ -1421,10 +1421,10 @@ end:
        return ret;
 }
 
-int bt_ctf_field_type_enumeration_get_mapping_count(
+int64_t bt_ctf_field_type_enumeration_get_mapping_count(
                struct bt_ctf_field_type *type)
 {
-       int ret = 0;
+       int64_t ret = 0;
        struct bt_ctf_field_type_enumeration *enumeration;
 
        if (!type || (type->id != BT_CTF_FIELD_TYPE_ID_ENUM)) {
@@ -1434,7 +1434,7 @@ int bt_ctf_field_type_enumeration_get_mapping_count(
 
        enumeration = container_of(type, struct bt_ctf_field_type_enumeration,
                parent);
-       ret = (int) enumeration->entries->len;
+       ret = (int64_t) enumeration->entries->len;
 end:
        return ret;
 }
@@ -1597,10 +1597,10 @@ end:
        return ret;
 }
 
-int bt_ctf_field_type_structure_get_field_count(
+int64_t bt_ctf_field_type_structure_get_field_count(
                struct bt_ctf_field_type *type)
 {
-       int ret = 0;
+       int64_t ret = 0;
        struct bt_ctf_field_type_structure *structure;
 
        if (!type || (type->id != BT_CTF_FIELD_TYPE_ID_STRUCT)) {
@@ -1610,7 +1610,7 @@ int bt_ctf_field_type_structure_get_field_count(
 
        structure = container_of(type, struct bt_ctf_field_type_structure,
                parent);
-       ret = (int) structure->fields->len;
+       ret = (int64_t) structure->fields->len;
 end:
        return ret;
 }
@@ -1891,9 +1891,9 @@ end:
        return field_type;
 }
 
-int bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *type)
+int64_t bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *type)
 {
-       int ret = 0;
+       int64_t ret = 0;
        struct bt_ctf_field_type_variant *variant;
 
        if (!type || (type->id != BT_CTF_FIELD_TYPE_ID_VARIANT)) {
@@ -1903,7 +1903,7 @@ int bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *type)
 
        variant = container_of(type, struct bt_ctf_field_type_variant,
                parent);
-       ret = (int) variant->fields->len;
+       ret = (int64_t) variant->fields->len;
 end:
        return ret;
 
@@ -2211,7 +2211,7 @@ int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type)
        }
        case BT_CTF_FIELD_TYPE_ID_STRUCT:
        {
-               int i, element_count;
+               int64_t i, element_count;
 
                element_count = bt_ctf_field_type_structure_get_field_count(
                        type);
@@ -4088,9 +4088,9 @@ end:
 }
 
 BT_HIDDEN
-int bt_ctf_field_type_get_field_count(struct bt_ctf_field_type *field_type)
+int64_t bt_ctf_field_type_get_field_count(struct bt_ctf_field_type *field_type)
 {
-       int field_count = -1;
+       int64_t field_count = -1;
        enum bt_ctf_field_type_id type_id = bt_ctf_field_type_get_type_id(field_type);
 
        switch (type_id) {
index 0463a119e591f620f0fae02be0b9c7bde294f6c8..1cab9590434ef710744e8568dac3de397c4d718e 100644 (file)
@@ -45,6 +45,7 @@
 #include <babeltrace/align-internal.h>
 #include <babeltrace/endian-internal.h>
 #include <inttypes.h>
+#include <stdint.h>
 
 static
 void bt_ctf_stream_class_destroy(struct bt_object *obj);
@@ -488,10 +489,10 @@ end:
        return ret;
 }
 
-int bt_ctf_stream_class_get_event_class_count(
+int64_t bt_ctf_stream_class_get_event_class_count(
                struct bt_ctf_stream_class *stream_class)
 {
-       int ret;
+       int64_t ret;
 
        if (!stream_class) {
                ret = -1;
@@ -694,7 +695,7 @@ void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class)
 }
 
 static
-int get_event_class_count(void *element)
+int64_t get_event_class_count(void *element)
 {
        return bt_ctf_stream_class_get_event_class_count(
                        (struct bt_ctf_stream_class *) element);
index 067e7db903d0937d494f6aecaa909270313bf06d..49c8308a5b32ef864ba36d8aa643ad20e9f2b611 100644 (file)
@@ -45,6 +45,7 @@
 #include <babeltrace/ref.h>
 #include <babeltrace/endian-internal.h>
 #include <inttypes.h>
+#include <stdint.h>
 
 #define DEFAULT_IDENTIFIER_SIZE 128
 #define DEFAULT_METADATA_STRING_SIZE 4096
@@ -322,9 +323,9 @@ end:
        return ret;
 }
 
-int bt_ctf_trace_get_environment_field_count(struct bt_ctf_trace *trace)
+int64_t bt_ctf_trace_get_environment_field_count(struct bt_ctf_trace *trace)
 {
-       int ret = 0;
+       int64_t ret = 0;
 
        if (!trace) {
                ret = -1;
@@ -411,9 +412,9 @@ end:
        return ret;
 }
 
-int bt_ctf_trace_get_clock_class_count(struct bt_ctf_trace *trace)
+int64_t bt_ctf_trace_get_clock_class_count(struct bt_ctf_trace *trace)
 {
-       int ret = -1;
+       int64_t ret = -1;
 
        if (!trace) {
                goto end;
@@ -442,7 +443,8 @@ end:
 int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace,
                struct bt_ctf_stream_class *stream_class)
 {
-       int ret, i;
+       int ret;
+       int64_t i;
        int64_t stream_id;
        struct bt_ctf_validation_output trace_sc_validation_output = { 0 };
        struct bt_ctf_validation_output *ec_validation_outputs = NULL;
@@ -455,7 +457,7 @@ int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace,
        struct bt_ctf_field_type *packet_context_type = NULL;
        struct bt_ctf_field_type *event_header_type = NULL;
        struct bt_ctf_field_type *stream_event_ctx_type = NULL;
-       int event_class_count;
+       int64_t event_class_count;
        struct bt_ctf_trace *current_parent_trace = NULL;
 
        if (!trace || !stream_class || trace->is_static) {
@@ -716,9 +718,9 @@ end:
        return ret;
 }
 
-int bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace)
+int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace)
 {
-       int ret;
+       int64_t ret;
 
        if (!trace) {
                ret = -1;
@@ -746,9 +748,9 @@ end:
        return stream;
 }
 
-int bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace)
+int64_t bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace)
 {
-       int ret;
+       int64_t ret;
 
        if (!trace) {
                ret = -1;
@@ -910,8 +912,8 @@ static
 void append_env_metadata(struct bt_ctf_trace *trace,
                struct metadata_context *context)
 {
-       int i;
-       int env_size;
+       int64_t i;
+       int64_t env_size;
 
        env_size = bt_ctf_attributes_get_count(trace->environment);
 
@@ -1108,7 +1110,7 @@ end:
 }
 
 static
-int get_stream_class_count(void *element)
+int64_t get_stream_class_count(void *element)
 {
        return bt_ctf_trace_get_stream_class_count(
                        (struct bt_ctf_trace *) element);
index 7e6543b4701d0739904be17fdbf1ba890dfdcec3..98e72522121a8b3f2d7d241e56c6dfb44a85d892 100644 (file)
@@ -82,16 +82,16 @@ end:
        return cc_prio_map;
 }
 
-int bt_clock_class_priority_map_get_clock_class_count(
+int64_t bt_clock_class_priority_map_get_clock_class_count(
                struct bt_clock_class_priority_map *cc_prio_map)
 {
-       int ret = -1;
+       int64_t ret = -1;
 
        if (!cc_prio_map) {
                goto end;
        }
 
-       ret = (int) cc_prio_map->entries->len;
+       ret = (int64_t) cc_prio_map->entries->len;
 
 end:
        return ret;
index 8837c0d1fa50dad479c6a36cbbd17db8a6acd3c8..e3464f45b646929b43952a78699fb73824d25f92 100644 (file)
@@ -188,14 +188,14 @@ end:
 }
 
 BT_HIDDEN
-uint64_t bt_component_get_input_port_count(struct bt_component *comp)
+int64_t bt_component_get_input_port_count(struct bt_component *comp)
 {
        assert(comp);
        return comp->input_ports->len;
 }
 
 BT_HIDDEN
-uint64_t bt_component_get_output_port_count(struct bt_component *comp)
+int64_t bt_component_get_output_port_count(struct bt_component *comp)
 {
        assert(comp);
        return comp->output_ports->len;
index 5931b3b3f7846c598f6fd334b7449f6ff77652be..f7d2961800e4ed5867402b0d3efa0a30900ca495 100644 (file)
@@ -80,20 +80,20 @@ end:
        return ret;
 }
 
-enum bt_component_status bt_component_filter_get_input_port_count(
+int64_t bt_component_filter_get_input_port_count(
                struct bt_component *component, uint64_t *count)
 {
-       enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+       int64_t ret;
 
-       if (!component || !count ||
+       if (!component ||
                        component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
-               status = BT_COMPONENT_STATUS_INVALID;
+               ret = -1;
                goto end;
        }
 
-       *count = bt_component_get_input_port_count(component);
+       ret = bt_component_get_input_port_count(component);
 end:
-       return status;
+       return ret;
 }
 
 struct bt_port *bt_component_filter_get_input_port(
@@ -133,20 +133,20 @@ struct bt_port *bt_component_filter_get_default_input_port(
                        DEFAULT_INPUT_PORT_NAME);
 }
 
-enum bt_component_status bt_component_filter_get_output_port_count(
+int64_t bt_component_filter_get_output_port_count(
                struct bt_component *component, uint64_t *count)
 {
-       enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+       int64_t ret;
 
        if (!component || !count ||
                        component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
-               status = BT_COMPONENT_STATUS_INVALID;
+               ret = -1;
                goto end;
        }
 
-       *count = bt_component_get_output_port_count(component);
+       ret = bt_component_get_output_port_count(component);
 end:
-       return status;
+       return ret;
 }
 
 struct bt_port *bt_component_filter_get_output_port(
index e397d354e3d138fe7c5359cb1cb45b9b56c69915..5a7e9e0bf9a7cc34e6b579a6fad30b835957a86a 100644 (file)
@@ -287,35 +287,39 @@ error:
 
 static
 enum bt_component_status get_component_port_counts(
-               struct bt_component *component, uint64_t *input_count,
-               uint64_t *output_count)
+               struct bt_component *component, int64_t *input_count,
+               int64_t *output_count)
 {
        enum bt_component_status ret;
 
        switch (bt_component_get_class_type(component)) {
        case BT_COMPONENT_CLASS_TYPE_SOURCE:
-               ret = bt_component_source_get_output_port_count(component,
-                               output_count);
-               if (ret != BT_COMPONENT_STATUS_OK) {
+               *output_count =
+                       bt_component_source_get_output_port_count(component);
+               if (*output_count < 0) {
+                       ret = BT_COMPONENT_STATUS_ERROR;
                        goto end;
                }
                break;
        case BT_COMPONENT_CLASS_TYPE_FILTER:
-               ret = bt_component_filter_get_output_port_count(component,
-                               output_count);
-               if (ret != BT_COMPONENT_STATUS_OK) {
+               *output_count =
+                       bt_component_filter_get_output_port_count(component);
+               if (*output_count < 0) {
+                       ret = BT_COMPONENT_STATUS_ERROR;
                        goto end;
                }
-               ret = bt_component_filter_get_input_port_count(component,
-                               input_count);
-               if (ret != BT_COMPONENT_STATUS_OK) {
+               *input_count =
+                       bt_component_filter_get_input_port_count(component);
+               if (*input_count < 0) {
+                       ret = BT_COMPONENT_STATUS_ERROR;
                        goto end;
                }
                break;
        case BT_COMPONENT_CLASS_TYPE_SINK:
-               ret = bt_component_sink_get_input_port_count(component,
-                               input_count);
-               if (ret != BT_COMPONENT_STATUS_OK) {
+               *input_count =
+                       bt_component_sink_get_input_port_count(component);
+               if (*input_count < 0) {
+                       ret = BT_COMPONENT_STATUS_ERROR;
                        goto end;
                }
                break;
@@ -332,10 +336,10 @@ enum bt_graph_status bt_graph_add_component_as_sibling(struct bt_graph *graph,
                struct bt_component *origin,
                struct bt_component *new_component)
 {
-       uint64_t origin_input_port_count = 0;
-       uint64_t origin_output_port_count = 0;
-       uint64_t new_input_port_count = 0;
-       uint64_t new_output_port_count = 0;
+       int64_t origin_input_port_count = 0;
+       int64_t origin_output_port_count = 0;
+       int64_t new_input_port_count = 0;
+       int64_t new_output_port_count = 0;
        enum bt_graph_status status = BT_GRAPH_STATUS_OK;
        struct bt_graph *origin_graph = NULL;
        struct bt_graph *new_graph = NULL;
index 49bd840249a8f8434d1295af9424345589e65719..916979adf3a9ba8670585260d7f5c32f071bb039 100644 (file)
@@ -100,20 +100,19 @@ end:
        return ret;
 }
 
-enum bt_component_status bt_component_sink_get_input_port_count(
-               struct bt_component *component, uint64_t *count)
+int64_t bt_component_sink_get_input_port_count(struct bt_component *component)
 {
-       enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+       int64_t ret;
 
-       if (!component || !count ||
+       if (!component ||
                        component->class->type != BT_COMPONENT_CLASS_TYPE_SINK) {
-               status = BT_COMPONENT_STATUS_INVALID;
+               ret = -1;
                goto end;
        }
 
-       *count = bt_component_get_input_port_count(component);
+       ret = bt_component_get_input_port_count(component);
 end:
-       return status;
+       return ret;
 }
 
 struct bt_port *bt_component_sink_get_input_port(
index 0c4f1817c91e7584efda10238a43d6c47c11dad6..7ab4eeae1149afc017ed0a69a01bbbd78a237130 100644 (file)
@@ -79,20 +79,20 @@ end:
        return source ? &source->parent : NULL;
 }
 
-enum bt_component_status bt_component_source_get_output_port_count(
+int64_t bt_component_source_get_output_port_count(
                struct bt_component *component, uint64_t *count)
 {
-       enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+       int64_t ret;
 
        if (!component || !count ||
                        component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
-               status = BT_COMPONENT_STATUS_INVALID;
+               ret = -1;
                goto end;
        }
 
-       *count = bt_component_get_output_port_count(component);
+       ret = bt_component_get_output_port_count(component);
 end:
-       return status;
+       return ret;
 }
 
 struct bt_port *bt_component_source_get_output_port(
index 5f251030fd20b84c304b0aa52e9fd6fe602dba69..a55b9843a3a92fa40f298c5082745c3335b91fba 100644 (file)
@@ -81,9 +81,9 @@ void fini_python_plugin_provider(void) {
 #endif
 
 extern
-int bt_plugin_set_get_plugin_count(struct bt_plugin_set *plugin_set)
+int64_t bt_plugin_set_get_plugin_count(struct bt_plugin_set *plugin_set)
 {
-       int count = -1;
+       int64_t count = -1;
 
        if (!plugin_set) {
                goto end;
@@ -502,7 +502,7 @@ end:
        return status;
 }
 
-int bt_plugin_get_component_class_count(struct bt_plugin *plugin)
+int64_t bt_plugin_get_component_class_count(struct bt_plugin *plugin)
 {
        return plugin ? plugin->comp_classes->len : -1;
 }
index 6d08aaeb80d685ad8942e26d95a276a39eb52d3e..fb62293e8dd6d06ef868b1dcde0c881bf5f9a615 100644 (file)
@@ -812,9 +812,9 @@ end:
        return ret;
 }
 
-int bt_value_array_size(const struct bt_value *array_obj)
+int64_t bt_value_array_size(const struct bt_value *array_obj)
 {
-       int ret;
+       int64_t ret;
        struct bt_value_array *typed_array_obj =
                BT_VALUE_TO_ARRAY(array_obj);
 
@@ -823,7 +823,7 @@ int bt_value_array_size(const struct bt_value *array_obj)
                goto end;
        }
 
-       ret = (int) typed_array_obj->garray->len;
+       ret = (int64_t) typed_array_obj->garray->len;
 
 end:
        return ret;
@@ -981,9 +981,9 @@ end:
        return ret;
 }
 
-int bt_value_map_size(const struct bt_value *map_obj)
+int64_t bt_value_map_size(const struct bt_value *map_obj)
 {
-       int ret;
+       int64_t ret;
        struct bt_value_map *typed_map_obj = BT_VALUE_TO_MAP(map_obj);
 
        if (!map_obj || !bt_value_is_map(map_obj)) {
@@ -991,7 +991,7 @@ int bt_value_map_size(const struct bt_value *map_obj)
                goto end;
        }
 
-       ret = (int) g_hash_table_size(typed_map_obj->ght);
+       ret = (int64_t) g_hash_table_size(typed_map_obj->ght);
 
 end:
        return ret;
index d78884d4fcf42b8665c550245829fdf1f89d2ea4..75b195971ac77049b0e0d5ca9d1f320d39dd3cbd 100644 (file)
@@ -802,8 +802,8 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
                struct muxer_notif_iter *muxer_notif_iter)
 {
        struct bt_component *comp;
-       uint64_t count;
-       uint64_t i;
+       int64_t count;
+       int64_t i;
        int ret = 0;
 
        /*
@@ -813,8 +813,8 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
         */
        comp = bt_component_from_private_component(muxer_comp->priv_comp);
        assert(comp);
-       ret = bt_component_filter_get_input_port_count(comp, &count);
-       if (ret) {
+       count = bt_component_filter_get_input_port_count(comp);
+       if (count < 0) {
                goto end;
        }
 
index 9c369b3986a209dc26c2668ed99dd46207975a4f..4b78966d6dfc5f8f1f2c4d3547909b5d9bdb5a5f 100644 (file)
@@ -983,10 +983,9 @@ void do_std_test(enum test test, const char *name,
        struct bt_port *upstream_port;
        struct bt_port *downstream_port;
        struct bt_graph *graph;
-       size_t i;
-       uint64_t count;
+       int64_t i;
+       int64_t count;
        void *conn;
-       int ret;
        enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
 
        clear_test_events();
@@ -998,8 +997,8 @@ void do_std_test(enum test test, const char *name,
 
        /* Connect source output ports to muxer input ports */
        if (with_upstream) {
-               ret = bt_component_source_get_output_port_count(src_comp, &count);
-               assert(ret == 0);
+               count = bt_component_source_get_output_port_count(src_comp);
+               assert(count >= 0);
 
                for (i = 0; i < count; i++) {
                        upstream_port = bt_component_source_get_output_port_at_index(
@@ -1344,12 +1343,11 @@ void connect_port_to_first_avail_muxer_port(struct bt_graph *graph,
 {
        struct bt_port *avail_muxer_port = NULL;
        void *conn;
-       uint64_t i;
-       uint64_t count;
-       int ret;
+       int64_t i;
+       int64_t count;
 
-       ret = bt_component_filter_get_input_port_count(muxer_comp, &count);
-       assert(ret == 0);
+       count = bt_component_filter_get_input_port_count(muxer_comp);
+       assert(count >= 0);
 
        for (i = 0; i < count; i++) {
                struct bt_port *muxer_port =
@@ -1402,8 +1400,8 @@ void test_single_end_then_multiple_full(void)
        struct bt_port *upstream_port;
        struct bt_port *downstream_port;
        struct bt_graph *graph;
-       size_t i;
-       uint64_t count;
+       int64_t i;
+       int64_t count;
        void *conn;
        int ret;
        enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
@@ -1482,7 +1480,7 @@ void test_single_end_then_multiple_full(void)
        assert(ret == 0);
 
        /* Connect source output ports to muxer input ports */
-       ret = bt_component_source_get_output_port_count(src_comp, &count);
+       count = bt_component_source_get_output_port_count(src_comp);
        assert(ret == 0);
 
        for (i = 0; i < count; i++) {
@@ -1530,8 +1528,8 @@ void test_single_again_end_then_multiple_full(void)
        struct bt_port *upstream_port;
        struct bt_port *downstream_port;
        struct bt_graph *graph;
-       size_t i;
-       uint64_t count;
+       int64_t i;
+       int64_t count;
        void *conn;
        int ret;
        enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
@@ -1611,7 +1609,7 @@ void test_single_again_end_then_multiple_full(void)
        assert(ret == 0);
 
        /* Connect source output ports to muxer input ports */
-       ret = bt_component_source_get_output_port_count(src_comp, &count);
+       count = bt_component_source_get_output_port_count(src_comp);
        assert(ret == 0);
 
        for (i = 0; i < count; i++) {
This page took 0.048695 seconds and 4 git commands to generate.