tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: KASSERTMSG fix



On 07.09.2011 17:02, Joerg Sonnenberger wrote:
> On Wed, Sep 07, 2011 at 04:54:05PM +0200, Jean-Yves Migeon wrote:
>> The attached patch takes care of this; it does not really "append" the
>> msg to the panic string (so it won't be available via panicstr like
>> before), but now KASSERTMSG() will print the additional info.
> 
> I'm not sure I like the approach. I would prefer to introduce a second
> panic() function with explicit file/line number / function argument.
> panic() itself could be replaced by a macro calling that new verbose
> panic function, maybe under an option.

Hmm. This is generally done via the fmt string of panic(9). Someone
could also ask to have explicit timestamping and function name, the
"verbose panic" prototype will become rapidly ugly...

> I think it is time for KASSERTMSG and friends to just adopt C99 variadic
> macros with the associated dropping of a pair of (). That involves more
> code churn though.

I did not propose this for this reason: I can fix all the KASSERTMSG()
uses in src, but not those outside the tree. And I expect that most
compile time warnings here won't make much sense once the macro gets
changed.

This can work around the limitations elegantly though (provided all call
sites are fixed):

#define KASSERTMSG(e, fmt, ...) do {            \
  panic(                                        \
    "kernel diag assert \"%s\" failed: file \"%s\", line %d; " fmt, \
    #e, __FILE__, __LINE__, ## __VA_ARGS__);    \
} while(0)

But do all compilers used with NetBSD support variadic macros?

-- 
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost


Home | Main Index | Thread Index | Old Index