Skip to contentSkip to conversation

init: fix the wrong __setup_param() definition

PATCH In review Yajun Deng 2 participants 3 messages Dec 20, 2021 – Dec 21, 2021

lore
Share & tools
lore

Yajun Deng

author
#0 lore raw

PATCH 1/1 init: fix the wrong __setup_param() definition

The parameters in __setup_param() should be four rather than three when MODULE isn't definited.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 include/linux/init.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/init.h +1 -1
index d82b4b2e1d25..62a77850f10e 100644
@@ -355,7 +355,7 @@ void __init parse_early_options(char *cmdline);
 
 #else /* MODULE */
 
-#define __setup_param(str, unique_id, fn)	/* nothing */
+#define __setup_param(str, unique_id, fn, early)/* nothing */
 #define __setup(str, func) 			/* nothing */
 #endif
 
Signature · 1 line
2.32.0
#1 lore raw
Quoted 3 lines · Yajun Deng

The parameters in __setup_param() should be four rather than three when MODULE isn't definited.

This is actually "when MODULE is defined". __setup_param() becomes a nop when compiling as a module.

But that begs the question: why hasn't this been caught before? Probably because nobody should be using __setup_param() if something can also be compiled as a module, in which case module_param() and friends should be used. But perhaps there are valid usecases where i t's meant to become a nop if MODULE.

I don't object this fix, since the !MODULE __setup_param() seems like it was meant to be defined.

Just curious: did you actually encounter a problem with some new code using __setup_param()?

Quoted 22 lines
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 include/linux/init.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/init.h +1 -2
index d82b4b2e1d25..62a77850f10e 100644
@@ -355,7 +355,7 @@ void __init parse_early_options(char *cmdline);
 
 #else /* MODULE */
 
-#define __setup_param(str, unique_id, fn)      /* nothing */
+#define __setup_param(str, unique_id, fn, early)/* nothing */
 #define __setup(str, func)                     /* nothing */
 #endif
 
--

2.32.0

#2 lore raw
Quoted 14 lines · Marco Elver
Quoted 2 lines · Yajun Deng

The parameters in __setup_param() should be four rather than three when MODULE isn't definited.

This is actually "when MODULE is defined". __setup_param() becomes a nop when compiling as a module.

But that begs the question: why hasn't this been caught before? Probably because nobody should be using __setup_param() if something can also be compiled as a module, in which case module_param() and friends should be used. But perhaps there are valid usecases where i t's meant to become a nop if MODULE.

Quoted 5 lines

I don't object this fix, since the !MODULE __setup_param() seems like it was meant to be defined.

Just curious: did you actually encounter a problem with some new code using __setup_param()?

NO, it is just code inspection. But for the current code, it's really a bug. vim drivers/clk/imx/clk.c +161

#ifndef MODULE

...
__setup_param("earlycon", imx_keep_uart_earlycon,

              imx_keep_uart_clocks_param, 0); 
__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
              imx_keep_uart_clocks_param, 0); 
Quoted 22 lines
Quoted 22 lines
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

---
include/linux/init.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/init.h +1 -2
index d82b4b2e1d25..62a77850f10e 100644
@@ -355,7 +355,7 @@ void __init parse_early_options(char *cmdline);
 
 #else /* MODULE */
 
-#define __setup_param(str, unique_id, fn) /* nothing */
+#define __setup_param(str, unique_id, fn, early)/* nothing */
 #define __setup(str, func) /* nothing */
 #endif
 
--

2.32.0