Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Aug 2015 22:17:56 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Xin LI <delphij@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r287217 - head/usr.sbin/syslogd
Message-ID:  <20150828215109.G1227@besplex.bde.org>
In-Reply-To: <201508271811.t7RIB0xl077002@repo.freebsd.org>
References:  <201508271811.t7RIB0xl077002@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 27 Aug 2015, Xin LI wrote:

> Log:
>  die() would never return, mark it as so.

Why?  (Except to add a style bug.)

> Modified: head/usr.sbin/syslogd/syslogd.c
> ==============================================================================
> --- head/usr.sbin/syslogd/syslogd.c	Thu Aug 27 17:16:18 2015	(r287216)
> +++ head/usr.sbin/syslogd/syslogd.c	Thu Aug 27 18:11:00 2015	(r287217)
> @@ -324,7 +324,7 @@ static const char *cvthname(struct socka
> static void	deadq_enter(pid_t, const char *);
> static int	deadq_remove(pid_t);
> static int	decode(const char *, const CODE *);
> -static void	die(int);
> +static void	die(int) __dead2;

Since the function is static, it is very easy for the compiler to see
that it doesn't return.  Even gcc-4.2.1 does this by default, since
-O implies -funit-at-a-time for gcc-4.2.1.  For clang, there is no way
to prevent this (except possibly -O0) since, since -fno-unit-at-a-time
is broken in clang.

Several other functions in the same file are still missing this style
bug:

- usage().  The style bug is clearly documented for usage() by its
   absence in style(9) and in most files that have usage().  Howvever,
   about 30 declarations of usage() in /usr/src have the style bug.

- timedout().  This is a signal handler, so doesn't really need it.
   This is broken signal handler.  It carefully uses _exit() so as
   to not use stdio in a signal handler, but defeats this by also
   using errx().

Bruce



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