public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] param: add null statement to compiled-in module params
@ 2011-01-05 12:27 Linus Walleij
  2011-01-16 23:41 ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2011-01-05 12:27 UTC (permalink / raw)
  To: Rusty Russell, linux-kernel; +Cc: Linus Walleij, Dan Carpenter

Add an unused struct declaration statement requiring a
terminating semicolon to the compile-in case to provoke an
error if __MODULE_INFO() is used without the terminating
semicolon. Previously MODULE_ALIAS("foo") (no semicolon)
compiled fine if MODULE was not selected.

Cc: Dan Carpenter <error27@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
More clever solutions appreciated, this thing works.
---
 include/linux/moduleparam.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 112adf8..07b4195 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -16,15 +16,17 @@
 /* Chosen so that structs with an unsigned long line up. */
 #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
 
-#ifdef MODULE
 #define ___module_cat(a,b) __mod_ ## a ## b
 #define __module_cat(a,b) ___module_cat(a,b)
+#ifdef MODULE
 #define __MODULE_INFO(tag, name, info)					  \
 static const char __module_cat(name,__LINE__)[]				  \
   __used __attribute__((section(".modinfo"), unused, aligned(1)))	  \
   = __stringify(tag) "=" info
 #else  /* !MODULE */
-#define __MODULE_INFO(tag, name, info)
+/* This struct is here for syntactic coherency, it is not used */
+#define __MODULE_INFO(tag, name, info)					  \
+  struct __module_cat(name,__LINE__) {}
 #endif
 #define __MODULE_PARM_TYPE(name, _type)					  \
   __MODULE_INFO(parmtype, name##type, #name ":" _type)
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] param: add null statement to compiled-in module params
  2011-01-05 12:27 [PATCH] param: add null statement to compiled-in module params Linus Walleij
@ 2011-01-16 23:41 ` Rusty Russell
  2011-01-17  8:12   ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2011-01-16 23:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel, Dan Carpenter

On Wed, 5 Jan 2011 10:57:04 pm Linus Walleij wrote:
> Add an unused struct declaration statement requiring a
> terminating semicolon to the compile-in case to provoke an
> error if __MODULE_INFO() is used without the terminating
> semicolon. Previously MODULE_ALIAS("foo") (no semicolon)
> compiled fine if MODULE was not selected.

I really prefer the other way; make everyone use a semicolon.

Let's look how many we're talking about... hmm, I'm having
trouble finding any!

Could you patch this the other way, to make MODULE_ALIAS w/o a
semicolon always an error?

Thanks,
Rusty.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] param: add null statement to compiled-in module params
  2011-01-16 23:41 ` Rusty Russell
@ 2011-01-17  8:12   ` Linus Walleij
  2011-01-18  1:09     ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2011-01-17  8:12 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel@vger.kernel.org, Dan Carpenter

On 01/17/2011 12:41 AM, Rusty Russell wrote:
> On Wed, 5 Jan 2011 10:57:04 pm Linus Walleij wrote:
>    
>> Add an unused struct declaration statement requiring a
>> terminating semicolon to the compile-in case to provoke an
>> error if __MODULE_INFO() is used without the terminating
>> semicolon. Previously MODULE_ALIAS("foo") (no semicolon)
>> compiled fine if MODULE was not selected.
>>      
> I really prefer the other way; make everyone use a semicolon.
>    

That's what it does. Currently the kernel allows you to
write MODULE_ALIAS("bar") sans semicolon if you
compile in the module statically...

Or am I getting things wrong?

> Let's look how many we're talking about... hmm, I'm having
> trouble finding any!
>    

There is no module in the kernel doing this, but I
had the issue in the merge window (and fixed it up),
this is to help developers not doing that mistake
again.

> Could you patch this the other way, to make MODULE_ALIAS w/o a
> semicolon always an error?
>    

This is what the patch does... after the patch the
MODULE_ALIAS("foo") without semicolon will throw
a compilation error also on statically linked modules.

Currently it doesn't...

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] param: add null statement to compiled-in module params
  2011-01-17  8:12   ` Linus Walleij
@ 2011-01-18  1:09     ` Rusty Russell
  0 siblings, 0 replies; 4+ messages in thread
From: Rusty Russell @ 2011-01-18  1:09 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel@vger.kernel.org, Dan Carpenter

On Mon, 17 Jan 2011 06:42:13 pm Linus Walleij wrote:
> On 01/17/2011 12:41 AM, Rusty Russell wrote:
> > On Wed, 5 Jan 2011 10:57:04 pm Linus Walleij wrote:
> >    
> >> Add an unused struct declaration statement requiring a
> >> terminating semicolon to the compile-in case to provoke an
> >> error if __MODULE_INFO() is used without the terminating
> >> semicolon. Previously MODULE_ALIAS("foo") (no semicolon)
> >> compiled fine if MODULE was not selected.
> >>      
> > I really prefer the other way; make everyone use a semicolon.
> >    
> 
> That's what it does. Currently the kernel allows you to
> write MODULE_ALIAS("bar") sans semicolon if you
> compile in the module statically...
> 
> Or am I getting things wrong?

No, I was.  Sorry, I should read more carefully.

Applied, thanks!
Rusty.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-18  1:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-05 12:27 [PATCH] param: add null statement to compiled-in module params Linus Walleij
2011-01-16 23:41 ` Rusty Russell
2011-01-17  8:12   ` Linus Walleij
2011-01-18  1:09     ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox