From: Frediano Ziglio <[email protected]>

This avoid that on full buffers compression is not attempted

Signed-off-by: Frediano Ziglio <[email protected]>
---
 server/spicevmc.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/server/spicevmc.c b/server/spicevmc.c
index f2b3be3..dce0dc6 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -123,7 +123,7 @@ static void 
spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient *rcc,
 static RedVmcPipeItem* try_compress_lz4(SpiceVmcState *state, int n, 
RedVmcPipeItem *msg_item)
 {
     RedVmcPipeItem *msg_item_compressed;
-    int bound, compressed_data_count;
+    int compressed_data_count;
 
     if (reds_stream_get_family(state->rcc->stream) == AF_UNIX) {
         /* AF_LOCAL - data will not be compressed */
@@ -137,17 +137,12 @@ static RedVmcPipeItem* try_compress_lz4(SpiceVmcState 
*state, int n, RedVmcPipeI
         /* Client doesn't has compression cap - data will not be compressed */
         return NULL;
     }
-    bound = LZ4_compressBound(n);
-    if (bound == 0 || bound >= BUF_SIZE) {
-        /* bound is invalid - data will not be compressed */
-        return NULL;
-    }
     msg_item_compressed = spice_new0(RedVmcPipeItem, 1);
     red_pipe_item_init(&msg_item_compressed->base, 
RED_PIPE_ITEM_TYPE_SPICEVMC_DATA);
     compressed_data_count = LZ4_compress_default((char*)&msg_item->buf,
                                                  
(char*)&msg_item_compressed->buf,
                                                  n,
-                                                 bound);
+                                                 BUF_SIZE);
 
     if (compressed_data_count > 0) {
         msg_item_compressed->type = SPICE_DATA_COMPRESSION_TYPE_LZ4;
-- 
2.5.5

_______________________________________________
Spice-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to