lib: remove unused public `enum bt_plugin_status`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 8 Dec 2018 20:38:21 +0000 (15:38 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
Also:

* Make the plugin's user exit function return nothing. It's not like we
  can cancel this anyway.

* Make the plugin's user init function return
  `enum bt_plugin_init_status`, an enumeration reserved for this
  function, in case `enum bt_plugin_status` becomes public in the
  future.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
cli/babeltrace.c
include/babeltrace/plugin/plugin-const.h
include/babeltrace/plugin/plugin-dev.h
include/babeltrace/plugin/plugin-internal.h
lib/plugin/plugin-so.c
tests/lib/test-plugin-plugins/minimal.c

index 101fb5f5a010cf8f9fa669822b88869d5e5c02ed..5abbcd0d8c065a3a3c51966f367de2245b66b6c6 100644 (file)
@@ -883,7 +883,7 @@ void print_plugin_info(const bt_plugin *plugin)
 {
        unsigned int major, minor, patch;
        const char *extra;
-       enum bt_plugin_status version_status;
+       enum bt_property_availability version_avail;
        const char *plugin_name;
        const char *path;
        const char *author;
@@ -895,7 +895,7 @@ void print_plugin_info(const bt_plugin *plugin)
        author = bt_plugin_get_author(plugin);
        license = bt_plugin_get_license(plugin);
        plugin_description = bt_plugin_get_description(plugin);
-       version_status = bt_plugin_get_version(plugin, &major, &minor,
+       version_avail = bt_plugin_get_version(plugin, &major, &minor,
                &patch, &extra);
        printf("%s%s%s%s:\n", bt_common_color_bold(),
                bt_common_color_fg_blue(), plugin_name,
@@ -907,7 +907,7 @@ void print_plugin_info(const bt_plugin *plugin)
                puts("  Built-in");
        }
 
-       if (version_status == BT_PLUGIN_STATUS_OK) {
+       if (version_avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) {
                printf("  %sVersion%s: %u.%u.%u",
                        bt_common_color_bold(), bt_common_color_reset(),
                        major, minor, patch);
index fe51a8564324b373cad5b84dae30c12f6a039b17..f19da61d28a1acebec1516800c0a03a708f8785c 100644 (file)
 extern "C" {
 #endif
 
-enum bt_plugin_status {
-       BT_PLUGIN_STATUS_OK =           0,
-       BT_PLUGIN_STATUS_ERROR =        -1,
-       BT_PLUGIN_STATUS_NOMEM =        -12,
-};
-
 extern const bt_plugin *bt_plugin_find(const char *plugin_name);
 
 extern const bt_plugin_set *bt_plugin_find_all_from_file(
index 94bfb700866e463c59f69ce0730e89c7993e1982..21771ca981a9f224252c5ee42d8894f02fe12aa1 100644 (file)
@@ -63,11 +63,17 @@ extern "C" {
 #define __BT_PLUGIN_VERSION_MINOR      0
 
 /* Plugin initialization function type */
-typedef enum bt_plugin_status (*bt_plugin_init_func)(
+enum bt_plugin_init_status {
+       BT_PLUGIN_INIT_STATUS_OK = 0,
+       BT_PLUGIN_INIT_STATUS_NOMEM = -12,
+       BT_PLUGIN_INIT_STATUS_ERROR = -1,
+};
+
+typedef enum bt_plugin_init_status (*bt_plugin_init_func)(
                const bt_plugin *plugin);
 
 /* Plugin exit function type */
-typedef enum bt_plugin_status (*bt_plugin_exit_func)(void);
+typedef void (*bt_plugin_exit_func)(void);
 
 /* Plugin descriptor: describes a single plugin (internal use) */
 struct __bt_plugin_descriptor {
index 65926c0b770bd4027dc794aa6c67ece06d4e5390..763a68b2a9941ae5316e32646c7fab3b7fe6263b 100644 (file)
@@ -39,6 +39,12 @@ enum bt_plugin_type {
        BT_PLUGIN_TYPE_PYTHON = 1,
 };
 
+enum bt_plugin_status {
+       BT_PLUGIN_STATUS_OK = 0,
+       BT_PLUGIN_STATUS_ERROR = -1,
+       BT_PLUGIN_STATUS_NOMEM = -12,
+};
+
 struct bt_plugin {
        struct bt_object base;
        enum bt_plugin_type type;
index f785554d6b847e2c1f69197d7a67ffb969ae5b84..a535d9d877ec98cbe844992173f9492d7036e78f 100644 (file)
@@ -102,6 +102,21 @@ void fini_comp_class_list(void)
        BT_LOGD_STR("Released references from all component classes to shared library handles.");
 }
 
+static inline
+const char *bt_plugin_init_status_string(enum bt_plugin_init_status status)
+{
+       switch (status) {
+       case BT_PLUGIN_INIT_STATUS_OK:
+               return "BT_PLUGIN_INIT_STATUS_OK";
+       case BT_PLUGIN_INIT_STATUS_ERROR:
+               return "BT_PLUGIN_INIT_STATUS_ERROR";
+       case BT_PLUGIN_INIT_STATUS_NOMEM:
+               return "BT_PLUGIN_INIT_STATUS_NOMEM";
+       default:
+               return "(unknown)";
+       }
+}
+
 static
 void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
 {
@@ -117,17 +132,9 @@ void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
                shared_lib_handle, path);
 
        if (shared_lib_handle->init_called && shared_lib_handle->exit) {
-               enum bt_plugin_status status;
-
                BT_LOGD_STR("Calling user's plugin exit function.");
-               status = shared_lib_handle->exit();
-               BT_LOGD("User function returned: %s",
-                       bt_plugin_status_string(status));
-
-               if (status < 0) {
-                       BT_LOGW("User's plugin exit function failed: "
-                               "path=\"%s\"", path);
-               }
+               shared_lib_handle->exit();
+               BT_LOGD_STR("User function returned.");
        }
 
        if (shared_lib_handle->module) {
@@ -673,13 +680,15 @@ enum bt_plugin_status bt_plugin_so_init(
 
        /* Initialize plugin */
        if (spec->init) {
+               enum bt_plugin_init_status init_status;
                BT_LOGD_STR("Calling user's plugin initialization function.");
-               status = spec->init(plugin);
+               init_status = spec->init(plugin);
                BT_LOGD("User function returned: %s",
-                       bt_plugin_status_string(status));
+                       bt_plugin_init_status_string(init_status));
 
-               if (status < 0) {
+               if (init_status < 0) {
                        BT_LOGW_STR("User's plugin initialization function failed.");
+                       status = BT_PLUGIN_STATUS_ERROR;
                        goto end;
                }
        }
index 5ea4bde65eeec3c12b3ea1d2febdb50b778f0b10..d6fa367e2e41c696f5faa8965159e437df620256 100644 (file)
 #include <stdlib.h>
 #include <glib.h>
 
-static enum bt_plugin_status plugin_init(const bt_plugin *plugin)
+static enum bt_plugin_init_status plugin_init(const bt_plugin *plugin)
 {
        g_setenv("BT_TEST_PLUGIN_INIT_CALLED", "1", 1);
-       return BT_PLUGIN_STATUS_OK;
+       return BT_PLUGIN_INIT_STATUS_OK;
 }
 
-static enum bt_plugin_status plugin_exit(void)
+static void plugin_exit(void)
 {
        g_setenv("BT_TEST_PLUGIN_EXIT_CALLED", "1", 1);
-       return BT_PLUGIN_STATUS_OK;
 }
 
 BT_PLUGIN_MODULE();
This page took 0.030446 seconds and 4 git commands to generate.