[Spice-commits] 2 commits - src/channel-usbredir.c src/channel-usbredir-priv.h src/usb-backend.c src/usb-backend.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Sep 5 13:21:23 UTC 2019


 src/channel-usbredir-priv.h |    2 +-
 src/channel-usbredir.c      |    2 +-
 src/usb-backend.c           |   17 ++++++++---------
 src/usb-backend.h           |    2 +-
 4 files changed, 11 insertions(+), 12 deletions(-)

New commits:
commit f361d17235228d9ce67eac6875a5324095edddfc
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Sep 5 11:02:07 2019 +0100

    usb-backend: SpiceUsbredirChannel is not opaque anymore
    
    Use specific type in spice_usb_backend_channel_new and
    specific name instead of "user_data" field.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/usb-backend.c b/src/usb-backend.c
index dbc9619..e021d43 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -78,7 +78,7 @@ struct _SpiceUsbBackendChannel
     struct usbredirfilter_rule *rules;
     int rules_count;
     SpiceUsbBackendDevice *attached;
-    SpiceUsbredirChannel  *user_data;
+    SpiceUsbredirChannel *usbredir_channel;
     SpiceUsbBackend *backend;
     GError **error;
 };
@@ -394,7 +394,7 @@ static void usbredir_write_flush_callback(void *user_data)
         /* just to be on the safe side */
         return;
     }
-    if (is_channel_ready(ch->user_data)) {
+    if (is_channel_ready(ch->usbredir_channel)) {
         SPICE_DEBUG("%s ch %p -> usbredirhost", __FUNCTION__, ch);
         usbredirhost_write_guest_data(ch->usbredirhost);
     } else {
@@ -614,14 +614,14 @@ static int usbredir_write_callback(void *user_data, uint8_t *data, int count)
     SpiceUsbBackendChannel *ch = user_data;
     int res;
     SPICE_DEBUG("%s ch %p, %d bytes", __FUNCTION__, ch, count);
-    res = spice_usbredir_write(ch->user_data, data, count);
+    res = spice_usbredir_write(ch->usbredir_channel, data, count);
     return res;
 }
 
 static uint64_t usbredir_buffered_output_size_callback(void *user_data)
 {
     SpiceUsbBackendChannel *ch = user_data;
-    return spice_channel_get_queue_size(SPICE_CHANNEL(ch->user_data));
+    return spice_channel_get_queue_size(SPICE_CHANNEL(ch->usbredir_channel));
 }
 
 int spice_usb_backend_read_guest_data(SpiceUsbBackendChannel *ch, uint8_t *data, int count)
@@ -747,16 +747,15 @@ void spice_usb_backend_channel_detach(SpiceUsbBackendChannel *ch)
     ch->attached = NULL;
 }
 
-SpiceUsbBackendChannel *spice_usb_backend_channel_new(SpiceUsbBackend *be,
-                                                      void *user_data)
+SpiceUsbBackendChannel *
+spice_usb_backend_channel_new(SpiceUsbBackend *be,
+                              SpiceUsbredirChannel *usbredir_channel)
 {
     SpiceUsbBackendChannel *ch;
 
-    g_return_val_if_fail(SPICE_IS_USBREDIR_CHANNEL(user_data), NULL);
-
     ch = g_new0(SpiceUsbBackendChannel, 1);
     SPICE_DEBUG("%s >>", __FUNCTION__);
-    ch->user_data = SPICE_USBREDIR_CHANNEL(user_data);
+    ch->usbredir_channel = usbredir_channel;
     if (be->libusb_context) {
         ch->backend = be;
         ch->usbredirhost = usbredirhost_open_full(
diff --git a/src/usb-backend.h b/src/usb-backend.h
index 5830312..7558807 100644
--- a/src/usb-backend.h
+++ b/src/usb-backend.h
@@ -73,7 +73,7 @@ int spice_usb_backend_device_check_filter(SpiceUsbBackendDevice *dev,
 
 /* Spice USB backend channel API */
 SpiceUsbBackendChannel *spice_usb_backend_channel_new(SpiceUsbBackend *context,
-                                                      void            *user_data);
+                                                      SpiceUsbredirChannel *usbredir_channel);
 void spice_usb_backend_channel_delete(SpiceUsbBackendChannel *ch);
 /* returns 0 for success or error code */
 int spice_usb_backend_read_guest_data(SpiceUsbBackendChannel *ch, uint8_t *data, int count);
commit d9ec1ce3b307d1a3e5cce7e11973f33cf99c1bd4
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Sep 5 10:57:19 2019 +0100

    channel-usbredir: Rename spice_usbredir_write_callback
    
    Remove "_callback" suffix.
    The function is called directly, no much reasons to keep that
    suffix.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/channel-usbredir-priv.h b/src/channel-usbredir-priv.h
index a36f5d9..1230628 100644
--- a/src/channel-usbredir-priv.h
+++ b/src/channel-usbredir-priv.h
@@ -70,7 +70,7 @@ void spice_usbredir_channel_get_guest_filter(
                           int                                *rules_count_ret);
 
 /* Callback for USB backend */
-int spice_usbredir_write_callback(SpiceUsbredirChannel *channel, uint8_t *data, int count);
+int spice_usbredir_write(SpiceUsbredirChannel *channel, uint8_t *data, int count);
 
 G_END_DECLS
 
diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index 8d4cd66..0a711c2 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -572,7 +572,7 @@ static int try_write_compress_LZ4(SpiceUsbredirChannel *channel, uint8_t *data,
 #endif
 
 G_GNUC_INTERNAL
-int spice_usbredir_write_callback(SpiceUsbredirChannel *channel, uint8_t *data, int count)
+int spice_usbredir_write(SpiceUsbredirChannel *channel, uint8_t *data, int count)
 {
     SpiceMsgOut *msg_out;
 
diff --git a/src/usb-backend.c b/src/usb-backend.c
index cfd14e2..dbc9619 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -614,7 +614,7 @@ static int usbredir_write_callback(void *user_data, uint8_t *data, int count)
     SpiceUsbBackendChannel *ch = user_data;
     int res;
     SPICE_DEBUG("%s ch %p, %d bytes", __FUNCTION__, ch, count);
-    res = spice_usbredir_write_callback(ch->user_data, data, count);
+    res = spice_usbredir_write(ch->user_data, data, count);
     return res;
 }
 


More information about the Spice-commits mailing list