printk-wrapper with sectionized string constants [was: Re: [RFC, PATCH] watchdog on gpio]

From: Johannes Weiner
Date: Mon Jan 14 2008 - 08:56:44 EST


Hi,

"Mike Frysinger" <vapier.adi@xxxxxxxxx> writes:
>> How about:
>>
>> #define init_printk(fmt, args...) ({ \
>> static const __init char __fmt[] = fmt; \
>> printk(__fmt, args); \
>> })
>>
>> Now it returns the printk result.
>
> i wasnt really worried about that ... i was worried about other random
> things i may have missed

Ok.

> your dropping of ## wont work as you need gcc to expand args and take
> away the , in the simple 1 arg case:
> init_printk("MOO");

Whoops, totally oversaw this one. Of course, this must be in.

Perhaps an even more generic solution would be good, like this:

#define section_printk(sect, fmt, args...) ({ \
static const sect char __fmt[] = fmt; \
printk(__fmt, ## args); \
})

And then just have convenience wrappers like {,dev}init_printk, ... etc.

Can someone please shout at us if there is a fundamental problem with
this approach?

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