bin/71628: [PATCH] cleanup of the usr.sbin/rpcbind code

Dima Dorfman dd at
Sun Sep 12 23:46:37 PDT 2004

Dan Lukes <dan at> wrote:
> Dima Dorfman wrote:
> > Any initialization in the form "T v = v" invokes undefined behavior by
> > using the indeterminate value of an object. Eliminating a warning or
> 	Unless compiler documentation say other ...
> 	The v=v DURING DECLARATION (not later) is special case.

I looked for such an exception in C99 before my original post, but I
didn't find one. If it is indeed there, I'd appreciate a pointer--I'm
genuinely curious. In either case, if it depends on the compiler
documentation, then it sounds like implementation-defined behavior at
best, so we'd still prefer to avoid it.

> 	But I'm far away from pushing this way to eliminate warnings. It's no
> problem to initialise variable to constant for me (I hope those patches
> will not be rejected "because the initialisation is not necesarry as
> variable is properly initialised later")

We're not rejecting your patches, but we're making suggestions for
improving them. That the initialization is not necessary could be a
valid point in some cases; not everyone likes a defensive style, and
spurious initializations can be confusing ("is there really a case
where the initial value is used?"). It might be better to set to a
bogus value only when necessary. E.g.:

: int
: f(int a)
: {
: 	int i, j;
: 	i = 0;
: 	if (a) {
: 		i = 1;
: 		j = -1;		/* Silence compiler warning. */
: 	} else
: 		j = 1;
: 	if (i)
: 		return (0);
: 	return (j);
: }

This isn't appropriate in all cases either, so use your judgement. If
you do decide to initialize it in the beginning, note that style(9)
discourages initializers. That's not a hard-and-fast rule, either.

Do I sound like a pedant yet? ;-)


More information about the freebsd-bugs mailing list