Re: [Gimp-developer] Testing on NULL an unitialized values

2010-11-27 Thread oliver
Hello, just because I found a nice jargon entry, which supports my view, I relate to that old topic again. On Wed, Apr 21, 2010 at 12:33:15PM +0200, Oliver Bandel wrote: [...] > I would do EVERY pointer set to NULL, when defining it. > And normally I also would set ANY other value to a certain v

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-23 Thread Oliver Bandel
hehe, the segfault did not came from the char* mytext, but from wrong indexing in the vector. :( my fault :( Heheh... nevertheless valgrind is on my side ;-) Somehow I got no crash from the uninitialized char*, but that might only happen after release at the user's computer: It's unpredic

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-23 Thread Tobias Ellinghaus
Am Freitag, 23. April 2010 schrub Oliver Bandel: > Zitat von "Tor Lillqvist" : > >> You are right, that in some seldom situations it might make sense > >> to initialize values to other start values. But they should always be > >> predictable. > > > > You didn't get the reasoning about letting the c

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-23 Thread Oliver Bandel
Zitat von "Tor Lillqvist" : You are right, that in some seldom situations it might make sense to initialize values to other start values. But they should always be predictable. You didn't get the reasoning about letting the compiler, or valgrind, catch use of uninitialized variables, did you?

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-23 Thread Oliver Bandel
Zitat von "Torsten Neuer" : > Am Freitag, 23. April 2010 08:39:52 schrieb Oliver Bandel: >> Zitat von "Sven Neumann" : >> > Hi, >> > >> > On Thu, 2010-04-22 at 14:38 +0200, Fredrik Alströmer wrote: >> >> For the record, I'm not necessarily against setting a predefined value >> >> to variables some

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-23 Thread Oliver Bandel
Zitat von "Tor Lillqvist" : >> You are right, that in some seldom situations it might make sense >> to initialize values to other start values. But they should always be >> predictable. > > You didn't get the reasoning about letting the compiler, or valgrind, > catch use of uninitialized variables

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-23 Thread Torsten Neuer
Am Freitag, 23. April 2010 08:39:52 schrieb Oliver Bandel: > Zitat von "Sven Neumann" : > > Hi, > > > > On Thu, 2010-04-22 at 14:38 +0200, Fredrik Alströmer wrote: > >> For the record, I'm not necessarily against setting a predefined value > >> to variables sometimes. I'm just against doing it for

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Tor Lillqvist
> Will the compiler stop execution on any warning? It should, and not > compile any code that gives warnings, otherwise your attempt will not > work. People will ignore it "just for testing". That depends on the project. Many projects do use flags like -Werror, although that is not always possible

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Tor Lillqvist
> You are right, that in some seldom situations it might make sense > to initialize values to other start values. But they should always be > predictable. You didn't get the reasoning about letting the compiler, or valgrind, catch use of uninitialized variables, did you? > The same is here:  a NU

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Oliver Bandel
Zitat von "Sven Neumann" : > Hi, > > On Thu, 2010-04-22 at 14:38 +0200, Fredrik Alströmer wrote: > >> For the record, I'm not necessarily against setting a predefined value >> to variables sometimes. I'm just against doing it for the wrong >> reasons, and I'd much rather have the compiler say "War

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Oliver Bandel
Hi Frederik, my main attend was to mention the problem of pointers, regarding uninitialized values. That's why I insisted on Null, and it makes sense often to use 0 or 0.0 for other values. As "strings" are char*, NULL should be used, not "". You are right, that in some seldom situations it

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Oliver Bandel
Zitat von "Sven Neumann" : > On Wed, 2010-04-21 at 18:30 +0200, Martin Nordholts wrote: >> On 04/21/2010 01:58 PM, Oliver Bandel wrote: >> > Even only temporarily valies, if set to a certain value, >> > like 0 or NULL, will help in finding problems. >> >> I agree, and I try to initialize all local

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Sven Neumann
Hi, On Thu, 2010-04-22 at 14:38 +0200, Fredrik Alströmer wrote: > For the record, I'm not necessarily against setting a predefined value > to variables sometimes. I'm just against doing it for the wrong > reasons, and I'd much rather have the compiler say "Warning: might be > used uninitialized i

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Sven Neumann
On Wed, 2010-04-21 at 18:30 +0200, Martin Nordholts wrote: > On 04/21/2010 01:58 PM, Oliver Bandel wrote: > > Even only temporarily valies, if set to a certain value, > > like 0 or NULL, will help in finding problems. > > I agree, and I try to initialize all local variables that I either add > or

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Fredrik Alströmer
On Thu, Apr 22, 2010 at 14:00, Oliver Bandel wrote: > Zitat von "Fredrik Alströmer" : >> And no valgrind, or >> static analyzers will notice that you're reading an uninitialized >> zero. > > No problem. > > You have that defined value, and with each run it gives you the same value. > That mean: th

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Oliver Bandel
Zitat von "Fredrik Alströmer" : > A couple of very small coins. > > On Thu, Apr 22, 2010 at 06:55, Martin Nordholts wrote: >> On 04/22/2010 03:54 AM, Marc Lehmann wrote: >>> On Wed, Apr 21, 2010 at 08:14:33PM +0200, Martin >>> Nordholts wrote: The compiler doesn't catch all cases, like th

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-22 Thread Fredrik Alströmer
A couple of very small coins. On Thu, Apr 22, 2010 at 06:55, Martin Nordholts wrote: > On 04/22/2010 03:54 AM, Marc Lehmann wrote: >> On Wed, Apr 21, 2010 at 08:14:33PM +0200, Martin >> Nordholts  wrote: >>> The compiler doesn't catch all cases, like this one: >>> >>> #include >>> int main(int a

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Martin Nordholts
On 04/22/2010 03:54 AM, Marc Lehmann wrote: > On Wed, Apr 21, 2010 at 08:14:33PM +0200, Martin Nordholts > wrote: >> The compiler doesn't catch all cases, like this one: >> >> #include >> int main(int argc, char **argv) >> { >> int var; >> if (argc == 2) >> var = 42; >> printf (

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Martin Nordholts
On 04/21/2010 11:45 PM, Oliver Bandel wrote: > Zitat von "Martin Nordholts": > >> On 04/21/2010 01:58 PM, Oliver Bandel wrote: >>> Even only temporarily valies, if set to a certain value, >>> like 0 or NULL, will help in finding problems. >> >> I agree, and I try to initialize all local variables t

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Oliver Bandel
Zitat von "Sven Neumann" : > On Wed, 2010-04-21 at 12:33 +0200, Oliver Bandel wrote: > >> Example: >> >> >> == >> /*/ >> /* public functions >> *

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Oliver Bandel
Zitat von "Martin Nordholts" : > On 04/21/2010 01:58 PM, Oliver Bandel wrote: >> Even only temporarily valies, if set to a certain value, >> like 0 or NULL, will help in finding problems. > > I agree, and I try to initialize all local variables that I either add > or modify the declaration of. I d

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Oliver Bandel
Hi, Zitat von "Omari Stephens" : > On 04/21/2010 11:58 AM, Oliver Bandel wrote: >> Zitat von "Tor Lillqvist": >> [...] >> Even only temporarily valies, if set to a certain value, >> like 0 or NULL, will help in finding problems. >> >> The mentioned function just was an example. >> >> Uninitial

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Oliver Bandel
Zitat von "Sven Neumann" : > On Wed, 2010-04-21 at 12:33 +0200, Oliver Bandel wrote: > >> Example: >> >> >> == >> /*/ >> /* public functions >> *

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Sven Neumann
On Wed, 2010-04-21 at 12:33 +0200, Oliver Bandel wrote: > Example: > > > == > /*/ > /* public functions > / > > Gim

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Martin Nordholts
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

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Sven Neumann
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 a

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Martin Nordholts
On 04/21/2010 01:58 PM, Oliver Bandel wrote: > Even only temporarily valies, if set to a certain value, > like 0 or NULL, will help in finding problems. I agree, and I try to initialize all local variables that I either add or modify the declaration of. I don't think it would be worth to commit

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Omari Stephens
On 04/21/2010 11:58 AM, Oliver Bandel wrote: > Zitat von "Tor Lillqvist": > >>> The test >>>if( template ) >>> makes only sense, if you can be sure that uninitialzed values >>> will definitelky be NULL. >> >> You must have missed the g_return_val_if_fail (! template || >> GIMP_IS_CONTEXT (templ

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Oliver Bandel
Zitat von "Tor Lillqvist" : >> The test >>   if( template ) >> makes only sense, if you can be sure that uninitialzed values >> will definitelky be NULL. > > You must have missed the g_return_val_if_fail (! template || > GIMP_IS_CONTEXT (template), NULL) . > > It checks if template is NULL or a po

Re: [Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Tor Lillqvist
> The test >   if( template ) > makes only sense, if you can be sure that uninitialzed values > will definitelky be NULL. You must have missed the g_return_val_if_fail (! template || GIMP_IS_CONTEXT (template), NULL) . It checks if template is NULL or a pointer to a valid GimpContext. If template

[Gimp-developer] Testing on NULL an unitialized values

2010-04-21 Thread Oliver Bandel
Hello, since some days I'm browsing through the Gimp-Code. What I have seen so far looks very tidy. But I also found some things that I would do differently, throughout the whole code, and maybe also in the libs (I didn't looked at them in detail). I would do EVERY pointer set to NULL, whe