]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kmod_module_probe_insert_module returns 0 on success, != 0 on failure
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 8 Oct 2017 14:18:57 +0000 (16:18 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 8 Oct 2017 20:29:32 +0000 (22:29 +0200)
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
src/test/test-netlink-manual.c

index 1cb9001c3973cd8782b39047219a31518235bb87..c1a89cf822a0d08aa54dadcbffbad052424f9414 100644 (file)
@@ -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));
                         }
                 }
         }
index f0471cf04ee2c81f4a0db380dd2ce57757b2e5bb..ce1c1c0b191c838fe6495188a3a684bb4fe5bea2 100644 (file)
@@ -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;