[Spice-commits] common/canvas_base.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 18 13:19:40 UTC 2021


 common/canvas_base.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

New commits:
commit bb0831cc105de856a4a6f15191f133e73b37d361
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Fri May 7 19:42:38 2021 +0100

    canvas_base: Fix missing ntohl for Win32 platform
    
    Win32 requires winsock2.h to be included in order to use ntohl.
    To avoid the include use GUINT32_FROM_BE instead, already available.
    
    This problem was reported by Biswapriyo Nath whom also tested the
    solution for Win32.
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 175a8a2..906fb83 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -25,9 +25,6 @@
 #include <math.h>
 
 #ifdef USE_LZ4
-#ifndef WIN32
-#include <arpa/inet.h>
-#endif
 #include <lz4.h>
 #endif
 #include <spice/macros.h>
@@ -49,7 +46,7 @@ typedef struct SPICE_ATTR_PACKED {
 } uint32_unaligned_t;
 #include <spice/end-packed.h>
 
-#define read_uint32_be(ptr) ntohl(((uint32_unaligned_t *)(ptr))->v)
+#define READ_UINT32_BE(ptr) GUINT32_FROM_BE(((uint32_unaligned_t *)(ptr))->v)
 
 #define ROUND(_x) ((int)floor((_x) + 0.5))
 
@@ -585,7 +582,7 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image)
             goto format_error;
         }
         // Read next compressed block
-        enc_size = read_uint32_be(data);
+        enc_size = READ_UINT32_BE(data);
         data += 4;
         /* check overflow. This check is a bit different to avoid
          * possible overflows. From previous check data_end - data cannot overflow.


More information about the Spice-commits mailing list