From 6bc7f6ca8822e80ec580f27096ebeb8488ddd5ac Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 28 Apr 2022 11:41:46 +0200 Subject: [PATCH] Fixed cast-qual warnings --- client/X11/xf_cliprdr.c | 11 ++++--- .../primitives/test/TestPrimitivesColors.c | 16 +++++---- .../primitives/test/TestPrimitivesYCbCr.c | 21 +++++++----- .../primitives/test/TestPrimitivesYUV.c | 33 +++++++++++++------ winpr/libwinpr/crt/test/TestString.c | 2 +- 5 files changed, 54 insertions(+), 29 deletions(-) diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 143e51c83..4f5164d05 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -1444,14 +1444,15 @@ xf_cliprdr_server_file_contents_response(CliprdrClientContext* context, break; } UINT64 size; - wStream* s = Stream_New((BYTE*)data, data_len); + wStream sbuffer = { 0 }; + wStream* s = Stream_StaticConstInit(&sbuffer, data, data_len); if (!s) { fuse_reply_err(req, ENOMEM); break; } Stream_Read_UINT64(s, size); - Stream_Free(s, FALSE); + ArrayList_Lock(clipboard->ino_list); ino = xf_cliprdr_fuse_util_get_inode(clipboard->ino_list, req_ino); /* ino must be exists and */ @@ -1984,6 +1985,9 @@ error: static BOOL xf_cliprdr_fuse_generate_list(xfClipboard* clipboard, const BYTE* data, UINT32 size) { BOOL status = FALSE; + wStream sbuffer = { 0 }; + wStream* s; + if (size < 4) { WLog_ERR(TAG, "size of format data response invalid : %d", size); @@ -1993,7 +1997,7 @@ static BOOL xf_cliprdr_fuse_generate_list(xfClipboard* clipboard, const BYTE* da if (count < 1) return FALSE; - wStream* s = Stream_New((BYTE*)data, size); + s = Stream_StaticConstInit(&sbuffer, data, size); if (!s || !xf_cliprdr_fuse_check_stream(s, count)) { WLog_ERR(TAG, "Stream_New failed"); @@ -2016,7 +2020,6 @@ static BOOL xf_cliprdr_fuse_generate_list(xfClipboard* clipboard, const BYTE* da error2: ArrayList_Unlock(clipboard->ino_list); error: - Stream_Free(s, FALSE); return status; } #endif diff --git a/libfreerdp/primitives/test/TestPrimitivesColors.c b/libfreerdp/primitives/test/TestPrimitivesColors.c index de75c3a58..927b4f218 100644 --- a/libfreerdp/primitives/test/TestPrimitivesColors.c +++ b/libfreerdp/primitives/test/TestPrimitivesColors.c @@ -119,6 +119,11 @@ fail: /* ------------------------------------------------------------------------- */ static BOOL test_RGBToRGB_16s8u_P3AC4R_speed(void) { + union + { + const UINT16** cpv; + UINT16** pv; + } cnv; const prim_size_t roi64x64 = { 64, 64 }; INT16 ALIGN(r[4096 + 1]), ALIGN(g[4096 + 1]), ALIGN(b[4096 + 1]); UINT32 ALIGN(dst[4096 + 1]); @@ -140,16 +145,15 @@ static BOOL test_RGBToRGB_16s8u_P3AC4R_speed(void) ptrs[1] = g + 1; ptrs[2] = b + 1; + cnv.pv = ptrs; if (!speed_test("RGBToRGB_16s8u_P3AC4R", "aligned", g_Iterations, - (speed_test_fkt)generic->RGBToRGB_16s8u_P3AC4R, - (speed_test_fkt)optimized->RGBToRGB_16s8u_P3AC4R, (const INT16**)ptrs, 64 * 2, - (BYTE*)dst, 64 * 4, &roi64x64)) + generic->RGBToRGB_16s8u_P3AC4R, optimized->RGBToRGB_16s8u_P3AC4R, cnv.cpv, + 64 * 2, (BYTE*)dst, 64 * 4, &roi64x64)) return FALSE; if (!speed_test("RGBToRGB_16s8u_P3AC4R", "unaligned", g_Iterations, - (speed_test_fkt)generic->RGBToRGB_16s8u_P3AC4R, - (speed_test_fkt)optimized->RGBToRGB_16s8u_P3AC4R, (const INT16**)ptrs, 64 * 2, - ((BYTE*)dst) + 1, 64 * 4, &roi64x64)) + generic->RGBToRGB_16s8u_P3AC4R, optimized->RGBToRGB_16s8u_P3AC4R, cnv.cpv, + 64 * 2, ((BYTE*)dst) + 1, 64 * 4, &roi64x64)) return FALSE; return TRUE; diff --git a/libfreerdp/primitives/test/TestPrimitivesYCbCr.c b/libfreerdp/primitives/test/TestPrimitivesYCbCr.c index a6173b0d6..7a8d3cc88 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYCbCr.c +++ b/libfreerdp/primitives/test/TestPrimitivesYCbCr.c @@ -1562,12 +1562,17 @@ static int test_bmp_cmp_dump(const BYTE* actual, const BYTE* expected, int size, static int test_PrimitivesYCbCr(const primitives_t* prims, UINT32 format, prim_size_t roi, BOOL compare) { + union + { + const UINT16** cpv; + UINT16** pv; + } cnv; pstatus_t status = -1; int cnt[3]; float err[3]; BYTE* actual; BYTE* actual1; - const BYTE* expected; + const BYTE* expected = TEST_XRGB_IMAGE; int margin = 1; INT16* pYCbCr[3] = { NULL, NULL, NULL }; const UINT32 srcStride = roi.width * 2; @@ -1578,7 +1583,7 @@ static int test_PrimitivesYCbCr(const primitives_t* prims, UINT32 format, prim_s PROFILER_DEFINE(prof1) PROFILER_DEFINE(prof2) // return test_YCbCr_pixels(); - expected = (const BYTE*)TEST_XRGB_IMAGE; + actual = _aligned_malloc(dstSize, 16); actual1 = _aligned_malloc(dstSize, 16); PROFILER_CREATE(prof, "yCbCrToRGB_16s8u") @@ -1610,8 +1615,9 @@ static int test_PrimitivesYCbCr(const primitives_t* prims, UINT32 format, prim_s { PROFILER_ENTER(prof) - status = prims->yCbCrToRGB_16s8u_P3AC4R((const INT16**)pYCbCr, srcStride, actual, dstStride, - format, &roi); + cnv.pv = pYCbCr; + status = + prims->yCbCrToRGB_16s8u_P3AC4R(cnv.cpv, srcStride, actual, dstStride, format, &roi); if (status != PRIMITIVES_SUCCESS) goto fail; @@ -1627,16 +1633,15 @@ static int test_PrimitivesYCbCr(const primitives_t* prims, UINT32 format, prim_s CopyMemory(pSrcDst[1], pYCbCr[1], srcSize); CopyMemory(pSrcDst[2], pYCbCr[2], srcSize); PROFILER_ENTER(prof1) - status = prims->yCbCrToRGB_16s16s_P3P3((const INT16**)pSrcDst, srcStride, pSrcDst, - srcStride, &roi); + cnv.pv = pSrcDst; + status = prims->yCbCrToRGB_16s16s_P3P3(cnv.cpv, srcStride, pSrcDst, srcStride, &roi); PROFILER_EXIT(prof1) if (status != PRIMITIVES_SUCCESS) goto fail2; PROFILER_ENTER(prof2) - status = prims->RGBToRGB_16s8u_P3AC4R((const INT16**)pSrcDst, srcStride, actual1, dstStride, - format, &roi); + status = prims->RGBToRGB_16s8u_P3AC4R(cnv.pv, srcStride, actual1, dstStride, format, &roi); PROFILER_EXIT(prof2) fail2: _aligned_free(pSrcDst[0]); diff --git a/libfreerdp/primitives/test/TestPrimitivesYUV.c b/libfreerdp/primitives/test/TestPrimitivesYUV.c index e121d9d3c..10f710726 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYUV.c +++ b/libfreerdp/primitives/test/TestPrimitivesYUV.c @@ -174,6 +174,11 @@ static void free_padding(void* src, size_t padding) * Combine them and check, if the data is at the expected position. */ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) { + union + { + const UINT16** cpv; + UINT16** pv; + } cnv; UINT32 x, y, i; UINT32 awidth, aheight; BOOL rc = FALSE; @@ -251,15 +256,17 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) PROFILER_ENTER(yuvCombine) - if (prims->YUV420CombineToYUV444(AVC444_LUMA, (const BYTE**)luma, lumaStride, roi.width, - roi.height, yuv, yuvStride, &rect) != PRIMITIVES_SUCCESS) + cnv.pv = luma; + if (prims->YUV420CombineToYUV444(AVC444_LUMA, cnv.cpv, lumaStride, roi.width, roi.height, yuv, + yuvStride, &rect) != PRIMITIVES_SUCCESS) { PROFILER_EXIT(yuvCombine) goto fail; } - if (prims->YUV420CombineToYUV444(AVC444_CHROMAv1, (const BYTE**)chroma, chromaStride, roi.width, - roi.height, yuv, yuvStride, &rect) != PRIMITIVES_SUCCESS) + cnv.pv = chroma; + if (prims->YUV420CombineToYUV444(AVC444_CHROMAv1, cnv.cpv, chromaStride, roi.width, roi.height, + yuv, yuvStride, &rect) != PRIMITIVES_SUCCESS) { PROFILER_EXIT(yuvCombine) goto fail; @@ -285,8 +292,9 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) PROFILER_ENTER(yuvSplit) - if (prims->YUV444SplitToYUV420((const BYTE**)yuv, yuvStride, pmain, lumaStride, paux, - chromaStride, &roi) != PRIMITIVES_SUCCESS) + cnv.pv = yuv; + if (prims->YUV444SplitToYUV420(cnv.cpv, yuvStride, pmain, lumaStride, paux, chromaStride, + &roi) != PRIMITIVES_SUCCESS) { PROFILER_EXIT(yuvSplit) goto fail; @@ -371,6 +379,11 @@ fail: static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) { + union + { + const UINT16** cpv; + UINT16** pv; + } cnv; BOOL res = FALSE; UINT32 x, y; UINT32 awidth, aheight; @@ -501,11 +514,11 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) goto loop_fail; } + cnv.pv = yuv; if (use444) { PROFILER_ENTER(yuv444ToRGB) - rc = prims->YUV444ToRGB_8u_P3AC4R((const BYTE**)yuv, yuv_step, rgb_dst, stride, - DstFormat, &roi); + rc = prims->YUV444ToRGB_8u_P3AC4R(cnv.cpv, yuv_step, rgb_dst, stride, DstFormat, &roi); PROFILER_EXIT(yuv444ToRGB) if (rc != PRIMITIVES_SUCCESS) @@ -524,8 +537,8 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) { PROFILER_ENTER(yuv420ToRGB) - if (prims->YUV420ToRGB_8u_P3AC4R((const BYTE**)yuv, yuv_step, rgb_dst, stride, - DstFormat, &roi) != PRIMITIVES_SUCCESS) + if (prims->YUV420ToRGB_8u_P3AC4R(cnv.cpv, yuv_step, rgb_dst, stride, DstFormat, &roi) != + PRIMITIVES_SUCCESS) { PROFILER_EXIT(yuv420ToRGB) goto fail; diff --git a/winpr/libwinpr/crt/test/TestString.c b/winpr/libwinpr/crt/test/TestString.c index d27c3bbbf..ebc131ab9 100644 --- a/winpr/libwinpr/crt/test/TestString.c +++ b/winpr/libwinpr/crt/test/TestString.c @@ -82,7 +82,7 @@ int TestString(int argc, char* argv[]) if (p != NULL) { - printf("_wcschr error: return value mismatch: Actual: %p, Expected: NULL\n", (void*)p); + printf("_wcschr error: return value mismatch: Actual: %p, Expected: NULL\n", p); return -1; }