Convert (hopefully) all comparisons to NULL

Apply badzero.cocci, badnull.coci and badnull2.cocci

This should convert all cases where there's a comparison to NULL to simpler
forms. This patch applies the following transformations:

code before patch               ||code after patch
===============================================================

return a == NULL;                 return !a;

return a != NULL;                 return !!a;

func(a == NULL);                  func(!a);

func(a != NULL);                  func(!!a);

b = a == NULL;                    b = !a;

b = a != NULL;                    b = !!a;

b = a == NULL ? c : d;            b = !a ? c : d;

b = a != NULL ? c : d;            b = a ? c : d;


other cases:

a == NULL                         !a
a != NULL                         a




SVN revision: 51487
This commit is contained in:
Lucas De Marchi 2010-08-21 13:52:25 +00:00
parent 3b31ee50e7
commit 2959caf18c
2 changed files with 2 additions and 2 deletions

View File

@ -54,7 +54,7 @@ char *homedir (int uid)
return (s);
}
return (g_strdup
((getenv ("TMPDIR") == NULL) ? "/tmp" : getenv ("TMPDIR")));
((!getenv("TMPDIR")) ? "/tmp" : getenv ("TMPDIR")));
}
void compile_regex ()

View File

@ -325,7 +325,7 @@ void update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
height = 1;
pixbuf = gdk_pixbuf_new_from_file_at_size (filename, width, height, NULL);
have_preview = (pixbuf != NULL);
have_preview = (pixbuf);
g_free (filename);
gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);