From: Jérémie Galarneau Date: Tue, 30 Aug 2016 04:01:39 +0000 (-0400) Subject: Add bt_component_source_validate() implementation X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=cc8f40669f043ac960e1cb104ae922416a5d5a60;p=deliverable%2Fbabeltrace.git Add bt_component_source_validate() implementation Signed-off-by: Jérémie Galarneau --- diff --git a/lib/plugin-system/source.c b/lib/plugin-system/source.c index 97992aac5..5ec8e4007 100644 --- a/lib/plugin-system/source.c +++ b/lib/plugin-system/source.c @@ -37,7 +37,31 @@ BT_HIDDEN enum bt_component_status bt_component_source_validate( struct bt_component *component) { - return BT_COMPONENT_STATUS_OK; + enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + struct bt_component_source *source; + + 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_TYPE_SOURCE) { + ret = BT_COMPONENT_STATUS_INVALID; + goto end; + } + + source = container_of(component, struct bt_component_source, parent); + if (source->init_iterator) { + ret = BT_COMPONENT_STATUS_INVALID; + goto end; + } +end: + return ret; } BT_HIDDEN