lkml.org 
[lkml]   [2005]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.6.14 assorted warnings
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 sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-10-30 23:57    [W:0.331 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site