Re: Testing on NULL an unitialized values

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

 



On 04/21/2010 07:53 PM, Sven Neumann wrote:
> On Wed, 2010-04-21 at 13:58 +0200, Oliver Bandel wrote:
>
>> Even only temporarily valies, if set to a certain value,
>> like 0 or NULL, will help in finding problems.
>
> Should be totally un-necessary as the compiler will warn you if your
> code uses uninitialized variables. We are compiling with -Wall and we
> try hard to eliminate all compiler warnings. What you are suggesting
> will not improve the code at all, it would most likely even degrade its
> readability.

The compiler doesn't catch all cases, like this one:

#include <stdio.h>
int main(int argc, char **argv)
{
   int var;
   if (argc == 2)
     var = 42;
   printf ("var = %d", var);
   return 0;
}

Since use of uninitlized variables very well can cause severe and 
hard-to-reproduce crashes, and since unpredictability never is a good 
thing when it comes to computers, I think it is pretty clear what the 
recommendation should be with regards to initialization of variables.

  / Martin
_______________________________________________
Gimp-developer mailing list
Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux