From owner-svn-src-head@freebsd.org Wed May 3 20:51:33 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8DF5ED5C5C4; Wed, 3 May 2017 20:51:33 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 2237889F; Wed, 3 May 2017 20:51:32 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-153-191.carlnfd1.nsw.optusnet.com.au [122.106.153.191]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id 859B31A5727; Thu, 4 May 2017 06:51:23 +1000 (AEST) Date: Thu, 4 May 2017 06:51:20 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Eric van Gyzen cc: Alan Somers , Warner Losh , Ngie Cooper , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r317755 - head/sbin/ifconfig In-Reply-To: Message-ID: <20170504062448.U1383@besplex.bde.org> References: <201705031721.v43HL2vS071819@repo.freebsd.org> <8EA7A2E9-A429-4DC2-85CE-1B5AAEDF86FD@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=AYLBJzfG c=1 sm=1 tr=0 a=Tj3pCpwHnMupdyZSltBt7Q==:117 a=Tj3pCpwHnMupdyZSltBt7Q==:17 a=kj9zAlcOel0A:10 a=7Qk2ozbKAAAA:8 a=6I5d2MoRAAAA:8 a=pGLkceISAAAA:8 a=I-FlVkIS5AL8CeXa67wA:9 a=CjuIK1q_8ugA:10 a=1lyxoWkJIXJV6VJUPhuM:22 a=IjZwj45LgO3ly-622nXo:22 a=6kGIvZw6iX1k4Y-7sg4_:22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 May 2017 20:51:33 -0000 On Wed, 3 May 2017, Eric van Gyzen wrote: > On 05/03/2017 14:38, Alan Somers wrote: >> On Wed, May 3, 2017 at 1:34 PM, Warner Losh wrote: >>> On Wed, May 3, 2017 at 1:32 PM, Alan Somers wrote: >>>> On Wed, May 3, 2017 at 12:16 PM, Ngie Cooper wrote: >>>>> >>>>>> On May 3, 2017, at 10:21, Alan Somers wrote: >>>>>> >>>>>> Author: asomers >>>>>> Date: Wed May 3 17:21:01 2017 >>>>>> New Revision: 317755 >>>>>> URL: https://svnweb.freebsd.org/changeset/base/317755 >>>>>> >>>>>> Log: >>>>>> Various Coverity fixes in ifconfig(8) >>>>> >>>>> ... >>>>> >>>>>> * Mark usage() as _Noreturn (1305806, 1305750) >>>>> >>>>> ... >>>>> >>>>>> -static void usage(void); >>>>>> +static void usage(void) _Noreturn; >>>>> >>>>> Hi Alan, >>>>> Please use __dead2 instead to be consistent with legacy use of similar gcc attributes. >>>>> Thanks, >>>>> -Ngie >>>> >>>> Why not use _Noreturn? It's standardized by C11, so tools understand >>>> it better than __dead2. >>> >>> Tools that can't understand #define __dead2 _Noreturn aren't worth supporting. >> Some tools don't expand preprocessor macros. Like my editor, for >> example, which highlights _Noreturn as a keyword but not __dead2. > > Please use _Noreturn, because it's standard. sys/cdefs.h already > defines it appropriately for C < C11. _Noreturn is far too hard to use. The above use of it is a syntax error: pts/12:bde@freefall:~/u3> cat z.c void foo(void) _Noreturn; _Noreturn void foo(void); pts/12:bde@freefall:~/u3> cc -std=c11 z.c z.c:1:16: error: '_Noreturn' keyword must precede function declarator void foo(void) _Noreturn; ^~~~~~~~~ _Noreturn 1 error generated. sys/cdefs.h defines might define it appropropriately for C < C11, but it defines it as __dead2 for all C, so prevents the C11 _Noreturn keyword being used. This normally breaks detection of the syntax error. Normally is included first, so you __dead2 obfuscated by spelling it _Noreturn instead of C11 _Noreturn. Defining _Noreturn as __dead2 is wrong because it gives the opposite syntax error. __dead2 can now be placed anywhere, but everything in sys/cdefs.h is supposed to be portable back to gcc-1. __dead2 must be placed after the function for gcc-2.0, since __attribute__(()) had more restrictions then. So if you write: #include _Noreturn void foo(void); to satisfy the C11 syntax, then you get a syntax error for old gcc (> 1). This is just the start of the complications for soft-coded C11'isms. C11 also has noreturn. You have to include to get that. But you actiually get the _Noreturn macro which expands to __dead2. There are further complications for C++11. sys/cdefs.h does have a correct-looking ifdef for C+11. This gives the [[noreturn]] keyward instead of __dead2. C11 doesn't have . I think its keyword must be spelled [[noreturn]]. This spelling is completely incompatibly with C. Bruce