Replace all assert(false) and assert(0) with abort()
[babeltrace.git] / lib / plugin / plugin-so.c
index 7b152e2ce606568bcd4fa08eb82956b2d40a7c90..f1fa9f71b2a37a298f773ad234c9d5eae372ad70 100644 (file)
@@ -34,8 +34,9 @@
 #include <babeltrace/plugin/plugin-dev.h>
 #include <babeltrace/plugin/plugin-internal.h>
 #include <babeltrace/graph/component-class-internal.h>
+#include <babeltrace/types.h>
 #include <string.h>
-#include <stdbool.h>
+#include <stdlib.h>
 #include <glib.h>
 #include <gmodule.h>
 
@@ -138,10 +139,24 @@ void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
        }
 
        if (shared_lib_handle->module) {
-               if (!g_module_close(shared_lib_handle->module)) {
-                       printf_error("Module close error: %s\n",
-                                       g_module_error());
+#ifndef NDEBUG
+               /*
+                * Valgrind shows incomplete stack traces when
+                * dynamically loaded libraries are closed before it
+                * finishes. Use the BABELTRACE_NO_DLCLOSE in a debug
+                * build to avoid this.
+                */
+               const char *var = getenv("BABELTRACE_NO_DLCLOSE");
+
+               if (!var || strcmp(var, "1") != 0) {
+#endif
+                       if (!g_module_close(shared_lib_handle->module)) {
+                               printf_error("Module close error: %s\n",
+                                               g_module_error());
+                       }
+#ifndef NDEBUG
                }
+#endif
        }
 
        if (shared_lib_handle->path) {
@@ -431,7 +446,7 @@ enum bt_plugin_status bt_plugin_so_init(
                }
        }
 
-       spec->shared_lib_handle->init_called = true;
+       spec->shared_lib_handle->init_called = BT_TRUE;
 
        /* Add described component classes to plugin */
        for (i = 0; i < comp_class_full_descriptors->len; i++) {
@@ -621,8 +636,7 @@ enum bt_plugin_status bt_plugin_so_init(
                case BT_COMPONENT_CLASS_TYPE_SINK:
                        break;
                default:
-                       assert(false);
-                       break;
+                       abort();
                }
 
                /*
@@ -813,7 +827,7 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
        struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_end = NULL;
        struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_begin = NULL;
        struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_end = NULL;
-       bool is_libtool_wrapper = false, is_shared_object = false;
+       bt_bool is_libtool_wrapper = BT_FALSE, is_shared_object = BT_FALSE;
        struct bt_plugin_so_shared_lib_handle *shared_lib_handle = NULL;
 
        if (!path) {
This page took 0.025482 seconds and 4 git commands to generate.