[Spice-devel] [PATCH 10/13] server: simplify and constify sync_write()

Marc-André Lureau marcandre.lureau at gmail.com
Tue Feb 22 08:26:53 PST 2011


Hi,

NACK for now

hmm, I realize rereading my own patch that this might change some
behaviour.. but in which case? Can someone enlighten me?

On Tue, Feb 22, 2011 at 5:09 PM, Marc-André Lureau
<marcandre.lureau at redhat.com> wrote:
> +    channel = reds_find_channel(link->link_mess->channel_type, 0);
> +    if (!channel)
> +        channel = &caps;
> +
> +    ack.num_common_caps = channel->num_common_caps;
> +    ack.num_channel_caps = channel->num_caps;
> +    header.size += (ack.num_common_caps + ack.num_channel_caps) * sizeof(uint32_t);
>     ack.caps_offset = sizeof(SpiceLinkReply);
>
>     if (!(link->tiTicketing.rsa = RSA_new())) {
> @@ -1391,13 +1391,12 @@ static int reds_send_link_ack(RedLinkInfo *link)
>     BIO_get_mem_ptr(bio, &bmBuf);
>     memcpy(ack.pub_key, bmBuf->data, sizeof(ack.pub_key));
>
> -    ret = sync_write(link->stream, &header, sizeof(header)) && sync_write(link->stream, &ack,
> -                                                                        sizeof(ack));
> -    if (channel) {
> -        ret = ret && sync_write(link->stream, channel->common_caps,
> -                                channel->num_common_caps * sizeof(uint32_t)) &&
> -              sync_write(link->stream, channel->caps, channel->num_caps * sizeof(uint32_t));
> -    }
> +    ret = sync_write(link->stream, &header, sizeof(header));
> +    ret &= sync_write(link->stream, &ack, sizeof(ack));
> +    ret &= sync_write(link->stream, channel->common_caps,
> +                      channel->num_common_caps * sizeof(uint32_t));
> +    ret &= sync_write(link->stream, channel->caps, channel->num_caps * sizeof(uint32_t));
> +

Here it does sync_write() of the caps unconditionnaly even if
reds_find_channel() returns NULL. It was not the case before. I'll
investigate.

regards

-- 
Marc-André Lureau


More information about the Spice-devel mailing list