[Spice-devel] server: More clearly identify channels that support multiple clients

Christophe Fergeau cfergeau at redhat.com
Thu Mar 24 14:26:16 UTC 2016


Hey,

On Mon, Mar 14, 2016 at 12:39:02AM +0100, Francois Gouget wrote:
> Rename the function to channel_supports_multiple_clients() as
> channel_is_secondary() is unclear and was coded to return the opposite
> of what was originally intended.
> Also there are few channel types and whether they support multiple
> clients is totally static so we might as well delegate the check to
> the compiler.

These 2 things (renaming and logic change) could have been part of
different commits.

Acked-by: Christophe Fergeau <cfergeau at redhat.com>
and pushed.

Christophe

> 
> Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
> ---
> 
> For reference the original commit was 614df171.
> 
>  server/reds.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/server/reds.c b/server/reds.c
> index b1e1139..08b6156 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -874,16 +874,14 @@ SPICE_GNUC_VISIBLE int spice_server_get_num_clients(SpiceServer *s)
>      return reds_get_n_clients(reds);
>  }
>  
> -static const int secondary_channels[] = {
> -    SPICE_CHANNEL_MAIN, SPICE_CHANNEL_DISPLAY, SPICE_CHANNEL_CURSOR, SPICE_CHANNEL_INPUTS};
> -
> -static int channel_is_secondary(RedChannel *channel)
> +static int channel_supports_multiple_clients(RedChannel *channel)
>  {
> -    int i;
> -    for (i = 0 ; i < G_N_ELEMENTS(secondary_channels); ++i) {
> -        if (channel->type == secondary_channels[i]) {
> -            return TRUE;
> -        }
> +    switch (channel->type) {
> +    case SPICE_CHANNEL_MAIN:
> +    case SPICE_CHANNEL_DISPLAY:
> +    case SPICE_CHANNEL_CURSOR:
> +    case SPICE_CHANNEL_INPUTS:
> +        return TRUE;
>      }
>      return FALSE;
>  }
> @@ -896,7 +894,8 @@ void reds_fill_channels(RedsState *reds, SpiceMsgChannels *channels_info)
>      channels_info->num_of_channels = reds->num_of_channels;
>      RING_FOREACH(now, &reds->channels) {
>          RedChannel *channel = SPICE_CONTAINEROF(now, RedChannel, link);
> -        if (reds->num_clients > 1 && !channel_is_secondary(channel)) {
> +        if (reds->num_clients > 1 &&
> +            !channel_supports_multiple_clients(channel)) {
>              continue;
>          }
>          channels_info->channels[used_channels].type = channel->type;
> -- 
> 2.7.0
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160324/a0a3da9a/attachment.sig>


More information about the Spice-devel mailing list