Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 May 2005 02:55:10 +0000
From:      Alexander Kabaev <kan@freebsd.org>
To:        Jeff Roberson <jroberson@chesapeake.net>
Cc:        arch@freebsd.org
Subject:   Re: printflike vs kprintflike
Message-ID:  <20050505025509.GA3120@freefall.freebsd.org>
In-Reply-To: <20050504180112.M18611@mail.chesapeake.net>
References:  <20050504180112.M18611@mail.chesapeake.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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?


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.  */
+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
@@ -785,9 +786,9 @@
      ("%6D", ptr, ":")		-> XX:XX:XX:XX:XX:XX
      ("%*D", len, ptr, " ")	-> XX XX XX XX ...
    */
-  { "D",   1, STD_EXT, { T89_C,  BADLEN,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      "cR" },
-  { "b",   1, STD_EXT, { T89_C,  BADLEN,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      ""   },
-  { "ry",  0, STD_EXT, { T89_I,  BADLEN,   BADLEN,   T89_L,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp0 +#",  "i"  },
+  { "D",   1, STD_BSD, { T89_C,  BADLEN,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      "cR" },
+  { "b",   1, STD_BSD, { T89_C,  BADLEN,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      ""   },
+  { "ry",  0, STD_BSD, { T89_I,  BADLEN,   BADLEN,   T89_L,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp0 +#",  "i"  },
   { NULL,  0, 0, NOLENGTHS, NULL, NULL }
 };
 
@@ -2091,7 +2092,8 @@
       format_chars++;
       fci = fki->conversion_specs;
       while (fci->format_chars != 0
-	     && strchr (fci->format_chars, format_char) == 0)
+	     && (strchr (fci->format_chars, format_char) == 0 ||
+	        (!flag_format_extensions && fci->std == STD_BSD)))
 	  ++fci;
       if (fci->format_chars == 0)
 	{
Index: c-opts.c
===================================================================
RCS file: /home/ncvs/src/contrib/gcc/c-opts.c,v
retrieving revision 1.2
diff -u -r1.2 c-opts.c
--- c-opts.c	29 Jul 2004 02:04:58 -0000	1.2
+++ c-opts.c	5 May 2005 02:41:26 -0000
@@ -1047,6 +1047,7 @@
       break;
 
     case OPT_fformat_extensions:
+      flag_format_extensions = value;
       break;
     }
 



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