Subject: Re: Warnings in nfsv3 code--buggy gcc?
To: Allen Briggs <briggs@puma.bevd.blacksburg.va.us>
From: Per Fogelstrom <pefo@enea.se>
List: tech-kern
Date: 03/29/1996 12:00:14
>
> I'm trying to compile a kernel on the mac with -Wall -Werror
> -Wstrict-prototypes and -Wmissing-prototypes (copied from Makefile.sparc).
> I can't, however, get past nfs_serv.c and nfs_socket.c because
> gcc complains:
>
> ../../../../nfs/nfs_socket.c: In function `nfs_timer':
> ../../../../nfs/nfs_socket.c:1243: warning: `cur_usec' might be used uninitialized in this function
>
> (the warning in nfs/nfs_serv.c was for a variable of the same name)
> As far as I can tell by looking at the code, this is a completely bogus
> warning. Has anyone else run across this? Does anyone know enough
> about gcc to know how this might be happening? Could it be related to
> the fact that cur_usec is a u_quad_t?
>
I haven't checked the code you mention but this is usually due to
some logic flow in the code that the compiler can't easy detect.
Somewhat stupid coding example:
int foo()
{
int f, x;
for(f = 0; f < 10; f++) {
if(f == 0)
x=1;
x= x+x;
x = fun(x);
}
return x;
}
x shure get initialized and the code will work but gcc warns...
i've seen this with other compilers than gcc too.