From: Philippe Proulx Date: Thu, 25 May 2017 22:01:09 +0000 (-0400) Subject: Remove useless component/iterator validation functions X-Git-Tag: v2.0.0-pre1~168 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=b95e1e3a30343ebce5aab61018ea54ac48da1c94 Remove useless component/iterator validation functions They only "validate" what we can assert anyway. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/include/babeltrace/graph/component-filter-internal.h b/include/babeltrace/graph/component-filter-internal.h index 15db1bb6..3bf79a18 100644 --- a/include/babeltrace/graph/component-filter-internal.h +++ b/include/babeltrace/graph/component-filter-internal.h @@ -51,14 +51,4 @@ struct bt_component *bt_component_filter_create( BT_HIDDEN void bt_component_filter_destroy(struct bt_component *component); -/** - * Validate a filter component. - * - * @param component Filter component instance to validate - * @returns One of #bt_component_status - */ -BT_HIDDEN -enum bt_component_status bt_component_filter_validate( - struct bt_component *component); - #endif /* BABELTRACE_COMPONENT_FILTER_INTERNAL_H */ diff --git a/include/babeltrace/graph/component-sink-internal.h b/include/babeltrace/graph/component-sink-internal.h index 84c37f2a..cffb9a96 100644 --- a/include/babeltrace/graph/component-sink-internal.h +++ b/include/babeltrace/graph/component-sink-internal.h @@ -54,16 +54,6 @@ struct bt_component *bt_component_sink_create( BT_HIDDEN void bt_component_sink_destroy(struct bt_component *component); -/** - * Validate a sink component. - * - * @param component Sink component instance to validate - * @returns One of #bt_component_status - */ -BT_HIDDEN -enum bt_component_status bt_component_sink_validate( - struct bt_component *component); - /** * Process one event, consuming from sources as needed. * diff --git a/include/babeltrace/graph/component-source-internal.h b/include/babeltrace/graph/component-source-internal.h index fa53bf04..fde15845 100644 --- a/include/babeltrace/graph/component-source-internal.h +++ b/include/babeltrace/graph/component-source-internal.h @@ -51,14 +51,4 @@ struct bt_component *bt_component_source_create( BT_HIDDEN void bt_component_source_destroy(struct bt_component *component); -/** - * Validate a source component. - * - * @param component Source component instance to validate - * @returns One of #bt_component_status - */ -BT_HIDDEN -enum bt_component_status bt_component_source_validate( - struct bt_component *component); - #endif /* BABELTRACE_COMPONENT_SOURCE_INTERNAL_H */ diff --git a/include/babeltrace/graph/notification-iterator-internal.h b/include/babeltrace/graph/notification-iterator-internal.h index ebbd01fc..7b748e7b 100644 --- a/include/babeltrace/graph/notification-iterator-internal.h +++ b/include/babeltrace/graph/notification-iterator-internal.h @@ -145,16 +145,6 @@ struct bt_notification_iterator *bt_notification_iterator_create( const enum bt_notification_type *notification_types, struct bt_connection *connection); -/** - * Validate a notification iterator. - * - * @param iterator Notification iterator instance - * @returns One of #bt_component_status values - */ -BT_HIDDEN -enum bt_notification_iterator_status bt_notification_iterator_validate( - struct bt_notification_iterator *iterator); - BT_HIDDEN void bt_notification_iterator_finalize( struct bt_notification_iterator *iterator); diff --git a/lib/graph/component.c b/lib/graph/component.c index 7a5c382a..9fad68ac 100644 --- a/lib/graph/component.c +++ b/lib/graph/component.c @@ -65,14 +65,6 @@ void (*component_destroy_funcs[])(struct bt_component *) = { [BT_COMPONENT_CLASS_TYPE_FILTER] = bt_component_filter_destroy, }; -static -enum bt_component_status (* const component_validation_funcs[])( - struct bt_component *) = { - [BT_COMPONENT_CLASS_TYPE_SOURCE] = bt_component_source_validate, - [BT_COMPONENT_CLASS_TYPE_SINK] = bt_component_sink_validate, - [BT_COMPONENT_CLASS_TYPE_FILTER] = bt_component_filter_validate, -}; - static void bt_component_destroy(struct bt_object *obj) { @@ -350,14 +342,6 @@ struct bt_component *bt_component_create_with_init_method_data( } } - ret = component_validation_funcs[type](component); - if (ret != BT_COMPONENT_STATUS_OK) { - BT_LOGW("Component is invalid: status=%s", - bt_component_status_string(ret)); - BT_PUT(component); - goto end; - } - BT_LOGD_STR("Freezing component class."); bt_component_class_freeze(component->class); BT_LOGD("Created component from component class: " diff --git a/lib/graph/connection.c b/lib/graph/connection.c index 96eed0f3..896ce270 100644 --- a/lib/graph/connection.c +++ b/lib/graph/connection.c @@ -276,7 +276,6 @@ bt_private_connection_create_notification_iterator( struct bt_private_connection *private_connection, const enum bt_notification_type *notification_types) { - enum bt_notification_iterator_status ret_iterator; enum bt_component_class_type upstream_comp_class_type; struct bt_notification_iterator *iterator = NULL; struct bt_port *upstream_port = NULL; @@ -374,13 +373,6 @@ bt_private_connection_create_notification_iterator( } } - ret_iterator = bt_notification_iterator_validate(iterator); - if (ret_iterator != BT_NOTIFICATION_ITERATOR_STATUS_OK) { - BT_LOGW("Notification iterator is invalid: status=%s", - bt_notification_iterator_status_string(ret_iterator)); - goto error; - } - g_ptr_array_add(connection->iterators, iterator); BT_LOGD("Created notification iterator from connection: " "conn-addr=%p, upstream-port-addr=%p, " diff --git a/lib/graph/filter.c b/lib/graph/filter.c index aaab3b78..8d2964e1 100644 --- a/lib/graph/filter.c +++ b/lib/graph/filter.c @@ -54,32 +54,6 @@ end: return filter ? &filter->parent : NULL; } -BT_HIDDEN -enum bt_component_status bt_component_filter_validate( - struct bt_component *component) -{ - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - - if (!component) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - if (!component->class) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - if (component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - /* Enforce iterator limits. */ -end: - return ret; -} - int64_t bt_component_filter_get_input_port_count( struct bt_component *component) { diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index 6819a2e9..56f4a251 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -510,21 +510,6 @@ end: return iterator; } -BT_HIDDEN -enum bt_notification_iterator_status bt_notification_iterator_validate( - struct bt_notification_iterator *iterator) -{ - enum bt_notification_iterator_status ret = - BT_NOTIFICATION_ITERATOR_STATUS_OK; - - if (!iterator) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_INVALID; - goto end; - } -end: - return ret; -} - void *bt_private_notification_iterator_get_user_data( struct bt_private_notification_iterator *private_iterator) { diff --git a/lib/graph/sink.c b/lib/graph/sink.c index e99d111f..a2ab2006 100644 --- a/lib/graph/sink.c +++ b/lib/graph/sink.c @@ -32,30 +32,6 @@ #include #include -BT_HIDDEN -enum bt_component_status bt_component_sink_validate( - struct bt_component *component) -{ - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - - if (!component) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - if (!component->class) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - if (component->class->type != BT_COMPONENT_CLASS_TYPE_SINK) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } -end: - return ret; -} - BT_HIDDEN void bt_component_sink_destroy(struct bt_component *component) { diff --git a/lib/graph/source.c b/lib/graph/source.c index 566d1c0e..96825708 100644 --- a/lib/graph/source.c +++ b/lib/graph/source.c @@ -34,31 +34,6 @@ #include #include -BT_HIDDEN -enum bt_component_status bt_component_source_validate( - struct bt_component *component) -{ - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - - if (!component) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - if (!component->class) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - - if (component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) { - ret = BT_COMPONENT_STATUS_INVALID; - goto end; - } - -end: - return ret; -} - BT_HIDDEN void bt_component_source_destroy(struct bt_component *component) {