svn commit: r287217 - head/usr.sbin/syslogd

Bruce Evans brde at optusnet.com.au
Fri Aug 28 12:48:30 UTC 2015


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


More information about the svn-src-all mailing list