From bb0831cc105de856a4a6f15191f133e73b37d361 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Fri, 7 May 2021 19:42:38 +0100 Subject: [PATCH] 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 --- common/canvas_base.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 #ifdef USE_LZ4 -#ifndef WIN32 -#include -#endif #include #endif #include @@ -49,7 +46,7 @@ typedef struct SPICE_ATTR_PACKED { } uint32_unaligned_t; #include -#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.