Re: [patch 1/7] BSD Secure Levels: printk overhaul

From: Bernd Petrovitsch
Date: Thu May 19 2005 - 05:43:10 EST


On Wed, 2005-05-18 at 18:29 -0700, Dave Hansen wrote:
> On Tue, 2005-05-17 at 10:23 -0500, Michael Halcrow wrote:
[...]
> > @@ -198,15 +196,15 @@
> > static int seclvl_sanity(int reqlvl)
> > {
> > if ((reqlvl < -1) || (reqlvl > 2)) {
> > - seclvl_printk(1, KERN_WARNING, "Attempt to set seclvl out of "
> > - "range: [%d]\n", reqlvl);
> > + seclvl_printk(1, KERN_WARNING "%s: Attempt to set seclvl out "
> > + "of range: [%d]\n", __FUNCTION__, reqlvl);
>
> Instead of changing each and every seclvl_printk() call to add
> __FUNCTION__, why not do this:
>
> +static void __seclvl_printk(int verb, const char *fmt, ...)
> ...
>
> #define seclvl_printk(verb, fmt, arg...) \
> __seclvl_printk(verb, __FUNCTION__ ": " fmt, arg)
>
> It requires that the fmt be a string literal, but it saves a lot of code
> duplication. I'm sure there are some more examples of this around as

And it duplicates identical format strings in different functions
(besides violating another unwritten rule). What about:
---- snip ----
#define seclvl_printk(verb, fmt, arg...) \
__seclvl_printk((verb), "%s: " fmt, __FUNCTION__, arg)
---- snip ----

Bernd
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services




-
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/