diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-netlink-manual.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/test/test-netlink-manual.c b/src/test/test-netlink-manual.c index bc6dd0926c..ce1c1c0b19 100644 --- a/src/test/test-netlink-manual.c +++ b/src/test/test-netlink-manual.c @@ -26,38 +26,33 @@ #include "sd-netlink.h" #include "macro.h" +#include "module-util.h" #include "util.h" static int load_module(const char *mod_name) { - struct kmod_ctx *ctx; - struct kmod_list *list = NULL, *l; + _cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL; + _cleanup_(kmod_module_unref_listp) struct kmod_list *list = NULL; + struct kmod_list *l; int r; ctx = kmod_new(NULL, NULL); - if (!ctx) { - kmod_unref(ctx); - return -ENOMEM; - } + if (!ctx) + return log_oom(); r = kmod_module_new_from_lookup(ctx, mod_name, &list); if (r < 0) - return -1; + return r; kmod_list_foreach(l, list) { - struct kmod_module *mod = kmod_module_get_module(l); + _cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL; - r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); - if (r >= 0) - r = 0; - else - r = -1; + mod = kmod_module_get_module(l); - kmod_module_unref(mod); + r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); + if (r > 0) + r = -EINVAL; } - kmod_module_unref_list(list); - kmod_unref(ctx); - return r; } |