[PATCH] pass proper type to SPICE_CONTAINEROF

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

 



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@xxxxxxxxxx>
---
 server/display-channel.c | 2 +-
 server/snd_worker.c      | 2 +-
 server/tree.c            | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)


This patch fixes compilation errors if SPICE_CONTAINEROF check
the type of the pointer.


diff --git a/server/display-channel.c b/server/display-channel.c
index 7017b2a..c70694a 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/snd_worker.c b/server/snd_worker.c
index b039939..1b9bad5 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.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 a3dfbde..9723284 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@xxxxxxxxxxxxxxxxxxxxx
http://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]