From owner-svn-src-head@freebsd.org Wed May 3 19:32:18 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 85E91D5821F; Wed, 3 May 2017 19:32:18 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 501DA1108; Wed, 3 May 2017 19:32:18 +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 mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 474DED67A8D; Thu, 4 May 2017 05:32:11 +1000 (AEST) Date: Thu, 4 May 2017 05:32:10 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ngie Cooper cc: Alan Somers , 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: <8EA7A2E9-A429-4DC2-85CE-1B5AAEDF86FD@gmail.com> Message-ID: <20170504044558.Y992@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=6I5d2MoRAAAA:8 a=ZGSl9oWYpliUKDSVMyYA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo: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 19:32:18 -0000 On Wed, 3 May 2017, 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; > > Please use __dead2 instead to be consistent with legacy use of similar gcc attributes. _Noreturn after the function is also a syntax error for C++11 and therefore a logic error in all cases (see below). Using either a static function is a style bug. __dead2 and _Noreturn are mostly for functions that can't be directly seen to not return because they are separately compiled, but static functions are never separately compiled. There might be exceptions for functions that don't return but this is not obvious. usage() is not an exception since it it is so simple. style(9) requires it to end with exit(). exit() must be declared as __dead2 so that it is known to not return. This depends on the compiler doing processing the whole file to see which static functions don't return before complaining about probems from them returning in calls earlier in the file, but compilers must do that to avoid spurious warnings. Even gcc-1 seems to have done it, and now -O implies -funit-at-a-time which does it and uses the results more To enlarge this style bug and break portability, use _Noreturn in some places and __dead2 in others, and place it before the function name and misindent it, as in . Actually, there are syntactical problems which require some of the style bugs if _Noreturn is used at all, so it should never be used. _Noreturn expands to [[noreturn]] for c++11. It is a syntax error if you place it where you did (after the function name). OTOH, __dead2 is a syntax error for the compiler it was written for (gcc-2.0) when it is placed before the function name. __dead2 replaced __dead which was for gcc-1 and had the same syntactical restriction as [[noreturn]]. gcc had obscure restrictions on the placement of __attribute__(()) much later than gcc-2.0, but the __noreturn__ attribute used by __dead2 is accepted both before and after the function name by gcc-2.95.4, so it is fairly portable in practice. should be careful about portablity and style, but ifconfig doesn't need to be portable. Bruce