Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Aug 2018 12:48:09 -0600
From:      Ian Lepore <ian@freebsd.org>
To:        Mark Johnston <markj@freebsd.org>, Bruce Evans <brde@optusnet.com.au>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r337426 - head/sbin/ifconfig
Message-ID:  <1533926889.9860.199.camel@freebsd.org>
In-Reply-To: <20180810184426.GB52302@raichu>
References:  <201808071725.w77HPciT051597@repo.freebsd.org> <20180810092251.K1276@besplex.bde.org> <20180810184426.GB52302@raichu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 2018-08-10 at 14:44 -0400, Mark Johnston wrote:
> On Fri, Aug 10, 2018 at 10:25:50AM +1000, Bruce Evans wrote:
> > 
> > On Tue, 7 Aug 2018, Mark Johnston wrote:
> > 
> > > 
> > > Log:
> > >  ifconfig: Fix use of _Noreturn.
> > > 
> > >  The _Noreturn is a function-specifier (like inline) which must preceed
> > >  the declarator.
> > > 
> > >  Submitted by:	Sebastian Huber 
> > >  MFC after:	1 week
> > _Noreturn is even more broken than I knew.  It should never be used.  Here
> > its use is wronger than usual.
> > 
> > > 
> > > Modified: head/sbin/ifconfig/ifconfig.c
> > > ==============================================================================
> > > --- head/sbin/ifconfig/ifconfig.c	Tue Aug  7 17:13:42 2018	(r337425)
> > > +++ head/sbin/ifconfig/ifconfig.c	Tue Aug  7 17:25:38 2018	(r337426)
> > > @@ -109,7 +109,7 @@ static	int ifconfig(int argc, char *const *argv, int i
> > > static	void status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
> > > 		struct ifaddrs *ifa);
> > > static	void tunnel_status(int s);
> > > -static	void usage(void) _Noreturn;
> > > +static _Noreturn void usage(void);
> > > 
> > > static struct afswtch *af_getbyname(const char *name);
> > > static struct afswtch *af_getbyfamily(int af);
> > FreeBSD code should use __dead2 since it is more portable (within
> > FreeBSD) and doesn't have so mean syntactical restrictions.  However,
> > it only exists at all since it had similar syntactial restrictions
> > when it was new (FreeBSD-1 used __dead, which must be placed like
> > _Noreturn, but __dead2 uses __attribute__(()) which couldn't be placed
> > there when it was new), and the macro that hides the details was renamed
> > to inhibit misuse.  Changing __dead2 to _Noreturn and moving it to satisfy
> > the restricted syntax of the latter mainly broke support for old compilers
> > where __dead2 cannot be placed there.
> __dead2 was never present.  _Noreturn was added in r317755, apparently
> to appease Coverity.
> 
> > 
> > However, all declarations of static usage() as non-returning are bogus, ...
> I can only agree, especially since exit() is already declared with
> _Noreturn in stdlib.h.  I don't understand why __dead2/_Noreturn keeps
> getting added to various usage() declarations.
> 

It was getting added to appease some not-very-capable static code
analyzer. Not Coverity, not clang's builtin analyzer, something else
someone was using, I forget the details.

-- Ian



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