[Spice-devel] [spice-server 3/3] audio: Improve snd_receive type-safety

Christophe Fergeau cfergeau at redhat.com
Tue Apr 5 13:09:50 UTC 2016


We can pass it a SndChannel rather than an opaque void* data pointer
which we then blindly cast.
This came to light through a -Wshadow warning as there was a local
variable 'data' in addition to the 'data' parameter.
---
 server/sound.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/server/sound.c b/server/sound.c
index 7ec0c6a..46f2cb1 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -185,7 +185,7 @@ typedef struct RecordChannel {
 static SndWorker *workers;
 static uint32_t playback_compression = TRUE;
 
-static void snd_receive(void* data);
+static void snd_receive(SndChannel *channel);
 
 static SndChannel *snd_channel_ref(SndChannel *channel)
 {
@@ -420,9 +420,8 @@ static int snd_record_handle_message(SndChannel *channel, size_t size, uint32_t
     return TRUE;
 }
 
-static void snd_receive(void* data)
+static void snd_receive(SndChannel *channel)
 {
-    SndChannel *channel = (SndChannel*)data;
     SpiceDataHeaderOpaque *header;
 
     if (!channel) {
@@ -1364,7 +1363,7 @@ SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance
 
     if (len < bufsize) {
         SndWorker *worker = record_channel->base.worker;
-        snd_receive(record_channel);
+        snd_receive(&record_channel->base);
         if (!worker->connection) {
             return 0;
         }
-- 
2.5.5



More information about the Spice-devel mailing list