Explanation can be found in the dlsym() man page: ... the correct way to test for an error is to call dlerror() to clear any old error conditions, then call dlsym(), and then call dlerror() again, saving its return value into a variable, and check whether this saved value is not NULL.
Signed-off-by: Luka Perkov <[email protected]> --- plugin.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin.c b/plugin.c index 687944d..5e7a1ea 100644 --- a/plugin.c +++ b/plugin.c @@ -412,15 +412,17 @@ rpc_plugin_register_library(struct ubus_context *ctx, const char *path) { struct rpc_plugin *p; void *dlh; + char *err; dlh = dlopen(path, RTLD_LAZY | RTLD_GLOBAL); if (!dlh) return UBUS_STATUS_UNKNOWN_ERROR; - p = dlsym(dlh, "rpc_plugin"); + dlerror(); + p = (struct rpc_plugin *) dlsym(dlh, "rpc_plugin"); - if (!p) + if ((err = dlerror()) != NULL) return UBUS_STATUS_NOT_FOUND; list_add(&p->list, &plugins); -- 1.8.5.3 _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
