[Spice-devel] [spice-gtk] usb-device-widget: use g_clear_pointer

Victor Toso victortoso at redhat.com
Mon Oct 1 15:49:42 UTC 2018


From: Victor Toso <me at victortoso.com>

---
 src/usb-device-widget.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index d6e440c..da24d00 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -135,10 +135,7 @@ static void spice_usb_device_widget_hide_info_bar(SpiceUsbDeviceWidget *self)
 {
     SpiceUsbDeviceWidgetPrivate *priv = self->priv;
 
-    if (priv->info_bar) {
-        gtk_widget_destroy(priv->info_bar);
-        priv->info_bar = NULL;
-    }
+    g_clear_pointer(&priv->info_bar, gtk_widget_destroy);
 }
 
 static void
@@ -412,8 +409,7 @@ static gboolean spice_usb_device_widget_update_status(gpointer user_data)
         spice_usb_device_widget_show_info_bar(self, priv->err_msg,
                                               GTK_MESSAGE_INFO,
                                               "dialog-warning");
-        g_free(priv->err_msg);
-        priv->err_msg = NULL;
+        g_clear_pointer(&priv->err_msg, g_free);
     } else if (redirecting) {
         spice_usb_device_widget_show_info_bar(self, _("Redirecting USB Device..."),
                                               GTK_MESSAGE_INFO,
-- 
2.17.1



More information about the Spice-devel mailing list