From 9ac68eb139149d2768848dae5e263cc5a755d439 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 27 Apr 2017 17:27:23 -0400 Subject: [PATCH] Standardize *get_*() functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make all getters that also have a "by name" version have the `_by_index()` suffix. Use uint64_t for all indexes. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- cli/babeltrace.c | 5 +- .../babeltrace/ctf-ir/event-class-internal.h | 2 +- include/babeltrace/ctf-ir/event-class.h | 42 ++++++----- include/babeltrace/ctf-ir/event.h | 13 ++-- include/babeltrace/ctf-ir/field-path.h | 3 +- include/babeltrace/ctf-ir/field-types.h | 24 +++--- include/babeltrace/ctf-ir/fields.h | 7 +- .../babeltrace/ctf-ir/stream-class-internal.h | 10 +-- include/babeltrace/ctf-ir/stream-class.h | 9 ++- include/babeltrace/ctf-ir/trace-internal.h | 2 +- include/babeltrace/ctf-ir/trace.h | 38 +++++----- .../graph/clock-class-priority-map.h | 11 +-- include/babeltrace/graph/component-filter.h | 12 +-- include/babeltrace/graph/component-internal.h | 12 +-- include/babeltrace/graph/component-sink.h | 7 +- include/babeltrace/graph/component-source.h | 6 +- .../graph/private-component-filter.h | 13 ++-- .../babeltrace/graph/private-component-sink.h | 7 +- .../graph/private-component-source.h | 8 +- include/babeltrace/plugin/plugin.h | 6 +- lib/ctf-ir/clock-class.c | 6 +- lib/ctf-ir/event-class.c | 58 ++++++++------ lib/ctf-ir/event.c | 8 +- lib/ctf-ir/field-path.c | 15 +--- lib/ctf-ir/field-types.c | 48 ++++++------ lib/ctf-ir/fields.c | 6 +- lib/ctf-ir/stream-class.c | 48 ++++++------ lib/ctf-ir/stream.c | 4 +- lib/ctf-ir/trace.c | 54 +++++++------ lib/ctf-writer/writer.c | 6 +- lib/graph/clock-class-priority-map.c | 7 +- lib/graph/component.c | 36 ++++----- lib/graph/filter.c | 48 ++++++------ lib/graph/graph.c | 10 +-- lib/graph/notification/event.c | 5 +- lib/graph/sink.c | 20 ++--- lib/graph/source.c | 28 +++---- lib/plugin/plugin.c | 11 +-- lib/values.c | 4 +- .../ctf/common/metadata/visitor-generate-ir.c | 5 +- plugins/ctf/common/notif-iter/notif-iter.c | 4 +- plugins/ctf/fs/fs.c | 4 +- plugins/debug-info/copy.c | 8 +- plugins/libctfcopytrace/clock-fields.c | 6 +- plugins/libctfcopytrace/ctfcopytrace.c | 42 +++++++---- plugins/libctfcopytrace/ctfcopytrace.h | 9 +++ plugins/text/pretty/print.c | 2 +- plugins/utils/muxer/muxer.c | 2 +- plugins/utils/trimmer/iterator.c | 5 +- tests/lib/test_bt_ctf_field_type_validation.c | 4 +- tests/lib/test_ctf_ir_ref.c | 16 ++-- tests/lib/test_ctf_writer.c | 75 ++++++++++--------- tests/lib/test_graph_topo.c | 3 +- tests/lib/test_plugin.c | 4 +- tests/plugins/test-utils-muxer.c | 16 ++-- 55 files changed, 464 insertions(+), 400 deletions(-) diff --git a/cli/babeltrace.c b/cli/babeltrace.c index 1a699909..0ef2491b 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -894,7 +894,7 @@ static int cmd_help(struct bt_config *cfg) for (i = 0; i < bt_plugin_get_component_class_count(plugin); i++) { struct bt_component_class *comp_cls = - bt_plugin_get_component_class(plugin, i); + bt_plugin_get_component_class_by_index(plugin, i); const char *comp_class_name = bt_component_class_get_name(comp_cls); const char *comp_class_description = @@ -1000,7 +1000,8 @@ static int cmd_list_plugins(struct bt_config *cfg) for (j = 0; j < component_classes_count; j++) { struct bt_component_class *comp_class = - bt_plugin_get_component_class(plugin, j); + bt_plugin_get_component_class_by_index( + plugin, j); const char *comp_class_name = bt_component_class_get_name(comp_class); const char *comp_class_description = diff --git a/include/babeltrace/ctf-ir/event-class-internal.h b/include/babeltrace/ctf-ir/event-class-internal.h index c6a39162..e6475fcd 100644 --- a/include/babeltrace/ctf-ir/event-class-internal.h +++ b/include/babeltrace/ctf-ir/event-class-internal.h @@ -76,7 +76,7 @@ void bt_ctf_event_class_set_native_byte_order( BT_HIDDEN int bt_ctf_event_class_set_stream_id(struct bt_ctf_event_class *event_class, - uint32_t stream_id); + uint64_t stream_id); static inline struct bt_ctf_stream_class *bt_ctf_event_class_borrow_stream_class( diff --git a/include/babeltrace/ctf-ir/event-class.h b/include/babeltrace/ctf-ir/event-class.h index 62791967..5052f70f 100644 --- a/include/babeltrace/ctf-ir/event-class.h +++ b/include/babeltrace/ctf-ir/event-class.h @@ -216,13 +216,14 @@ of the stream class to which you eventually add \p event_class. @prenotnull{event_class} @prehot{event_class} +@pre \p id is lesser than or equal to 9223372036854775807 (\c INT64_MAX). @postrefcountsame{event_class} @sa bt_ctf_event_class_get_id(): Returns the numeric ID of a given event class. */ extern int bt_ctf_event_class_set_id( - struct bt_ctf_event_class *event_class, uint32_t id); + struct bt_ctf_event_class *event_class, uint64_t id); /** @brief Returns the number of attributes contained in the CTF IR event @@ -236,10 +237,10 @@ extern int bt_ctf_event_class_set_id( @prenotnull{event_class} @postrefcountsame{event_class} -@sa bt_ctf_event_class_get_attribute_name(): Returns the name of - the attribute of a given event class at a given index. -@sa bt_ctf_event_class_get_attribute_value(): Returns the value of - the attribute of a given event class at a given index. +@sa bt_ctf_event_class_get_attribute_name_by_index(): Returns the name + of the attribute of a given event class at a given index. +@sa bt_ctf_event_class_get_attribute_value_by_index(): Returns the value + of the attribute of a given event class at a given index. */ extern int64_t bt_ctf_event_class_get_attribute_count( struct bt_ctf_event_class *event_class); @@ -261,12 +262,12 @@ string. \p event_class. @postrefcountsame{event_class} -@sa bt_ctf_event_class_get_attribute_value(): Returns the value of - the attribute of a given event class at a given index. +@sa bt_ctf_event_class_get_attribute_value_by_index(): Returns the value + of the attribute of a given event class at a given index. */ extern const char * -bt_ctf_event_class_get_attribute_name( - struct bt_ctf_event_class *event_class, int index); +bt_ctf_event_class_get_attribute_name_by_index( + struct bt_ctf_event_class *event_class, uint64_t index); /** @brief Returns the value of the attribute at the index \p index of the @@ -283,12 +284,12 @@ bt_ctf_event_class_get_attribute_name( @postsuccessrefcountretinc @postrefcountsame{event_class} -@sa bt_ctf_event_class_get_attribute_name(): Returns the name of - the attribute of a given event class at a given index. +@sa bt_ctf_event_class_get_attribute_name_by_index(): Returns the name + of the attribute of a given event class at a given index. */ extern struct bt_value * -bt_ctf_event_class_get_attribute_value(struct bt_ctf_event_class *event_class, - int index); +bt_ctf_event_class_get_attribute_value_by_index( + struct bt_ctf_event_class *event_class, uint64_t index); /** @brief Returns the value of the attribute named \p name of the CTF IR @@ -482,7 +483,7 @@ bt_ctf_field_type_structure_get_field_count(). @prenotnull{event_class} @postrefcountsame{event_class} */ -extern int64_t bt_ctf_event_class_get_field_count( +extern int64_t bt_ctf_event_class_get_payload_type_field_count( struct bt_ctf_event_class *event_class); /** @@ -518,14 +519,15 @@ bt_ctf_field_type_structure_get_field(). @prenotnull{event_class} @pre \p index is lesser than the number of fields contained in the payload field type of \p event_class (see - bt_ctf_event_class_get_field_count()). + bt_ctf_event_class_get_payload_type_field_count()). @postrefcountsame{event_class} @post On success, if \p field_type is not \c NULL, the reference count of \p *field_type is incremented. */ -extern int bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class, +extern int bt_ctf_event_class_get_payload_type_field_by_index( + struct bt_ctf_event_class *event_class, const char **field_name, struct bt_ctf_field_type **field_type, - int index); + uint64_t index); /** @brief Returns the type of the field named \p name in the payload @@ -550,9 +552,13 @@ bt_ctf_field_type_structure_get_field_type_by_name(). @postrefcountsame{event_class} @postsuccessrefcountretinc */ -extern struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name( +extern struct bt_ctf_field_type * +bt_ctf_event_class_get_payload_type_field_type_by_name( struct bt_ctf_event_class *event_class, const char *name); +/* Pre-2.0 CTF writer compatibility */ +#define bt_ctf_event_class_get_field_by_name bt_ctf_event_class_get_payload_type_field_type_by_name + /** @brief Adds a field named \p name with the type \p field_type to the payload field type of the CTF IR event class \p event_class. diff --git a/include/babeltrace/ctf-ir/event.h b/include/babeltrace/ctf-ir/event.h index 42d39269..d42cc91d 100644 --- a/include/babeltrace/ctf-ir/event.h +++ b/include/babeltrace/ctf-ir/event.h @@ -140,7 +140,7 @@ struct bt_ctf_packet; On success, the four fields of the created event object are not set. You can set them with bt_ctf_event_set_header(), bt_ctf_event_set_stream_event_context(), -bt_ctf_event_set_event_context(), and bt_ctf_event_set_payload_field(). +bt_ctf_event_set_event_context(), and bt_ctf_event_set_event_payload(). This function tries to resolve the needed \link ctfirfieldtypes CTF IR field type\endlink of the dynamic field @@ -411,10 +411,10 @@ extern int bt_ctf_event_set_event_context(struct bt_ctf_event *event, @postrefcountsame{event} @postsuccessrefcountretinc -@sa bt_ctf_event_set_payload_field(): Sets the payload field of a given +@sa bt_ctf_event_set_event_payload(): Sets the payload field of a given event. */ -extern struct bt_ctf_field *bt_ctf_event_get_payload_field( +extern struct bt_ctf_field *bt_ctf_event_get_event_payload( struct bt_ctf_event *event); /** @@ -440,7 +440,7 @@ bt_ctf_event_class_get_payload_type() for the parent class of \p event. @sa bt_ctf_event_get_payload(): Returns the payload field of a given event. */ -extern int bt_ctf_event_set_payload_field(struct bt_ctf_event *event, +extern int bt_ctf_event_set_event_payload(struct bt_ctf_event *event, struct bt_ctf_field *payload); /** @cond DOCUMENT */ @@ -482,7 +482,7 @@ extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, * Note: Will return an error if the payload's type is not a structure. */ extern struct bt_ctf_field *bt_ctf_event_get_payload_by_index( - struct bt_ctf_event *event, int index); + struct bt_ctf_event *event, uint64_t index); /* * TODO: Doxygenize. @@ -536,7 +536,8 @@ extern int bt_ctf_event_set_payload(struct bt_ctf_event *event, @sa bt_ctf_event_set_clock_value(): Sets the clock value of a given event. */ extern struct bt_ctf_clock_value *bt_ctf_event_get_clock_value( - struct bt_ctf_event *event, struct bt_ctf_clock_class *clock_class); + struct bt_ctf_event *event, + struct bt_ctf_clock_class *clock_class); /** @brief Sets the value, as of the CTF IR event \p event, of the diff --git a/include/babeltrace/ctf-ir/field-path.h b/include/babeltrace/ctf-ir/field-path.h index e53b50f1..cb2466aa 100644 --- a/include/babeltrace/ctf-ir/field-path.h +++ b/include/babeltrace/ctf-ir/field-path.h @@ -130,8 +130,7 @@ extern int64_t bt_ctf_field_path_get_index_count( @postrefcountsame{field_path} */ extern int bt_ctf_field_path_get_index( - const struct bt_ctf_field_path *field_path, - int index); + const struct bt_ctf_field_path *field_path, uint64_t index); /** @} */ diff --git a/include/babeltrace/ctf-ir/field-types.h b/include/babeltrace/ctf-ir/field-types.h index 3e35a8d0..6391f154 100644 --- a/include/babeltrace/ctf-ir/field-types.h +++ b/include/babeltrace/ctf-ir/field-types.h @@ -1378,7 +1378,7 @@ On success, \p enum_field_type remains the sole owner of \p *name. at a given index. */ extern int bt_ctf_field_type_enumeration_get_mapping_signed( - struct bt_ctf_field_type *enum_field_type, int index, + struct bt_ctf_field_type *enum_field_type, uint64_t index, const char **name, int64_t *range_begin, int64_t *range_end); /** @@ -1420,7 +1420,7 @@ On success, \p enum_field_type remains the sole owner of \p *name. at a given index. */ extern int bt_ctf_field_type_enumeration_get_mapping_unsigned( - struct bt_ctf_field_type *enum_field_type, int index, + struct bt_ctf_field_type *enum_field_type, uint64_t index, const char **name, uint64_t *range_begin, uint64_t *range_end); @@ -1955,10 +1955,13 @@ On success, the field's type is placed in \p *field_type if @sa bt_ctf_field_type_structure_get_field_type_by_name(): Finds a structure field type's field by name. */ -extern int bt_ctf_field_type_structure_get_field( +extern int bt_ctf_field_type_structure_get_field_by_index( struct bt_ctf_field_type *struct_field_type, const char **field_name, struct bt_ctf_field_type **field_type, - int index); + uint64_t index); + +/* Pre-2.0 CTF writer compatibility */ +#define bt_ctf_field_type_structure_get_field bt_ctf_field_type_structure_get_field_by_index /** @brief Returns the type of the field named \p field_name found in @@ -1977,7 +1980,7 @@ extern int bt_ctf_field_type_structure_get_field( @postrefcountsame{struct_field_type} @postsuccessrefcountretinc -@sa bt_ctf_field_type_structure_get_field(): Finds a +@sa bt_ctf_field_type_structure_get_field_by_index(): Finds a structure field type's field by index. */ extern @@ -2436,10 +2439,13 @@ On success, the field's type is placed in \p *field_type if @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant field type's field by current tag value. */ -extern int bt_ctf_field_type_variant_get_field( +extern int bt_ctf_field_type_variant_get_field_by_index( struct bt_ctf_field_type *variant_field_type, const char **field_name, - struct bt_ctf_field_type **field_type, int index); + struct bt_ctf_field_type **field_type, uint64_t index); + +/* Pre-2.0 CTF writer compatibility */ +#define bt_ctf_field_type_variant_get_field bt_ctf_field_type_variant_get_field_by_index /** @brief Returns the type of the field (choice) named \p field_name @@ -2458,7 +2464,7 @@ extern int bt_ctf_field_type_variant_get_field( @postrefcountsame{variant_field_type} @postsuccessrefcountretinc -@sa bt_ctf_field_type_variant_get_field(): Finds a variant field type's +@sa bt_ctf_field_type_variant_get_field_by_index(): Finds a variant field type's field by index. @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant field type's field by current tag value. @@ -2494,7 +2500,7 @@ bt_ctf_field_type_variant_get_tag_type() for \p variant_field_type. @postrefcountsame{tag_field} @postsuccessrefcountretinc -@sa bt_ctf_field_type_variant_get_field(): Finds a variant field type's +@sa bt_ctf_field_type_variant_get_field_by_index(): Finds a variant field type's field by index. @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant field type's field by name. diff --git a/include/babeltrace/ctf-ir/fields.h b/include/babeltrace/ctf-ir/fields.h index abdc3dd1..5a030b35 100644 --- a/include/babeltrace/ctf-ir/fields.h +++ b/include/babeltrace/ctf-ir/fields.h @@ -863,9 +863,12 @@ exist. @sa bt_ctf_field_structure_set_field(): Sets the field of a given structure field. */ -extern struct bt_ctf_field *bt_ctf_field_structure_get_field( +extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name( struct bt_ctf_field *struct_field, const char *name); +/* Pre-2.0 CTF writer compatibility */ +#define bt_ctf_field_structure_get_field bt_ctf_field_structure_get_field_by_name + /** @brief Returns the @field at index \p index in the @structfield \p struct_field. @@ -890,7 +893,7 @@ extern struct bt_ctf_field *bt_ctf_field_structure_get_field( structure field. */ extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index( - struct bt_ctf_field *struct_field, int index); + struct bt_ctf_field *struct_field, uint64_t index); /** @brief Sets the field of the @structfield \p struct_field named \p name diff --git a/include/babeltrace/ctf-ir/stream-class-internal.h b/include/babeltrace/ctf-ir/stream-class-internal.h index b8366aaa..0dc33b13 100644 --- a/include/babeltrace/ctf-ir/stream-class-internal.h +++ b/include/babeltrace/ctf-ir/stream-class-internal.h @@ -45,9 +45,9 @@ struct bt_ctf_stream_class { /* event class id (int64_t) to event class */ GHashTable *event_classes_ht; int id_set; - uint32_t id; - uint32_t next_event_id; - uint32_t next_stream_id; + int64_t id; + int64_t next_event_id; + int64_t next_stream_id; struct bt_ctf_field_type *packet_context_type; struct bt_ctf_field_type *event_header_type; struct bt_ctf_field_type *event_context_type; @@ -75,11 +75,11 @@ void bt_ctf_stream_class_set_byte_order( /* Set stream_class id without checking if the stream class is frozen */ BT_HIDDEN int _bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class, - uint32_t id); + int64_t id); BT_HIDDEN int bt_ctf_stream_class_set_id_no_check( - struct bt_ctf_stream_class *stream_class, uint32_t id); + struct bt_ctf_stream_class *stream_class, int64_t id); static inline struct bt_ctf_trace *bt_ctf_stream_class_borrow_trace( diff --git a/include/babeltrace/ctf-ir/stream-class.h b/include/babeltrace/ctf-ir/stream-class.h index dc7b35d6..6a0e2e13 100644 --- a/include/babeltrace/ctf-ir/stream-class.h +++ b/include/babeltrace/ctf-ir/stream-class.h @@ -274,13 +274,14 @@ of the trace class to which you eventually add \p stream_class. @prenotnull{stream_class} @prehot{stream_class} +@pre \p id is lesser than or equal to 9223372036854775807 (\c INT64_MAX). @postrefcountsame{stream_class} @sa bt_ctf_stream_class_get_id(): Returns the numeric ID of a given stream class. */ extern int bt_ctf_stream_class_set_id( - struct bt_ctf_stream_class *stream_class, uint32_t id); + struct bt_ctf_stream_class *stream_class, uint64_t id); /** @} */ @@ -498,8 +499,8 @@ extern int64_t bt_ctf_stream_class_get_event_class_count( @sa bt_ctf_stream_class_get_event_class_by_name(): Finds an event class by name. */ -extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class( - struct bt_ctf_stream_class *stream_class, int index); +extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index( + struct bt_ctf_stream_class *stream_class, uint64_t index); /** @brief Returns the event class named \c name found in the CTF IR stream @@ -538,7 +539,7 @@ extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name( by name. */ extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id( - struct bt_ctf_stream_class *stream_class, uint32_t id); + struct bt_ctf_stream_class *stream_class, uint64_t id); /** @brief Adds the CTF IR event class \p event_class to the diff --git a/include/babeltrace/ctf-ir/trace-internal.h b/include/babeltrace/ctf-ir/trace-internal.h index 8b6c1f5a..c3121cbd 100644 --- a/include/babeltrace/ctf-ir/trace-internal.h +++ b/include/babeltrace/ctf-ir/trace-internal.h @@ -58,7 +58,7 @@ struct bt_ctf_trace { GPtrArray *stream_classes; /* Array of ptrs to bt_ctf_stream_class */ GPtrArray *streams; /* Array of ptrs to bt_ctf_stream */ struct bt_ctf_field_type *packet_header_type; - uint64_t next_stream_id; + int64_t next_stream_id; int is_created_by_writer; /* diff --git a/include/babeltrace/ctf-ir/trace.h b/include/babeltrace/ctf-ir/trace.h index 16cec454..4286df93 100644 --- a/include/babeltrace/ctf-ir/trace.h +++ b/include/babeltrace/ctf-ir/trace.h @@ -78,7 +78,7 @@ trace class with bt_ctf_trace_add_stream_class(). You can access the streams of a trace, that is, the streams which were created from the trace's stream classes with bt_ctf_stream_create(), -with bt_ctf_trace_get_stream(). +with bt_ctf_trace_get_stream_by_index(). A trace class owns the trace packet header \link ctfirfieldtypes field type\endlink, which represents the @@ -315,7 +315,7 @@ the returned string. \p trace_class (see bt_ctf_trace_get_environment_field_count()). @postrefcountsame{trace_class} -@sa bt_ctf_trace_get_environment_field_value(): Finds a trace class's +@sa bt_ctf_trace_get_environment_field_value_by_index(): Finds a trace class's environment entry by index. @sa bt_ctf_trace_get_environment_field_value_by_name(): Finds a trace class's environment entry by name. @@ -323,8 +323,8 @@ the returned string. class's environment entry. */ extern const char * -bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace_class, - int index); +bt_ctf_trace_get_environment_field_name_by_index( + struct bt_ctf_trace *trace_class, uint64_t index); /** @brief Returns the value of the environment entry at index @@ -348,8 +348,8 @@ bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace_class, class's environment entry. */ extern struct bt_value * -bt_ctf_trace_get_environment_field_value(struct bt_ctf_trace *trace_class, - int index); +bt_ctf_trace_get_environment_field_value_by_index(struct bt_ctf_trace *trace_class, + uint64_t index); /** @brief Returns the value of the environment entry named \p name @@ -367,7 +367,7 @@ bt_ctf_trace_get_environment_field_value(struct bt_ctf_trace *trace_class, @postrefcountsame{trace_class} @postsuccessrefcountretinc -@sa bt_ctf_trace_get_environment_field_value(): Finds a trace class's +@sa bt_ctf_trace_get_environment_field_value_by_index(): Finds a trace class's environment entry by index. @sa bt_ctf_trace_set_environment_field(): Sets the value of a trace class's environment entry. @@ -401,7 +401,7 @@ value is first put, and then replaced by \p value. @postrefcountsame{trace_class} @postsuccessrefcountinc{value} -@sa bt_ctf_trace_get_environment_field_value(): Finds a trace class's +@sa bt_ctf_trace_get_environment_field_value_by_index(): Finds a trace class's environment entry by index. @sa bt_ctf_trace_get_environment_field_value_by_name(): Finds a trace class's environment entry by name. @@ -573,8 +573,8 @@ extern int64_t bt_ctf_trace_get_clock_class_count( in a given trace class. @sa bt_ctf_trace_add_clock_class(): Adds a clock class to a trace class. */ -extern struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class( - struct bt_ctf_trace *trace_class, int index); +extern struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index( + struct bt_ctf_trace *trace_class, uint64_t index); /** @brief Returns the CTF IR clock class named \c name found in the CTF @@ -591,7 +591,7 @@ extern struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class( @postrefcountsame{trace_class} @postsuccessrefcountretinc -@sa bt_ctf_trace_get_clock_class(): Returns the clock class contained +@sa bt_ctf_trace_get_clock_class_by_index(): Returns the clock class contained in a given trace class at a given index. @sa bt_ctf_trace_add_clock_class(): Adds a clock class to a trace class. */ @@ -618,7 +618,7 @@ are frozen. @post On success, if \p trace_class is frozen, \p clock_class is frozen. -@sa bt_ctf_trace_get_clock_class(): Returns the clock class contained +@sa bt_ctf_trace_get_clock_class_by_index(): Returns the clock class contained in a given trace class at a given index. @sa bt_ctf_trace_get_clock_class_by_name(): Finds a clock class by name in a given trace class. @@ -667,8 +667,8 @@ extern int64_t bt_ctf_trace_get_stream_class_count( @sa bt_ctf_trace_get_stream_class_by_id(): Finds a stream class by ID. @sa bt_ctf_trace_add_stream_class(): Adds a stream class to a trace class. */ -extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class( - struct bt_ctf_trace *trace_class, int index); +extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index( + struct bt_ctf_trace *trace_class, uint64_t index); /** @brief Returns the stream class with ID \c id found in the CTF IR @@ -683,12 +683,12 @@ extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class( @postrefcountsame{trace_class} @postsuccessrefcountretinc -@sa bt_ctf_trace_get_stream_class(): Returns the stream class contained +@sa bt_ctf_trace_get_stream_class_by_index(): Returns the stream class contained in a given trace class at a given index. @sa bt_ctf_trace_add_stream_class(): Adds a stream class to a trace class. */ extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id( - struct bt_ctf_trace *trace_class, uint32_t id); + struct bt_ctf_trace *trace_class, uint64_t id); /** @brief Adds the CTF IR stream class \p stream_class to the @@ -717,7 +717,7 @@ resolving fails, then this function fails. @postsuccessrefcountinc{stream_class} @postsuccessfrozen{stream_class} -@sa bt_ctf_trace_get_stream_class(): Returns the stream class contained +@sa bt_ctf_trace_get_stream_class_by_index(): Returns the stream class contained in a given trace class at a given index. @sa bt_ctf_trace_get_stream_class_by_id(): Finds a stream class by ID. */ @@ -761,8 +761,8 @@ extern int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace_class); bt_ctf_trace_get_stream_count()). @postrefcountsame{trace_class} */ -extern struct bt_ctf_stream *bt_ctf_trace_get_stream( - struct bt_ctf_trace *trace_class, int index); +extern struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index( + struct bt_ctf_trace *trace_class, uint64_t index); /** @} */ diff --git a/include/babeltrace/graph/clock-class-priority-map.h b/include/babeltrace/graph/clock-class-priority-map.h index f810a443..bda9eb3b 100644 --- a/include/babeltrace/graph/clock-class-priority-map.h +++ b/include/babeltrace/graph/clock-class-priority-map.h @@ -139,9 +139,10 @@ extern int64_t bt_clock_class_priority_map_get_clock_class_count( @sa bt_clock_class_priority_map_add_clock_class(): Adds a clock class to a clock class priority map. */ -extern struct bt_ctf_clock_class *bt_clock_class_priority_map_get_clock_class( +extern struct bt_ctf_clock_class * +bt_clock_class_priority_map_get_clock_class_by_index( struct bt_clock_class_priority_map *clock_class_priority_map, - unsigned int index); + uint64_t index); /** @brief Returns the CTF IR clock class named \c name found in the clock @@ -161,7 +162,7 @@ extern struct bt_ctf_clock_class *bt_clock_class_priority_map_get_clock_class( @postrefcountsame{clock_class_priority_map} @postsuccessrefcountretinc -@sa bt_clock_class_priority_map_get_clock_class(): Returns the clock +@sa bt_clock_class_priority_map_get_clock_class_by_index(): Returns the clock class contained in a given clock class priority map at a given index. @sa bt_clock_class_priority_map_get_highest_priority_clock_class(): @@ -198,7 +199,7 @@ this function returns. @postrefcountsame{clock_class_priority_map} @postsuccessrefcountretinc -@sa bt_clock_class_priority_map_get_clock_class(): Returns the clock +@sa bt_clock_class_priority_map_get_clock_class_by_index(): Returns the clock class contained in a given clock class priority map at a given index. @sa bt_clock_class_priority_map_get_clock_class_by_name(): Finds a @@ -270,7 +271,7 @@ map. @postrefcountsame{clock_class_priority_map} @postsuccessrefcountinc{clock_class} -@sa bt_clock_class_priority_map_get_clock_class(): Returns the clock +@sa bt_clock_class_priority_map_get_clock_class_by_index(): Returns the clock class contained in a given clock class priority map at a given index. @sa bt_clock_class_priority_map_get_clock_class_by_name(): Finds a diff --git a/include/babeltrace/graph/component-filter.h b/include/babeltrace/graph/component-filter.h index 557432d8..43da9db0 100644 --- a/include/babeltrace/graph/component-filter.h +++ b/include/babeltrace/graph/component-filter.h @@ -39,19 +39,19 @@ struct bt_component; extern int64_t bt_component_filter_get_input_port_count( struct bt_component *component); -extern struct bt_port *bt_component_filter_get_input_port( +extern struct bt_port *bt_component_filter_get_input_port_by_name( struct bt_component *component, const char *name); -extern struct bt_port *bt_component_filter_get_input_port_at_index( - struct bt_component *component, int index); +extern struct bt_port *bt_component_filter_get_input_port_by_index( + struct bt_component *component, uint64_t index); extern struct bt_port *bt_component_filter_get_default_input_port( struct bt_component *component); extern int64_t bt_component_filter_get_output_port_count( struct bt_component *component); -extern struct bt_port *bt_component_filter_get_output_port( +extern struct bt_port *bt_component_filter_get_output_port_by_name( struct bt_component *component, const char *name); -extern struct bt_port *bt_component_filter_get_output_port_at_index( - struct bt_component *component, int index); +extern struct bt_port *bt_component_filter_get_output_port_by_index( + struct bt_component *component, uint64_t index); extern struct bt_port *bt_component_filter_get_default_output_port( struct bt_component *component); diff --git a/include/babeltrace/graph/component-internal.h b/include/babeltrace/graph/component-internal.h index ae08b8b7..f6ed6ac7 100644 --- a/include/babeltrace/graph/component-internal.h +++ b/include/babeltrace/graph/component-internal.h @@ -112,19 +112,19 @@ BT_HIDDEN 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, - int index); +struct bt_port *bt_component_get_input_port_by_index(struct bt_component *comp, + uint64_t index); BT_HIDDEN -struct bt_port *bt_component_get_output_port_at_index(struct bt_component *comp, - int index); +struct bt_port *bt_component_get_output_port_by_index(struct bt_component *comp, + uint64_t index); BT_HIDDEN -struct bt_port *bt_component_get_input_port(struct bt_component *comp, +struct bt_port *bt_component_get_input_port_by_name(struct bt_component *comp, const char *name); BT_HIDDEN -struct bt_port *bt_component_get_output_port(struct bt_component *comp, +struct bt_port *bt_component_get_output_port_by_name(struct bt_component *comp, const char *name); BT_HIDDEN diff --git a/include/babeltrace/graph/component-sink.h b/include/babeltrace/graph/component-sink.h index 3c462bff..96a935c5 100644 --- a/include/babeltrace/graph/component-sink.h +++ b/include/babeltrace/graph/component-sink.h @@ -27,6 +27,7 @@ * SOFTWARE. */ +#include #include #ifdef __cplusplus @@ -38,10 +39,10 @@ struct bt_notification; extern int64_t bt_component_sink_get_input_port_count( struct bt_component *component); -extern struct bt_port *bt_component_sink_get_input_port( +extern struct bt_port *bt_component_sink_get_input_port_by_name( struct bt_component *component, const char *name); -extern struct bt_port *bt_component_sink_get_input_port_at_index( - struct bt_component *component, int index); +extern struct bt_port *bt_component_sink_get_input_port_by_index( + struct bt_component *component, uint64_t index); extern struct bt_port *bt_component_sink_get_default_input_port( struct bt_component *component); diff --git a/include/babeltrace/graph/component-source.h b/include/babeltrace/graph/component-source.h index 24a8c006..75cf0213 100644 --- a/include/babeltrace/graph/component-source.h +++ b/include/babeltrace/graph/component-source.h @@ -39,10 +39,10 @@ struct bt_notification_iterator; extern int64_t bt_component_source_get_output_port_count( struct bt_component *component); -extern struct bt_port *bt_component_source_get_output_port( +extern struct bt_port *bt_component_source_get_output_port_by_name( struct bt_component *component, const char *name); -extern struct bt_port *bt_component_source_get_output_port_at_index( - struct bt_component *component, int index); +extern struct bt_port *bt_component_source_get_output_port_by_index( + struct bt_component *component, uint64_t index); extern struct bt_port *bt_component_source_get_default_output_port( struct bt_component *component); diff --git a/include/babeltrace/graph/private-component-filter.h b/include/babeltrace/graph/private-component-filter.h index 4c52d0f4..51944afd 100644 --- a/include/babeltrace/graph/private-component-filter.h +++ b/include/babeltrace/graph/private-component-filter.h @@ -23,6 +23,7 @@ * SOFTWARE. */ +#include #include #ifdef __cplusplus @@ -33,13 +34,13 @@ struct bt_private_component; struct bt_private_port; extern struct bt_private_port * -bt_private_component_filter_get_output_private_port( +bt_private_component_filter_get_output_private_port_by_name( struct bt_private_component *private_component, const char *name); extern struct bt_private_port * -bt_private_component_filter_get_output_private_port_at_index( - struct bt_private_component *private_component, int index); +bt_private_component_filter_get_output_private_port_by_index( + struct bt_private_component *private_component, uint64_t index); extern struct bt_private_port * bt_private_component_filter_get_default_output_private_port( @@ -51,13 +52,13 @@ bt_private_component_filter_add_output_private_port( const char *name); extern struct bt_private_port * -bt_private_component_filter_get_input_private_port( +bt_private_component_filter_get_input_private_port_by_name( struct bt_private_component *private_component, const char *name); extern struct bt_private_port * -bt_private_component_filter_get_input_private_port_at_index( - struct bt_private_component *private_component, int index); +bt_private_component_filter_get_input_private_port_by_index( + struct bt_private_component *private_component, uint64_t index); extern struct bt_private_port * bt_private_component_filter_get_default_input_private_port( diff --git a/include/babeltrace/graph/private-component-sink.h b/include/babeltrace/graph/private-component-sink.h index 52178aeb..db3e71f1 100644 --- a/include/babeltrace/graph/private-component-sink.h +++ b/include/babeltrace/graph/private-component-sink.h @@ -23,6 +23,7 @@ * SOFTWARE. */ +#include #include #ifdef __cplusplus @@ -33,13 +34,13 @@ struct bt_private_component; struct bt_private_port; extern struct bt_private_port * -bt_private_component_sink_get_input_private_port( +bt_private_component_sink_get_input_private_port_by_name( struct bt_private_component *private_component, const char *name); extern struct bt_private_port * -bt_private_component_sink_get_input_private_port_at_index( - struct bt_private_component *private_component, int index); +bt_private_component_sink_get_input_private_port_by_index( + struct bt_private_component *private_component, uint64_t index); extern struct bt_private_port * bt_private_component_sink_get_default_input_private_port( diff --git a/include/babeltrace/graph/private-component-source.h b/include/babeltrace/graph/private-component-source.h index d74df865..257e6485 100644 --- a/include/babeltrace/graph/private-component-source.h +++ b/include/babeltrace/graph/private-component-source.h @@ -23,6 +23,7 @@ * SOFTWARE. */ +#include #include #ifdef __cplusplus @@ -33,13 +34,14 @@ struct bt_private_component; struct bt_private_port; extern struct bt_private_port * -bt_private_component_source_get_output_private_port( +bt_private_component_source_get_output_private_port_by_name( struct bt_private_component *private_component, const char *name); extern struct bt_private_port * -bt_private_component_source_get_output_private_port_at_index( - struct bt_private_component *private_component, int index); +bt_private_component_source_get_output_private_port_by_index( + struct bt_private_component *private_component, + uint64_t index); extern struct bt_private_port * bt_private_component_source_get_default_output_private_port( diff --git a/include/babeltrace/plugin/plugin.h b/include/babeltrace/plugin/plugin.h index 64192b3d..1738c27d 100644 --- a/include/babeltrace/plugin/plugin.h +++ b/include/babeltrace/plugin/plugin.h @@ -112,8 +112,8 @@ extern enum bt_plugin_status bt_plugin_get_version(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); +extern struct bt_component_class *bt_plugin_get_component_class_by_index( + struct bt_plugin *plugin, uint64_t index); extern struct bt_component_class *bt_plugin_get_component_class_by_name_and_type( @@ -125,7 +125,7 @@ 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, - unsigned int index); + uint64_t index); #ifdef __cplusplus } diff --git a/lib/ctf-ir/clock-class.c b/lib/ctf-ir/clock-class.c index 9760d731..96fd2c33 100644 --- a/lib/ctf-ir/clock-class.c +++ b/lib/ctf-ir/clock-class.c @@ -171,7 +171,7 @@ int bt_ctf_clock_class_set_frequency(struct bt_ctf_clock_class *clock_class, { int ret = 0; - if (!clock_class || clock_class->frozen) { + if (!clock_class || clock_class->frozen || freq == -1ULL) { ret = -1; goto end; } @@ -199,7 +199,7 @@ int bt_ctf_clock_class_set_precision(struct bt_ctf_clock_class *clock_class, { int ret = 0; - if (!clock_class || clock_class->frozen) { + if (!clock_class || clock_class->frozen || precision == -1ULL) { ret = -1; goto end; } @@ -467,7 +467,7 @@ int bt_ctf_clock_value_get_value_ns_from_epoch(struct bt_ctf_clock_value *value, } /* Initialize nanosecond timestamp to clock's offset in seconds. */ - ns = value->clock_class->offset_s * 1000000000; + ns = value->clock_class->offset_s * (int64_t) 1000000000; /* Add offset in cycles, converted to nanoseconds. */ ns += ns_from_value(value->clock_class->frequency, diff --git a/lib/ctf-ir/event-class.c b/lib/ctf-ir/event-class.c index c50e39bf..e37331f0 100644 --- a/lib/ctf-ir/event-class.c +++ b/lib/ctf-ir/event-class.c @@ -140,12 +140,12 @@ int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class) int64_t ret = 0; if (!event_class) { - ret = -1; + ret = (int64_t) -1; goto end; } if (event_class->id >= 0) { - ret = event_class->id; + ret = (int64_t) event_class->id; goto end; } @@ -156,12 +156,12 @@ int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class) } if (bt_value_integer_get(obj, &ret)) { - ret = -1; + ret = (int64_t) -1; } if (ret < 0) { /* means ID is not set */ - ret = -1; + ret = (int64_t) -1; goto end; } @@ -171,14 +171,14 @@ end: } int bt_ctf_event_class_set_id(struct bt_ctf_event_class *event_class, - uint32_t id) + uint64_t id_param) { int ret = 0; struct bt_value *obj = NULL; struct bt_ctf_stream_class *stream_class = NULL; + int64_t id = (int64_t) id_param; - - if (!event_class) { + if (!event_class || id < 0) { ret = -1; goto end; } @@ -265,10 +265,10 @@ end: int64_t bt_ctf_event_class_get_attribute_count( struct bt_ctf_event_class *event_class) { - int64_t ret = 0; + int64_t ret; if (!event_class) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -279,8 +279,8 @@ end: } const char * -bt_ctf_event_class_get_attribute_name( - struct bt_ctf_event_class *event_class, int index) +bt_ctf_event_class_get_attribute_name_by_index( + struct bt_ctf_event_class *event_class, uint64_t index) { const char *ret; @@ -296,8 +296,8 @@ end: } struct bt_value * -bt_ctf_event_class_get_attribute_value(struct bt_ctf_event_class *event_class, - int index) +bt_ctf_event_class_get_attribute_value_by_index( + struct bt_ctf_event_class *event_class, uint64_t index) { struct bt_value *ret; @@ -400,19 +400,19 @@ end: return ret; } -int64_t bt_ctf_event_class_get_field_count( +int64_t bt_ctf_event_class_get_payload_type_field_count( struct bt_ctf_event_class *event_class) { int64_t ret; if (!event_class) { - ret = -1; + ret = (int64_t) -1; goto end; } if (bt_ctf_field_type_get_type_id(event_class->fields) != BT_CTF_FIELD_TYPE_ID_STRUCT) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -421,13 +421,14 @@ end: return ret; } -int bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class, +int bt_ctf_event_class_get_payload_type_field_by_index( + struct bt_ctf_event_class *event_class, const char **field_name, struct bt_ctf_field_type **field_type, - int index) + uint64_t index) { int ret; - if (!event_class || index < 0) { + if (!event_class) { ret = -1; goto end; } @@ -444,7 +445,8 @@ end: return ret; } -struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name( +struct bt_ctf_field_type * +bt_ctf_event_class_get_payload_type_field_type_by_name( struct bt_ctf_event_class *event_class, const char *name) { GQuark name_quark; @@ -525,10 +527,18 @@ void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class) BT_HIDDEN int bt_ctf_event_class_set_stream_id(struct bt_ctf_event_class *event_class, - uint32_t stream_id) + uint64_t stream_id_param) { int ret = 0; - struct bt_value *obj; + struct bt_value *obj = NULL; + int64_t stream_id = (int64_t) stream_id_param; + + assert(event_class); + + if (stream_id < 0) { + ret = -1; + goto end; + } obj = bt_value_integer_create_init(stream_id); @@ -598,9 +608,9 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class, for (i = 0; i < count; ++i) { const char *attr_name = NULL; - attr_name = bt_ctf_event_class_get_attribute_name( + attr_name = bt_ctf_event_class_get_attribute_name_by_index( event_class, i); - attr_value = bt_ctf_event_class_get_attribute_value( + attr_value = bt_ctf_event_class_get_attribute_value_by_index( event_class, i); if (!attr_name || !attr_value) { diff --git a/lib/ctf-ir/event.c b/lib/ctf-ir/event.c index ff153559..a92c4301 100644 --- a/lib/ctf-ir/event.c +++ b/lib/ctf-ir/event.c @@ -316,7 +316,7 @@ end: return ret; } -struct bt_ctf_field *bt_ctf_event_get_payload_field(struct bt_ctf_event *event) +struct bt_ctf_field *bt_ctf_event_get_event_payload(struct bt_ctf_event *event) { struct bt_ctf_field *payload = NULL; @@ -330,7 +330,7 @@ end: return payload; } -int bt_ctf_event_set_payload_field(struct bt_ctf_event *event, +int bt_ctf_event_set_event_payload(struct bt_ctf_event *event, struct bt_ctf_field *payload) { int ret = 0; @@ -381,11 +381,11 @@ end: } struct bt_ctf_field *bt_ctf_event_get_payload_by_index( - struct bt_ctf_event *event, int index) + struct bt_ctf_event *event, uint64_t index) { struct bt_ctf_field *field = NULL; - if (!event || index < 0) { + if (!event) { goto end; } diff --git a/lib/ctf-ir/field-path.c b/lib/ctf-ir/field-path.c index a3d42352..bc991f40 100644 --- a/lib/ctf-ir/field-path.c +++ b/lib/ctf-ir/field-path.c @@ -115,24 +115,15 @@ end: int64_t bt_ctf_field_path_get_index_count( const struct bt_ctf_field_path *field_path) { - int64_t ret = -1; - - if (!field_path) { - goto end; - } - - ret = field_path->indexes->len; - -end: - return ret; + return field_path ? (int64_t) field_path->indexes->len : (int64_t) -1; } int bt_ctf_field_path_get_index(const struct bt_ctf_field_path *field_path, - int index) + uint64_t index) { int ret = INT_MIN; - if (!field_path || index < 0) { + if (!field_path) { goto end; } diff --git a/lib/ctf-ir/field-types.c b/lib/ctf-ir/field-types.c index 442aff0e..2c334183 100644 --- a/lib/ctf-ir/field-types.c +++ b/lib/ctf-ir/field-types.c @@ -599,7 +599,7 @@ int bt_ctf_field_type_structure_validate(struct bt_ctf_field_type *type) } for (i = 0; i < field_count; ++i) { - ret = bt_ctf_field_type_structure_get_field(type, + ret = bt_ctf_field_type_structure_get_field_by_index(type, NULL, &child_type, i); if (ret) { goto end; @@ -720,7 +720,7 @@ int bt_ctf_field_type_variant_validate(struct bt_ctf_field_type *type) } for (i = 0; i < field_count; ++i) { - ret = bt_ctf_field_type_variant_get_field(type, + ret = bt_ctf_field_type_variant_get_field_by_index(type, NULL, &child_type, i); if (ret) { goto end; @@ -1201,14 +1201,13 @@ end: int bt_ctf_field_type_enumeration_get_mapping_signed( struct bt_ctf_field_type *enum_field_type, - int index, - const char **mapping_name, int64_t *range_begin, + uint64_t index, const char **mapping_name, int64_t *range_begin, int64_t *range_end) { int ret = 0; struct enumeration_mapping *mapping; - if (!enum_field_type || index < 0) { + if (!enum_field_type) { ret = -1; goto end; } @@ -1236,14 +1235,14 @@ end: int bt_ctf_field_type_enumeration_get_mapping_unsigned( struct bt_ctf_field_type *enum_field_type, - int index, + uint64_t index, const char **mapping_name, uint64_t *range_begin, uint64_t *range_end) { int ret = 0; struct enumeration_mapping *mapping; - if (!enum_field_type || index < 0) { + if (!enum_field_type) { ret = -1; goto end; } @@ -1428,7 +1427,7 @@ int64_t bt_ctf_field_type_enumeration_get_mapping_count( struct bt_ctf_field_type_enumeration *enumeration; if (!type || (type->id != BT_CTF_FIELD_TYPE_ID_ENUM)) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -1604,7 +1603,7 @@ int64_t bt_ctf_field_type_structure_get_field_count( struct bt_ctf_field_type_structure *structure; if (!type || (type->id != BT_CTF_FIELD_TYPE_ID_STRUCT)) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -1615,16 +1614,16 @@ end: return ret; } -int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *type, +int bt_ctf_field_type_structure_get_field_by_index( + struct bt_ctf_field_type *type, const char **field_name, struct bt_ctf_field_type **field_type, - int index) + uint64_t index) { struct bt_ctf_field_type_structure *structure; struct structure_field *field; int ret = 0; - if (!type || index < 0 || - (type->id != BT_CTF_FIELD_TYPE_ID_STRUCT)) { + if (!type || type->id != BT_CTF_FIELD_TYPE_ID_STRUCT) { ret = -1; goto end; } @@ -1897,7 +1896,7 @@ int64_t bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *type struct bt_ctf_field_type_variant *variant; if (!type || (type->id != BT_CTF_FIELD_TYPE_ID_VARIANT)) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -1909,16 +1908,15 @@ end: } -int bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *type, +int bt_ctf_field_type_variant_get_field_by_index(struct bt_ctf_field_type *type, const char **field_name, struct bt_ctf_field_type **field_type, - int index) + uint64_t index) { struct bt_ctf_field_type_variant *variant; struct structure_field *field; int ret = 0; - if (!type || index < 0 || - (type->id != BT_CTF_FIELD_TYPE_ID_VARIANT)) { + if (!type || type->id != BT_CTF_FIELD_TYPE_ID_VARIANT) { ret = -1; goto end; } @@ -2016,7 +2014,7 @@ int64_t bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *type) struct bt_ctf_field_type_array *array; if (!type || (type->id != BT_CTF_FIELD_TYPE_ID_ARRAY)) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -2224,8 +2222,8 @@ int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type) struct bt_ctf_field_type *field; int field_alignment; - ret = bt_ctf_field_type_structure_get_field(type, NULL, - &field, i); + ret = bt_ctf_field_type_structure_get_field_by_index( + type, NULL, &field, i); if (ret) { goto end; } @@ -4126,13 +4124,13 @@ struct bt_ctf_field_type *bt_ctf_field_type_get_field_at_index( switch (type_id) { case CTF_TYPE_STRUCT: - bt_ctf_field_type_structure_get_field(field_type, NULL, &field, - index); + bt_ctf_field_type_structure_get_field_by_index(field_type, + NULL, &field, index); break; case CTF_TYPE_VARIANT: { - int ret = bt_ctf_field_type_variant_get_field(field_type, NULL, - &field, index); + int ret = bt_ctf_field_type_variant_get_field_by_index( + field_type, NULL, &field, index); if (ret) { field = NULL; goto end; diff --git a/lib/ctf-ir/fields.c b/lib/ctf-ir/fields.c index c43b4afa..28a5e937 100644 --- a/lib/ctf-ir/fields.c +++ b/lib/ctf-ir/fields.c @@ -469,7 +469,7 @@ end: return ret; } -struct bt_ctf_field *bt_ctf_field_structure_get_field( +struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name( struct bt_ctf_field *field, const char *name) { struct bt_ctf_field *new_field = NULL; @@ -520,7 +520,7 @@ error: } struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index( - struct bt_ctf_field *field, int index) + struct bt_ctf_field *field, uint64_t index) { int ret; const char *field_name; @@ -674,7 +674,7 @@ struct bt_ctf_field *bt_ctf_field_sequence_get_field(struct bt_ctf_field *field, } sequence = container_of(field, struct bt_ctf_field_sequence, parent); - if (!sequence->elements || sequence->elements->len <= index) { + if (!sequence->elements || index >= sequence->elements->len) { goto end; } diff --git a/lib/ctf-ir/stream-class.c b/lib/ctf-ir/stream-class.c index 1cab9590..f9d91aaf 100644 --- a/lib/ctf-ir/stream-class.c +++ b/lib/ctf-ir/stream-class.c @@ -196,45 +196,45 @@ int64_t bt_ctf_stream_class_get_id(struct bt_ctf_stream_class *stream_class) int64_t ret; if (!stream_class || !stream_class->id_set) { - ret = -1; + ret = (int64_t) -1; goto end; } - ret = (int64_t) stream_class->id; + ret = stream_class->id; end: return ret; } BT_HIDDEN int _bt_ctf_stream_class_set_id( - struct bt_ctf_stream_class *stream_class, uint32_t id) + struct bt_ctf_stream_class *stream_class, int64_t id) { stream_class->id = id; stream_class->id_set = 1; return 0; } -struct event_class_set_stream_id_data { - uint32_t stream_id; +struct event_class_set_stream_class_id_data { + int64_t stream_class_id; int ret; }; static void event_class_set_stream_id(gpointer event_class, gpointer data) { - struct event_class_set_stream_id_data *typed_data = data; + struct event_class_set_stream_class_id_data *typed_data = data; typed_data->ret |= bt_ctf_event_class_set_stream_id(event_class, - typed_data->stream_id); + typed_data->stream_class_id); } BT_HIDDEN int bt_ctf_stream_class_set_id_no_check( - struct bt_ctf_stream_class *stream_class, uint32_t id) + struct bt_ctf_stream_class *stream_class, int64_t id) { int ret = 0; - struct event_class_set_stream_id_data data = - { .stream_id = id, .ret = 0 }; + struct event_class_set_stream_class_id_data data = + { .stream_class_id = id, .ret = 0 }; /* * Make sure all event classes have their "stream_id" attribute @@ -256,11 +256,12 @@ end: } int bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class, - uint32_t id) + uint64_t id_param) { int ret = 0; + int64_t id = (int64_t) id_param; - if (!stream_class || stream_class->frozen) { + if (!stream_class || stream_class->frozen || id < 0) { ret = -1; goto end; } @@ -495,22 +496,21 @@ int64_t bt_ctf_stream_class_get_event_class_count( int64_t ret; if (!stream_class) { - ret = -1; + ret = (int64_t) -1; goto end; } - ret = (int) stream_class->event_classes->len; + ret = (int64_t) stream_class->event_classes->len; end: return ret; } -struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class( - struct bt_ctf_stream_class *stream_class, int index) +struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index( + struct bt_ctf_stream_class *stream_class, uint64_t index) { struct bt_ctf_event_class *event_class = NULL; - if (!stream_class || index < 0 || - index >= stream_class->event_classes->len) { + if (!stream_class || index >= stream_class->event_classes->len) { goto end; } @@ -547,12 +547,12 @@ end: } struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id( - struct bt_ctf_stream_class *stream_class, uint32_t id) + struct bt_ctf_stream_class *stream_class, uint64_t id) { - int64_t id_key = id; + int64_t id_key = (int64_t) id; struct bt_ctf_event_class *event_class = NULL; - if (!stream_class) { + if (!stream_class || id_key < 0) { goto end; } @@ -704,7 +704,7 @@ int64_t get_event_class_count(void *element) static void *get_event_class(void *element, int i) { - return bt_ctf_stream_class_get_event_class( + return bt_ctf_stream_class_get_event_class_by_index( (struct bt_ctf_stream_class *) element, i); } @@ -759,7 +759,7 @@ BT_HIDDEN int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class, struct metadata_context *context) { - int64_t ret = 0; + int ret = 0; size_t i; g_string_assign(context->field_name, ""); @@ -770,7 +770,7 @@ int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class, } g_string_append_printf(context->string, - "stream {\n\tid = %" PRIu32 ";\n\tevent.header := ", + "stream {\n\tid = %" PRId64 ";\n\tevent.header := ", stream_class->id); ret = bt_ctf_field_type_serialize(stream_class->event_header_type, context); diff --git a/lib/ctf-ir/stream.c b/lib/ctf-ir/stream.c index 7ab3544a..98fa25ad 100644 --- a/lib/ctf-ir/stream.c +++ b/lib/ctf-ir/stream.c @@ -200,8 +200,7 @@ int set_packet_header_uuid(struct bt_ctf_stream *stream) uuid_element, (int64_t) trace->uuid[i]); } else { ret = bt_ctf_field_unsigned_integer_set_value( - uuid_element, - (uint64_t) trace->uuid[i]); + uuid_element, (uint64_t) trace->uuid[i]); } bt_put(uuid_element); if (ret) { @@ -610,6 +609,7 @@ void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream, } new_count = previous_count + event_count; + assert(new_count >= previous_count); if (field_signed) { ret = bt_ctf_field_signed_integer_set_value( events_discarded_field, (int64_t) new_count); diff --git a/lib/ctf-ir/trace.c b/lib/ctf-ir/trace.c index 49c8308a..fd464b01 100644 --- a/lib/ctf-ir/trace.c +++ b/lib/ctf-ir/trace.c @@ -328,7 +328,7 @@ int64_t bt_ctf_trace_get_environment_field_count(struct bt_ctf_trace *trace) int64_t ret = 0; if (!trace) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -339,8 +339,8 @@ end: } const char * -bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace, - int index) +bt_ctf_trace_get_environment_field_name_by_index(struct bt_ctf_trace *trace, + uint64_t index) { const char *ret = NULL; @@ -354,8 +354,8 @@ end: return ret; } -struct bt_value *bt_ctf_trace_get_environment_field_value( - struct bt_ctf_trace *trace, int index) +struct bt_value *bt_ctf_trace_get_environment_field_value_by_index( + struct bt_ctf_trace *trace, uint64_t index) { struct bt_value *ret = NULL; @@ -414,7 +414,7 @@ end: int64_t bt_ctf_trace_get_clock_class_count(struct bt_ctf_trace *trace) { - int64_t ret = -1; + int64_t ret = (int64_t) -1; if (!trace) { goto end; @@ -425,12 +425,12 @@ end: return ret; } -struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class( - struct bt_ctf_trace *trace, int index) +struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index( + struct bt_ctf_trace *trace, uint64_t index) { struct bt_ctf_clock_class *clock_class = NULL; - if (!trace || index < 0 || index >= trace->clocks->len) { + if (!trace || index >= trace->clocks->len) { goto end; } @@ -589,7 +589,8 @@ int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace, /* Validate each event class individually */ for (i = 0; i < event_class_count; i++) { struct bt_ctf_event_class *event_class = - bt_ctf_stream_class_get_event_class(stream_class, i); + bt_ctf_stream_class_get_event_class_by_index( + stream_class, i); struct bt_ctf_field_type *event_context_type = NULL; struct bt_ctf_field_type *event_payload_type = NULL; @@ -630,6 +631,10 @@ int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace, stream_id = bt_ctf_stream_class_get_id(stream_class); if (stream_id < 0) { stream_id = trace->next_stream_id++; + if (stream_id < 0) { + ret = -1; + goto end; + } /* Try to assign a new stream id */ for (i = 0; i < trace->stream_classes->len; i++) { @@ -672,7 +677,8 @@ int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace, for (i = 0; i < event_class_count; i++) { struct bt_ctf_event_class *event_class = - bt_ctf_stream_class_get_event_class(stream_class, i); + bt_ctf_stream_class_get_event_class_by_index( + stream_class, i); bt_ctf_validation_replace_types(NULL, NULL, event_class, &ec_validation_outputs[i], ec_validation_flags); @@ -723,18 +729,19 @@ int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace) int64_t ret; if (!trace) { - ret = -1; + ret = (int64_t) -1; goto end; } - ret = trace->streams->len; + ret = (int64_t) trace->streams->len; end: return ret; } -struct bt_ctf_stream *bt_ctf_trace_get_stream(struct bt_ctf_trace *trace, - int index) +struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index( + struct bt_ctf_trace *trace, + uint64_t index) { struct bt_ctf_stream *stream = NULL; @@ -753,21 +760,21 @@ int64_t bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace) int64_t ret; if (!trace) { - ret = -1; + ret = (int64_t) -1; goto end; } - ret = trace->stream_classes->len; + ret = (int64_t) trace->stream_classes->len; end: return ret; } -struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class( - struct bt_ctf_trace *trace, int index) +struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index( + struct bt_ctf_trace *trace, uint64_t index) { struct bt_ctf_stream_class *stream_class = NULL; - if (!trace || index < 0 || index >= trace->stream_classes->len) { + if (!trace || index >= trace->stream_classes->len) { goto end; } @@ -778,12 +785,13 @@ end: } struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id( - struct bt_ctf_trace *trace, uint32_t id) + struct bt_ctf_trace *trace, uint64_t id_param) { int i; struct bt_ctf_stream_class *stream_class = NULL; + int64_t id = (int64_t) id_param; - if (!trace) { + if (!trace || id < 0) { goto end; } @@ -1119,7 +1127,7 @@ int64_t get_stream_class_count(void *element) static void *get_stream_class(void *element, int i) { - return bt_ctf_trace_get_stream_class( + return bt_ctf_trace_get_stream_class_by_index( (struct bt_ctf_trace *) element, i); } diff --git a/lib/ctf-writer/writer.c b/lib/ctf-writer/writer.c index c7b658fc..e9d74731 100644 --- a/lib/ctf-writer/writer.c +++ b/lib/ctf-writer/writer.c @@ -166,7 +166,8 @@ struct bt_ctf_stream *bt_ctf_writer_create_stream(struct bt_ctf_writer *writer, for (i = 0; i < stream_class_count; i++) { struct bt_ctf_stream_class *existing_stream_class = - bt_ctf_trace_get_stream_class(writer->trace, i); + bt_ctf_trace_get_stream_class_by_index( + writer->trace, i); if (existing_stream_class == stream_class) { stream_class_found = true; @@ -217,8 +218,7 @@ end: } int bt_ctf_writer_add_environment_field_int64(struct bt_ctf_writer *writer, - const char *name, - int64_t value) + const char *name, int64_t value) { int ret = -1; diff --git a/lib/graph/clock-class-priority-map.c b/lib/graph/clock-class-priority-map.c index 98e72522..f09fd06e 100644 --- a/lib/graph/clock-class-priority-map.c +++ b/lib/graph/clock-class-priority-map.c @@ -29,6 +29,7 @@ #include #include #include +#include #include static @@ -85,7 +86,7 @@ end: int64_t bt_clock_class_priority_map_get_clock_class_count( struct bt_clock_class_priority_map *cc_prio_map) { - int64_t ret = -1; + int64_t ret = (int64_t) -1; if (!cc_prio_map) { goto end; @@ -97,9 +98,9 @@ end: return ret; } -struct bt_ctf_clock_class *bt_clock_class_priority_map_get_clock_class( +struct bt_ctf_clock_class *bt_clock_class_priority_map_get_clock_class_by_index( struct bt_clock_class_priority_map *cc_prio_map, - unsigned int index) + uint64_t index) { struct bt_ctf_clock_class *clock_class = NULL; diff --git a/lib/graph/component.c b/lib/graph/component.c index e3464f45..792a3614 100644 --- a/lib/graph/component.c +++ b/lib/graph/component.c @@ -41,6 +41,7 @@ #include #include #include +#include static struct bt_component * (* const component_create_funcs[])( @@ -191,14 +192,14 @@ BT_HIDDEN int64_t bt_component_get_input_port_count(struct bt_component *comp) { assert(comp); - return comp->input_ports->len; + return (int64_t) comp->input_ports->len; } BT_HIDDEN int64_t bt_component_get_output_port_count(struct bt_component *comp) { assert(comp); - return comp->output_ports->len; + return (int64_t) comp->output_ports->len; } struct bt_component *bt_component_create_with_init_method_data( @@ -414,7 +415,8 @@ struct bt_graph *bt_component_get_graph( } static -struct bt_port *bt_component_get_port(GPtrArray *ports, const char *name) +struct bt_port *bt_component_get_port_by_name(GPtrArray *ports, + const char *name) { size_t i; struct bt_port *ret_port = NULL; @@ -439,29 +441,29 @@ struct bt_port *bt_component_get_port(GPtrArray *ports, const char *name) } BT_HIDDEN -struct bt_port *bt_component_get_input_port(struct bt_component *comp, +struct bt_port *bt_component_get_input_port_by_name(struct bt_component *comp, const char *name) { assert(comp); - return bt_component_get_port(comp->input_ports, name); + return bt_component_get_port_by_name(comp->input_ports, name); } BT_HIDDEN -struct bt_port *bt_component_get_output_port(struct bt_component *comp, +struct bt_port *bt_component_get_output_port_by_name(struct bt_component *comp, const char *name) { assert(comp); - return bt_component_get_port(comp->output_ports, name); + return bt_component_get_port_by_name(comp->output_ports, name); } static -struct bt_port *bt_component_get_port_at_index(GPtrArray *ports, int index) +struct bt_port *bt_component_get_port_by_index(GPtrArray *ports, uint64_t index) { struct bt_port *port = NULL; - if (index < 0 || index >= ports->len) { + if (index >= ports->len) { goto end; } @@ -471,21 +473,21 @@ end: } BT_HIDDEN -struct bt_port *bt_component_get_input_port_at_index(struct bt_component *comp, - int index) +struct bt_port *bt_component_get_input_port_by_index(struct bt_component *comp, + uint64_t index) { assert(comp); - return bt_component_get_port_at_index(comp->input_ports, index); + return bt_component_get_port_by_index(comp->input_ports, index); } BT_HIDDEN -struct bt_port *bt_component_get_output_port_at_index(struct bt_component *comp, - int index) +struct bt_port *bt_component_get_output_port_by_index(struct bt_component *comp, + uint64_t index) { assert(comp); - return bt_component_get_port_at_index(comp->output_ports, index); + return bt_component_get_port_by_index(comp->output_ports, index); } BT_HIDDEN @@ -505,7 +507,7 @@ struct bt_port *bt_component_add_output_port( } static -void bt_component_remove_port_at_index(struct bt_component *component, +void bt_component_remove_port_by_index(struct bt_component *component, GPtrArray *ports, size_t index) { struct bt_port *port; @@ -561,7 +563,7 @@ enum bt_component_status bt_component_remove_port( struct bt_port *cur_port = g_ptr_array_index(ports, i); if (cur_port == port) { - bt_component_remove_port_at_index(component, + bt_component_remove_port_by_index(component, ports, i); goto end; } diff --git a/lib/graph/filter.c b/lib/graph/filter.c index f7d29618..81f872e6 100644 --- a/lib/graph/filter.c +++ b/lib/graph/filter.c @@ -81,22 +81,22 @@ end: } int64_t bt_component_filter_get_input_port_count( - struct bt_component *component, uint64_t *count) + struct bt_component *component) { int64_t ret; if (!component || component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) { - ret = -1; + ret = (int64_t) -1; goto end; } - ret = bt_component_get_input_port_count(component); + ret = (int64_t) bt_component_get_input_port_count(component); end: return ret; } -struct bt_port *bt_component_filter_get_input_port( +struct bt_port *bt_component_filter_get_input_port_by_name( struct bt_component *component, const char *name) { struct bt_port *port = NULL; @@ -106,13 +106,13 @@ struct bt_port *bt_component_filter_get_input_port( goto end; } - port = bt_component_get_input_port(component, name); + port = bt_component_get_input_port_by_name(component, name); end: return port; } -struct bt_port *bt_component_filter_get_input_port_at_index( - struct bt_component *component, int index) +struct bt_port *bt_component_filter_get_input_port_by_index( + struct bt_component *component, uint64_t index) { struct bt_port *port = NULL; @@ -121,7 +121,7 @@ struct bt_port *bt_component_filter_get_input_port_at_index( goto end; } - port = bt_component_get_input_port_at_index(component, index); + port = bt_component_get_input_port_by_index(component, index); end: return port; } @@ -129,18 +129,18 @@ end: struct bt_port *bt_component_filter_get_default_input_port( struct bt_component *component) { - return bt_component_filter_get_input_port(component, + return bt_component_filter_get_input_port_by_name(component, DEFAULT_INPUT_PORT_NAME); } int64_t bt_component_filter_get_output_port_count( - struct bt_component *component, uint64_t *count) + struct bt_component *component) { int64_t ret; - if (!component || !count || + if (!component || component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -149,7 +149,7 @@ end: return ret; } -struct bt_port *bt_component_filter_get_output_port( +struct bt_port *bt_component_filter_get_output_port_by_name( struct bt_component *component, const char *name) { struct bt_port *port = NULL; @@ -159,13 +159,13 @@ struct bt_port *bt_component_filter_get_output_port( goto end; } - port = bt_component_get_output_port(component, name); + port = bt_component_get_output_port_by_name(component, name); end: return port; } -struct bt_port *bt_component_filter_get_output_port_at_index( - struct bt_component *component, int index) +struct bt_port *bt_component_filter_get_output_port_by_index( + struct bt_component *component, uint64_t index) { struct bt_port *port = NULL; @@ -174,7 +174,7 @@ struct bt_port *bt_component_filter_get_output_port_at_index( goto end; } - port = bt_component_get_output_port_at_index(component, index); + port = bt_component_get_output_port_by_index(component, index); end: return port; } @@ -182,16 +182,16 @@ end: struct bt_port *bt_component_filter_get_default_output_port( struct bt_component *component) { - return bt_component_filter_get_output_port(component, + return bt_component_filter_get_output_port_by_name(component, DEFAULT_OUTPUT_PORT_NAME); } struct bt_private_port * -bt_private_component_filter_get_input_private_port_at_index( - struct bt_private_component *private_component, int index) +bt_private_component_filter_get_input_private_port_by_index( + struct bt_private_component *private_component, uint64_t index) { return bt_private_port_from_port( - bt_component_filter_get_input_port_at_index( + bt_component_filter_get_input_port_by_index( bt_component_from_private(private_component), index)); } @@ -223,11 +223,11 @@ end: } struct bt_private_port * -bt_private_component_filter_get_output_private_port_at_index( - struct bt_private_component *private_component, int index) +bt_private_component_filter_get_output_private_port_by_index( + struct bt_private_component *private_component, uint64_t index) { return bt_private_port_from_port( - bt_component_filter_get_output_port_at_index( + bt_component_filter_get_output_port_by_index( bt_component_from_private(private_component), index)); } diff --git a/lib/graph/graph.c b/lib/graph/graph.c index 5a7e9e0b..35ccde70 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -349,7 +349,7 @@ enum bt_graph_status bt_graph_add_component_as_sibling(struct bt_graph *graph, struct bt_port *downstream_port = NULL; struct bt_connection *origin_connection = NULL; struct bt_connection *new_connection = NULL; - int port_index; + int64_t port_index; if (!graph || !origin || !new_component) { status = BT_GRAPH_STATUS_INVALID; @@ -393,14 +393,14 @@ enum bt_graph_status bt_graph_add_component_as_sibling(struct bt_graph *graph, /* Replicate input connections. */ for (port_index = 0; port_index< origin_input_port_count; port_index++) { - origin_port = bt_component_get_input_port_at_index(origin, + origin_port = bt_component_get_input_port_by_index(origin, port_index); if (!origin_port) { status = BT_GRAPH_STATUS_ERROR; goto error_disconnect; } - new_port = bt_component_get_input_port_at_index(new_component, + new_port = bt_component_get_input_port_by_index(new_component, port_index); if (!new_port) { status = BT_GRAPH_STATUS_ERROR; @@ -431,13 +431,13 @@ enum bt_graph_status bt_graph_add_component_as_sibling(struct bt_graph *graph, /* Replicate output connections. */ for (port_index = 0; port_index < origin_output_port_count; port_index++) { - origin_port = bt_component_get_output_port_at_index(origin, + origin_port = bt_component_get_output_port_by_index(origin, port_index); if (!origin_port) { status = BT_GRAPH_STATUS_ERROR; goto error_disconnect; } - new_port = bt_component_get_output_port_at_index(new_component, + new_port = bt_component_get_output_port_by_index(new_component, port_index); if (!new_port) { status = BT_GRAPH_STATUS_ERROR; diff --git a/lib/graph/notification/event.c b/lib/graph/notification/event.c index 44bb6f23..8d9d6f3d 100644 --- a/lib/graph/notification/event.c +++ b/lib/graph/notification/event.c @@ -78,7 +78,7 @@ bool validate_clock_classes(struct bt_notification_event *notif) for (cc_prio_map_cc_i = 0; cc_prio_map_cc_i < cc_prio_map_cc_count; cc_prio_map_cc_i++) { struct bt_ctf_clock_class *clock_class = - bt_clock_class_priority_map_get_clock_class( + bt_clock_class_priority_map_get_clock_class_by_index( notif->cc_prio_map, cc_prio_map_cc_i); struct bt_ctf_clock_value *clock_value; bool found_in_trace = false; @@ -96,7 +96,8 @@ bool validate_clock_classes(struct bt_notification_event *notif) for (trace_cc_i = 0; trace_cc_i < trace_cc_count; trace_cc_i++) { struct bt_ctf_clock_class *trace_clock_class = - bt_ctf_trace_get_clock_class(trace, trace_cc_i); + bt_ctf_trace_get_clock_class_by_index(trace, + trace_cc_i); assert(trace_clock_class); diff --git a/lib/graph/sink.c b/lib/graph/sink.c index 916979ad..1bd09283 100644 --- a/lib/graph/sink.c +++ b/lib/graph/sink.c @@ -106,7 +106,7 @@ int64_t bt_component_sink_get_input_port_count(struct bt_component *component) if (!component || component->class->type != BT_COMPONENT_CLASS_TYPE_SINK) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -115,7 +115,7 @@ end: return ret; } -struct bt_port *bt_component_sink_get_input_port( +struct bt_port *bt_component_sink_get_input_port_by_name( struct bt_component *component, const char *name) { struct bt_port *port = NULL; @@ -125,13 +125,13 @@ struct bt_port *bt_component_sink_get_input_port( goto end; } - port = bt_component_get_input_port(component, name); + port = bt_component_get_input_port_by_name(component, name); end: return port; } -struct bt_port *bt_component_sink_get_input_port_at_index( - struct bt_component *component, int index) +struct bt_port *bt_component_sink_get_input_port_by_index( + struct bt_component *component, uint64_t index) { struct bt_port *port = NULL; @@ -140,7 +140,7 @@ struct bt_port *bt_component_sink_get_input_port_at_index( goto end; } - port = bt_component_get_input_port_at_index(component, index); + port = bt_component_get_input_port_by_index(component, index); end: return port; } @@ -148,16 +148,16 @@ end: struct bt_port *bt_component_sink_get_default_input_port( struct bt_component *component) { - return bt_component_sink_get_input_port(component, + return bt_component_sink_get_input_port_by_name(component, DEFAULT_INPUT_PORT_NAME); } struct bt_private_port * -bt_private_component_sink_get_input_private_port_at_index( - struct bt_private_component *private_component, int index) +bt_private_component_sink_get_input_private_port_by_index( + struct bt_private_component *private_component, uint64_t index) { return bt_private_port_from_port( - bt_component_sink_get_input_port_at_index( + bt_component_sink_get_input_port_by_index( bt_component_from_private(private_component), index)); } diff --git a/lib/graph/source.c b/lib/graph/source.c index 7ab4eeae..ed052ded 100644 --- a/lib/graph/source.c +++ b/lib/graph/source.c @@ -86,7 +86,7 @@ int64_t bt_component_source_get_output_port_count( if (!component || !count || component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) { - ret = -1; + ret = (int64_t) -1; goto end; } @@ -95,7 +95,7 @@ end: return ret; } -struct bt_port *bt_component_source_get_output_port( +struct bt_port *bt_component_source_get_output_port_by_name( struct bt_component *component, const char *name) { struct bt_port *port = NULL; @@ -105,13 +105,13 @@ struct bt_port *bt_component_source_get_output_port( goto end; } - port = bt_component_get_output_port(component, name); + port = bt_component_get_output_port_by_name(component, name); end: return port; } -struct bt_port *bt_component_source_get_output_port_at_index( - struct bt_component *component, int index) +struct bt_port *bt_component_source_get_output_port_by_index( + struct bt_component *component, uint64_t index) { struct bt_port *port = NULL; @@ -120,7 +120,7 @@ struct bt_port *bt_component_source_get_output_port_at_index( goto end; } - port = bt_component_get_output_port_at_index(component, index); + port = bt_component_get_output_port_by_index(component, index); end: return port; } @@ -128,24 +128,26 @@ end: struct bt_port *bt_component_source_get_default_output_port( struct bt_component *component) { - return bt_component_source_get_output_port(component, + return bt_component_source_get_output_port_by_name(component, DEFAULT_OUTPUT_PORT_NAME); } -struct bt_private_port *bt_private_component_source_get_output_private_port( +struct bt_private_port * +bt_private_component_source_get_output_private_port_by_name( struct bt_private_component *private_component, const char *name) { - return bt_private_port_from_port(bt_component_source_get_output_port( - bt_component_from_private(private_component), name)); + return bt_private_port_from_port( + bt_component_source_get_output_port_by_name( + bt_component_from_private(private_component), name)); } struct bt_private_port * -bt_private_component_source_get_output_private_port_at_index( - struct bt_private_component *private_component, int index) +bt_private_component_source_get_output_private_port_by_index( + struct bt_private_component *private_component, uint64_t index) { return bt_private_port_from_port( - bt_component_source_get_output_port_at_index( + bt_component_source_get_output_port_by_index( bt_component_from_private(private_component), index)); } diff --git a/lib/plugin/plugin.c b/lib/plugin/plugin.c index a55b9843..c5dfd033 100644 --- a/lib/plugin/plugin.c +++ b/lib/plugin/plugin.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -89,7 +90,7 @@ int64_t bt_plugin_set_get_plugin_count(struct bt_plugin_set *plugin_set) goto end; } - count = plugin_set->plugins->len; + count = (int64_t) plugin_set->plugins->len; end: return count; @@ -97,7 +98,7 @@ end: extern struct bt_plugin *bt_plugin_set_get_plugin(struct bt_plugin_set *plugin_set, - unsigned int index) + uint64_t index) { struct bt_plugin *plugin = NULL; @@ -504,11 +505,11 @@ end: int64_t bt_plugin_get_component_class_count(struct bt_plugin *plugin) { - return plugin ? plugin->comp_classes->len : -1; + return plugin ? plugin->comp_classes->len : (int64_t) -1; } -struct bt_component_class *bt_plugin_get_component_class( - struct bt_plugin *plugin, size_t index) +struct bt_component_class *bt_plugin_get_component_class_by_index( + struct bt_plugin *plugin, uint64_t index) { struct bt_component_class *comp_class = NULL; diff --git a/lib/values.c b/lib/values.c index fb62293e..24b26e11 100644 --- a/lib/values.c +++ b/lib/values.c @@ -819,7 +819,7 @@ int64_t bt_value_array_size(const struct bt_value *array_obj) BT_VALUE_TO_ARRAY(array_obj); if (!array_obj || !bt_value_is_array(array_obj)) { - ret = BT_VALUE_STATUS_INVAL; + ret = (int64_t) BT_VALUE_STATUS_INVAL; goto end; } @@ -987,7 +987,7 @@ int64_t bt_value_map_size(const struct bt_value *map_obj) struct bt_value_map *typed_map_obj = BT_VALUE_TO_MAP(map_obj); if (!map_obj || !bt_value_is_map(map_obj)) { - ret = BT_VALUE_STATUS_INVAL; + ret = (int64_t) BT_VALUE_STATUS_INVAL; goto end; } diff --git a/plugins/ctf/common/metadata/visitor-generate-ir.c b/plugins/ctf/common/metadata/visitor-generate-ir.c index 050573d7..cb50a7e7 100644 --- a/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/plugins/ctf/common/metadata/visitor-generate-ir.c @@ -3437,8 +3437,9 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node) } else { assert(bt_ctf_trace_get_stream_class_count( ctx->trace) == 1); - stream_class = bt_ctf_trace_get_stream_class( - ctx->trace, 0); + stream_class = + bt_ctf_trace_get_stream_class_by_index( + ctx->trace, 0); assert(stream_class); stream_id = bt_ctf_stream_class_get_id( stream_class); diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index bb629b18..be79603e 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -2082,7 +2082,7 @@ struct bt_ctf_event *create_event(struct bt_ctf_notif_iter *notit) goto error; } - ret = bt_ctf_event_set_payload_field(event, + ret = bt_ctf_event_set_event_payload(event, notit->dscopes.event_payload); if (ret) { goto error; @@ -2249,7 +2249,7 @@ int init_clock_states(GHashTable *clock_states, struct bt_ctf_trace *trace) for (i = 0; i < clock_class_count; i++) { struct bt_ctf_clock_class *clock_class; - clock_class = bt_ctf_trace_get_clock_class(trace, i); + clock_class = bt_ctf_trace_get_clock_class_by_index(trace, i); if (!clock_class) { ret = -1; goto end; diff --git a/plugins/ctf/fs/fs.c b/plugins/ctf/fs/fs.c index 808f9ccf..e734a1e1 100644 --- a/plugins/ctf/fs/fs.c +++ b/plugins/ctf/fs/fs.c @@ -347,8 +347,8 @@ int create_cc_prio_map(struct ctf_fs_component *ctf_fs) for (i = 0; i < count; i++) { struct bt_ctf_clock_class *clock_class = - bt_ctf_trace_get_clock_class(ctf_fs->metadata->trace, - i); + bt_ctf_trace_get_clock_class_by_index( + ctf_fs->metadata->trace, i); assert(clock_class); ret = bt_clock_class_priority_map_add_clock_class( diff --git a/plugins/debug-info/copy.c b/plugins/debug-info/copy.c index 6c392602..55cf1351 100644 --- a/plugins/debug-info/copy.c +++ b/plugins/debug-info/copy.c @@ -825,7 +825,7 @@ int add_clock_classes(FILE *err, struct bt_ctf_trace *writer_trace, for (i = 0; i < clock_class_count; i++) { struct bt_ctf_clock_class *clock_class = - bt_ctf_trace_get_clock_class(trace, i); + bt_ctf_trace_get_clock_class_by_index(trace, i); if (!clock_class) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, @@ -1366,7 +1366,7 @@ struct bt_ctf_clock_class *stream_class_get_clock_class(FILE *err, } /* FIXME multi-clock? */ - clock_class = bt_ctf_trace_get_clock_class(trace, 0); + clock_class = bt_ctf_trace_get_clock_class_by_index(trace, 0); bt_put(trace); @@ -1518,7 +1518,7 @@ struct bt_ctf_event *debug_info_copy_event(FILE *err, struct bt_ctf_event *event } BT_PUT(field); - field = bt_ctf_event_get_payload_field(event); + field = bt_ctf_event_get_event_payload(event); if (!field) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); @@ -1526,7 +1526,7 @@ struct bt_ctf_event *debug_info_copy_event(FILE *err, struct bt_ctf_event *event } copy_field = bt_ctf_field_copy(field); if (copy_field) { - ret = bt_ctf_event_set_payload_field(writer_event, copy_field); + ret = bt_ctf_event_set_event_payload(writer_event, copy_field); if (ret < 0) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); diff --git a/plugins/libctfcopytrace/clock-fields.c b/plugins/libctfcopytrace/clock-fields.c index 68fb5b75..f24206a2 100644 --- a/plugins/libctfcopytrace/clock-fields.c +++ b/plugins/libctfcopytrace/clock-fields.c @@ -329,7 +329,7 @@ struct bt_ctf_field_type *override_header_type(FILE *err, int ret; /* FIXME multi-clock? */ - writer_clock_class = bt_ctf_trace_get_clock_class(writer_trace, 0); + writer_clock_class = bt_ctf_trace_get_clock_class_by_index(writer_trace, 0); if (!writer_clock_class) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); @@ -516,7 +516,7 @@ int copy_find_clock_enum_field(FILE *err, struct bt_ctf_event *event, __LINE__); goto error; } - + ret = 0; goto end; @@ -818,7 +818,7 @@ struct bt_ctf_clock_class *stream_class_get_clock_class(FILE *err, } /* FIXME multi-clock? */ - clock_class = bt_ctf_trace_get_clock_class(trace, 0); + clock_class = bt_ctf_trace_get_clock_class_by_index(trace, 0); bt_put(trace); end: diff --git a/plugins/libctfcopytrace/ctfcopytrace.c b/plugins/libctfcopytrace/ctfcopytrace.c index 898e6c4e..c2d5b4d1 100644 --- a/plugins/libctfcopytrace/ctfcopytrace.c +++ b/plugins/libctfcopytrace/ctfcopytrace.c @@ -39,6 +39,7 @@ #include "ctfcopytrace.h" #include "clock-fields.h" +BT_HIDDEN struct bt_ctf_clock_class *ctf_copy_clock_class(FILE *err, struct bt_ctf_clock_class *clock_class) { @@ -156,6 +157,7 @@ end: return writer_clock_class; } +BT_HIDDEN enum bt_component_status ctf_copy_clock_classes(FILE *err, struct bt_ctf_trace *writer_trace, struct bt_ctf_stream_class *writer_stream_class, @@ -169,7 +171,7 @@ enum bt_component_status ctf_copy_clock_classes(FILE *err, for (i = 0; i < clock_class_count; i++) { struct bt_ctf_clock_class *writer_clock_class; struct bt_ctf_clock_class *clock_class = - bt_ctf_trace_get_clock_class(trace, i); + bt_ctf_trace_get_clock_class_by_index(trace, i); if (!clock_class) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, @@ -207,6 +209,7 @@ end: return ret; } +BT_HIDDEN struct bt_ctf_event_class *ctf_copy_event_class(FILE *err, struct bt_ctf_event_class *event_class) { @@ -234,13 +237,15 @@ struct bt_ctf_event_class *ctf_copy_event_class(FILE *err, struct bt_value *attr_value; int ret; - attr_name = bt_ctf_event_class_get_attribute_name(event_class, i); + attr_name = bt_ctf_event_class_get_attribute_name_by_index( + event_class, i); if (!attr_name) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); goto error; } - attr_value = bt_ctf_event_class_get_attribute_value(event_class, i); + attr_value = bt_ctf_event_class_get_attribute_value_by_index( + event_class, i); if (!attr_value) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); @@ -257,14 +262,14 @@ struct bt_ctf_event_class *ctf_copy_event_class(FILE *err, } } - count = bt_ctf_event_class_get_field_count(event_class); + count = bt_ctf_event_class_get_payload_type_field_count(event_class); for (i = 0; i < count; i++) { const char *field_name; struct bt_ctf_field_type *field_type; int ret; - ret = bt_ctf_event_class_get_field(event_class, &field_name, - &field_type, i); + ret = bt_ctf_event_class_get_payload_type_field_by_index( + event_class, &field_name, &field_type, i); if (ret < 0) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); goto error; @@ -288,6 +293,7 @@ end: return writer_event_class; } +BT_HIDDEN enum bt_component_status ctf_copy_event_classes(FILE *err, struct bt_ctf_stream_class *stream_class, struct bt_ctf_stream_class *writer_stream_class) @@ -307,7 +313,7 @@ enum bt_component_status ctf_copy_event_classes(FILE *err, struct bt_ctf_field_type *context; int int_ret; - event_class = bt_ctf_stream_class_get_event_class( + event_class = bt_ctf_stream_class_get_event_class_by_index( stream_class, i); if (!event_class) { fprintf(err, "[error] %s in %s:%d\n", __func__, @@ -360,6 +366,7 @@ end: return ret; } +BT_HIDDEN struct bt_ctf_stream_class *ctf_copy_stream_class(FILE *err, struct bt_ctf_stream_class *stream_class, struct bt_ctf_trace *writer_trace, @@ -454,6 +461,7 @@ end: return writer_stream_class; } +BT_HIDDEN enum bt_component_status ctf_copy_packet_context_field(FILE *err, struct bt_ctf_field *field, const char *field_name, struct bt_ctf_field *writer_packet_context, @@ -482,8 +490,8 @@ enum bt_component_status ctf_copy_packet_context_field(FILE *err, } BT_PUT(field_type); - writer_field = bt_ctf_field_structure_get_field(writer_packet_context, - field_name); + writer_field = bt_ctf_field_structure_get_field_by_name( + writer_packet_context, field_name); if (!writer_field) { ret = BT_COMPONENT_STATUS_ERROR; fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, @@ -519,6 +527,7 @@ end: return ret; } +BT_HIDDEN struct bt_ctf_field *ctf_copy_packet_context(FILE *err, struct bt_ctf_packet *packet, struct bt_ctf_stream *writer_stream) @@ -579,7 +588,7 @@ struct bt_ctf_field *ctf_copy_packet_context(FILE *err, __FILE__, __LINE__); goto error; } - if (bt_ctf_field_type_structure_get_field(struct_type, + if (bt_ctf_field_type_structure_get_field_by_index(struct_type, &field_name, &field_type, i) < 0) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); @@ -623,6 +632,7 @@ end: return writer_packet_context; } +BT_HIDDEN int ctf_copy_event_header(FILE *err, struct bt_ctf_event *event, struct bt_ctf_event_class *writer_event_class, struct bt_ctf_event *writer_event, @@ -706,6 +716,7 @@ end: return ret; } +BT_HIDDEN struct bt_ctf_event *ctf_copy_event(FILE *err, struct bt_ctf_event *event, struct bt_ctf_event_class *writer_event_class, bool override_ts64) @@ -788,7 +799,7 @@ struct bt_ctf_event *ctf_copy_event(FILE *err, struct bt_ctf_event *event, BT_PUT(field); BT_PUT(copy_field); - field = bt_ctf_event_get_payload_field(event); + field = bt_ctf_event_get_event_payload(event); if (!field) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); @@ -796,7 +807,7 @@ struct bt_ctf_event *ctf_copy_event(FILE *err, struct bt_ctf_event *event, } copy_field = bt_ctf_field_copy(field); if (copy_field) { - ret = bt_ctf_event_set_payload_field(writer_event, copy_field); + ret = bt_ctf_event_set_event_payload(writer_event, copy_field); if (ret < 0) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); @@ -816,6 +827,7 @@ end: return writer_event; } +BT_HIDDEN enum bt_component_status ctf_copy_trace(FILE *err, struct bt_ctf_trace *trace, struct bt_ctf_trace *writer_trace) { @@ -829,14 +841,16 @@ enum bt_component_status ctf_copy_trace(FILE *err, struct bt_ctf_trace *trace, const char *name; struct bt_value *value = NULL; - name = bt_ctf_trace_get_environment_field_name(trace, i); + name = bt_ctf_trace_get_environment_field_name_by_index( + trace, i); if (!name) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); ret = BT_COMPONENT_STATUS_ERROR; goto end; } - value = bt_ctf_trace_get_environment_field_value(trace, i); + value = bt_ctf_trace_get_environment_field_value_by_index( + trace, i); if (!value) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); diff --git a/plugins/libctfcopytrace/ctfcopytrace.h b/plugins/libctfcopytrace/ctfcopytrace.h index b4a60a2a..6820a8a2 100644 --- a/plugins/libctfcopytrace/ctfcopytrace.h +++ b/plugins/libctfcopytrace/ctfcopytrace.h @@ -51,6 +51,7 @@ struct bt_ctf_clock_class *ctf_copy_clock_class(FILE *err, * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on * error. */ +BT_HIDDEN enum bt_component_status ctf_copy_clock_classes(FILE *err, struct bt_ctf_trace *writer_trace, struct bt_ctf_stream_class *writer_stream_class, @@ -61,6 +62,7 @@ enum bt_component_status ctf_copy_clock_classes(FILE *err, * * Returns NULL on error. */ +BT_HIDDEN struct bt_ctf_event_class *ctf_copy_event_class(FILE *err, struct bt_ctf_event_class *event_class); @@ -71,6 +73,7 @@ struct bt_ctf_event_class *ctf_copy_event_class(FILE *err, * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on * error. */ +BT_HIDDEN enum bt_component_status ctf_copy_event_classes(FILE *err, struct bt_ctf_stream_class *stream_class, struct bt_ctf_stream_class *writer_stream_class); @@ -80,6 +83,7 @@ enum bt_component_status ctf_copy_event_classes(FILE *err, * * Returns NULL or error. */ +BT_HIDDEN struct bt_ctf_stream_class *ctf_copy_stream_class(FILE *err, struct bt_ctf_stream_class *stream_class, struct bt_ctf_trace *writer_trace, @@ -92,6 +96,7 @@ struct bt_ctf_stream_class *ctf_copy_stream_class(FILE *err, * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on * error. */ +BT_HIDDEN enum bt_component_status ctf_copy_packet_context_field(FILE *err, struct bt_ctf_field *field, const char *field_name, struct bt_ctf_field *writer_packet_context, @@ -106,6 +111,7 @@ enum bt_component_status ctf_copy_packet_context_field(FILE *err, * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on * error. */ +BT_HIDDEN struct bt_ctf_field *ctf_copy_packet_context(FILE *err, struct bt_ctf_packet *packet, struct bt_ctf_stream *writer_stream); @@ -116,6 +122,7 @@ struct bt_ctf_field *ctf_copy_packet_context(FILE *err, * * Returns NULL on error. */ +BT_HIDDEN struct bt_ctf_event *ctf_copy_event(FILE *err, struct bt_ctf_event *event, struct bt_ctf_event_class *writer_event_class, bool override_ts64); @@ -125,6 +132,7 @@ struct bt_ctf_event *ctf_copy_event(FILE *err, struct bt_ctf_event *event, * * Returns 0 on success, -1 on error. */ +BT_HIDDEN int ctf_copy_event_header(FILE *err, struct bt_ctf_event *event, struct bt_ctf_event_class *writer_event_class, struct bt_ctf_event *writer_event, @@ -137,6 +145,7 @@ int ctf_copy_event_header(FILE *err, struct bt_ctf_event *event, * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on * error. */ +BT_HIDDEN enum bt_component_status ctf_copy_trace(FILE *err, struct bt_ctf_trace *trace, struct bt_ctf_trace *writer_trace); diff --git a/plugins/text/pretty/print.c b/plugins/text/pretty/print.c index fb7bae4f..9a8d002c 100644 --- a/plugins/text/pretty/print.c +++ b/plugins/text/pretty/print.c @@ -1440,7 +1440,7 @@ enum bt_component_status print_event_payload(struct pretty_component *pretty, enum bt_component_status ret = BT_COMPONENT_STATUS_OK; struct bt_ctf_field *main_field = NULL; - main_field = bt_ctf_event_get_payload_field(event); + main_field = bt_ctf_event_get_event_payload(event); if (!main_field) { goto end; } diff --git a/plugins/utils/muxer/muxer.c b/plugins/utils/muxer/muxer.c index 75b19597..5db1e426 100644 --- a/plugins/utils/muxer/muxer.c +++ b/plugins/utils/muxer/muxer.c @@ -820,7 +820,7 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp, for (i = 0; i < count; i++) { struct bt_private_port *priv_port = - bt_private_component_filter_get_input_private_port_at_index( + bt_private_component_filter_get_input_private_port_by_index( muxer_comp->priv_comp, i); struct bt_port *port; diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index 8b35cf98..6043db92 100644 --- a/plugins/utils/trimmer/iterator.c +++ b/plugins/utils/trimmer/iterator.c @@ -214,7 +214,7 @@ struct bt_notification *evaluate_event_notification( assert(trace); /* FIXME multi-clock? */ - clock_class = bt_ctf_trace_get_clock_class(trace, 0); + clock_class = bt_ctf_trace_get_clock_class_by_index(trace, 0); if (!clock_class) { goto end; } @@ -348,7 +348,8 @@ int64_t get_raw_timestamp(struct bt_ctf_packet *writer_packet, assert(writer_trace); /* FIXME multi-clock? */ - writer_clock_class = bt_ctf_trace_get_clock_class(writer_trace, 0); + writer_clock_class = bt_ctf_trace_get_clock_class_by_index( + writer_trace, 0); assert(writer_clock_class); ret = bt_ctf_clock_class_get_offset_s(writer_clock_class, &sec_offset); diff --git a/tests/lib/test_bt_ctf_field_type_validation.c b/tests/lib/test_bt_ctf_field_type_validation.c index 065d367b..1448566c 100644 --- a/tests/lib/test_bt_ctf_field_type_validation.c +++ b/tests/lib/test_bt_ctf_field_type_validation.c @@ -1717,9 +1717,9 @@ void validate_test_pass(struct bt_ctf_trace *trace) struct bt_ctf_field_type *ft_target = NULL; struct bt_ctf_field_type *ft_tag = NULL; - sc = bt_ctf_trace_get_stream_class(trace, 0); + sc = bt_ctf_trace_get_stream_class_by_index(trace, 0); assert(sc); - ec = bt_ctf_stream_class_get_event_class(sc, 0); + ec = bt_ctf_stream_class_get_event_class_by_index(sc, 0); assert(ec); ph = bt_ctf_trace_get_packet_header_type(trace); diff --git a/tests/lib/test_ctf_ir_ref.c b/tests/lib/test_ctf_ir_ref.c index f82c3145..5ffb069a 100644 --- a/tests/lib/test_ctf_ir_ref.c +++ b/tests/lib/test_ctf_ir_ref.c @@ -348,11 +348,11 @@ static void init_weak_refs(struct bt_ctf_trace *tc, struct bt_ctf_event_class **ec3) { *tc1 = tc; - *sc1 = bt_ctf_trace_get_stream_class(tc, 0); - *sc2 = bt_ctf_trace_get_stream_class(tc, 1); - *ec1 = bt_ctf_stream_class_get_event_class(*sc1, 0); - *ec2 = bt_ctf_stream_class_get_event_class(*sc1, 1); - *ec3 = bt_ctf_stream_class_get_event_class(*sc2, 0); + *sc1 = bt_ctf_trace_get_stream_class_by_index(tc, 0); + *sc2 = bt_ctf_trace_get_stream_class_by_index(tc, 1); + *ec1 = bt_ctf_stream_class_get_event_class_by_index(*sc1, 0); + *ec2 = bt_ctf_stream_class_get_event_class_by_index(*sc1, 1); + *ec3 = bt_ctf_stream_class_get_event_class_by_index(*sc2, 0); bt_put(*sc1); bt_put(*sc2); bt_put(*ec1); @@ -402,7 +402,7 @@ static void test_example_scenario(void) "TC1 reference count is 1"); /* User A acquires a reference to SC2 from TC1. */ - user_a.sc = bt_ctf_trace_get_stream_class(user_a.tc, 1); + user_a.sc = bt_ctf_trace_get_stream_class_by_index(user_a.tc, 1); ok(user_a.sc, "User A acquires SC2 from TC1"); ok(bt_object_get_ref_count(weak_tc1) == 2, "TC1 reference count is 2"); @@ -410,7 +410,7 @@ static void test_example_scenario(void) "SC2 reference count is 1"); /* User A acquires a reference to EC3 from SC2. */ - user_a.ec = bt_ctf_stream_class_get_event_class(user_a.sc, 0); + user_a.ec = bt_ctf_stream_class_get_event_class_by_index(user_a.sc, 0); ok(user_a.ec, "User A acquires EC3 from SC2"); ok(bt_object_get_ref_count(weak_tc1) == 2, "TC1 reference count is 2"); @@ -457,7 +457,7 @@ static void test_example_scenario(void) /* User C acquires a reference to EC1. */ diag("User C acquires a reference to EC1"); - user_c.ec = bt_ctf_stream_class_get_event_class(user_b.sc, 0); + user_c.ec = bt_ctf_stream_class_get_event_class_by_index(user_b.sc, 0); ok(bt_object_get_ref_count(weak_ec1) == 1, "EC1 reference count is 1"); ok(bt_object_get_ref_count(weak_sc1) == 2, diff --git a/tests/lib/test_ctf_writer.c b/tests/lib/test_ctf_writer.c index e05b3d28..7ea4b583 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -416,11 +416,11 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, "bt_ctf_stream_class_get_event_class_count handles NULL correctly"); ok(bt_ctf_stream_class_get_event_class_count(stream_class) == 1, "bt_ctf_stream_class_get_event_class_count returns a correct number of event classes"); - ok(bt_ctf_stream_class_get_event_class(NULL, 0) == NULL, + ok(bt_ctf_stream_class_get_event_class_by_index(NULL, 0) == NULL, "bt_ctf_stream_class_get_event_class handles NULL correctly"); - ok(bt_ctf_stream_class_get_event_class(stream_class, 8724) == NULL, + ok(bt_ctf_stream_class_get_event_class_by_index(stream_class, 8724) == NULL, "bt_ctf_stream_class_get_event_class handles invalid indexes correctly"); - ret_event_class = bt_ctf_stream_class_get_event_class(stream_class, 0); + ret_event_class = bt_ctf_stream_class_get_event_class_by_index(stream_class, 0); ok(ret_event_class == simple_event_class, "bt_ctf_stream_class_get_event_class returns the correct event class"); bt_put(ret_event_class); @@ -892,21 +892,22 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, "bt_ctf_event_class_get_attribute_count handles a NULL event class"); ok(bt_ctf_event_class_get_attribute_count(event_class) == 4, "bt_ctf_event_class_get_attribute_count returns the correct count"); - ok(!bt_ctf_event_class_get_attribute_name(NULL, 0), + ok(!bt_ctf_event_class_get_attribute_name_by_index(NULL, 0), "bt_ctf_event_class_get_attribute_name handles a NULL event class correctly"); - ok(!bt_ctf_event_class_get_attribute_name(event_class, 4), + ok(!bt_ctf_event_class_get_attribute_name_by_index(event_class, 4), "bt_ctf_event_class_get_attribute_name handles a too large index correctly"); - ok(!bt_ctf_event_class_get_attribute_value(NULL, 0), + ok(!bt_ctf_event_class_get_attribute_value_by_index(NULL, 0), "bt_ctf_event_class_get_attribute_value handles a NULL event class correctly"); - ok(!bt_ctf_event_class_get_attribute_value(event_class, 4), + ok(!bt_ctf_event_class_get_attribute_value_by_index(event_class, 4), "bt_ctf_event_class_get_attribute_value handles a too large index correctly"); memset(&attrs_count, 0, sizeof(attrs_count)); for (i = 0; i < 4; ++i) { - ret_string = bt_ctf_event_class_get_attribute_name(event_class, - i); - obj = bt_ctf_event_class_get_attribute_value(event_class, i); + ret_string = bt_ctf_event_class_get_attribute_name_by_index( + event_class, i); + obj = bt_ctf_event_class_get_attribute_value_by_index( + event_class, i); assert(ret_string && obj); if (!strcmp(ret_string, "id")) { @@ -954,25 +955,25 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, "bt_ctf_event_class_get_stream_class returns the correct stream class"); bt_put(ret_stream_class); - ok(bt_ctf_event_class_get_field_count(NULL) < 0, + ok(bt_ctf_event_class_get_payload_type_field_count(NULL) < 0, "bt_ctf_event_class_get_field_count handles NULL correctly"); - ok(bt_ctf_event_class_get_field_count(event_class) == 3, + ok(bt_ctf_event_class_get_payload_type_field_count(event_class) == 3, "bt_ctf_event_class_get_field_count returns a correct value"); - ok(bt_ctf_event_class_get_field(NULL, &ret_string, + ok(bt_ctf_event_class_get_payload_type_field_by_index(NULL, &ret_string, &ret_field_type, 0) < 0, "bt_ctf_event_class_get_field handles a NULL event class correctly"); - ok(bt_ctf_event_class_get_field(event_class, NULL, + ok(bt_ctf_event_class_get_payload_type_field_by_index(event_class, NULL, &ret_field_type, 0) == 0, "bt_ctf_event_class_get_field handles a NULL field name correctly"); bt_put(ret_field_type); - ok(bt_ctf_event_class_get_field(event_class, &ret_string, + ok(bt_ctf_event_class_get_payload_type_field_by_index(event_class, &ret_string, NULL, 0) == 0, "bt_ctf_event_class_get_field handles a NULL field type correctly"); - ok(bt_ctf_event_class_get_field(event_class, &ret_string, + ok(bt_ctf_event_class_get_payload_type_field_by_index(event_class, &ret_string, &ret_field_type, 42) < 0, "bt_ctf_event_class_get_field handles an invalid index correctly"); - ok(bt_ctf_event_class_get_field(event_class, &ret_string, + ok(bt_ctf_event_class_get_payload_type_field_by_index(event_class, &ret_string, &ret_field_type, 0) == 0, "bt_ctf_event_class_get_field returns a field"); ok(bt_ctf_field_type_compare(ret_field_type, uint_35_type) == 0, @@ -2954,41 +2955,41 @@ int main(int argc, char **argv) "bt_ctf_trace_get_environment_field_count returns a correct number of environment fields"); /* Test bt_ctf_trace_get_environment_field_name */ - ok(bt_ctf_trace_get_environment_field_name(NULL, 0) == NULL, + ok(bt_ctf_trace_get_environment_field_name_by_index(NULL, 0) == NULL, "bt_ctf_trace_get_environment_field_name handles a NULL trace correctly"); - ok(bt_ctf_trace_get_environment_field_name(trace, -1) == NULL, + ok(bt_ctf_trace_get_environment_field_name_by_index(trace, -1) == NULL, "bt_ctf_trace_get_environment_field_name handles an invalid index correctly (negative)"); - ok(bt_ctf_trace_get_environment_field_name(trace, 5) == NULL, + ok(bt_ctf_trace_get_environment_field_name_by_index(trace, 5) == NULL, "bt_ctf_trace_get_environment_field_name handles an invalid index correctly (too large)"); - ret_string = bt_ctf_trace_get_environment_field_name(trace, 0); + ret_string = bt_ctf_trace_get_environment_field_name_by_index(trace, 0); ok(ret_string && !strcmp(ret_string, "host"), "bt_ctf_trace_get_environment_field_name returns a correct field name"); - ret_string = bt_ctf_trace_get_environment_field_name(trace, 1); + ret_string = bt_ctf_trace_get_environment_field_name_by_index(trace, 1); ok(ret_string && !strcmp(ret_string, "test_env_int_obj"), "bt_ctf_trace_get_environment_field_name returns a correct field name"); - ret_string = bt_ctf_trace_get_environment_field_name(trace, 2); + ret_string = bt_ctf_trace_get_environment_field_name_by_index(trace, 2); ok(ret_string && !strcmp(ret_string, "test_env_str_obj"), "bt_ctf_trace_get_environment_field_name returns a correct field name"); - ret_string = bt_ctf_trace_get_environment_field_name(trace, 3); + ret_string = bt_ctf_trace_get_environment_field_name_by_index(trace, 3); ok(ret_string && !strcmp(ret_string, "test_env_int"), "bt_ctf_trace_get_environment_field_name returns a correct field name"); - ret_string = bt_ctf_trace_get_environment_field_name(trace, 4); + ret_string = bt_ctf_trace_get_environment_field_name_by_index(trace, 4); ok(ret_string && !strcmp(ret_string, "test_env_str"), "bt_ctf_trace_get_environment_field_name returns a correct field name"); /* Test bt_ctf_trace_get_environment_field_value */ - ok(bt_ctf_trace_get_environment_field_value(NULL, 0) == NULL, + ok(bt_ctf_trace_get_environment_field_value_by_index(NULL, 0) == NULL, "bt_ctf_trace_get_environment_field_value handles a NULL trace correctly"); - ok(bt_ctf_trace_get_environment_field_value(trace, -1) == NULL, + ok(bt_ctf_trace_get_environment_field_value_by_index(trace, -1) == NULL, "bt_ctf_trace_get_environment_field_value handles an invalid index correctly (negative)"); - ok(bt_ctf_trace_get_environment_field_value(trace, 5) == NULL, + ok(bt_ctf_trace_get_environment_field_value_by_index(trace, 5) == NULL, "bt_ctf_trace_get_environment_field_value handles an invalid index correctly (too large)"); - obj = bt_ctf_trace_get_environment_field_value(trace, 1); + 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 == 23, "bt_ctf_trace_get_environment_field_value succeeds in getting an integer value"); BT_PUT(obj); - obj = bt_ctf_trace_get_environment_field_value(trace, 2); + 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, "the value"), "bt_ctf_trace_get_environment_field_value succeeds in getting a string value"); @@ -3015,7 +3016,7 @@ int main(int argc, char **argv) "bt_ctf_trace_set_environment_field_integer succeeds with an existing name"); ok(bt_ctf_trace_get_environment_field_count(trace) == 5, "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(trace, 3); + obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 3); ret = bt_value_integer_get(obj, &ret_int64_t); ok(!ret && ret_int64_t == 654321, "bt_ctf_trace_get_environment_field_value successfully replaces an existing field"); @@ -3325,9 +3326,9 @@ int main(int argc, char **argv) ok(stream1, "Instanciate a stream class from writer"); ok(bt_ctf_trace_get_stream_count(trace) == 1, "bt_ctf_trace_get_stream_count() succeeds and returns the correct value (1)"); - stream = bt_ctf_trace_get_stream(trace, 0); + stream = bt_ctf_trace_get_stream_by_index(trace, 0); ok(stream == stream1, - "bt_ctf_trace_get_stream() succeeds and returns the correct value"); + "bt_ctf_trace_get_stream_by_index() succeeds and returns the correct value"); BT_PUT(stream); /* @@ -3339,13 +3340,13 @@ int main(int argc, char **argv) "bt_ctf_trace_get_clock_class_count correctly handles NULL"); ok(bt_ctf_trace_get_clock_class_count(trace) == 1, "bt_ctf_trace_get_clock_class_count returns the correct number of clocks"); - ok(!bt_ctf_trace_get_clock_class(NULL, 0), + ok(!bt_ctf_trace_get_clock_class_by_index(NULL, 0), "bt_ctf_trace_get_clock_class correctly handles NULL"); - ok(!bt_ctf_trace_get_clock_class(trace, -1), + ok(!bt_ctf_trace_get_clock_class_by_index(trace, -1), "bt_ctf_trace_get_clock_class correctly handles negative indexes"); - ok(!bt_ctf_trace_get_clock_class(trace, 1), + ok(!bt_ctf_trace_get_clock_class_by_index(trace, 1), "bt_ctf_trace_get_clock_class correctly handles out of bound accesses"); - ret_clock_class = bt_ctf_trace_get_clock_class(trace, 0); + ret_clock_class = bt_ctf_trace_get_clock_class_by_index(trace, 0); ok(strcmp(bt_ctf_clock_class_get_name(ret_clock_class), bt_ctf_clock_get_name(clock)) == 0, "bt_ctf_trace_get_clock_class returns the right clock instance"); diff --git a/tests/lib/test_graph_topo.c b/tests/lib/test_graph_topo.c index 2f243b05..274f7872 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -946,7 +946,8 @@ void test_src_adds_port_in_port_connected(void) assert(sink_def_port); conn = bt_graph_connect_ports(graph, src_def_port, sink_def_port); assert(conn); - src_hello_port = bt_component_source_get_output_port(src, "hello"); + src_hello_port = bt_component_source_get_output_port_by_name(src, + "hello"); assert(src_hello_port); /* We're supposed to have 6 events */ diff --git a/tests/lib/test_plugin.c b/tests/lib/test_plugin.c index b66cb827..a256b7cb 100644 --- a/tests/lib/test_plugin.c +++ b/tests/lib/test_plugin.c @@ -87,8 +87,8 @@ static void test_invalid(const char *plugin_dir) "bt_plugin_get_path() handles NULL correctly"); ok(bt_plugin_get_component_class_count(NULL) < 0, "bt_plugin_get_component_class_count() handles NULL correctly"); - ok(!bt_plugin_get_component_class(NULL, 0), - "bt_plugin_get_component_class() handles NULL correctly"); + ok(!bt_plugin_get_component_class_by_index(NULL, 0), + "bt_plugin_get_component_class_by_index() handles NULL correctly"); ok(!bt_plugin_get_component_class_by_name_and_type(NULL, NULL, 0), "bt_plugin_get_component_class_by_name_and_type() handles NULL correctly"); } diff --git a/tests/plugins/test-utils-muxer.c b/tests/plugins/test-utils-muxer.c index 4b78966d..707672c5 100644 --- a/tests/plugins/test-utils-muxer.c +++ b/tests/plugins/test-utils-muxer.c @@ -1001,10 +1001,10 @@ void do_std_test(enum test test, const char *name, assert(count >= 0); for (i = 0; i < count; i++) { - upstream_port = bt_component_source_get_output_port_at_index( + upstream_port = bt_component_source_get_output_port_by_index( src_comp, i); assert(upstream_port); - downstream_port = bt_component_filter_get_input_port_at_index( + downstream_port = bt_component_filter_get_input_port_by_index( muxer_comp, i); assert(downstream_port); conn = bt_graph_connect_ports(graph, @@ -1017,7 +1017,7 @@ void do_std_test(enum test test, const char *name, } /* Connect muxer output port to sink input port */ - upstream_port = bt_component_filter_get_output_port(muxer_comp, + upstream_port = bt_component_filter_get_output_port_by_name(muxer_comp, "out"); assert(upstream_port); downstream_port = bt_component_sink_get_default_input_port(sink_comp); @@ -1351,7 +1351,7 @@ void connect_port_to_first_avail_muxer_port(struct bt_graph *graph, for (i = 0; i < count; i++) { struct bt_port *muxer_port = - bt_component_filter_get_input_port_at_index( + bt_component_filter_get_input_port_by_index( muxer_comp, i); assert(muxer_port); @@ -1484,7 +1484,7 @@ void test_single_end_then_multiple_full(void) assert(ret == 0); for (i = 0; i < count; i++) { - upstream_port = bt_component_source_get_output_port_at_index( + upstream_port = bt_component_source_get_output_port_by_index( src_comp, i); assert(upstream_port); connect_port_to_first_avail_muxer_port(graph, @@ -1493,7 +1493,7 @@ void test_single_end_then_multiple_full(void) } /* Connect muxer output port to sink input port */ - upstream_port = bt_component_filter_get_output_port(muxer_comp, + upstream_port = bt_component_filter_get_output_port_by_name(muxer_comp, "out"); assert(upstream_port); downstream_port = bt_component_sink_get_default_input_port(sink_comp); @@ -1613,7 +1613,7 @@ void test_single_again_end_then_multiple_full(void) assert(ret == 0); for (i = 0; i < count; i++) { - upstream_port = bt_component_source_get_output_port_at_index( + upstream_port = bt_component_source_get_output_port_by_index( src_comp, i); assert(upstream_port); connect_port_to_first_avail_muxer_port(graph, @@ -1622,7 +1622,7 @@ void test_single_again_end_then_multiple_full(void) } /* Connect muxer output port to sink input port */ - upstream_port = bt_component_filter_get_output_port(muxer_comp, + upstream_port = bt_component_filter_get_output_port_by_name(muxer_comp, "out"); assert(upstream_port); downstream_port = bt_component_sink_get_default_input_port(sink_comp); -- 2.34.1