From 914575515c65df149b18d6eacfd51010c39fab21 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 28 Mar 2017 20:15:40 -0400 Subject: [PATCH] Update notification iterator's "init" function signature MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As per this project's standard way of calling methods, the self object should always be the first parameter. In the cast of bt_component_class_notification_iterator_init_method, we don't need to explicitly pass the bt_private_component object since you can get it from the notification iterator with bt_private_notification_iterator_get_private_component(). Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- include/babeltrace/component/component-class.h | 5 ++--- lib/component/connection.c | 5 ++--- lib/component/filter.c | 4 ++-- lib/component/iterator.c | 9 +++++++++ plugins/ctf/fs/fs.c | 16 ++++++++++------ plugins/ctf/fs/fs.h | 5 ++--- plugins/utils/trimmer/iterator.c | 8 +++++--- plugins/utils/trimmer/iterator.h | 5 ++--- tests/lib/test-plugin-plugins/sfs.c | 5 ++--- 9 files changed, 36 insertions(+), 26 deletions(-) diff --git a/include/babeltrace/component/component-class.h b/include/babeltrace/component/component-class.h index ea95f4e06..a5bfee871 100644 --- a/include/babeltrace/component/component-class.h +++ b/include/babeltrace/component/component-class.h @@ -65,9 +65,8 @@ typedef void (*bt_component_class_finalize_method)( typedef enum bt_notification_iterator_status (*bt_component_class_notification_iterator_init_method)( - struct bt_private_component *private_component, - struct bt_private_port *private_port, - struct bt_private_notification_iterator *private_notification_iterator); + struct bt_private_notification_iterator *private_notification_iterator, + struct bt_private_port *private_port); typedef void (*bt_component_class_notification_iterator_finalize_method)( struct bt_private_notification_iterator *private_notification_iterator); diff --git a/lib/component/connection.c b/lib/component/connection.c index 87d967788..587a19565 100644 --- a/lib/component/connection.c +++ b/lib/component/connection.c @@ -223,9 +223,8 @@ bt_private_connection_create_notification_iterator( if (init_method) { enum bt_notification_iterator_status status = init_method( - bt_private_component_from_component(upstream_component), - bt_private_port_from_port(upstream_port), - bt_private_notification_iterator_from_notification_iterator(iterator)); + bt_private_notification_iterator_from_notification_iterator(iterator), + bt_private_port_from_port(upstream_port)); if (status < 0) { goto error; } diff --git a/lib/component/filter.c b/lib/component/filter.c index 2b1eb51f9..20c8b6279 100644 --- a/lib/component/filter.c +++ b/lib/component/filter.c @@ -196,7 +196,7 @@ bt_private_component_filter_get_input_private_port_at_index( } struct bt_private_port * -bt_private_component_filter_get_default_private_input_port( +bt_private_component_filter_get_default_input_private_port( struct bt_private_component *private_component) { return bt_private_port_from_port( @@ -232,7 +232,7 @@ bt_private_component_filter_get_output_private_port_at_index( } struct bt_private_port * -bt_private_component_filter_get_default_private_output_port( +bt_private_component_filter_get_default_output_private_port( struct bt_private_component *private_component) { return bt_private_port_from_port( diff --git a/lib/component/iterator.c b/lib/component/iterator.c index e2ffd2f01..d72f86499 100644 --- a/lib/component/iterator.c +++ b/lib/component/iterator.c @@ -238,6 +238,15 @@ struct bt_component *bt_notification_iterator_get_component( return bt_get(iterator->component); } +struct bt_private_component * +bt_private_notification_iterator_get_private_component( + struct bt_private_notification_iterator *private_iterator) +{ + return bt_private_component_from_component( + bt_notification_iterator_get_component( + bt_notification_iterator_from_private(private_iterator))); +} + enum bt_notification_iterator_status bt_notification_iterator_seek_time( struct bt_notification_iterator *iterator, enum bt_notification_iterator_seek_origin seek_origin, diff --git a/plugins/ctf/fs/fs.c b/plugins/ctf/fs/fs.c index 83e1a7e29..f559a7ba4 100644 --- a/plugins/ctf/fs/fs.c +++ b/plugins/ctf/fs/fs.c @@ -577,12 +577,13 @@ end: } enum bt_notification_iterator_status ctf_fs_iterator_init( - struct bt_private_component *source, - struct bt_private_port *port, - struct bt_private_notification_iterator *it) + struct bt_private_notification_iterator *it, + struct bt_private_port *port) { struct ctf_fs_iterator *ctf_it; struct ctf_fs_component *ctf_fs; + struct bt_private_component *source = + bt_private_notification_iterator_get_private_component(it); enum bt_notification_iterator_status ret = BT_NOTIFICATION_ITERATOR_STATUS_OK; assert(source && it); @@ -625,12 +626,15 @@ enum bt_notification_iterator_status ctf_fs_iterator_init( goto error; } -end: - return ret; + goto end; + error: (void) bt_private_notification_iterator_set_user_data(it, NULL); ctf_fs_iterator_destroy_data(ctf_it); - goto end; + +end: + bt_put(source); + return ret; } static diff --git a/plugins/ctf/fs/fs.h b/plugins/ctf/fs/fs.h index 9e03b013a..037d47eeb 100644 --- a/plugins/ctf/fs/fs.h +++ b/plugins/ctf/fs/fs.h @@ -113,9 +113,8 @@ void ctf_fs_finalize(struct bt_private_component *component); BT_HIDDEN enum bt_notification_iterator_status ctf_fs_iterator_init( - struct bt_private_component *source, - struct bt_private_port *port, - struct bt_private_notification_iterator *it); + struct bt_private_notification_iterator *it, + struct bt_private_port *port); void ctf_fs_iterator_finalize(struct bt_private_notification_iterator *it); diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index d0a51a6f9..9d15ba1da 100644 --- a/plugins/utils/trimmer/iterator.c +++ b/plugins/utils/trimmer/iterator.c @@ -63,15 +63,16 @@ void trimmer_iterator_finalize(struct bt_private_notification_iterator *it) BT_HIDDEN enum bt_notification_iterator_status trimmer_iterator_init( - struct bt_private_component *component, - struct bt_private_port *port, - struct bt_private_notification_iterator *iterator) + struct bt_private_notification_iterator *iterator, + struct bt_private_port *port) { enum bt_notification_iterator_status ret = BT_NOTIFICATION_ITERATOR_STATUS_OK; enum bt_notification_iterator_status it_ret; struct bt_private_port *input_port = NULL; struct bt_private_connection *connection = NULL; + struct bt_private_component *component = + bt_private_notification_iterator_get_private_component(iterator); struct trimmer_iterator *it_data = g_new0(struct trimmer_iterator, 1); if (!it_data) { @@ -99,6 +100,7 @@ enum bt_notification_iterator_status trimmer_iterator_init( goto end; } end: + bt_put(component); bt_put(connection); bt_put(input_port); return ret; diff --git a/plugins/utils/trimmer/iterator.h b/plugins/utils/trimmer/iterator.h index 63b34e808..3fe3dc4b7 100644 --- a/plugins/utils/trimmer/iterator.h +++ b/plugins/utils/trimmer/iterator.h @@ -40,9 +40,8 @@ struct trimmer_iterator { BT_HIDDEN enum bt_notification_iterator_status trimmer_iterator_init( - struct bt_private_component *component, - struct bt_private_port *port, - struct bt_private_notification_iterator *iterator); + struct bt_private_notification_iterator *iterator, + struct bt_private_port *port); BT_HIDDEN void trimmer_iterator_finalize(struct bt_private_notification_iterator *it); diff --git a/tests/lib/test-plugin-plugins/sfs.c b/tests/lib/test-plugin-plugins/sfs.c index 43acb8adf..93fbb0236 100644 --- a/tests/lib/test-plugin-plugins/sfs.c +++ b/tests/lib/test-plugin-plugins/sfs.c @@ -28,9 +28,8 @@ static enum bt_component_status sink_consume( } static enum bt_notification_iterator_status dummy_iterator_init_method( - struct bt_private_component *private_component, - struct bt_private_port *private_port, - struct bt_private_notification_iterator *private_iterator) + struct bt_private_notification_iterator *private_iterator, + struct bt_private_port *private_port) { return BT_NOTIFICATION_ITERATOR_STATUS_OK; } -- 2.34.1