[Spice-devel] [PATCH 17/18] display: replace some dubious asserts

Jonathon Jongsma jjongsma at redhat.com
Fri Nov 20 08:25:46 PST 2015


On Fri, 2015-11-20 at 11:17 +0000, Frediano Ziglio wrote:
> From: Marc-André Lureau <marcandre.lureau at gmail.com>
> 
> ---
>  server/display-channel.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 381a582..7aa3ea9 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -860,10 +860,10 @@ int display_channel_wait_for_migrate_data(DisplayChannel
> *display)
>      RedChannelClient *rcc;
>  
>      spice_debug(NULL);
> -    spice_assert(channel->clients_num == 1);
> +    spice_warn_if_fail(channel->clients_num == 1);


I don't understand the migration code well enough to know whether this condition
really indicates a programming error or whether it could conceivably happen in
normal operation. But I don't see any reason to abort the guest if there are
more than one client connected during migration. At the moment we don't support
multiple clients, but a warning or an early return seems more appropriate than
an abort. I think an early return would probably be a better choice.


>  
>      rcc = SPICE_CONTAINEROF(ring_get_head(&channel->clients),
> RedChannelClient, channel_link);
> -    spice_assert(red_channel_client_waits_for_migrate_data(rcc));
> +    spice_return_val_if_fail(red_channel_client_waits_for_migrate_data(rcc), 
> FALSE);

It seems to me that returning early here will not cause any problems -- there is
already another path that returns a failure value from this function. So I think
an early return is appropriate here (and therefore we should use
g_return_val_if_fail()).


>  
>      for (;;) {
>          red_channel_client_receive(rcc);

Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com>


More information about the Spice-devel mailing list