I have a program that crashes after some days of work, so I decided run it with Valgrind. I have cleaned up all the warnings but this one:
==30522== Conditional jump or move depends on uninitialised value(s)
==30522== at 0x405E32: main (main.c:548)
==30522== Uninitialised value was created by a stack allocation
==30522== at 0x405652: main (main.c:80)
main.c:80 is the first line of the program:
int main(int argc, char *argv[])
{ // <- this is the line 80
I think I already cleaned up all the bugs, but it still get me mad. What’s up?
listado_ips->ocr=(float)listado_ips->ocr/tiempo_milisecs; // <-line 548
A couple lines before this:
milisecs1=milisecs1-milisecs2
tiempo_milisecs=(float)milisecs1/1000;
milisecs1 is initialised.
The problem is that in the list of variables created at the start of
main(), there is at least one that is still uninitialized when you read it on line 548.Since you’ve not shown what’s at line 548, nor what is between line 80 and 548, we can’t easily tell you more. But concentrate on line 548 – not line 80.
If line 548 is:
then analyze where ‘
tiempo_milisecs‘ is set. If that’s set cleanly, then you need to look at wherelistado_ips->ocris set. We can reasonably safely assume thatlistado_ipsitself (the pointer) is initialized.