[Spice-devel] [PATCH] pass proper type to SPICE_CONTAINEROF

Fabiano FidĂȘncio fidencio at redhat.com
Fri Dec 4 05:32:59 PST 2015


On Fri, Dec 4, 2015 at 12:38 PM, Frediano Ziglio <fziglio at redhat.com> wrote:
> In some case the member specified to SPICE_CONTAINEROF was not
> exactly the same type of the pointer passed.
> This can cause issues if structure changes so use proper member.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/display-channel.c | 2 +-
>  server/sound.c           | 2 +-
>  server/tree.c            | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 2ef1c88..f0ff2bd 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -429,7 +429,7 @@ static void current_remove(DisplayChannel *display, TreeItem *item)
>          RingItem *ring_item;
>
>          if (now->type == TREE_ITEM_TYPE_DRAWABLE) {
> -            Drawable *drawable = SPICE_CONTAINEROF(now, Drawable, tree_item);
> +            Drawable *drawable = SPICE_CONTAINEROF(now, Drawable, tree_item.base);
>              ring_item = now->siblings_link.prev;
>              drawable_remove_from_pipes(drawable);
>              current_remove_drawable(display, drawable);
> diff --git a/server/sound.c b/server/sound.c
> index 2d3f393..0c94964 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -1102,7 +1102,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_put_samples(SpicePlaybackInstance
>      PlaybackChannel *playback_channel;
>      AudioFrame *frame;
>
> -    frame = SPICE_CONTAINEROF(samples, AudioFrame, samples);
> +    frame = SPICE_CONTAINEROF(samples, AudioFrame, samples[0]);
>      playback_channel = frame->channel;
>      spice_assert(playback_channel);
>      if (!snd_channel_put(&playback_channel->base) ||
> diff --git a/server/tree.c b/server/tree.c
> index e5e3c76..9e5a281 100644
> --- a/server/tree.c
> +++ b/server/tree.c
> @@ -129,7 +129,7 @@ static void dump_item(TreeItem *item, void *data)
>
>      switch (item->type) {
>      case TREE_ITEM_TYPE_DRAWABLE: {
> -        Drawable *drawable = SPICE_CONTAINEROF(item, Drawable, tree_item);
> +        Drawable *drawable = SPICE_CONTAINEROF(item, Drawable, tree_item.base);
>          const int max_indent = 200;
>          char indent_str[max_indent + 1];
>          int indent_str_len;
> --
> 2.4.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

Acked-by: Fabiano FidĂȘncio <fidencio at redhat.com>


More information about the Spice-devel mailing list