Re: 2.6.14 assorted warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also, this test case:

------------------------------------------------------------
extern int f1(void);

static unsigned char f2(unsigned int *def)
{
	if (!f1())
		return 0;
	*def = 1;
	return 1;
}

unsigned char f3(unsigned char **eoc)
{
	unsigned int def;

	if (!f2(&def))
		return 0;
	if (def)
		*eoc = (unsigned char *)1;
	else
		*eoc = 0;
	return 1;
}

static int f4(unsigned int *def)
{
	if (!f1())
		return 0;
	*def = 1;
	return 1;
}

unsigned char f5(unsigned char **eoc)
{
	unsigned int def;

	if (!f4(&def))
		return 0;
	if (def)
		*eoc = (unsigned char *)1;
	else
		*eoc = 0;
	return 1;
}
------------------------------------------------------------

compiled with "gcc -Wall -O2" gives:
xx.c: In function 'f3':
xx.c:14: warning: 'def' may be used uninitialized in this function

but doesn't complain about the same code in f5.  The difference is that
f4 returns "int" while f2 returns "unsigned char".  This has apparently
been fixed in gcc mainline - the above comes from Debian unstables' gcc
(4.0.3 20051023 (prerelease) (Debian 4.0.2-3)).

Compiling with "gcc -Wall -O2 -fnoinline" suppresses the warning.

-- 
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/

Attachment: pgp5zWsteaXXe.pgp
Description: PGP signature


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux