Fix -Wmissing-prototypes/-Wmissing-declarations warnings
[babeltrace.git] / src / lib / plugin / plugin.c
index fbf02c510b361befa1b3df2092d09414280a1c98..24b3aef9bbcc44a89bb301fec3c2bc5146c929d4 100644 (file)
 
 #define APPEND_ALL_FROM_DIR_NFDOPEN_MAX        8
 
+/* Declare here to make sure definition in both ifdef branches are in sync. */
+static
+int init_python_plugin_provider(void);
+typedef int (*create_all_from_file_sym_type)(
+               const char *path,
+               bool fail_on_load_error,
+               struct bt_plugin_set **plugin_set_out);
+
 #ifdef BT_BUILT_IN_PYTHON_PLUGIN_SUPPORT
 #include <plugin/python-plugin-provider.h>
 
 static
-int (*bt_plugin_python_create_all_from_file_sym)(
-               const char *path, bool fail_on_load_error,
-               struct bt_plugin_set **plugin_set_out) =
-       bt_plugin_python_create_all_from_file;
+create_all_from_file_sym_type
+       bt_plugin_python_create_all_from_file_sym =
+                       bt_plugin_python_create_all_from_file;
 
 static
-enum bt_plugin_status init_python_plugin_provider(void)
+int init_python_plugin_provider(void)
 {
 }
 #else /* BT_BUILT_IN_PYTHON_PLUGIN_SUPPORT */
 static GModule *python_plugin_provider_module;
 
 static
-int (*bt_plugin_python_create_all_from_file_sym)(
-               const char *path, bool fail_on_load_error,
-                struct bt_plugin_set **plugin_set_out);
+create_all_from_file_sym_type bt_plugin_python_create_all_from_file_sym;
 
 static
 int init_python_plugin_provider(void) {
@@ -470,6 +475,7 @@ enum bt_plugin_find_status bt_plugin_find(const char *plugin_name,
                find_in_sys_dir, find_in_static, fail_on_load_error,
                &plugin_set);
        if (status != BT_FUNC_STATUS_OK) {
+               BT_ASSERT(!plugin_set);
                goto end;
        }
 
@@ -480,7 +486,7 @@ enum bt_plugin_find_status bt_plugin_find(const char *plugin_name,
 
                if (strcmp(plugin->info.name->str, plugin_name) == 0) {
                        *plugin_out = plugin;
-                       bt_object_get_no_null_check(*plugin_out);
+                       bt_object_get_ref_no_null_check(*plugin_out);
                        goto end;
                }
        }
@@ -497,6 +503,8 @@ end:
                        "name=\"%s\"", plugin_name);
        }
 
+       bt_plugin_set_put_ref(plugin_set);
+
        return status;
 }
 
@@ -842,7 +850,7 @@ struct bt_component_class *borrow_component_class_by_name(
                const char *comp_class_cand_name =
                        bt_component_class_get_name(comp_class_candidate);
 
-               BT_ASSERT(comp_class_cand_name);
+               BT_ASSERT_DBG(comp_class_cand_name);
 
                if (strcmp(name, comp_class_cand_name) == 0) {
                        comp_class = comp_class_candidate;
This page took 0.023805 seconds and 4 git commands to generate.