]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: remove the "Ugly assignment + check."
authorEmil Velikov <emil.l.velikov@gmail.com>
Fri, 6 Sep 2024 21:48:40 +0000 (22:48 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 9 Sep 2024 04:22:38 +0000 (23:22 -0500)
Check if the module is blacklisted first and then perform the individual
flag checks. As result drop the no-longer needed comment.

This might be a dozen CPU cycles slower, but overall clarity triumphs.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/112
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-module.c

index 1d50df03f37c076435c99b3311ded2942ce34f27..10e58cee4451208603fb6a4c4a9033d447f94688 100644 (file)
@@ -1072,17 +1072,15 @@ KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod,
                        return 0;
        }
 
-       /*
-        * Ugly assignment + check. We need to check if we were told to check
-        * blacklist and also return the reason why we failed.
-        * KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY will take effect only if the
-        * module is an alias, so we also need to check it
-        */
-       if ((mod->alias != NULL && ((err = flags & KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY)))
-                       || (err = flags & KMOD_PROBE_APPLY_BLACKLIST_ALL)
-                       || (err = flags & KMOD_PROBE_APPLY_BLACKLIST)) {
-               if (module_is_blacklisted(mod))
-                       return err;
+       if (module_is_blacklisted(mod)) {
+               if (mod->alias != NULL && (flags & KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY))
+                       return KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY;
+
+               if (flags & KMOD_PROBE_APPLY_BLACKLIST_ALL)
+                       return KMOD_PROBE_APPLY_BLACKLIST_ALL;
+
+               if (flags & KMOD_PROBE_APPLY_BLACKLIST)
+                       return KMOD_PROBE_APPLY_BLACKLIST;
        }
 
        err = kmod_module_get_probe_list(mod,