[Spice-commits] 8 commits - server/char-device.h server/cursor-channel.cpp server/cursor-channel.h server/image-encoders.cpp server/red-stream-device.cpp server/red-worker.cpp server/sound.cpp server/spicevmc.cpp server/spice-wrapped.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 28 13:39:28 UTC 2020


 server/char-device.h         |    4 +-
 server/cursor-channel.cpp    |   59 +++++++++++++++++++------------------------
 server/cursor-channel.h      |    9 ++----
 server/image-encoders.cpp    |    4 +-
 server/red-stream-device.cpp |    4 +-
 server/red-worker.cpp        |   14 +++++-----
 server/sound.cpp             |    6 ----
 server/spice-wrapped.h       |    4 ++
 server/spicevmc.cpp          |   18 ++-----------
 9 files changed, 52 insertions(+), 70 deletions(-)

New commits:
commit 4dbc6dae01e8a9fb07b3ee09c7547a2706b1b46c
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Wed May 6 19:55:52 2020 +0100

    cursor-channel: Turn cursor_channel_reset into method
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/server/cursor-channel.cpp b/server/cursor-channel.cpp
index 4171da2b..c8d4a227 100644
--- a/server/cursor-channel.cpp
+++ b/server/cursor-channel.cpp
@@ -254,21 +254,19 @@ void CursorChannel::process_cmd(RedCursorCmd *cursor_cmd)
     }
 }
 
-void cursor_channel_reset(CursorChannel *cursor)
+void CursorChannel::reset()
 {
-    spice_return_if_fail(cursor);
-
-    cursor_channel_set_item(cursor, NULL);
-    cursor->cursor_visible = true;
-    cursor->cursor_position.x = cursor->cursor_position.y = 0;
-    cursor->cursor_trail_length = cursor->cursor_trail_frequency = 0;
-
-    if (cursor->is_connected()) {
-        cursor->pipes_add_type(RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
-        if (!cursor->get_during_target_migrate()) {
-            cursor->pipes_add_empty_msg(SPICE_MSG_CURSOR_RESET);
+    cursor_channel_set_item(this, NULL);
+    cursor_visible = true;
+    cursor_position.x = cursor_position.y = 0;
+    cursor_trail_length = cursor_trail_frequency = 0;
+
+    if (is_connected()) {
+        pipes_add_type(RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
+        if (!get_during_target_migrate()) {
+            pipes_add_empty_msg(SPICE_MSG_CURSOR_RESET);
         }
-        cursor->wait_all_sent(COMMON_CLIENT_TIMEOUT);
+        wait_all_sent(COMMON_CLIENT_TIMEOUT);
     }
 }
 
diff --git a/server/cursor-channel.h b/server/cursor-channel.h
index 126834da..d223c965 100644
--- a/server/cursor-channel.h
+++ b/server/cursor-channel.h
@@ -36,6 +36,7 @@ struct CursorChannel final: public CommonGraphicsChannel
     CursorChannel(RedsState *reds, uint32_t id,
                   SpiceCoreInterfaceInternal *core=nullptr, Dispatcher *dispatcher=nullptr);
     ~CursorChannel();
+    void reset();
     void do_init();
     void process_cmd(RedCursorCmd *cursor_cmd);
     void set_mouse_mode(uint32_t mode);
@@ -61,8 +62,6 @@ red::shared_ptr<CursorChannel> cursor_channel_new(RedsState *server, int id,
                                                   SpiceCoreInterfaceInternal *core,
                                                   Dispatcher *dispatcher);
 
-void                 cursor_channel_reset       (CursorChannel *cursor);
-
 #include "pop-visibility.h"
 
 #endif /* CURSOR_CHANNEL_H_ */
diff --git a/server/red-worker.cpp b/server/red-worker.cpp
index e54e7a9e..86b02bfd 100644
--- a/server/red-worker.cpp
+++ b/server/red-worker.cpp
@@ -395,7 +395,7 @@ static void handle_dev_destroy_surfaces(void *opaque, void *payload)
 
     flush_all_qxl_commands(worker);
     display_channel_destroy_surfaces(worker->display_channel);
-    cursor_channel_reset(worker->cursor_channel);
+    worker->cursor_channel->reset();
 }
 
 static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id,
@@ -478,7 +478,7 @@ static void destroy_primary_surface(RedWorker *worker, uint32_t surface_id)
     */
     spice_warn_if_fail(!display_channel_surface_has_canvas(display, surface_id));
 
-    cursor_channel_reset(worker->cursor_channel);
+    worker->cursor_channel->reset();
 }
 
 static void handle_dev_destroy_primary_surface(void *opaque, void *payload)
@@ -583,7 +583,7 @@ static void handle_dev_reset_cursor(void *opaque, void *payload)
 {
     RedWorker *worker = (RedWorker*) opaque;
 
-    cursor_channel_reset(worker->cursor_channel);
+    worker->cursor_channel->reset();
 }
 
 static void handle_dev_reset_image_cache(void *opaque, void *payload)
@@ -609,7 +609,7 @@ static void handle_dev_destroy_surfaces_async(void *opaque, void *payload)
 
     flush_all_qxl_commands(worker);
     display_channel_destroy_surfaces(worker->display_channel);
-    cursor_channel_reset(worker->cursor_channel);
+    worker->cursor_channel->reset();
     red_qxl_async_complete(worker->qxl, msg->base.cookie);
 }
 
commit e044c5bd507807a02204884537bbf9c258bc7523
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Wed May 6 19:52:51 2020 +0100

    cursor-channel: Turn cursor_channel_set_mouse_mode into method
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/server/cursor-channel.cpp b/server/cursor-channel.cpp
index c5d60882..4171da2b 100644
--- a/server/cursor-channel.cpp
+++ b/server/cursor-channel.cpp
@@ -293,11 +293,9 @@ void CursorChannel::do_init()
     cursor_channel_init_client(this, NULL);
 }
 
-void cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode)
+void CursorChannel::set_mouse_mode(uint32_t mode)
 {
-    spice_return_if_fail(cursor);
-
-    cursor->mouse_mode = mode;
+    mouse_mode = mode;
 }
 
 /**
diff --git a/server/cursor-channel.h b/server/cursor-channel.h
index 0a60e03e..126834da 100644
--- a/server/cursor-channel.h
+++ b/server/cursor-channel.h
@@ -38,6 +38,7 @@ struct CursorChannel final: public CommonGraphicsChannel
     ~CursorChannel();
     void do_init();
     void process_cmd(RedCursorCmd *cursor_cmd);
+    void set_mouse_mode(uint32_t mode);
     void on_connect(RedClient *client, RedStream *stream, int migration,
                     RedChannelCapabilities *caps) override;
 
@@ -61,7 +62,6 @@ red::shared_ptr<CursorChannel> cursor_channel_new(RedsState *server, int id,
                                                   Dispatcher *dispatcher);
 
 void                 cursor_channel_reset       (CursorChannel *cursor);
-void                 cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode);
 
 #include "pop-visibility.h"
 
diff --git a/server/red-worker.cpp b/server/red-worker.cpp
index 9824d1d1..e54e7a9e 100644
--- a/server/red-worker.cpp
+++ b/server/red-worker.cpp
@@ -707,7 +707,7 @@ static void handle_dev_set_mouse_mode(void *opaque, void *payload)
     RedWorker *worker = (RedWorker*) opaque;
 
     spice_debug("mouse mode %u", msg->mode);
-    cursor_channel_set_mouse_mode(worker->cursor_channel, msg->mode);
+    worker->cursor_channel->set_mouse_mode(msg->mode);
 }
 
 static void dev_add_memslot(RedWorker *worker, QXLDevMemSlot mem_slot)
commit f30d35a8c71dfa77d7d41f25ca114dde27341a2a
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Wed May 6 19:51:05 2020 +0100

    cursor-channel: Turn cursor_channel_do_init into method
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/server/cursor-channel.cpp b/server/cursor-channel.cpp
index 6bc3e874..c5d60882 100644
--- a/server/cursor-channel.cpp
+++ b/server/cursor-channel.cpp
@@ -288,9 +288,9 @@ static void cursor_channel_init_client(CursorChannel *cursor, CursorChannelClien
         cursor->pipes_add_type(RED_PIPE_ITEM_TYPE_CURSOR_INIT);
 }
 
-void cursor_channel_do_init(CursorChannel *cursor)
+void CursorChannel::do_init()
 {
-    cursor_channel_init_client(cursor, NULL);
+    cursor_channel_init_client(this, NULL);
 }
 
 void cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode)
diff --git a/server/cursor-channel.h b/server/cursor-channel.h
index 7ecccea7..0a60e03e 100644
--- a/server/cursor-channel.h
+++ b/server/cursor-channel.h
@@ -36,6 +36,7 @@ struct CursorChannel final: public CommonGraphicsChannel
     CursorChannel(RedsState *reds, uint32_t id,
                   SpiceCoreInterfaceInternal *core=nullptr, Dispatcher *dispatcher=nullptr);
     ~CursorChannel();
+    void do_init();
     void process_cmd(RedCursorCmd *cursor_cmd);
     void on_connect(RedClient *client, RedStream *stream, int migration,
                     RedChannelCapabilities *caps) override;
@@ -60,7 +61,6 @@ red::shared_ptr<CursorChannel> cursor_channel_new(RedsState *server, int id,
                                                   Dispatcher *dispatcher);
 
 void                 cursor_channel_reset       (CursorChannel *cursor);
-void                 cursor_channel_do_init     (CursorChannel *cursor);
 void                 cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode);
 
 #include "pop-visibility.h"
diff --git a/server/red-worker.cpp b/server/red-worker.cpp
index c6d1020f..9824d1d1 100644
--- a/server/red-worker.cpp
+++ b/server/red-worker.cpp
@@ -448,7 +448,7 @@ static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id,
         display->push();
     }
 
-    cursor_channel_do_init(worker->cursor_channel);
+    worker->cursor_channel->do_init();
 }
 
 static void handle_dev_create_primary_surface(void *opaque, void *payload)
commit 0528fadff38aa6cc85ae997841899b0a454a5493
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Wed May 6 19:49:19 2020 +0100

    cursor-channel: Turn cursor_channel_process_cmd into method
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/server/cursor-channel.cpp b/server/cursor-channel.cpp
index aa35e4a6..6bc3e874 100644
--- a/server/cursor-channel.cpp
+++ b/server/cursor-channel.cpp
@@ -212,32 +212,31 @@ cursor_channel_new(RedsState *server, int id,
     return red::make_shared<CursorChannel>(server, id, core, dispatcher);
 }
 
-void cursor_channel_process_cmd(CursorChannel *cursor, RedCursorCmd *cursor_cmd)
+void CursorChannel::process_cmd(RedCursorCmd *cursor_cmd)
 {
     RedCursorPipeItem *cursor_pipe_item;
     bool cursor_show = false;
 
-    spice_return_if_fail(cursor);
     spice_return_if_fail(cursor_cmd);
 
     cursor_pipe_item = cursor_pipe_item_new(cursor_cmd);
 
     switch (cursor_cmd->type) {
     case QXL_CURSOR_SET:
-        cursor->cursor_visible = !!cursor_cmd->u.set.visible;
-        cursor_channel_set_item(cursor, cursor_pipe_item);
+        cursor_visible = !!cursor_cmd->u.set.visible;
+        cursor_channel_set_item(this, cursor_pipe_item);
         break;
     case QXL_CURSOR_MOVE:
-        cursor_show = !cursor->cursor_visible;
-        cursor->cursor_visible = true;
-        cursor->cursor_position = cursor_cmd->u.position;
+        cursor_show = !cursor_visible;
+        cursor_visible = true;
+        cursor_position = cursor_cmd->u.position;
         break;
     case QXL_CURSOR_HIDE:
-        cursor->cursor_visible = false;
+        cursor_visible = false;
         break;
     case QXL_CURSOR_TRAIL:
-        cursor->cursor_trail_length = cursor_cmd->u.trail.length;
-        cursor->cursor_trail_frequency = cursor_cmd->u.trail.frequency;
+        cursor_trail_length = cursor_cmd->u.trail.length;
+        cursor_trail_frequency = cursor_cmd->u.trail.frequency;
         break;
     default:
         spice_warning("invalid cursor command %u", cursor_cmd->type);
@@ -245,11 +244,11 @@ void cursor_channel_process_cmd(CursorChannel *cursor, RedCursorCmd *cursor_cmd)
         return;
     }
 
-    if (cursor->is_connected() &&
-        (cursor->mouse_mode == SPICE_MOUSE_MODE_SERVER
+    if (is_connected() &&
+        (mouse_mode == SPICE_MOUSE_MODE_SERVER
          || cursor_cmd->type != QXL_CURSOR_MOVE
          || cursor_show)) {
-        cursor->pipes_add(&cursor_pipe_item->base);
+        pipes_add(&cursor_pipe_item->base);
     } else {
         red_pipe_item_unref(&cursor_pipe_item->base);
     }
diff --git a/server/cursor-channel.h b/server/cursor-channel.h
index 6ae8b079..7ecccea7 100644
--- a/server/cursor-channel.h
+++ b/server/cursor-channel.h
@@ -36,6 +36,7 @@ struct CursorChannel final: public CommonGraphicsChannel
     CursorChannel(RedsState *reds, uint32_t id,
                   SpiceCoreInterfaceInternal *core=nullptr, Dispatcher *dispatcher=nullptr);
     ~CursorChannel();
+    void process_cmd(RedCursorCmd *cursor_cmd);
     void on_connect(RedClient *client, RedStream *stream, int migration,
                     RedChannelCapabilities *caps) override;
 
@@ -60,7 +61,6 @@ red::shared_ptr<CursorChannel> cursor_channel_new(RedsState *server, int id,
 
 void                 cursor_channel_reset       (CursorChannel *cursor);
 void                 cursor_channel_do_init     (CursorChannel *cursor);
-void                 cursor_channel_process_cmd (CursorChannel *cursor, RedCursorCmd *cursor_cmd);
 void                 cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode);
 
 #include "pop-visibility.h"
diff --git a/server/red-stream-device.cpp b/server/red-stream-device.cpp
index d1f08898..73dd6527 100644
--- a/server/red-stream-device.cpp
+++ b/server/red-stream-device.cpp
@@ -472,7 +472,7 @@ StreamDevice::handle_msg_cursor_set(SpiceCharDeviceInstance *sin)
     if (!cmd) {
         return handle_msg_invalid(sin, NULL);
     }
-    cursor_channel_process_cmd(cursor_channel.get(), cmd);
+    cursor_channel->process_cmd(cmd);
 
     return true;
 }
@@ -499,7 +499,7 @@ StreamDevice::handle_msg_cursor_move(SpiceCharDeviceInstance *sin)
     cmd->u.position.x = move->x;
     cmd->u.position.y = move->y;
 
-    cursor_channel_process_cmd(cursor_channel.get(), cmd);
+    cursor_channel->process_cmd(cmd);
 
     return true;
 }
diff --git a/server/red-worker.cpp b/server/red-worker.cpp
index cbb89a66..c6d1020f 100644
--- a/server/red-worker.cpp
+++ b/server/red-worker.cpp
@@ -99,7 +99,7 @@ static gboolean red_process_cursor_cmd(RedWorker *worker, const QXLCommandExt *e
         return FALSE;
     }
 
-    cursor_channel_process_cmd(worker->cursor_channel, cursor_cmd);
+    worker->cursor_channel->process_cmd(cursor_cmd);
     red_cursor_cmd_unref(cursor_cmd);
 
     return TRUE;
commit aa0dddde0f628989f27132b942d9313dec8760f9
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Tue May 5 02:26:34 2020 +0100

    sound: Move define "trick" to spice-wrapped.h header
    
    The spice-wrapped.h was introduced to deal with such tricks
    in the code and limit them to a single place.
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/server/sound.cpp b/server/sound.cpp
index ace4a1f0..859c9c8b 100644
--- a/server/sound.cpp
+++ b/server/sound.cpp
@@ -73,10 +73,6 @@ struct PlaybackChannelClient;
 struct RecordChannelClient;
 struct AudioFrame;
 struct AudioFrameContainer;
-typedef struct SpicePlaybackState PlaybackChannel;
-#define PlaybackChannel SpicePlaybackState
-typedef struct SpiceRecordState RecordChannel;
-#define RecordChannel SpiceRecordState
 
 struct PersistentPipeItem: public RedPipeItem
 {
@@ -162,7 +158,7 @@ typedef struct SpiceVolumeState {
     int mute;
 } SpiceVolumeState;
 
-/* Base class for SpicePlaybackState and SpiceRecordState */
+/* Base class for PlaybackChannel and RecordChannel */
 struct SndChannel: public RedChannel
 {
     using RedChannel::RedChannel;
diff --git a/server/spice-wrapped.h b/server/spice-wrapped.h
index cfcbc227..769f652f 100644
--- a/server/spice-wrapped.h
+++ b/server/spice-wrapped.h
@@ -24,6 +24,8 @@
 #define SPICE_GNUC_DEPRECATED
 
 #define SpiceCharDeviceState RedCharDevice
+#define SpicePlaybackState PlaybackChannel
+#define SpiceRecordState RecordChannel
 
 #include "push-visibility.h"
 struct RedCharDevice;
@@ -33,3 +35,5 @@ struct SpiceCharDeviceInstance;
 #include "spice.h"
 
 #undef SpiceCharDeviceState
+#undef SpicePlaybackState
+#undef SpiceRecordState
commit bd17418f9e576e5035004db413b6c886560cac51
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Tue May 5 05:08:16 2020 +0100

    char-device: Make RedCharDevice::write_retry private
    
    Not meant to be called externally.
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/server/char-device.h b/server/char-device.h
index daf0d44c..4aa8cd7f 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -208,8 +208,6 @@ public:
     /* This cb is called when device receives an event */
     virtual void port_event(uint8_t event);
 
-    // XXX private
-    static void write_retry(RedCharDevice *dev);
 private:
     inline void write_buffer_release(RedCharDeviceWriteBuffer **p_write_buf)
     {
@@ -217,6 +215,8 @@ private:
     }
     int write_to_device();
     void init_device_instance();
+
+    static void write_retry(RedCharDevice *dev);
 };
 
 /* api for specific char devices */
commit 19f3406db64fd9d23aa1e3790b31024b69ec357e
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Tue May 5 05:57:28 2020 +0100

    spicevmc: Cleanup some "this" usage
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/server/spicevmc.cpp b/server/spicevmc.cpp
index 027c391b..265f6049 100644
--- a/server/spicevmc.cpp
+++ b/server/spicevmc.cpp
@@ -249,8 +249,6 @@ static RedVmcPipeItem* try_compress_lz4(RedVmcChannel *channel, int n, RedVmcPip
 
 RedPipeItem* RedCharDeviceSpiceVmc::read_one_msg_from_device(SpiceCharDeviceInstance *sin)
 {
-    RedCharDeviceSpiceVmc *vmc = this;
-    RedVmcChannel *channel = vmc->channel.get();
     SpiceCharDeviceInterface *sif;
     RedVmcPipeItem *msg_item;
     int n;
@@ -278,16 +276,16 @@ RedPipeItem* RedCharDeviceSpiceVmc::read_one_msg_from_device(SpiceCharDeviceInst
 #ifdef USE_LZ4
         RedVmcPipeItem *msg_item_compressed;
 
-        msg_item_compressed = try_compress_lz4(channel, n, msg_item);
+        msg_item_compressed = try_compress_lz4(channel.get(), n, msg_item);
         if (msg_item_compressed != NULL) {
-            spicevmc_red_channel_queue_data(channel, msg_item_compressed);
+            spicevmc_red_channel_queue_data(channel.get(), msg_item_compressed);
             return NULL;
         }
 #endif
         stat_inc_counter(channel->out_data, n);
         msg_item->uncompressed_data_size = n;
         msg_item->buf_used = n;
-        spicevmc_red_channel_queue_data(channel, msg_item);
+        spicevmc_red_channel_queue_data(channel.get(), msg_item);
         return NULL;
     }
     channel->pipe_item = msg_item;
@@ -326,8 +324,6 @@ static void spicevmc_port_send_event(RedChannelClient *rcc, uint8_t event)
 void RedCharDeviceSpiceVmc::remove_client(RedCharDeviceClientOpaque *opaque)
 {
     RedClient *client = (RedClient *) opaque;
-    RedCharDeviceSpiceVmc *vmc = this;
-    RedVmcChannel *channel = vmc->channel.get();
 
     spice_assert(channel->rcc &&
                  channel->rcc->get_client() == client);
@@ -470,9 +466,6 @@ bool VmcChannelClient::handle_message(uint16_t type, uint32_t size, void *msg)
 /* if device manage to send some data attempt to unblock the channel */
 void RedCharDeviceSpiceVmc::on_free_self_token()
 {
-    RedCharDeviceSpiceVmc *vmc = this;
-    RedVmcChannel *channel = vmc->channel.get();
-
     channel->rcc->unblock_read();
 }
 
@@ -682,11 +675,6 @@ spicevmc_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin, uint8_t c
 
 void RedCharDeviceSpiceVmc::port_event(uint8_t event)
 {
-    RedVmcChannel *channel;
-    RedCharDeviceSpiceVmc *device = this;
-
-    channel = device->channel.get();
-
     if (event == SPICE_PORT_EVENT_OPENED) {
         channel->port_opened = TRUE;
     } else if (event == SPICE_PORT_EVENT_CLOSED) {
commit fc55e9fa27c2b1c7b280206b8152992da7b66eb0
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Tue May 5 14:20:27 2020 +0100

    image-encoders: Fix compile warnings for ARM7 platform
    
    Compiling under ARM7 GCC compiler report these warning:
    
    image-encoders.cpp: In function 'int lz4_usr_more_space(Lz4EncoderUsrContext*, uint8_t**)':
    image-encoders.cpp:261:32: error: cast from 'Lz4EncoderUsrContext*' to 'Lz4Data*' increases required alignment of target type [-Werror=cast-align]
      261 |     EncoderData *usr_data = &(((Lz4Data *)usr)->data);
          |                                ^~~~~~~~~~~~~~
    image-encoders.cpp: In function 'int lz4_usr_more_lines(Lz4EncoderUsrContext*, uint8_t**)':
    image-encoders.cpp:329:32: error: cast from 'Lz4EncoderUsrContext*' to 'Lz4Data*' increases required alignment of target type [-Werror=cast-align]
      329 |     EncoderData *usr_data = &(((Lz4Data *)usr)->data);
          |                                ^~~~~~~~~~~~~~
    
    In all other occurrences of these cast we are already using
    SPICE_CONTAINEROF.
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/server/image-encoders.cpp b/server/image-encoders.cpp
index d9c25cd6..7e019c27 100644
--- a/server/image-encoders.cpp
+++ b/server/image-encoders.cpp
@@ -258,7 +258,7 @@ static int jpeg_usr_more_space(JpegEncoderUsrContext *usr, uint8_t **io_ptr)
 #ifdef USE_LZ4
 static int lz4_usr_more_space(Lz4EncoderUsrContext *usr, uint8_t **io_ptr)
 {
-    EncoderData *usr_data = &(((Lz4Data *)usr)->data);
+    EncoderData *usr_data = &(SPICE_CONTAINEROF(usr, Lz4Data, usr)->data);
     return encoder_usr_more_space(usr_data, io_ptr);
 }
 #endif
@@ -326,7 +326,7 @@ static int jpeg_usr_more_lines(JpegEncoderUsrContext *usr, uint8_t **lines)
 #ifdef USE_LZ4
 static int lz4_usr_more_lines(Lz4EncoderUsrContext *usr, uint8_t **lines)
 {
-    EncoderData *usr_data = &(((Lz4Data *)usr)->data);
+    EncoderData *usr_data = &(SPICE_CONTAINEROF(usr, Lz4Data, usr)->data);
     return encoder_usr_more_lines(usr_data, lines);
 }
 #endif


More information about the Spice-commits mailing list