Subject: Re: netinet compilation warnings with IPv6 code, but without INET6
To: Simon Burge <simonb@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@itojun.org>
List: current-users
Date: 07/03/1999 23:13:47
>> No, most ports don't use -Wuninitialized due to EGCS getting it wrong
>> some large amount of the time on the i386 and m68k ports.  but it seems
>> to be usually right on the MIPS.
>Do we know in this particular case whether or not it was a false
>positive?  Until INET6, pmax kernels were building happily for a
>couple of months with this option.

	I believe this particular case was false positive.
	Before committing workarounds, the code was like this.
	There's no possibiltiy for the code to visit call to baz()
	when family is not AF_INET nor AF_INET6.

	If we initialize pointer p to NULL on declaration,
	it may shut up the compiler but hides other potential trouble.

itojun


int func()
{
	char *p;

	switch (family) {
	case AF_INET:
	case AF_INET6:
		break;
	default:
		return -1;
	}

	...
	switch (family) {
	case AF_INET:
		p = foo();
		break;
	case AF_INET6:
		p = baa();
		break;
	}

	baz(p);		/*pmax compiler got angry on it with uninitialized p*/
}