[Spice-devel] [PATCH spice-server 3/3] char-device: Avoid possible invalid function pointer cast

Frediano Ziglio fziglio at redhat.com
Sun May 6 11:10:33 UTC 2018


This is reported by GCC 8.0.1 (Fedora 28).
Instead of doing a possible invalid cast destroy and create the
queue again.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/char-device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/char-device.c b/server/char-device.c
index 242d8782..aef6e887 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -835,8 +835,8 @@ void red_char_device_reset(RedCharDevice *dev)
 
         spice_debug("send_queue_empty %d", g_queue_is_empty(dev_client->send_queue));
         dev_client->num_send_tokens += g_queue_get_length(dev_client->send_queue);
-        g_queue_foreach(dev_client->send_queue, (GFunc)red_pipe_item_unref, NULL);
-        g_queue_clear(dev_client->send_queue);
+        g_queue_free_full(dev_client->send_queue, (GDestroyNotify)red_pipe_item_unref);
+        dev_client->send_queue = g_queue_new();
 
         /* If device is reset, we must reset the tokens counters as well as we
          * don't hold any data from client and upon agent's reconnection we send
-- 
2.17.0



More information about the Spice-devel mailing list