GNOME Bugzilla – Bug 733157
Remove redundant checks for NULL
Last modified: 2014-10-02 17:09:30 UTC
Created attachment 280640 [details] [review] Remove redundant checks for NULL I've grepped sources of gtk+ for checks for NULL just before g_free() (and g_clear_pointer() and g_clear_object()). Here is a patch which removes such redundant checks.
Review of attachment 280640 [details] [review]: looks generally good, except for the GdkQuartzView.c chunk: that could do with a proper refactoring. ::: gdk/quartz/GdkQuartzView.c @@ +128,2 @@ prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_MARKED_TEXT); + g_free (prev_str); this could be solved by using g_object_set_data_full() instead. @@ +157,2 @@ prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_MARKED_TEXT); + g_free (prev_str); same as above. @@ +215,2 @@ prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_INSERT_TEXT); + g_free (prev_str); same as above.
Created attachment 280650 [details] [review] Remove redundant checks for NULL Thank you for the review. (In reply to comment #1) > Review of attachment 280640 [details] [review]: > > looks generally good, except for the GdkQuartzView.c chunk: that could do with > a proper refactoring. > > ::: gdk/quartz/GdkQuartzView.c > @@ +128,2 @@ > prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_MARKED_TEXT); > + g_free (prev_str); > > this could be solved by using g_object_set_data_full() instead. > > @@ +157,2 @@ > prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_MARKED_TEXT); > + g_free (prev_str); > > same as above. > > @@ +215,2 @@ > prev_str = g_object_get_data (G_OBJECT (gdk_window), TIC_INSERT_TEXT); > + g_free (prev_str); > > same as above. I've replaced the g_object_set_data() with g_object_set_data_full(). I forgot to check whether there are also some checks for NULL followed not just by a free but also by setting of the pointer to NULL. I've replaced such code by g_clear_pointer() in the patch. Regards Marek
Review of attachment 280650 [details] [review]: Ok
Comment on attachment 280650 [details] [review] Remove redundant checks for NULL Thank you for the review, I've pushed it to master.