[PATCH spice-gtk 36/44] fixup! usb-redir: add implementation of emulated CD device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use g_clear_object where possible
---
 src/usb-device-cd.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/usb-device-cd.c b/src/usb-device-cd.c
index 9554a82f..e48236b4 100644
--- a/src/usb-device-cd.c
+++ b/src/usb-device-cd.c
@@ -131,8 +131,7 @@ static int cd_device_open_stream(SpiceCdLU *unit, const char *filename)
         }
         if (!unit->stream) {
             SPICE_DEBUG("%s: can't open stream on %s", __FUNCTION__, unit->filename);
-            g_object_unref(unit->file_object);
-            unit->file_object = NULL;
+            g_clear_object(&unit->file_object);
             error = -1;
         }
     }
@@ -286,8 +285,7 @@ static int cd_device_open_stream(SpiceCdLU *unit, const char *filename)
         }
         if (!unit->stream) {
             SPICE_DEBUG("%s: can't open stream on %s", __FUNCTION__, unit->filename);
-            g_object_unref(unit->file_object);
-            unit->file_object = NULL;
+            g_clear_object(&unit->file_object);
             error = -1;
         }
     } else {
@@ -353,14 +351,8 @@ static gboolean open_stream(SpiceCdLU *unit, const char *filename)
 
 static void close_stream(SpiceCdLU *unit)
 {
-    if (unit->stream) {
-        g_object_unref(unit->stream);
-        unit->stream = NULL;
-    }
-    if (unit->file_object) {
-        g_object_unref(unit->file_object);
-        unit->file_object = NULL;
-    }
+    g_clear_object(&unit->stream);
+    g_clear_object(&unit->file_object);
 }
 
 static gboolean load_lun(UsbCd *d, int unit, gboolean load)
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]