From 07e4c1c20f544ee2ad2273a35e5ca89831238310 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 21 Feb 2019 05:31:51 +1100 Subject: [PATCH] [client] spice: correct issue with new channel list support --- client/spice/messages.h | 9 ++++++++- client/spice/spice.c | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/client/spice/messages.h b/client/spice/messages.h index 87fe29d5..8be1dc4f 100644 --- a/client/spice/messages.h +++ b/client/spice/messages.h @@ -40,10 +40,17 @@ typedef struct SpiceMsgMainInit } SpiceMsgMainInit; +typedef struct SpiceChannelID +{ + uint8_t type; + uint8_t channel_id; +} +SpiceChannelID; + typedef struct SpiceMsgMainChannelsList { uint32_t num_of_channels; - //uint8_t channels[num_of_channels] + //SpiceChannelID channels[num_of_channels] } SpiceMainChannelsList; diff --git a/client/spice/spice.c b/client/spice/spice.c index e3c77dec..43948c9a 100644 --- a/client/spice/spice.c +++ b/client/spice/spice.c @@ -442,8 +442,8 @@ bool spice_on_main_channel_read() } // documentation doesn't state that the array is null terminated but it seems that it is - uint8_t channels[msg.num_of_channels+1]; - if (!spice_read(channel, &channels, msg.num_of_channels+1)) + SpiceChannelID channels[msg.num_of_channels]; + if (!spice_read(channel, &channels, msg.num_of_channels * sizeof(SpiceChannelID))) { DEBUG_ERROR("Failed to read channel list vector"); spice_disconnect(); @@ -452,8 +452,8 @@ bool spice_on_main_channel_read() for(int i = 0; i < msg.num_of_channels; ++i) { - DEBUG_PROTO("channel %d = %u", i, channels[i]); - if (channels[i] == SPICE_CHANNEL_INPUTS) + DEBUG_PROTO("channel %d = %u", i, channels[i].type); + if (channels[i].type == SPICE_CHANNEL_INPUTS) { if (spice.scInputs.connected) {