Re: [PATCH spice-gtk 5/6] channel: pass the size to store_caps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
> 
> Move g_array_set_size() there.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
> ---
>  src/spice-channel.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/src/spice-channel.c b/src/spice-channel.c
> index 7cd6251..642e829 100644
> --- a/src/spice-channel.c
> +++ b/src/spice-channel.c
> @@ -1884,14 +1884,17 @@ cleanup:
>  #endif /* HAVE_SASL */
>  
>  /* coroutine context */
> -static void store_caps(const uint8_t *caps_src, const GArray *caps_dst)
> +static void store_caps(const uint8_t *caps_src, uint32_t ncaps,
> +                       GArray *caps_dst)
>  {
>      uint32_t *caps;
>      guint i;
>  
> +    g_array_set_size(caps_dst, ncaps);
>      caps = &g_array_index(caps_dst, uint32_t, 0);
> -    memcpy(caps, caps_src, caps_dst->len * sizeof(uint32_t));
> -    for (i = 0; i < caps_dst->len; i++, caps++) {
> +    memcpy(caps, caps_src, ncaps * sizeof(uint32_t));
> +
> +    for (i = 0; i < ncaps; i++, caps++) {
>          *caps = GUINT32_FROM_LE(*caps);
>          SPICE_DEBUG("\t%u:0x%X", i, *caps);
>      }
> @@ -1944,14 +1947,12 @@ static gboolean
> spice_channel_recv_link_msg(SpiceChannel *channel)
>      /* g_return_if_fail(c->peer_msg + c->peer_msg->caps_offset *
>      sizeof(uint32_t) > c->peer_msg + c->peer_hdr.size); */
>  
>      caps_src = (uint8_t *)c->peer_msg +
>      GUINT32_FROM_LE(c->peer_msg->caps_offset);
> -    g_array_set_size(c->remote_common_caps, num_common_caps);
>      CHANNEL_DEBUG(channel, "got remote common caps:");
> -    store_caps(caps_src, c->remote_common_caps);
> +    store_caps(caps_src, num_common_caps, c->remote_common_caps);
>  
>      caps_src += num_common_caps * sizeof(uint32_t);
> -    g_array_set_size(c->remote_caps, num_channel_caps);
>      CHANNEL_DEBUG(channel, "got remote channel caps:");
> -    store_caps(caps_src, c->remote_caps);
> +    store_caps(caps_src, num_channel_caps, c->remote_caps);
>  
>      if (!spice_channel_test_common_capability(channel,
>              SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION)) {

Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]