[spice-gtk,v1,3/6] usbredir: use g_object_get() for socket access

Submitted by Victor Toso on Sept. 24, 2019, 9:14 a.m.

Details

Message ID 20190924091502.16038-4-victortoso@redhat.com
State New
Headers show
Series "migration object" ( rev: 2 1 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso Sept. 24, 2019, 9:14 a.m.
From: Victor Toso <me@victortoso.com>

Instead of accessing Private of SpiceChannel.

Signed-off-by: Victor Toso <victortoso@redhat.com>
---
 src/channel-usbredir.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index e407bac..fed9bd4 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -511,7 +511,6 @@  static void usbredir_free_write_cb_data(uint8_t *data, void *user_data)
 #ifdef USE_LZ4
 static int try_write_compress_LZ4(SpiceUsbredirChannel *channel, uint8_t *data, int count)
 {
-    SpiceChannelPrivate *c;
     SpiceMsgOut *msg_out_compressed;
     int bound, compressed_data_count;
     uint8_t *compressed_buf;
@@ -520,11 +519,15 @@  static int try_write_compress_LZ4(SpiceUsbredirChannel *channel, uint8_t *data,
         .uncompressed_size = count
     };
 
-    c = SPICE_CHANNEL(channel)->priv;
-    if (g_socket_get_family(c->sock) == G_SOCKET_FAMILY_UNIX) {
+    GSocket *sock;
+    g_object_get(channel, "socket", &sock, NULL);
+    if (g_socket_get_family(sock) == G_SOCKET_FAMILY_UNIX) {
+        g_object_unref(sock);
         /* AF_LOCAL socket - data will not be compressed */
         return FALSE;
     }
+    g_object_unref(sock);
+
     if (count <= COMPRESS_THRESHOLD) {
         /* Not enough data to compress */
         return FALSE;