[Spice-devel] [spice-server v2 01/10] sound: Rework spice_server_playback_get_buffer() error handling

Frediano Ziglio fziglio at redhat.com
Tue Jan 24 13:31:33 UTC 2017


> 
> Missing detailed log...
> 

Maybe:

Set error results before any error handling to
make easier returning on error conditions.
Split error condition in order to avoid to use a pointer
before NULL check.

> Based on a patch from Frediano Ziglio <fziglio at redhat.com>
> 
> Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
> ---
>  server/sound.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/server/sound.c b/server/sound.c
> index bacd340..2165644 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -1166,11 +1166,14 @@ SPICE_GNUC_VISIBLE void
> spice_server_playback_get_buffer(SpicePlaybackInstance *
>                                                           uint32_t **frame,
>                                                           uint32_t
>                                                           *num_samples)
>  {
>      SndChannelClient *client = sin->st->channel.connection;
> -    PlaybackChannelClient *playback_client = SPICE_CONTAINEROF(client,
> PlaybackChannelClient, base);
>  
> -    if (!client || !playback_client->free_frames) {
> -        *frame = NULL;
> -        *num_samples = 0;
> +    *frame = NULL;
> +    *num_samples = 0;
> +    if (!client) {
> +        return;
> +    }
> +    PlaybackChannelClient *playback_client = SPICE_CONTAINEROF(client,
> PlaybackChannelClient, base);
> +    if (!playback_client->free_frames) {
>          return;
>      }
>      spice_assert(client->active);

Frediano


More information about the Spice-devel mailing list