Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 May 2005 19:04:21 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Alexander Kabaev <kan@freebsd.org>
Cc:        arch@freebsd.org
Subject:   Re: printflike vs kprintflike
Message-ID:  <20050505184727.A1664@epsplex.bde.org>
In-Reply-To: <20050505025509.GA3120@freefall.freebsd.org>
References:  <20050504180112.M18611@mail.chesapeake.net> <20050505025509.GA3120@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 5 May 2005, Alexander Kabaev wrote:

> On Wed, May 04, 2005 at 06:16:06PM -0400, Jeff Roberson wrote:
>> I have a patch from Neal Fachan of isilon that implements a new gcc
>> attribute 'kprintflike' that is used in place of 'printflike' in the
>> kernel.  This is done to stop us from leaking kernel printf formats into
>> userspace.  Apparently -fformat-extensions is broken in gcc3.  This also
>> stops our formats from leaking into any other custom formats defined in
>> gcc.
>>
>
> I would like to avoid introduction of a new printf attribute if possible.
> Does fixed -fformat-extensions suffice your needs? If so, can you try the
> patch below instead?

-fformat-extensions was intended for this.

> Index: c-common.h
> ===================================================================
> RCS file: /home/ncvs/src/contrib/gcc/c-common.h,v
> retrieving revision 1.7
> diff -u -r1.7 c-common.h
> --- c-common.h	28 Jul 2004 03:46:02 -0000	1.7
> +++ c-common.h	5 May 2005 02:45:10 -0000
> @@ -840,6 +840,9 @@
> /* Nonzero means the expression being parsed will never be evaluated.
>    This is a count, since unevaluated expressions can nest.  */
>
> +/* Nonzero allows FreeBSD kenrel-specific printf formats.  */

Spelling.

> +extern int flag_format_extensions;
> +
> extern int skip_evaluation;
>
> /* C types are partitioned into three subsets: object, function, and
> Index: c-format.c
> ===================================================================
> RCS file: /home/ncvs/src/contrib/gcc/c-format.c,v
> retrieving revision 1.9
> diff -u -r1.9 c-format.c
> --- c-format.c	28 Jul 2004 03:57:21 -0000	1.9
> +++ c-format.c	5 May 2005 02:33:31 -0000
> @@ -257,7 +257,8 @@
>   STD_C94,
>   STD_C9L, /* C99, but treat as C89 if -Wno-long-long.  */
>   STD_C99,
> -  STD_EXT
> +  STD_EXT,
> +  STD_BSD
> };
>
> /* The C standard version C++ is treated as equivalent to

-fformat-extensions was also intended to unextend (sic) to the formats
that are actually supported by the kernel printf.  I never got around
to implementing this.  It is now easier to implement, but not as easy
as it should be (the enums in the above should be bitmaps ...).  The
kernel printf doesn't support floating point formats, at least, and
shouldn't support mistakes like %q and %ll.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050505184727.A1664>