module: Fix ERRORs reported by checkpatch.pl
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Mon, 13 Jun 2022 06:02:01 +0000 (08:02 +0200)
committerLuis Chamberlain <mcgrof@kernel.org>
Mon, 11 Jul 2022 17:49:14 +0000 (10:49 -0700)
Checkpatch reports following errors:

ERROR: do not use assignment in if condition
+ if ((colon = strnchr(name, MODULE_NAME_LEN, ':')) != NULL) {

ERROR: do not use assignment in if condition
+ if ((mod = find_module_all(name, colon - name, false)) != NULL)

ERROR: do not use assignment in if condition
+ if ((ret = find_kallsyms_symbol_value(mod, name)) != 0)

ERROR: do not initialise globals to 0
+int modules_disabled = 0;

Fix them.

The following one has to remain, because the condition has to be evaluated
multiple times by the macro wait_event_interruptible_timeout().

ERROR: do not use assignment in if condition
+ if (wait_event_interruptible_timeout(module_wq,

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
kernel/module/kallsyms.c
kernel/module/main.c

index 77e75bead5698c3ffe86d0a4a991543484ff2c69..6a74545fc8a160a9640ac5f4151ccfb2ef162e77 100644 (file)
@@ -466,14 +466,17 @@ unsigned long module_kallsyms_lookup_name(const char *name)
 
        /* Don't lock: we're in enough trouble already. */
        preempt_disable();
-       if ((colon = strnchr(name, MODULE_NAME_LEN, ':')) != NULL) {
-               if ((mod = find_module_all(name, colon - name, false)) != NULL)
+       colon = strnchr(name, MODULE_NAME_LEN, ':');
+       if (colon) {
+               mod = find_module_all(name, colon - name, false);
+               if (mod)
                        ret = find_kallsyms_symbol_value(mod, colon + 1);
        } else {
                list_for_each_entry_rcu(mod, &modules, list) {
                        if (mod->state == MODULE_STATE_UNFORMED)
                                continue;
-                       if ((ret = find_kallsyms_symbol_value(mod, name)) != 0)
+                       ret = find_kallsyms_symbol_value(mod, name);
+                       if (ret)
                                break;
                }
        }
index 07dd9c293ab9c380ad8f14d4992e537a1ca9ca02..b2de00e09abcf9beedf3354238737000bd6e1236 100644 (file)
@@ -119,7 +119,7 @@ static void mod_update_bounds(struct module *mod)
 }
 
 /* Block module loading/unloading? */
-int modules_disabled = 0;
+int modules_disabled;
 core_param(nomodule, modules_disabled, bint, 0);
 
 /* Waiting for a module to finish initializing? */