X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fplugin%2Fplugin.c;h=838ceeff439a16d2cb9f8582454d8a4975b3ee11;hb=43c59509042845f8d42c3e99ec74d45fa2dc0908;hp=193adcaf7255f8d637e5d5e71041078f8fc26db4;hpb=6871026b82224d83bb63cbb44cc33c16c766d96d;p=babeltrace.git diff --git a/src/lib/plugin/plugin.c b/src/lib/plugin/plugin.c index 193adcaf..838ceeff 100644 --- a/src/lib/plugin/plugin.c +++ b/src/lib/plugin/plugin.c @@ -31,13 +31,14 @@ #include "common/macros.h" #include "compat/compiler.h" #include "common/common.h" -#include -#include -#include +#include +#include +#include #include "lib/graph/component-class.h" #include #include #include +#include #include #include #include @@ -56,26 +57,31 @@ #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 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) { @@ -182,6 +188,8 @@ enum bt_plugin_find_all_from_static_status bt_plugin_find_all_from_static( bt_bool fail_on_load_error, const struct bt_plugin_set **plugin_set_out) { + BT_ASSERT_PRE_NO_ERROR(); + /* bt_plugin_so_create_all_from_static() logs errors */ return bt_plugin_so_create_all_from_static(fail_on_load_error, (void *) plugin_set_out); @@ -193,6 +201,7 @@ enum bt_plugin_find_all_from_file_status bt_plugin_find_all_from_file( { enum bt_plugin_find_all_from_file_status status; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(path, "Path"); BT_ASSERT_PRE_NON_NULL(path, "Plugin set (output)"); BT_LOGI("Creating plugins from file: path=\"%s\"", path); @@ -276,6 +285,7 @@ enum bt_plugin_find_all_status bt_plugin_find_all(bt_bool find_in_std_env_var, int status = BT_FUNC_STATUS_OK; uint64_t dir_i, plugin_i; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(plugin_set_out, "Plugin set (output)"); BT_LOGI("Finding all plugins in standard directories and built-in plugins: " "find-in-std-env-var=%d, find-in-user-dir=%d, " @@ -459,6 +469,7 @@ enum bt_plugin_find_status bt_plugin_find(const char *plugin_name, const struct bt_plugin_set *plugin_set = NULL; uint64_t i; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(plugin_name, "Name"); BT_ASSERT_PRE_NON_NULL(plugin_out, "Plugin (output)"); BT_LOGI("Finding named plugin in standard directories and built-in plugins: " @@ -615,7 +626,7 @@ int bt_plugin_create_append_all_from_dir(struct bt_plugin_set *plugin_set, ": path=\"%s\", recurse=%d", path, recurse); (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN( - "Babeltrace library", + BT_LIB_LOG_LIBBABELTRACE2_NAME, "Cannot open directory: path=\"%s\", recurse=%d", path, recurse); status = BT_FUNC_STATUS_ERROR; @@ -660,6 +671,7 @@ enum bt_plugin_find_all_from_dir_status bt_plugin_find_all_from_dir( enum bt_plugin_find_all_from_dir_status status = BT_FUNC_STATUS_OK; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(plugin_set_out, "Plugin set (output)"); BT_LOGI("Creating all plugins in directory: path=\"%s\", recurse=%d", path, recurse); @@ -845,7 +857,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;