[Spice-devel,13/13] char device: use _reset_dev_instance() to set 'sin'

Submitted by Jonathon Jongsma on April 13, 2016, 7:38 p.m.

Details

Message ID 1460576282-27544-14-git-send-email-jjongsma@redhat.com
State Accepted
Commit 39b00dc71e786f564b7de361c9710a13cd7196a1
Headers show
Series "Backported patches from refactory branch (April 13)" ( rev: 4 3 2 1 ) in Spice

Commit Message

Jonathon Jongsma April 13, 2016, 7:38 p.m.
Internally, use the method to set the 'sin' member variable so that we
don't have to duplicate the g_object_notify() calls, and there are
consistent debug statements whenever this value is modified. This also
means that we need to handle NULL arguments to this function.
---
 server/char-device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/char-device.c b/server/char-device.c
index c7e6eca..fbd9302 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -705,7 +705,8 @@  void red_char_device_reset_dev_instance(RedCharDevice *dev,
 {
     spice_debug("sin %p, char device %p", sin, dev);
     dev->priv->sin = sin;
-    sin->st = dev;
+    if (sin)
+        sin->st = dev;
     g_object_notify(G_OBJECT(dev), "sin");
 }
 
@@ -865,8 +866,7 @@  void red_char_device_reset(RedCharDevice *dev)
         dev_client = SPICE_CONTAINEROF(client_item, RedCharDeviceClient, link);
         red_char_device_client_send_queue_free(dev, dev_client);
     }
-    dev->priv->sin = NULL;
-    g_object_notify(G_OBJECT(dev), "sin");
+    red_char_device_reset_dev_instance(dev, NULL);
 }
 
 void red_char_device_wakeup(RedCharDevice *dev)
@@ -1089,7 +1089,7 @@  red_char_device_set_property(GObject      *object,
     switch (property_id)
     {
         case PROP_CHAR_DEV_INSTANCE:
-            self->priv->sin = g_value_get_pointer(value);
+            red_char_device_reset_dev_instance(self, g_value_get_pointer(value));
             break;
         case PROP_SPICE_SERVER:
             self->priv->reds = g_value_get_pointer(value);