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