From owner-svn-src-head@freebsd.org Wed May 3 21:07:45 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 911FED5CE3E; Wed, 3 May 2017 21:07:45 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-yw0-x231.google.com (mail-yw0-x231.google.com [IPv6:2607:f8b0:4002:c05::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 465855F6; Wed, 3 May 2017 21:07:45 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-yw0-x231.google.com with SMTP id u70so912327ywe.2; Wed, 03 May 2017 14:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=c+Mkcjh45jU5LrWLz7z30RkF5MMYyZTIUCs1Z/IKAME=; b=iwBO9h3XbxYC2dM5cGBBt04pn68taBqjkfugDV4SmVWjmhdtAJPrxsU+4AquSvD+kg 8KZJZ1oYaXRVh6ervKdIvh3awnLAzH1WSiP1ZSXTTHFZkU9yELVlZ6sGcVt7PNf6H0po tzkARfQYd+1MrUpjXY6HkXFM73uAY0cZjTxDvMI56FPvFvaX3O4NAFBTKe9BKnuleK2q LpvD+2tLzIlavcJXkj5PP/tSw5xWp3+hoEp4jEve6J5dchs+MQdVHTp4gTEg0TJHhvHH 82kXDZ81VOajkrqfwRUQaD5egoJIay2dtSQXmewx13nFbRlByNr3eWmC3oZsUznAXXdl 3P9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=c+Mkcjh45jU5LrWLz7z30RkF5MMYyZTIUCs1Z/IKAME=; b=RcB2TQ2oKY7cWS0CO+j7ebbmNewvexqeaCTjUaFTG/K79FeVNFyXO58ZIYF/j1hmfa 8HzHqwMDQriBBk9FVlu/hLFHyNfUi2PrRVa9u+6XYb/csI0J9wOHMMLJjMoOzsB3JgBo IBUvKizpD6g8Wqyz//nklcy9PpppqYDeTjn0KJ3Pe/A1ev0ziii9ZW/WaGihXkYZXlH0 cooaguUvjYg93QGb9NfbjN3XA5A4KdmH8t9R8KdIBlsyBlf20W+INr+4E6KbpkacjlXD l5gMGIkRbzsTTQhqYaytae0mf68u4JO+k4bj4ZEAoUFH3I2HcOhyC19SUQJdguFqRLqa uy3Q== X-Gm-Message-State: AN3rC/50nbdBkVlvRn7iWjqn2slcEob7ftkY/IktFDgkNPJQ8XecE7Z0 IHlp03xp9BuakPiH5dTiUsP4y3xcHhSi X-Received: by 10.129.89.215 with SMTP id n206mr31126720ywb.94.1493845664335; Wed, 03 May 2017 14:07:44 -0700 (PDT) MIME-Version: 1.0 Sender: asomers@gmail.com Received: by 10.129.20.214 with HTTP; Wed, 3 May 2017 14:07:43 -0700 (PDT) In-Reply-To: <20170504062448.U1383@besplex.bde.org> References: <201705031721.v43HL2vS071819@repo.freebsd.org> <8EA7A2E9-A429-4DC2-85CE-1B5AAEDF86FD@gmail.com> <20170504062448.U1383@besplex.bde.org> From: Alan Somers Date: Wed, 3 May 2017 15:07:43 -0600 X-Google-Sender-Auth: 52EODXP_BhWRvfa_40m_Qa9cPPU Message-ID: Subject: Re: svn commit: r317755 - head/sbin/ifconfig To: Bruce Evans Cc: Eric van Gyzen , Warner Losh , Ngie Cooper , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 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 21:07:45 -0000 On Wed, May 3, 2017 at 2:51 PM, Bruce Evans wrote: > 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 Why do you say that cdefs.h should be compatible with gcc-1? gcc-2 was released more than 25 years ago. gcc-1 isn't the default compiler for any architecture and isn't available in ports. If anybody can find a copy of gcc-1, I doubt that much of our codebase would compile. It sounds to me that the best practice would be to place both __dead2 and _Noreturn before the function name. -Alan