diff options
Diffstat (limited to 'src/libmowgli/module/loader_posix.c')
-rw-r--r-- | src/libmowgli/module/loader_posix.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/libmowgli/module/loader_posix.c b/src/libmowgli/module/loader_posix.c index f15c38a..d4114e7 100644 --- a/src/libmowgli/module/loader_posix.c +++ b/src/libmowgli/module/loader_posix.c @@ -30,22 +30,25 @@ #endif #ifndef RTLD_LOCAL -#define RTLD_LOCAL 0 +# define RTLD_LOCAL 0 #endif -mowgli_module_t mowgli_module_open(const char *path) +mowgli_module_t +mowgli_module_open(const char *path) { void *handle = dlopen(path, RTLD_NOW | RTLD_LOCAL); - /* make sure we have something. make this an assertion so that - * there is feedback if something happens. (poor programming practice). - */ - return_val_if_fail(handle != NULL, NULL); + if (handle == NULL) + { + mowgli_log("Failed to open %s: %s", path, dlerror()); + return NULL; + } return handle; } -void * mowgli_module_symbol(mowgli_module_t module, const char *symbol) +void * +mowgli_module_symbol(mowgli_module_t module, const char *symbol) { void *handle; @@ -53,15 +56,17 @@ void * mowgli_module_symbol(mowgli_module_t module, const char *symbol) handle = dlsym(module, symbol); - /* make sure we have something. make this an assertion so that - * there is feedback if something happens. (poor programming practice). - */ - return_val_if_fail(handle != NULL, NULL); + if (handle == NULL) + { + mowgli_log("Failed to find symbol %s: %s", symbol, dlerror()); + return NULL; + } return handle; } -void mowgli_module_close(mowgli_module_t module) +void +mowgli_module_close(mowgli_module_t module) { return_if_fail(module != NULL); |