|
From: Robert C. <r.c...@gs...> - 2007-10-16 11:47:40
|
Julian Seward wrote: > On Tuesday 16 October 2007 12:40, Robert Cussons wrote: >> I have quite a lot of functions in which I pass a pointer to a structure >> at first uninitialised [...] > > A bit hard to follow. Can you send a small test program which > illustrates the problem(s)? That would help. > > J Of course, sorry, it wasn't that clear. So for example I have a file "interactionfile" containing information that I want to read into a struct called Inf of type Information. char* informationfile = argv[optind+3]; Information Inf; if (readInteractionfromFile(&Inf, informationfile)) exit(-1); readInteractionfromFile reads lines from the file and stores them into elements in the structure Inf, if the file is not in the expected format, readInteractionfromFile outputs a message and returns a non-zero value, causing the if to be entered and the routine to exit. So inside the function, Inf is initialised, but it seems that valgrind doesn't check for that, it just sees the if, sees Inf, which is not initialised until you descend into the function, which is of course done before the if condition is evaluated. and gives the warning: Conditional jump or move depends on uninitialised value(s) Hope that's a bit clearer. Thanks for the help. |