[coreboot] [PATCH] Check the printk format string against the arguments

Uwe Hermann uwe at hermann-uwe.de
Tue Jan 6 01:03:41 CET 2009

On Mon, Jan 05, 2009 at 02:03:04PM +0100, Carl-Daniel Hailfinger wrote:
> Check the printk format string against the matching arguments. We have
> this type of checking in the v3 code since ages, but v2 will happily
> compile any code with bogus printk format strings and/or parameters.
> This can cause real bugs and at least needs to emit a warning, if not an
> error. Go with a warning for now since most of the flagged format
> strings are wrong but harmless in a 32-bit x86 environment.
> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

If this is abuild-tested, it's:

Acked-by: Uwe Hermann <uwe at hermann-uwe.de>

(Please make sure we don't get some romcc compile trouble because of
the __attribute__)

> Index: LinuxBIOSv2-printk_format/src/include/console/console.h
> ===================================================================
> --- LinuxBIOSv2-printk_format/src/include/console/console.h	(Revision 3845)
> +++ LinuxBIOSv2-printk_format/src/include/console/console.h	(Arbeitskopie)
> @@ -27,7 +27,7 @@
>  extern struct console_driver econsole_drivers[];
>  extern int console_loglevel;
> -int do_printk(int msg_level, const char *fmt, ...);
> +int do_printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
>  #define printk_emerg(fmt, arg...)   do_printk(BIOS_EMERG   ,fmt, ##arg)
>  #define printk_alert(fmt, arg...)   do_printk(BIOS_ALERT   ,fmt, ##arg)

http://www.hermann-uwe.de  | http://www.holsham-traders.de
http://www.crazy-hacks.org | http://www.unmaintained-free-software.org

More information about the coreboot mailing list