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@xxxxxxxxxx> --- server/smartcard-channel-client.c | 5 +++-- server/smartcard.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) 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; -- 2.20.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel