On Tuesday, 14 April 2009, at 18:19:57 (-0300), Gustavo Sverzut Barbieri wrote:
> yes, it is better, because you can know when you're not using them > and if you are using them without proper initialization, so you would > not hide a bug, possibly a segfault. See: > > char *a; > ... > if (strcmp(a, "x") == 0) ... // compile warning > > now compare: > > char *a = NULL; > ... > if (strcmp(a, "x") == 0) ... // silent segv The real problem here is that you're blindly dereferencing a pointer without checking its validity first. And the proper way to do that is to initialize it to NULL first and then check for NULL before dereferencing. Dereferencing a potentially invalid pointer is the error and will SEGV whether that pointer is NULL or not. Michael -- Michael Jennings (a.k.a. KainX) http://www.kainx.org/ <m...@kainx.org> Linux Server/Cluster Admin, LBL.gov Author, Eterm (www.eterm.org) ----------------------------------------------------------------------- "I don't know where you came from, but I know you got out climbing a ladder made out of those command lines. You figure computer code saved your life, and maybe it did. But somewhere along the line you've got to let people back in. Otherwise you're just numbers and hate." -- Mark-Paul Gosselaar, "Hyperion Bay" ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel