[spice-server] red-channel-client: Use SpiceMsgcAckSync structure

Submitted by Frediano Ziglio on Sept. 29, 2019, 11:03 a.m.

Details

Message ID 20190929110336.9613-1-fziglio@redhat.com
State Superseded
Headers show
Series "red-channel-client: Use SpiceMsgcAckSync structure" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Sept. 29, 2019, 11:03 a.m.
red_channel_client_handle_message is called after parsing the
message so it's not necessary to check it again or parse manually.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/red-channel-client.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 66b8fd4a..f861cce5 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1473,11 +1473,7 @@  bool red_channel_client_handle_message(RedChannelClient *rcc, uint16_t type,
 {
     switch (type) {
     case SPICE_MSGC_ACK_SYNC:
-        if (size != sizeof(uint32_t)) {
-            red_channel_warning(red_channel_client_get_channel(rcc), "bad message size");
-            return FALSE;
-        }
-        rcc->priv->ack_data.client_generation = *(uint32_t *)(message);
+        rcc->priv->ack_data.client_generation = ((SpiceMsgcAckSync *) message)->generation;
         break;
     case SPICE_MSGC_ACK:
         if (rcc->priv->ack_data.client_generation == rcc->priv->ack_data.generation) {

Comments

> 
> red_channel_client_handle_message is called after parsing the
> message so it's not necessary to check it again or parse manually.
> 
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> ---
>  server/red-channel-client.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/server/red-channel-client.c b/server/red-channel-client.c
> index 66b8fd4a..f861cce5 100644
> --- a/server/red-channel-client.c
> +++ b/server/red-channel-client.c
> @@ -1473,11 +1473,7 @@ bool
> red_channel_client_handle_message(RedChannelClient *rcc, uint16_t type,
>  {
>      switch (type) {
>      case SPICE_MSGC_ACK_SYNC:
> -        if (size != sizeof(uint32_t)) {
> -            red_channel_warning(red_channel_client_get_channel(rcc), "bad
> message size");
> -            return FALSE;
> -        }
> -        rcc->priv->ack_data.client_generation = *(uint32_t *)(message);
> +        rcc->priv->ack_data.client_generation = ((SpiceMsgcAckSync *)
> message)->generation;

This last line is fine but I realized that for some reasons smartcard
channel is not setting the parser so would be better to leave the check.
Even better to use the parser maybe.

>          break;
>      case SPICE_MSGC_ACK:
>          if (rcc->priv->ack_data.client_generation ==
>          rcc->priv->ack_data.generation) {

Frediano