Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Dec 2017 13:21:52 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Warner Losh <imp@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r326771 - head/usr.sbin/efibootmgr
Message-ID:  <20171212130425.H1415@besplex.bde.org>
In-Reply-To: <201712111617.vBBGHrCZ027885@repo.freebsd.org>
References:  <201712111617.vBBGHrCZ027885@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 11 Dec 2017, Warner Losh wrote:

> Log:
>  Unbreak gcc build by using (void) for functions that take no args.

You mean "Fix a bug (K&R function definition without even a C99 prototype)
that is detected by compilers like gcc with non-broken support for the -W
flag that we used to detect such bugs.  The bug is only a style bug in
this case."

> Modified: head/usr.sbin/efibootmgr/efibootmgr.c
> ==============================================================================
> --- head/usr.sbin/efibootmgr/efibootmgr.c	Mon Dec 11 15:33:24 2017	(r326770)
> +++ head/usr.sbin/efibootmgr/efibootmgr.c	Mon Dec 11 16:17:53 2017	(r326771)
> @@ -275,7 +275,7 @@ parse_args(int argc, char *argv[])
>
>
> static void
> -print_order()
> +print_order(void)
> {
> 	uint32_t attrs;
> 	uint8_t *data;

This is a K&R function definition.  Since the function is also unprototyped,
it has K&R semantics.  Since it is defined before it is used, the compiler
can see what it does even without -funit-at-a-time.  It still has K&R
semantics.  However, since it is static the compiler can use a non-K&R
compatible ABI to call or inline it anyway.  Apparently broken compilers
use this to suppress the warning, leaving only a style bug.  This is a
feature if the user didn't explicitly ask for warnings, otherwise a bug.

Similarly for the other functions.

KNF requires prototypes even for static functions, but this rule is often
not followed.  It allows the functions to be defined after they are used,
in some sort of stable order.  With -funit-at-a-time, this doesn't prevent
inlining and other optimizations that you ask for (or even inlining that
you don't ask for and don't want).

Bruce



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