[spice-server,v2,2/2] smartcard: Use RedChannelClient as the type for RedCharDevice client

Submitted by Frediano Ziglio on June 2, 2019, 7:32 p.m.

Details

Message ID 20190602193226.19766-2-fziglio@redhat.com
State Accepted
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio June 2, 2019, 7:32 p.m.
As now is an opaque type for RedCharDevice use the type that
better suits us.
This avoid useless conversions or look ups.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/smartcard-channel-client.c |  5 +++--
 server/smartcard.c                | 16 ++++++++--------
 2 files changed, 11 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/smartcard-channel-client.c b/server/smartcard-channel-client.c
index e22b39adf..3d1b446e3 100644
--- a/server/smartcard-channel-client.c
+++ b/server/smartcard-channel-client.c
@@ -16,6 +16,8 @@ 
 */
 #include <config.h>
 
+#define RedCharDeviceClientOpaque RedChannelClient
+
 #include "smartcard-channel-client.h"
 
 struct SmartCardChannelClientPrivate
@@ -121,7 +123,6 @@  smartcard_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc,
                                            uint16_t type, uint32_t size)
 {
     SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);
-    RedClient *client = red_channel_client_get_client(rcc);
 
     /* todo: only one reader is actually supported. When we fix the code to support
      * multiple readers, we will porbably associate different devices to
@@ -137,7 +138,7 @@  smartcard_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc,
         spice_assert(smartcard_char_device_get_client(smartcard) || scc->priv->smartcard);
         spice_assert(!scc->priv->write_buf);
         scc->priv->write_buf =
-            red_char_device_write_buffer_get_client(RED_CHAR_DEVICE(smartcard), client, size);
+            red_char_device_write_buffer_get_client(RED_CHAR_DEVICE(smartcard), rcc, size);
 
         if (!scc->priv->write_buf) {
             spice_error("failed to allocate write buffer");
diff --git a/server/smartcard.c b/server/smartcard.c
index e6d3b6ace..17794b06f 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -22,6 +22,8 @@ 
 #include <libcacard.h>
 #endif
 
+#define RedCharDeviceClientOpaque RedChannelClient
+
 #include "reds.h"
 #include "char-device.h"
 #include "smartcard.h"
@@ -164,24 +166,22 @@  static RedPipeItem *smartcard_read_msg_from_device(RedCharDevice *self,
  * so no mutex is required. */
 static void smartcard_send_msg_to_client(RedCharDevice *self,
                                          RedPipeItem *msg,
-                                         RedClient *client)
+                                         RedChannelClient *client)
 {
     RedCharDeviceSmartcard *dev = RED_CHAR_DEVICE_SMARTCARD(self);
     RedChannelClient *rcc = RED_CHANNEL_CLIENT(dev->priv->scc);
 
-    spice_assert(dev->priv->scc &&
-                 red_channel_client_get_client(rcc) == client);
+    spice_assert(dev->priv->scc && rcc == client);
     red_pipe_item_ref(msg);
     red_channel_client_pipe_add_push(rcc, msg);
 }
 
-static void smartcard_remove_client(RedCharDevice *self, RedClient *client)
+static void smartcard_remove_client(RedCharDevice *self, RedChannelClient *client)
 {
     RedCharDeviceSmartcard *dev = RED_CHAR_DEVICE_SMARTCARD(self);
     RedChannelClient *rcc = RED_CHANNEL_CLIENT(dev->priv->scc);
 
-    spice_assert(dev->priv->scc &&
-                 red_channel_client_get_client(rcc) == client);
+    spice_assert(dev->priv->scc && rcc == client);
     red_channel_client_shutdown(rcc);
 }
 
@@ -305,7 +305,7 @@  void smartcard_char_device_attach_client(SpiceCharDeviceInstance *char_device,
     dev->priv->scc = scc;
     smartcard_channel_client_set_char_device(scc, dev);
     client_added = red_char_device_client_add(RED_CHAR_DEVICE(dev),
-                                              red_channel_client_get_client(RED_CHANNEL_CLIENT(scc)),
+                                              RED_CHANNEL_CLIENT(scc),
                                               FALSE, /* no flow control yet */
                                               0, /* send queue size */
                                               ~0,
@@ -362,7 +362,7 @@  void smartcard_char_device_detach_client(RedCharDeviceSmartcard *smartcard,
 
     spice_assert(smartcard->priv->scc == scc);
     red_char_device_client_remove(RED_CHAR_DEVICE(smartcard),
-                                  red_channel_client_get_client(RED_CHANNEL_CLIENT(scc)));
+                                  RED_CHANNEL_CLIENT(scc));
     smartcard_channel_client_set_char_device(scc, NULL);
     smartcard->priv->scc = NULL;