[Linux-ha-dev] [RFC] Suggested cleanups & improvements to the
STONITH code base
Alan Robertson
alanr at unix.sh
Tue Oct 5 11:09:10 MDT 2004
Alan Robertson wrote:
> Alan Robertson wrote:
>
>> Lars Marowsky-Bree wrote:
>>
>>> So, instead of just ranting I want to actually fix things.
>>
>>
>>
>> The thought is appreciated, but when you make changes to the code,
>> please make sure they compile.
>>
>> I suspect you didn't commit some fix or another.
>>
>> The getws script is highly recommend for finding these kinds of problems.
>
>
> AND, it appears that you probably undid a bunch of work gshi had done to
> fix up the logging corectly.
>
> Do NOT call PluginImports->log directly. There is a VERY good reason
> why gshi changed it to call PilCallLog() everywhere instead.
>
> It was not an accident or a fluke that he made these changes so
> consistently.
>
> He changed it everywhere because when you call a function pointer, gcc
> will not check for arguments matching the format string. You cannot
> apply that funky attribute to function pointers - only real functions
> (extern, inline or static).
I guess I messed up on this one, because I saw the definitions in other
functions.
HOWEVER, the #define you used is not standard C.
But, since nothing compiles at the moment, it's impossible to really check
on other platforms...
#define LOG(w...) PILCallLog(PluginImports->log, w)
I believe that this is a gcc-ism. Here is the corresponding information
from 'info gcc' which agrees with this assessment:
-------------------------------------------------------------------
Macros with a Variable Number of Arguments.
===========================================
In the ISO C standard of 1999, a macro can be declared to accept a
variable number of arguments much as a function can. The syntax for
defining the macro is similar to that of a function. Here is an
example:
#define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
Here `...' is a "variable argument". In the invocation of such a
macro, it represents the zero or more tokens until the closing
parenthesis that ends the invocation, including any commas. This set of
tokens replaces the identifier `__VA_ARGS__' in the macro body wherever
it appears. See the CPP manual for more information.
GCC has long supported variadic macros, and used a different syntax
that allowed you to give a name to the variable arguments just like any
other argument. Here is an example:
#define debug(format, args...) fprintf (stderr, format, args)
This is in all ways equivalent to the ISO C example above, but
arguably more readable and descriptive.
GNU CPP has two further variadic macro extensions, and permits them
to be used with either of the above forms of macro definition.
-------------------------------------------------
Can some of you Solaris and BSD check and see if this works on your platform?
--
Alan Robertson <alanr at unix.sh>
"Openness is the foundation and preservative of friendship... Let me claim
from you at all times your undisguised opinions." - William Wilberforce
More information about the Linux-HA-Dev
mailing list