[Spice-commits] 3 commits - server/red-channel.c server/red-channel-client.c server/tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 8 16:14:24 UTC 2019


 server/red-channel-client.c       |   19 +++----------------
 server/red-channel.c              |    1 +
 server/tests/test-stream-device.c |    3 +++
 3 files changed, 7 insertions(+), 16 deletions(-)

New commits:
commit d54669642477f7a01580c56ec5e06b43c4e78e94
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Sep 29 12:03:05 2019 +0100

    red-channel-client: Use SpiceMsgcAckSync structure
    
    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 at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 832b4175..c3ad6818 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1464,7 +1464,7 @@ bool red_channel_client_handle_message(RedChannelClient *rcc, uint16_t type,
 {
     switch (type) {
     case SPICE_MSGC_ACK_SYNC:
-        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) {
commit 2b56398c34eeb930c8eea7c4a81c90484e34f51d
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Oct 5 21:37:26 2019 +0100

    red-channel-client: Remove useless check
    
    Message is checked by generated message parser.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 35eafa7a..832b4175 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1464,10 +1464,6 @@ 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);
         break;
     case SPICE_MSGC_ACK:
commit 774d466cf87fa34a976a5158118e944e2a51f45a
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Oct 5 21:36:36 2019 +0100

    red-channel: Make parser function compulsory
    
    As base messages require parsing better channels should always use
    the generated parser.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 66b8fd4a..35eafa7a 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1175,18 +1175,9 @@ static uint8_t *red_channel_client_parse(RedChannelClient *rcc, uint8_t *message
 {
     RedChannel *channel = red_channel_client_get_channel(rcc);
     RedChannelClass *klass = RED_CHANNEL_GET_CLASS(channel);
-    uint8_t *parsed_message;
 
-    if (klass->parser) {
-        parsed_message = klass->parser(message, message + message_size, message_type,
-                                       SPICE_VERSION_MINOR, size_out, free_message);
-    } else {
-        parsed_message = message;
-        *size_out = message_size;
-        *free_message = NULL;
-    }
-
-    return parsed_message;
+    return klass->parser(message, message + message_size, message_type,
+                         SPICE_VERSION_MINOR, size_out, free_message);
 }
 
 // TODO: this implementation, as opposed to the old implementation in red_worker,
diff --git a/server/red-channel.c b/server/red-channel.c
index c36b68dc..0ed58dc8 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -208,6 +208,7 @@ red_channel_constructed(GObject *object)
 
     G_OBJECT_CLASS(red_channel_parent_class)->constructed(object);
 
+    spice_assert(klass->parser != NULL);
     spice_assert(klass->handle_migrate_data ||
                  !(self->priv->migration_flags & SPICE_MIGRATE_NEED_DATA_TRANSFER));
 }
diff --git a/server/tests/test-stream-device.c b/server/tests/test-stream-device.c
index f5698c7d..a5e85f11 100644
--- a/server/tests/test-stream-device.c
+++ b/server/tests/test-stream-device.c
@@ -197,6 +197,9 @@ stream_channel_init(StreamChannel *channel)
 static void
 stream_channel_class_init(StreamChannelClass *klass)
 {
+    RedChannelClass *channel_class = RED_CHANNEL_CLASS(klass);
+
+    channel_class->parser = spice_get_client_channel_parser(SPICE_CHANNEL_DISPLAY, NULL);
 }
 
 void stream_channel_change_format(StreamChannel *channel,


More information about the Spice-commits mailing list