tech-kern archive

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

Re: KASSERTMSG fix



On 07.09.2011 20:56, David Laight wrote:
>>> #define KASSERTMSG(e, fmt, ...) do {            \
>>>   panic(                                        \
>>>     "kernel diag assert \"%s\" failed: file \"%s\", line %d; " fmt, \
>>>     #e, __FILE__, __LINE__, ## __VA_ARGS__);    \
>>> } while(0)
>>
>> That assumes that fmt is a string literal. I don't think it is easier
>> than:
>>
>> panic_verbose(__FILE__, __LINE__, #e, fmt, ##__VA_ARGS__);
> 
> The latter has the advantage that the string for __FILE__ will
> only occur once in the object file.

Yep; the big downside with the fmt as string literal is that it can
inflate the code by a good margin for no real purpose -- it creates a
string for each KASSERTMSG().

I can't think of another approach, we have two candidates for variable
argument lists: "msg" from KASSERTMSG(), and panic(9) itself. And I am
not aware of a solution where you can have two "..." in a C function.

Other possible solutions are either the ones that involve a more
"featureful" panic_verbose(9) function, but that will still be
incomplete unless designed specifically for this use case. Lots of code
churn for little gain?

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


Home | Main Index | Thread Index | Old Index