From 61e32eb07f64933983765393676c9db2e0546df7 Mon Sep 17 00:00:00 2001 From: Frank Benkstein Date: Sun, 30 Sep 2007 21:47:18 +0200 Subject: [PATCH] src/plugins.c: change error handling of __load_plugin --- src/plugins.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/plugins.c b/src/plugins.c index 61f1da4..0923355 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "plugins.h" @@ -114,37 +115,30 @@ static struct plugin *get_plugin(const char *name) return NULL; } -/* Load and return the named plugin. Aborts on error. */ +/* Load and return the named plugin. */ static struct plugin *__load_plugin(const char *name) { - char *e1 = NULL; - char *e2 = NULL; struct plugin *p = get_plugin(name); if (p != NULL) return p; - p = open_module(name, &e1); + /* Try to open a module first. */ + p = open_module(name); - if (p == NULL) - p = open_script(name, &e2); + if (p != NULL) + goto success; - if (p == NULL) { - if (e1 == NULL && e2 == NULL) - fatal_error("vlock-plugins: error loading plugin '%s'", name); + if (errno != ENOENT) + return NULL; - if (e1 != NULL) { - fprintf(stderr, "vlock-plugins: error loading module '%s': %s\n", name, e1); - free(e1); - } - if (e2 != NULL) { - fprintf(stderr, "vlock-plugins: error loading script '%s': %s\n", name, e2); - free(e2); - } + /* Now try to open a script. */ + p = open_script(name); - abort(); - } + if (p == NULL) + return NULL; +success: list_append(plugins, p); return p; } -- 2.11.4.GIT