From owner-freebsd-arch@FreeBSD.ORG Thu May 5 02:56:12 2005 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8F2D516A4CE for ; Thu, 5 May 2005 02:56:12 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id F2E9743D39; Thu, 5 May 2005 02:56:11 +0000 (GMT) (envelope-from kan@FreeBSD.org) Received: from freefall.freebsd.org (kan@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j452tAXp003181; Thu, 5 May 2005 02:55:10 GMT (envelope-from kan@freefall.freebsd.org) Received: (from kan@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j452tASC003180; Thu, 5 May 2005 02:55:10 GMT (envelope-from kan) Date: Thu, 5 May 2005 02:55:10 +0000 From: Alexander Kabaev To: Jeff Roberson Message-ID: <20050505025509.GA3120@freefall.freebsd.org> References: <20050504180112.M18611@mail.chesapeake.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050504180112.M18611@mail.chesapeake.net> User-Agent: Mutt/1.4.2.1i cc: arch@freebsd.org Subject: Re: printflike vs kprintflike X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2005 02:56:12 -0000 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; }