Add bt_component_source_validate() implementation
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 30 Aug 2016 04:01:39 +0000 (00:01 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:05 +0000 (14:09 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/plugin-system/source.c

index 97992aac56ebdf60fbf38bd01c84b27e9388bdf3..5ec8e4007b63449ae77a76ef5760839fab077aef 100644 (file)
@@ -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
This page took 0.026581 seconds and 4 git commands to generate.