lkml.org 
[lkml]   [2000]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [idea] request_module(const char *fmt, ...);
On Fri, Jan 14, 2000 at 01:16:53PM +0100, willy tarreau wrote:
> Hi guys,
>
> I think I have a solution to the variable-length macro
> :
>
> if you define an empty macro for request_module, this
> line :
>
> request_module("blah","blah2","foobar");
>
> will be converted to :
>
> ("blah","blah2","foobar");
>
> which is treated by the compiler as useless code and
> will no even generate one byte of code.
But gives a warning?

Better to do it like this:

-------------------
#include <stdio.h>
#include <errno.h>
#include <stdarg.h>

#ifndef ENABLE
#define request_module(fmt,rest...) ({-EINVAL;})
#else
int request_module(char* fmt, ...)
{
char buf[1024];
va_list ap;
va_start(ap,fmt);
vsprintf(buf,fmt,ap);
va_end(ap);

return 0;
}
#endif
--------------------

When enable is off, request_module resolves to a nice constant
value, which may or may not be used in the an if() construct.
If enabled, we build the proper string and do the old
request_module() thing

However, this still implies a recompile of all files containing
CONFIG_KMOD...
(Which I frankly dont care about; it happens to infreqently to
worry about)

Met vriendelijke groet,
Pauline Middelink
--
PGP Key fingerprint = DE 6B D0 D9 19 AD A7 A0 58 A3 06 9D B6 34 39 E2
For more details look at my website http://www.polyware.nl/~middelink

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.158 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site