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

Submitted by Frediano Ziglio on July 30, 2019, 12:03 p.m.

Details

Message ID 20190730120331.17967-35-fziglio@redhat.com
State Superseded
Headers show
Series "Follow ups for CD emulation patch series" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 30, 2019, 12:03 p.m.
Use g_clear_object where possible
---
 src/usb-device-cd.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

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)