After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 733157 - Remove redundant checks for NULL
Remove redundant checks for NULL
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other Linux
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-07-14 13:48 UTC by Marek Kašík
Modified: 2014-10-02 17:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Remove redundant checks for NULL (8.34 KB, patch)
2014-07-14 13:48 UTC, Marek Kašík
reviewed Details | Review
Remove redundant checks for NULL (14.04 KB, patch)
2014-07-14 15:08 UTC, Marek Kašík
committed Details | Review

Description Marek Kašík 2014-07-14 13:48:18 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.
Comment 1 Emmanuele Bassi (:ebassi) 2014-07-14 13:58:30 UTC
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.
Comment 2 Marek Kašík 2014-07-14 15:08:08 UTC
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
Comment 3 Matthias Clasen 2014-09-28 00:19:59 UTC
Review of attachment 280650 [details] [review]:

Ok
Comment 4 Marek Kašík 2014-10-02 17:09:08 UTC
Comment on attachment 280650 [details] [review]
Remove redundant checks for NULL

Thank you for the review, I've pushed it to master.