From 2c3f0bb207f89f0347a4a84a8cde57e979f33896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 8 Oct 2017 16:18:57 +0200 Subject: [PATCH] kmod_module_probe_insert_module returns 0 on success, != 0 on failure More specifically, it should return > 0 only for conditions specified in probe_flags. We only set KMOD_PROBE_APPLY_BLACKLIST in probe_flags, so the code was correct, but add an assert to clarify this. --- src/modules-load/modules-load.c | 5 +++-- src/test/test-netlink-manual.c | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index 1cb9001c397..c1a89cf822a 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -118,8 +118,9 @@ static int load_module(struct kmod_ctx *ctx, const char *m) { else if (err == KMOD_PROBE_APPLY_BLACKLIST) log_info("Module '%s' is blacklisted", kmod_module_get_name(mod)); else { - log_error_errno(err, "Failed to insert '%s': %m", kmod_module_get_name(mod)); - r = err; + assert(err < 0); + r = log_error_errno(err, "Failed to insert '%s': %m", + kmod_module_get_name(mod)); } } } diff --git a/src/test/test-netlink-manual.c b/src/test/test-netlink-manual.c index f0471cf04ee..ce1c1c0b191 100644 --- a/src/test/test-netlink-manual.c +++ b/src/test/test-netlink-manual.c @@ -41,7 +41,7 @@ static int load_module(const char *mod_name) { r = kmod_module_new_from_lookup(ctx, mod_name, &list); if (r < 0) - return -1; + return r; kmod_list_foreach(l, list) { _cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL; @@ -49,10 +49,8 @@ static int load_module(const char *mod_name) { mod = kmod_module_get_module(l); r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); - if (r >= 0) - r = 0; - else - r = -1; + if (r > 0) + r = -EINVAL; } return r;