From cc8f40669f043ac960e1cb104ae922416a5d5a60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 30 Aug 2016 00:01:39 -0400 Subject: [PATCH] Add bt_component_source_validate() implementation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- lib/plugin-system/source.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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 -- 2.34.1