svn commit: r326771 - head/usr.sbin/efibootmgr

Bruce Evans brde at optusnet.com.au
Tue Dec 12 02:39:45 UTC 2017


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


More information about the svn-src-all mailing list