From 352da6ea3c0c03f852206feadfca56ed300787d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Thu, 25 May 2017 17:30:24 +0200 Subject: [PATCH] module.c: cleanup unused code Searching the default library path for modules wasn't a good idea anyway. --- lib/module.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/module.c b/lib/module.c index cea899fe8..7d9c91c5b 100644 --- a/lib/module.c +++ b/lib/module.c @@ -54,13 +54,9 @@ static void *load_symbol(void *lib, const char *prefix, const char *name) static int load_library(struct kr_module *module, const char *name, const char *path) { + assert(module && name && path); /* Absolute or relative path (then only library search path is used). */ - auto_free char *lib_path = NULL; - if (path != NULL) { - lib_path = kr_strcatdup(4, path, "/", name, LIBEXT); - } else { - lib_path = kr_strcatdup(2, name, LIBEXT); - } + auto_free char *lib_path = kr_strcatdup(4, path, "/", name, LIBEXT); if (lib_path == NULL) { return kr_error(ENOMEM); } @@ -131,7 +127,7 @@ int kr_module_load(struct kr_module *module, const char *name, const char *path) } /* Search for module library, use current namespace if not found. */ - if (load_library(module, name, path) != 0) { + if (!path || load_library(module, name, path) != 0) { if (load_library(module, name, MODULEDIR) != 0) { module->lib = RTLD_DEFAULT; } -- 2.47.2