diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index f9cead2d8..8efba7d6d 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -804,11 +804,10 @@ static UINT audin_register_device_plugin(IWTSPlugin* pPlugin, IAudinDevice* devi */ static UINT audin_load_device_plugin(AUDIN_PLUGIN* audin, const char* name, const ADDIN_ARGV* args) { - PFREERDP_AUDIN_DEVICE_ENTRY entry; FREERDP_AUDIN_DEVICE_ENTRY_POINTS entryPoints; UINT error; - entry = (PFREERDP_AUDIN_DEVICE_ENTRY)freerdp_load_channel_addin_entry("audin", (LPSTR)name, - NULL, 0); + const PFREERDP_AUDIN_DEVICE_ENTRY entry = + (const PFREERDP_AUDIN_DEVICE_ENTRY)freerdp_load_channel_addin_entry("audin", name, NULL, 0); if (entry == NULL) { diff --git a/channels/client/addin.c b/channels/client/addin.c index df6894136..85e4b2751 100644 --- a/channels/client/addin.c +++ b/channels/client/addin.c @@ -48,8 +48,7 @@ static void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABL const char* identifier) { size_t index = 0; - STATIC_ENTRY* pEntry; - pEntry = (STATIC_ENTRY*)&table->table[index++]; + const STATIC_ENTRY* pEntry = (const STATIC_ENTRY*)&table->table[index++]; while (pEntry->entry != NULL) { @@ -58,7 +57,7 @@ static void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABL return (void*)pEntry->entry; } - pEntry = (STATIC_ENTRY*)&table->table[index++]; + pEntry = (const STATIC_ENTRY*)&table->table[index++]; } return NULL; @@ -91,7 +90,7 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName size_t i, j; DWORD nAddins; FREERDP_ADDIN** ppAddins = NULL; - STATIC_SUBSYSTEM_ENTRY* subsystems; + const STATIC_SUBSYSTEM_ENTRY* subsystems; nAddins = 0; ppAddins = (FREERDP_ADDIN**)calloc(128, sizeof(FREERDP_ADDIN*)); @@ -118,7 +117,7 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName pAddin->dwFlags |= FREERDP_ADDIN_STATIC; pAddin->dwFlags |= FREERDP_ADDIN_NAME; ppAddins[nAddins++] = pAddin; - subsystems = (STATIC_SUBSYSTEM_ENTRY*)CLIENT_STATIC_ADDIN_TABLE[i].table; + subsystems = (const STATIC_SUBSYSTEM_ENTRY*)CLIENT_STATIC_ADDIN_TABLE[i].table; for (j = 0; subsystems[j].name != NULL; j++) { diff --git a/channels/geometry/client/geometry_main.c b/channels/geometry/client/geometry_main.c index 8abf8fb74..7d38279dd 100644 --- a/channels/geometry/client/geometry_main.c +++ b/channels/geometry/client/geometry_main.c @@ -80,8 +80,8 @@ static UINT32 mappedGeometryHash(const void* v) static BOOL mappedGeometryKeyCompare(const void* v1, const void* v2) { - const UINT64* g1 = (UINT64*)v1; - const UINT64* g2 = (UINT64*)v2; + const UINT64* g1 = (const UINT64*)v1; + const UINT64* g2 = (const UINT64*)v2; return *g1 == *g2; } diff --git a/channels/rdpsnd/server/rdpsnd_main.c b/channels/rdpsnd/server/rdpsnd_main.c index a52f5d72d..fa5fd7b59 100644 --- a/channels/rdpsnd/server/rdpsnd_main.c +++ b/channels/rdpsnd/server/rdpsnd_main.c @@ -571,7 +571,7 @@ static UINT rdpsnd_server_send_samples(RdpsndServerContext* context, const void* CopyMemory(context->priv->out_buffer + (context->priv->out_pending_frames * context->priv->src_bytes_per_frame), buf, cframesize); - buf = (BYTE*)buf + cframesize; + buf = (const BYTE*)buf + cframesize; nframes -= cframes; context->priv->out_pending_frames += cframes; diff --git a/client/Wayland/wlf_pointer.c b/client/Wayland/wlf_pointer.c index decde7ff3..95a4f4187 100644 --- a/client/Wayland/wlf_pointer.c +++ b/client/Wayland/wlf_pointer.c @@ -72,7 +72,7 @@ static void wlf_Pointer_Free(rdpContext* context, rdpPointer* pointer) static BOOL wlf_Pointer_Set(rdpContext* context, const rdpPointer* pointer) { wlfContext* wlf = (wlfContext*)context; - wlfPointer* ptr = (wlfPointer*)pointer; + const wlfPointer* ptr = (const wlfPointer*)pointer; void* data; UINT32 w, h, x, y; size_t size; diff --git a/client/Wayland/wlfreerdp.c b/client/Wayland/wlfreerdp.c index 4e94d94e6..8a0578331 100644 --- a/client/Wayland/wlfreerdp.c +++ b/client/Wayland/wlfreerdp.c @@ -585,7 +585,7 @@ static void wlf_client_free(freerdp* instance, rdpContext* context) static void* uwac_event_clone(const void* val) { UwacEvent* copy; - UwacEvent* ev = (UwacEvent*)val; + const UwacEvent* ev = (const UwacEvent*)val; copy = calloc(1, sizeof(UwacEvent)); if (!copy) diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index fdf7d3276..af6b639ea 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -1211,7 +1211,7 @@ void xf_cliprdr_handle_xevent(xfContext* xfc, const XEvent* event) if (clipboard->xfixes_supported && event->type == XFixesSelectionNotify + clipboard->xfixes_event_base) { - XFixesSelectionNotifyEvent* se = (XFixesSelectionNotifyEvent*)event; + const XFixesSelectionNotifyEvent* se = (const XFixesSelectionNotifyEvent*)event; if (se->subtype == XFixesSetSelectionOwnerNotify) { @@ -2269,7 +2269,7 @@ static UINT xf_cliprdr_clipboard_file_range_success(wClipboardDelegate* delegate response.msgFlags = CB_RESPONSE_OK; response.streamId = request->streamId; response.cbRequested = size; - response.requestedData = (BYTE*)data; + response.requestedData = (const BYTE*)data; return clipboard->context->ClientFileContentsResponse(clipboard->context, &response); } diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index 4f52853bf..3739998bd 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -1000,9 +1000,9 @@ static BOOL xf_gdi_update_screen(xfContext* xfc, const BYTE* pSrcData, UINT32 sc UINT32 top = rects[i].top; UINT32 width = rects[i].right - rects[i].left; UINT32 height = rects[i].bottom - rects[i].top; - const BYTE* src = pSrcData + top * scanline + bpp * left; - image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*)src, width, - height, xfc->scanline_pad, scanline); + BYTE* src = pSrcData + top * scanline + bpp * left; + image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, src, width, height, + xfc->scanline_pad, scanline); if (!image) break; diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index ca6f7ba58..c70e395c5 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -227,7 +227,7 @@ static BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL pr return TRUE; } -static BOOL _xf_Pointer_GetCursorForCurrentScale(rdpContext* context, const rdpPointer* pointer, +static BOOL _xf_Pointer_GetCursorForCurrentScale(rdpContext* context, rdpPointer* pointer, Cursor* cursor) { #ifdef WITH_XCURSOR @@ -451,7 +451,7 @@ static BOOL xf_Pointer_Set(rdpContext* context, const rdpPointer* pointer) #ifdef WITH_XCURSOR xfContext* xfc = (xfContext*)context; Window handle = xf_Pointer_get_window(xfc); - xfc->pointer = (xfPointer*)pointer; + xfc->pointer = (const xfPointer*)pointer; /* in RemoteApp mode, window can be null if none has had focus */ @@ -566,12 +566,12 @@ out: } /* Glyph Class */ -static BOOL xf_Glyph_New(rdpContext* context, const rdpGlyph* glyph) +static BOOL xf_Glyph_New(rdpContext* context, rdpGlyph* glyph) { int scanline; XImage* image; - xfGlyph* xf_glyph; - xf_glyph = (xfGlyph*)glyph; + xfGlyph* xf_glyph = (xfGlyph*)glyph; + xfContext* xfc = (xfContext*)context; xf_lock_x11(xfc); scanline = (glyph->cx + 7) / 8; @@ -605,9 +605,9 @@ static void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph) static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x, INT32 y, INT32 w, INT32 h, INT32 sx, INT32 sy, BOOL fOpRedundant) { - xfGlyph* xf_glyph; + const xfGlyph* xf_glyph = (const xfGlyph*)glyph; xfContext* xfc = (xfContext*)context; - xf_glyph = (xfGlyph*)glyph; + xf_lock_x11(xfc); if (!fOpRedundant) diff --git a/include/freerdp/channels/channels.h b/include/freerdp/channels/channels.h index 6cd961038..b841db604 100644 --- a/include/freerdp/channels/channels.h +++ b/include/freerdp/channels/channels.h @@ -56,7 +56,7 @@ extern "C" FREERDP_API UINT16 freerdp_channels_get_id_by_name(freerdp* instance, const char* channel_name); FREERDP_API const char* freerdp_channels_get_name_by_id(freerdp* instance, UINT16 channelId); - FREERDP_API PWtsApiFunctionTable FreeRDP_InitWtsApi(void); + FREERDP_API const PWtsApiFunctionTable FreeRDP_InitWtsApi(void); #ifdef __cplusplus } diff --git a/libfreerdp/cache/glyph.c b/libfreerdp/cache/glyph.c index 5c41f912a..ca5ea460d 100644 --- a/libfreerdp/cache/glyph.c +++ b/libfreerdp/cache/glyph.c @@ -141,7 +141,7 @@ static BOOL update_process_glyph_fragments(rdpContext* context, const BYTE* data UINT32 id; UINT32 size; UINT32 index = 0; - BYTE* fragments; + const BYTE* fragments; rdpGraphics* graphics; rdpGlyphCache* glyph_cache; rdpGlyph* glyph; @@ -245,7 +245,7 @@ static BOOL update_process_glyph_fragments(rdpContext* context, const BYTE* data return FALSE; id = data[index++]; - fragments = (BYTE*)glyph_cache_fragment_get(glyph_cache, id, &size); + fragments = (const BYTE*)glyph_cache_fragment_get(glyph_cache, id, &size); if (fragments == NULL) return FALSE; diff --git a/libfreerdp/codec/test/TestFreeRDPCodecMppc.c b/libfreerdp/codec/test/TestFreeRDPCodecMppc.c index 1387af219..53a6253c4 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecMppc.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecMppc.c @@ -752,7 +752,7 @@ static int test_MppcCompressBellsRdp5(void) return -1; SrcSize = sizeof(TEST_MPPC_BELLS) - 1; - pSrcData = (BYTE*)TEST_MPPC_BELLS; + pSrcData = (const BYTE*)TEST_MPPC_BELLS; expectedSize = sizeof(TEST_MPPC_BELLS_RDP5) - 1; DstSize = sizeof(OutputBuffer); pDstData = OutputBuffer; @@ -805,7 +805,7 @@ static int test_MppcCompressBellsRdp4(void) return -1; SrcSize = sizeof(TEST_MPPC_BELLS) - 1; - pSrcData = (BYTE*)TEST_MPPC_BELLS; + pSrcData = (const BYTE*)TEST_MPPC_BELLS; expectedSize = sizeof(TEST_MPPC_BELLS_RDP4) - 1; DstSize = sizeof(OutputBuffer); pDstData = OutputBuffer; @@ -857,7 +857,7 @@ static int test_MppcDecompressBellsRdp5(void) return -1; SrcSize = sizeof(TEST_MPPC_BELLS_RDP5) - 1; - pSrcData = (BYTE*)TEST_MPPC_BELLS_RDP5; + pSrcData = (const BYTE*)TEST_MPPC_BELLS_RDP5; Flags = PACKET_AT_FRONT | PACKET_COMPRESSED | 1; expectedSize = sizeof(TEST_MPPC_BELLS) - 1; status = mppc_decompress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, Flags); @@ -904,7 +904,7 @@ static int test_MppcDecompressBellsRdp4(void) return -1; SrcSize = sizeof(TEST_MPPC_BELLS_RDP4) - 1; - pSrcData = (BYTE*)TEST_MPPC_BELLS_RDP4; + pSrcData = (const BYTE*)TEST_MPPC_BELLS_RDP4; Flags = PACKET_AT_FRONT | PACKET_COMPRESSED | 0; expectedSize = sizeof(TEST_MPPC_BELLS) - 1; status = mppc_decompress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, Flags); @@ -952,7 +952,7 @@ static int test_MppcCompressIslandRdp5(void) return -1; SrcSize = sizeof(TEST_ISLAND_DATA) - 1; - pSrcData = (BYTE*)TEST_ISLAND_DATA; + pSrcData = (const BYTE*)TEST_ISLAND_DATA; expectedSize = sizeof(TEST_ISLAND_DATA_RDP5) - 1; DstSize = sizeof(OutputBuffer); pDstData = OutputBuffer; @@ -1005,7 +1005,7 @@ static int test_MppcCompressBufferRdp5(void) return -1; SrcSize = sizeof(TEST_RDP5_UNCOMPRESSED_DATA); - pSrcData = (BYTE*)TEST_RDP5_UNCOMPRESSED_DATA; + pSrcData = (const BYTE*)TEST_RDP5_UNCOMPRESSED_DATA; expectedSize = sizeof(TEST_RDP5_COMPRESSED_DATA); DstSize = sizeof(OutputBuffer); pDstData = OutputBuffer; @@ -1054,7 +1054,7 @@ static int test_MppcDecompressBufferRdp5(void) return -1; SrcSize = sizeof(TEST_RDP5_COMPRESSED_DATA); - pSrcData = (BYTE*)TEST_RDP5_COMPRESSED_DATA; + pSrcData = (const BYTE*)TEST_RDP5_COMPRESSED_DATA; Flags = PACKET_AT_FRONT | PACKET_COMPRESSED | 1; expectedSize = sizeof(TEST_RDP5_UNCOMPRESSED_DATA); status = mppc_decompress(mppc, pSrcData, SrcSize, &pDstData, &DstSize, Flags); diff --git a/libfreerdp/codec/test/TestFreeRDPCodecNCrush.c b/libfreerdp/codec/test/TestFreeRDPCodecNCrush.c index 00a8b779a..7a38e8a8a 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecNCrush.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecNCrush.c @@ -27,7 +27,7 @@ static BOOL test_NCrushCompressBells(void) return rc; SrcSize = sizeof(TEST_BELLS_DATA) - 1; - pSrcData = (BYTE*)TEST_BELLS_DATA; + pSrcData = (const BYTE*)TEST_BELLS_DATA; expectedSize = sizeof(TEST_BELLS_NCRUSH) - 1; pDstData = OutputBuffer; DstSize = sizeof(OutputBuffer); @@ -83,7 +83,7 @@ static BOOL test_NCrushDecompressBells(void) return rc; SrcSize = sizeof(TEST_BELLS_NCRUSH) - 1; - pSrcData = (BYTE*)TEST_BELLS_NCRUSH; + pSrcData = (const BYTE*)TEST_BELLS_NCRUSH; Flags = PACKET_COMPRESSED | 2; expectedSize = sizeof(TEST_BELLS_DATA) - 1; status = ncrush_decompress(ncrush, pSrcData, SrcSize, &pDstData, &DstSize, Flags); diff --git a/libfreerdp/codec/test/TestFreeRDPCodecXCrush.c b/libfreerdp/codec/test/TestFreeRDPCodecXCrush.c index 359a56749..69611ce13 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecXCrush.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecXCrush.c @@ -55,7 +55,7 @@ static int test_XCrushCompressBells(void) XCRUSH_CONTEXT* xcrush; xcrush = xcrush_context_new(TRUE); SrcSize = sizeof(TEST_BELLS_DATA) - 1; - pSrcData = (BYTE*)TEST_BELLS_DATA; + pSrcData = (const BYTE*)TEST_BELLS_DATA; expectedSize = sizeof(TEST_BELLS_DATA_XCRUSH) - 1; pDstData = OutputBuffer; DstSize = sizeof(OutputBuffer); @@ -102,7 +102,7 @@ static int test_XCrushCompressIsland(void) XCRUSH_CONTEXT* xcrush; xcrush = xcrush_context_new(TRUE); SrcSize = sizeof(TEST_ISLAND_DATA) - 1; - pSrcData = (BYTE*)TEST_ISLAND_DATA; + pSrcData = (const BYTE*)TEST_ISLAND_DATA; expectedSize = sizeof(TEST_ISLAND_DATA_XCRUSH) - 1; pDstData = OutputBuffer; DstSize = sizeof(OutputBuffer); diff --git a/libfreerdp/codec/test/TestFreeRDPCodecZGfx.c b/libfreerdp/codec/test/TestFreeRDPCodecZGfx.c index f26db255b..405fb826a 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecZGfx.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecZGfx.c @@ -40,7 +40,7 @@ static int test_ZGfxCompressFox(void) return -1; SrcSize = sizeof(TEST_FOX_DATA) - 1; - pSrcData = (BYTE*)TEST_FOX_DATA; + pSrcData = (const BYTE*)TEST_FOX_DATA; Flags = 0; expectedSize = sizeof(TEST_FOX_DATA_SINGLE) - 1; status = zgfx_compress(zgfx, pSrcData, SrcSize, &pDstData, &DstSize, &Flags); @@ -92,7 +92,7 @@ static int test_ZGfxDecompressFoxSingle(void) return -1; SrcSize = sizeof(TEST_FOX_DATA_SINGLE) - 1; - pSrcData = (BYTE*)TEST_FOX_DATA_SINGLE; + pSrcData = (const BYTE*)TEST_FOX_DATA_SINGLE; Flags = 0; expectedSize = sizeof(TEST_FOX_DATA) - 1; status = zgfx_decompress(zgfx, pSrcData, SrcSize, &pDstData, &DstSize, Flags); @@ -144,7 +144,7 @@ static int test_ZGfxDecompressFoxMultipart(void) return -1; SrcSize = sizeof(TEST_FOX_DATA_MULTIPART) - 1; - pSrcData = (BYTE*)TEST_FOX_DATA_MULTIPART; + pSrcData = (const BYTE*)TEST_FOX_DATA_MULTIPART; Flags = 0; expectedSize = sizeof(TEST_FOX_DATA) - 1; status = zgfx_decompress(zgfx, pSrcData, SrcSize, &pDstData, &DstSize, Flags); @@ -183,8 +183,9 @@ static int test_ZGfxCompressConsistent(void) { int rc = -1; int status; + UINT32 Flags; - BYTE* pSrcData; + const BYTE* pSrcData; UINT32 SrcSize; UINT32 DstSize; BYTE* pDstData = NULL; @@ -202,7 +203,7 @@ static int test_ZGfxCompressConsistent(void) /* Compress */ expectedSize = SrcSize = sizeof(BigBuffer); - pSrcData = (BYTE*)BigBuffer; + pSrcData = (const BYTE*)BigBuffer; Flags = 0; status = zgfx_compress(zgfx, pSrcData, SrcSize, &pDstData2, &DstSize2, &Flags); diff --git a/libfreerdp/codec/xcrush.c b/libfreerdp/codec/xcrush.c index 350801df3..0efca2304 100644 --- a/libfreerdp/codec/xcrush.c +++ b/libfreerdp/codec/xcrush.c @@ -775,7 +775,7 @@ static int xcrush_decompress_l1(XCRUSH_CONTEXT* xcrush, const BYTE* pSrcData, UI UINT16 MatchLength = 0; UINT16 MatchOutputOffset = 0; UINT32 MatchHistoryOffset = 0; - RDP61_MATCH_DETAILS* MatchDetails = NULL; + const RDP61_MATCH_DETAILS* MatchDetails = NULL; if (SrcSize < 1) return -1001; @@ -802,8 +802,8 @@ static int xcrush_decompress_l1(XCRUSH_CONTEXT* xcrush, const BYTE* pSrcData, UI return -1003; Data_Read_UINT16(pSrcData, MatchCount); - MatchDetails = (RDP61_MATCH_DETAILS*)&pSrcData[2]; - Literals = (BYTE*)&MatchDetails[MatchCount]; + MatchDetails = (const RDP61_MATCH_DETAILS*)&pSrcData[2]; + Literals = (const BYTE*)&MatchDetails[MatchCount]; OutputOffset = 0; if (Literals > pSrcEnd) diff --git a/libfreerdp/core/certificate.c b/libfreerdp/core/certificate.c index c24e53d45..cf787c785 100644 --- a/libfreerdp/core/certificate.c +++ b/libfreerdp/core/certificate.c @@ -716,7 +716,7 @@ rdpRsaKey* key_new_from_content(const char* keycontent, const char* keyfile) if (!key) return NULL; - bio = BIO_new_mem_buf((void*)keycontent, strlen(keycontent)); + bio = BIO_new_mem_buf((const void*)keycontent, strlen(keycontent)); if (!bio) goto out_free; diff --git a/libfreerdp/core/channels.c b/libfreerdp/core/channels.c index 159d8ffca..5b8f5e9ab 100644 --- a/libfreerdp/core/channels.c +++ b/libfreerdp/core/channels.c @@ -294,7 +294,7 @@ static const WtsApiFunctionTable FreeRDP_WtsApiFunctionTable = { FreeRDP_WTSStartRemoteControlSessionExA }; -PWtsApiFunctionTable FreeRDP_InitWtsApi(void) +const PWtsApiFunctionTable FreeRDP_InitWtsApi(void) { - return (PWtsApiFunctionTable)&FreeRDP_WtsApiFunctionTable; + return &FreeRDP_WtsApiFunctionTable; } diff --git a/libfreerdp/core/gateway/rdg.c b/libfreerdp/core/gateway/rdg.c index a9b6b2c44..b165d9345 100644 --- a/libfreerdp/core/gateway/rdg.c +++ b/libfreerdp/core/gateway/rdg.c @@ -2010,7 +2010,7 @@ static int rdg_write_websocket_data_packet(rdpRdg* rdg, const BYTE* buf, int isi /* mask as much as possible with 32bit access */ for (streamPos = 0; streamPos + 4 <= isize; streamPos += 4) { - uint32_t masked = *((uint32_t*)((BYTE*)buf + streamPos)) ^ maskingKey; + uint32_t masked = *((const uint32_t*)((const BYTE*)buf + streamPos)) ^ maskingKey; Stream_Write_UINT32(sWS, masked); } @@ -2018,7 +2018,7 @@ static int rdg_write_websocket_data_packet(rdpRdg* rdg, const BYTE* buf, int isi for (; streamPos < isize; streamPos++) { BYTE* partialMask = (BYTE*)(&maskingKey) + streamPos % 4; - BYTE masked = *((BYTE*)((BYTE*)buf + streamPos)) ^ *partialMask; + BYTE masked = *((const BYTE*)((const BYTE*)buf + streamPos)) ^ *partialMask; Stream_Write_UINT8(sWS, masked); } diff --git a/libfreerdp/core/gateway/rts.c b/libfreerdp/core/gateway/rts.c index c003b1ea0..83cb38feb 100644 --- a/libfreerdp/core/gateway/rts.c +++ b/libfreerdp/core/gateway/rts.c @@ -247,7 +247,7 @@ static int rts_empty_command_write(BYTE* buffer) static SSIZE_T rts_padding_command_read(const BYTE* buffer, size_t length) { UINT32 ConformanceCount; - ConformanceCount = *((UINT32*)&buffer[0]); /* ConformanceCount (4 bytes) */ + ConformanceCount = *((const UINT32*)&buffer[0]); /* ConformanceCount (4 bytes) */ /* Padding (variable) */ return ConformanceCount + 4; } @@ -297,7 +297,7 @@ static int rts_ance_command_write(BYTE* buffer) static SSIZE_T rts_client_address_command_read(const BYTE* buffer, size_t length) { UINT32 AddressType; - AddressType = *((UINT32*)&buffer[0]); /* AddressType (4 bytes) */ + AddressType = *((const UINT32*)&buffer[0]); /* AddressType (4 bytes) */ if (AddressType == 0) { diff --git a/libfreerdp/core/gateway/rts_signature.c b/libfreerdp/core/gateway/rts_signature.c index 4d605f041..638985625 100644 --- a/libfreerdp/core/gateway/rts_signature.c +++ b/libfreerdp/core/gateway/rts_signature.c @@ -306,7 +306,7 @@ BOOL rts_match_pdu_signature(const RtsPduSignature* signature, const rpcconn_rts for (i = 0; i < rts->NumberOfCommands; i++) { - CommandType = *((UINT32*)&buffer[offset]); /* CommandType (4 bytes) */ + CommandType = *((const UINT32*)&buffer[offset]); /* CommandType (4 bytes) */ offset += 4; if (CommandType != signature->CommandTypes[i]) @@ -329,7 +329,7 @@ BOOL rts_extract_pdu_signature(RtsPduSignature* signature, const rpcconn_rts_hdr { int i; int status; - BYTE* buffer; + const BYTE* buffer; UINT32 length; UINT32 offset; UINT32 CommandType; @@ -340,13 +340,13 @@ BOOL rts_extract_pdu_signature(RtsPduSignature* signature, const rpcconn_rts_hdr signature->Flags = rts->Flags; signature->NumberOfCommands = rts->NumberOfCommands; - buffer = (BYTE*)rts; + buffer = (const BYTE*)rts; offset = RTS_PDU_HEADER_LENGTH; length = rts->header.frag_length - offset; for (i = 0; i < rts->NumberOfCommands; i++) { - CommandType = *((UINT32*)&buffer[offset]); /* CommandType (4 bytes) */ + CommandType = *((const UINT32*)&buffer[offset]); /* CommandType (4 bytes) */ offset += 4; signature->CommandTypes[i] = CommandType; status = rts_command_length(CommandType, &buffer[offset], length); diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index c0ac9a368..7ceae35a6 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -2246,7 +2246,7 @@ static int transport_bio_tsg_write(BIO* bio, const char* buf, int num) int status; rdpTsg* tsg = (rdpTsg*)BIO_get_data(bio); BIO_clear_flags(bio, BIO_FLAGS_WRITE); - status = tsg_write(tsg, (BYTE*)buf, num); + status = tsg_write(tsg, (const BYTE*)buf, num); if (status < 0) { diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 457fad750..7e78fa1b2 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -2108,7 +2108,7 @@ BOOL update_write_cache_bitmap_order(wStream* s, const CACHE_BITMAP_ORDER* cache { if ((*flags & NO_BITMAP_COMPRESSION_HDR) == 0) { - BYTE* bitmapComprHdr = (BYTE*)&(cache_bitmap->bitmapComprHdr); + const BYTE* bitmapComprHdr = (const BYTE*)&(cache_bitmap->bitmapComprHdr); Stream_Write(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */ bitmapLength -= 8; } @@ -2431,8 +2431,9 @@ BOOL update_write_cache_color_table_order(wStream* s, const CACHE_COLOR_TABLE_ORDER* cache_color_table, UINT16* flags) { - int i, inf; - UINT32* colorTable; + size_t i; + int inf; + const UINT32* colorTable; if (cache_color_table->numberColors != 256) return FALSE; @@ -2444,9 +2445,9 @@ BOOL update_write_cache_color_table_order(wStream* s, Stream_Write_UINT8(s, cache_color_table->cacheIndex); /* cacheIndex (1 byte) */ Stream_Write_UINT16(s, cache_color_table->numberColors); /* numberColors (2 bytes) */ - colorTable = (UINT32*)&cache_color_table->colorTable; + colorTable = (const UINT32*)&cache_color_table->colorTable; - for (i = 0; i < (int)cache_color_table->numberColors; i++) + for (i = 0; i < cache_color_table->numberColors; i++) { update_write_color_quad(s, colorTable[i]); } diff --git a/libfreerdp/core/security.c b/libfreerdp/core/security.c index 6ada9d779..79089bf98 100644 --- a/libfreerdp/core/security.c +++ b/libfreerdp/core/security.c @@ -147,7 +147,7 @@ static BOOL security_premaster_hash(const char* input, int length, const BYTE* p BYTE* output) { /* PremasterHash(Input) = SaltedHash(PremasterSecret, Input, ClientRandom, ServerRandom) */ - return security_salted_hash(premaster_secret, (BYTE*)input, length, client_random, + return security_salted_hash(premaster_secret, (const BYTE*)input, length, client_random, server_random, output); } diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index 8aed13c59..8a9ef6cdc 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -660,8 +660,8 @@ BIO_METHOD* BIO_s_buffered_socket(void) char* freerdp_tcp_address_to_string(const struct sockaddr_storage* addr, BOOL* pIPv6) { char ipAddress[INET6_ADDRSTRLEN + 1] = { 0 }; - struct sockaddr_in6* sockaddr_ipv6 = (struct sockaddr_in6*)addr; - struct sockaddr_in* sockaddr_ipv4 = (struct sockaddr_in*)addr; + const struct sockaddr_in6* sockaddr_ipv6 = (const struct sockaddr_in6*)addr; + const struct sockaddr_in* sockaddr_ipv4 = (const struct sockaddr_in*)addr; if (addr == NULL) { diff --git a/libfreerdp/crypto/certificate.c b/libfreerdp/crypto/certificate.c index d6edec0bc..e8039b198 100644 --- a/libfreerdp/crypto/certificate.c +++ b/libfreerdp/crypto/certificate.c @@ -157,13 +157,14 @@ static BOOL certificate_store_init(rdpCertificateStore* certificate_store) if (!ConfigPath) return FALSE; if (!(certificate_store->certs_path = - GetCombinedPath(ConfigPath, (char*)certificate_store_dir))) + GetCombinedPath(ConfigPath, (const char*)certificate_store_dir))) goto fail; - certificate_store->server_path = GetCombinedPath(ConfigPath, (char*)certificate_server_dir); + certificate_store->server_path = + GetCombinedPath(ConfigPath, (const char*)certificate_server_dir); if (!certificate_store->server_path) goto fail; if (!(certificate_store->file = - GetCombinedPath(ConfigPath, (char*)certificate_known_hosts_file))) + GetCombinedPath(ConfigPath, (const char*)certificate_known_hosts_file))) goto fail; PathCchConvertStyleA(certificate_store->file, strlen(certificate_store->file), PATH_STYLE_UNIX); @@ -560,7 +561,7 @@ static char* encode(const char* value) if (!value) return NULL; len = strlen(value); - return (char*)crypto_base64_encode((BYTE*)value, len); + return (char*)crypto_base64_encode((const BYTE*)value, len); } static char* allocated_printf(const char* fmt, ...) diff --git a/libfreerdp/gdi/graphics.c b/libfreerdp/gdi/graphics.c index c8b5fc913..e50cce424 100644 --- a/libfreerdp/gdi/graphics.c +++ b/libfreerdp/gdi/graphics.c @@ -215,7 +215,7 @@ static BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL p } /* Glyph Class */ -static BOOL gdi_Glyph_New(rdpContext* context, const rdpGlyph* glyph) +static BOOL gdi_Glyph_New(rdpContext* context, rdpGlyph* glyph) { BYTE* data; gdiGlyph* gdi_glyph; @@ -270,7 +270,7 @@ static void gdi_Glyph_Free(rdpContext* context, rdpGlyph* glyph) static BOOL gdi_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x, INT32 y, INT32 w, INT32 h, INT32 sx, INT32 sy, BOOL fOpRedundant) { - gdiGlyph* gdi_glyph; + const gdiGlyph* gdi_glyph; rdpGdi* gdi; HGDI_BRUSH brush; BOOL rc = FALSE; @@ -279,7 +279,7 @@ static BOOL gdi_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x, return FALSE; gdi = context->gdi; - gdi_glyph = (gdiGlyph*)glyph; + gdi_glyph = (const gdiGlyph*)glyph; if (!fOpRedundant && 0) { diff --git a/libfreerdp/locale/locale.c b/libfreerdp/locale/locale.c index 0e6668f5c..063795fbc 100644 --- a/libfreerdp/locale/locale.c +++ b/libfreerdp/locale/locale.c @@ -736,12 +736,12 @@ static BOOL freerdp_get_system_language_and_country_codes(char* language, char* #endif } -static SYSTEM_LOCALE* freerdp_detect_system_locale(void) +static const SYSTEM_LOCALE* freerdp_detect_system_locale(void) { size_t i; char language[LOCALE_LANGUAGE_LEN] = { 0 }; char country[LOCALE_COUNTRY_LEN] = { 0 }; - SYSTEM_LOCALE* locale = NULL; + const SYSTEM_LOCALE* locale = NULL; freerdp_get_system_language_and_country_codes(language, country); for (i = 0; i < ARRAYSIZE(SYSTEM_LOCALE_TABLE); i++) @@ -749,7 +749,7 @@ static SYSTEM_LOCALE* freerdp_detect_system_locale(void) if ((strcmp(language, SYSTEM_LOCALE_TABLE[i].language) == 0) && (strcmp(country, SYSTEM_LOCALE_TABLE[i].country) == 0)) { - locale = (SYSTEM_LOCALE*)&SYSTEM_LOCALE_TABLE[i]; + locale = (const SYSTEM_LOCALE*)&SYSTEM_LOCALE_TABLE[i]; break; } } diff --git a/libfreerdp/primitives/prim_YCoCg_opt.c b/libfreerdp/primitives/prim_YCoCg_opt.c index edc7cd3c1..33b84e3c6 100644 --- a/libfreerdp/primitives/prim_YCoCg_opt.c +++ b/libfreerdp/primitives/prim_YCoCg_opt.c @@ -105,17 +105,17 @@ static pstatus_t ssse3_YCoCgRToRGB_8u_AC4R_invert(const BYTE* pSrc, UINT32 srcSt if (onStride) { /* The faster path, 16-byte aligned load. */ - R0 = _mm_load_si128((__m128i*)sptr); + R0 = _mm_load_si128((const __m128i*)sptr); sptr += (128 / 8); - R1 = _mm_load_si128((__m128i*)sptr); + R1 = _mm_load_si128((const __m128i*)sptr); sptr += (128 / 8); } else { /* Off-stride, slower LDDQU load. */ - R0 = _mm_lddqu_si128((__m128i*)sptr); + R0 = _mm_lddqu_si128((const __m128i*)sptr); sptr += (128 / 8); - R1 = _mm_lddqu_si128((__m128i*)sptr); + R1 = _mm_lddqu_si128((const __m128i*)sptr); sptr += (128 / 8); } @@ -275,7 +275,7 @@ static pstatus_t ssse3_YCoCgRToRGB_8u_AC4R_no_invert(const BYTE* pSrc, UINT32 sr } /* Each loop handles eight pixels at a time. */ - onStride = (((ULONG_PTR)sptr & 0x0f) == 0) ? TRUE : FALSE; + onStride = (((const ULONG_PTR)sptr & 0x0f) == 0) ? TRUE : FALSE; while (w >= 8) { @@ -284,17 +284,17 @@ static pstatus_t ssse3_YCoCgRToRGB_8u_AC4R_no_invert(const BYTE* pSrc, UINT32 sr if (onStride) { /* The faster path, 16-byte aligned load. */ - R0 = _mm_load_si128((__m128i*)sptr); + R0 = _mm_load_si128((const __m128i*)sptr); sptr += (128 / 8); - R1 = _mm_load_si128((__m128i*)sptr); + R1 = _mm_load_si128((const __m128i*)sptr); sptr += (128 / 8); } else { /* Off-stride, slower LDDQU load. */ - R0 = _mm_lddqu_si128((__m128i*)sptr); + R0 = _mm_lddqu_si128((const __m128i*)sptr); sptr += (128 / 8); - R1 = _mm_lddqu_si128((__m128i*)sptr); + R1 = _mm_lddqu_si128((const __m128i*)sptr); sptr += (128 / 8); } diff --git a/libfreerdp/primitives/prim_YUV_ssse3.c b/libfreerdp/primitives/prim_YUV_ssse3.c index ef438a28d..a2497605a 100644 --- a/libfreerdp/primitives/prim_YUV_ssse3.c +++ b/libfreerdp/primitives/prim_YUV_ssse3.c @@ -169,9 +169,9 @@ static pstatus_t ssse3_YUV420ToRGB_BGRX(const BYTE* const* pSrc, const UINT32* s for (x = 0; x < nWidth - pad; x += 16) { - const __m128i Y = _mm_loadu_si128((__m128i*)YData); - const __m128i uRaw = _mm_loadu_si128((__m128i*)UData); - const __m128i vRaw = _mm_loadu_si128((__m128i*)VData); + const __m128i Y = _mm_loadu_si128((const __m128i*)YData); + const __m128i uRaw = _mm_loadu_si128((const __m128i*)UData); + const __m128i vRaw = _mm_loadu_si128((const __m128i*)VData); const __m128i U = _mm_shuffle_epi8(uRaw, duplicate); const __m128i V = _mm_shuffle_epi8(vRaw, duplicate); YData += 16; @@ -237,9 +237,9 @@ static pstatus_t ssse3_YUV444ToRGB_8u_P3AC4R_BGRX(const BYTE* const* pSrc, const for (x = 0; x < nWidth - pad; x += 16) { - __m128i Y = _mm_load_si128((__m128i*)YData); - __m128i U = _mm_load_si128((__m128i*)UData); - __m128i V = _mm_load_si128((__m128i*)VData); + __m128i Y = _mm_load_si128((const __m128i*)YData); + __m128i U = _mm_load_si128((const __m128i*)UData); + __m128i V = _mm_load_si128((const __m128i*)VData); YData += 16; UData += 16; VData += 16; @@ -1101,7 +1101,7 @@ static pstatus_t ssse3_LumaToYUV444(const BYTE* const pSrcRaw[3], const UINT32 s const __m128i unpackLow = _mm_set_epi8(15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8); { - const __m128i u = _mm_loadu_si128((__m128i*)&Um[x]); + const __m128i u = _mm_loadu_si128((const __m128i*)&Um[x]); const __m128i uHigh = _mm_shuffle_epi8(u, unpackHigh); const __m128i uLow = _mm_shuffle_epi8(u, unpackLow); _mm_storeu_si128((__m128i*)&pU[2 * x], uHigh); @@ -1110,7 +1110,7 @@ static pstatus_t ssse3_LumaToYUV444(const BYTE* const pSrcRaw[3], const UINT32 s _mm_storeu_si128((__m128i*)&pU1[2 * x + 16], uLow); } { - const __m128i u = _mm_loadu_si128((__m128i*)&Vm[x]); + const __m128i u = _mm_loadu_si128((const __m128i*)&Vm[x]); const __m128i uHigh = _mm_shuffle_epi8(u, unpackHigh); const __m128i uLow = _mm_shuffle_epi8(u, unpackLow); _mm_storeu_si128((__m128i*)&pV[2 * x], uHigh); @@ -1145,8 +1145,8 @@ static INLINE void ssse3_filter(BYTE* pSrcDst, const BYTE* pSrc2) const __m128i odd = _mm_set_epi8(0x80, 15, 0x80, 13, 0x80, 11, 0x80, 9, 0x80, 7, 0x80, 5, 0x80, 3, 0x80, 1); const __m128i interleave = _mm_set_epi8(15, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 0); - const __m128i u = _mm_loadu_si128((__m128i*)pSrcDst); - const __m128i u1 = _mm_loadu_si128((__m128i*)pSrc2); + const __m128i u = _mm_loadu_si128((const __m128i*)pSrcDst); + const __m128i u1 = _mm_loadu_si128((const __m128i*)pSrc2); const __m128i uEven = _mm_shuffle_epi8(u, even); const __m128i uEven4 = _mm_slli_epi16(uEven, 2); const __m128i uOdd = _mm_shuffle_epi8(u, odd); @@ -1282,14 +1282,14 @@ static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* const pSrcRaw[3], const UINT for (x = 0; x < halfWidth - halfPad; x += 16) { { - const __m128i u = _mm_loadu_si128((__m128i*)&Ua[x]); + const __m128i u = _mm_loadu_si128((const __m128i*)&Ua[x]); const __m128i u2 = _mm_unpackhi_epi8(u, zero); const __m128i u1 = _mm_unpacklo_epi8(u, zero); _mm_maskmoveu_si128(u1, mask, (char*)&pU[2 * x]); _mm_maskmoveu_si128(u2, mask, (char*)&pU[2 * x + 16]); } { - const __m128i u = _mm_loadu_si128((__m128i*)&Va[x]); + const __m128i u = _mm_loadu_si128((const __m128i*)&Va[x]); const __m128i u2 = _mm_unpackhi_epi8(u, zero); const __m128i u1 = _mm_unpacklo_epi8(u, zero); _mm_maskmoveu_si128(u1, mask, (char*)&pV[2 * x]); @@ -1343,14 +1343,14 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const pSrc[3], const UINT32 for (x = 0; x < halfWidth - halfPad; x += 16) { { - const __m128i u = _mm_loadu_si128((__m128i*)&pYaU[x]); + const __m128i u = _mm_loadu_si128((const __m128i*)&pYaU[x]); const __m128i u2 = _mm_unpackhi_epi8(zero, u); const __m128i u1 = _mm_unpacklo_epi8(zero, u); _mm_maskmoveu_si128(u1, mask, (char*)&pU[2 * x]); _mm_maskmoveu_si128(u2, mask, (char*)&pU[2 * x + 16]); } { - const __m128i v = _mm_loadu_si128((__m128i*)&pYaV[x]); + const __m128i v = _mm_loadu_si128((const __m128i*)&pYaV[x]); const __m128i v2 = _mm_unpackhi_epi8(zero, v); const __m128i v1 = _mm_unpacklo_epi8(zero, v); _mm_maskmoveu_si128(v1, mask, (char*)&pV[2 * x]); @@ -1379,8 +1379,8 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const pSrc[3], const UINT32 for (x = 0; x < quaterWidth - quaterPad; x += 16) { { - const __m128i uU = _mm_loadu_si128((__m128i*)&pUaU[x]); - const __m128i uV = _mm_loadu_si128((__m128i*)&pVaU[x]); + const __m128i uU = _mm_loadu_si128((const __m128i*)&pUaU[x]); + const __m128i uV = _mm_loadu_si128((const __m128i*)&pVaU[x]); const __m128i uHigh = _mm_unpackhi_epi8(uU, uV); const __m128i uLow = _mm_unpacklo_epi8(uU, uV); const __m128i u1 = _mm_shuffle_epi8(uLow, shuffle2); @@ -1393,8 +1393,8 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const pSrc[3], const UINT32 _mm_maskmoveu_si128(u4, mask2, (char*)&pU[4 * x + 48]); } { - const __m128i vU = _mm_loadu_si128((__m128i*)&pUaV[x]); - const __m128i vV = _mm_loadu_si128((__m128i*)&pVaV[x]); + const __m128i vU = _mm_loadu_si128((const __m128i*)&pUaV[x]); + const __m128i vV = _mm_loadu_si128((const __m128i*)&pVaV[x]); const __m128i vHigh = _mm_unpackhi_epi8(vU, vV); const __m128i vLow = _mm_unpacklo_epi8(vU, vV); const __m128i v1 = _mm_shuffle_epi8(vLow, shuffle2); diff --git a/libfreerdp/primitives/prim_colors_opt.c b/libfreerdp/primitives/prim_colors_opt.c index b8f509018..3834ae496 100644 --- a/libfreerdp/primitives/prim_colors_opt.c +++ b/libfreerdp/primitives/prim_colors_opt.c @@ -87,9 +87,9 @@ static pstatus_t sse2_yCbCrToRGB_16s16s_P3P3(const INT16* const pSrc[3], int src zero = _mm_setzero_si128(); max = _mm_set1_epi16(255); - y_buf = (__m128i*)(pSrc[0]); - cb_buf = (__m128i*)(pSrc[1]); - cr_buf = (__m128i*)(pSrc[2]); + y_buf = (const __m128i*)(pSrc[0]); + cb_buf = (const __m128i*)(pSrc[1]); + cr_buf = (const __m128i*)(pSrc[2]); r_buf = (__m128i*)(pDst[0]); g_buf = (__m128i*)(pDst[1]); b_buf = (__m128i*)(pDst[2]); @@ -204,9 +204,9 @@ static pstatus_t sse2_yCbCrToRGB_16s8u_P3AC4R_BGRX(const INT16* const pSrc[3], U const __m128i g_cr = _mm_set1_epi16(-11698); /* -0.714 << 14 */ const __m128i b_cb = _mm_set1_epi16(28999); /* 1.770 << 14 */ const __m128i c4096 = _mm_set1_epi16(4096); - const INT16* y_buf = (INT16*)pSrc[0]; - const INT16* cb_buf = (INT16*)pSrc[1]; - const INT16* cr_buf = (INT16*)pSrc[2]; + const INT16* y_buf = (const INT16*)pSrc[0]; + const INT16* cb_buf = (const INT16*)pSrc[1]; + const INT16* cr_buf = (const INT16*)pSrc[2]; const UINT32 pad = roi->width % 16; const UINT32 step = sizeof(__m128i) / sizeof(INT16); const UINT32 imax = (roi->width - pad) * sizeof(INT16) / sizeof(__m128i); @@ -264,15 +264,15 @@ static pstatus_t sse2_yCbCrToRGB_16s8u_P3AC4R_BGRX(const INT16* const pSrc[3], U */ /* y = (y_r_buf[i] + 4096) >> 2 */ __m128i y1, y2, cb1, cb2, cr1, cr2, r1, r2, g1, g2, b1, b2; - y1 = _mm_load_si128((__m128i*)y_buf); + y1 = _mm_load_si128((const __m128i*)y_buf); y_buf += step; y1 = _mm_add_epi16(y1, c4096); y1 = _mm_srai_epi16(y1, 2); /* cb = cb_g_buf[i]; */ - cb1 = _mm_load_si128((__m128i*)cb_buf); + cb1 = _mm_load_si128((const __m128i*)cb_buf); cb_buf += step; /* cr = cr_b_buf[i]; */ - cr1 = _mm_load_si128((__m128i*)cr_buf); + cr1 = _mm_load_si128((const __m128i*)cr_buf); cr_buf += step; /* (y + HIWORD(cr*22986)) >> 3 */ r1 = _mm_add_epi16(y1, _mm_mulhi_epi16(cr1, r_cr)); @@ -290,15 +290,15 @@ static pstatus_t sse2_yCbCrToRGB_16s8u_P3AC4R_BGRX(const INT16* const pSrc[3], U b1 = _mm_srai_epi16(b1, 3); /* b_buf[i] = CLIP(b); */ _mm_between_epi16(b1, zero, max); - y2 = _mm_load_si128((__m128i*)y_buf); + y2 = _mm_load_si128((const __m128i*)y_buf); y_buf += step; y2 = _mm_add_epi16(y2, c4096); y2 = _mm_srai_epi16(y2, 2); /* cb = cb_g_buf[i]; */ - cb2 = _mm_load_si128((__m128i*)cb_buf); + cb2 = _mm_load_si128((const __m128i*)cb_buf); cb_buf += step; /* cr = cr_b_buf[i]; */ - cr2 = _mm_load_si128((__m128i*)cr_buf); + cr2 = _mm_load_si128((const __m128i*)cr_buf); cr_buf += step; /* (y + HIWORD(cr*22986)) >> 3 */ r2 = _mm_add_epi16(y2, _mm_mulhi_epi16(cr2, r_cr)); @@ -391,9 +391,9 @@ static pstatus_t sse2_yCbCrToRGB_16s8u_P3AC4R_RGBX(const INT16* const pSrc[3], U const __m128i g_cr = _mm_set1_epi16(-11698); /* -0.714 << 14 */ const __m128i b_cb = _mm_set1_epi16(28999); /* 1.770 << 14 */ const __m128i c4096 = _mm_set1_epi16(4096); - const INT16* y_buf = (INT16*)pSrc[0]; - const INT16* cb_buf = (INT16*)pSrc[1]; - const INT16* cr_buf = (INT16*)pSrc[2]; + const INT16* y_buf = (const INT16*)pSrc[0]; + const INT16* cb_buf = (const INT16*)pSrc[1]; + const INT16* cr_buf = (const INT16*)pSrc[2]; const UINT32 pad = roi->width % 16; const UINT32 step = sizeof(__m128i) / sizeof(INT16); const UINT32 imax = (roi->width - pad) * sizeof(INT16) / sizeof(__m128i); @@ -451,15 +451,15 @@ static pstatus_t sse2_yCbCrToRGB_16s8u_P3AC4R_RGBX(const INT16* const pSrc[3], U */ /* y = (y_r_buf[i] + 4096) >> 2 */ __m128i y1, y2, cb1, cb2, cr1, cr2, r1, r2, g1, g2, b1, b2; - y1 = _mm_load_si128((__m128i*)y_buf); + y1 = _mm_load_si128((const __m128i*)y_buf); y_buf += step; y1 = _mm_add_epi16(y1, c4096); y1 = _mm_srai_epi16(y1, 2); /* cb = cb_g_buf[i]; */ - cb1 = _mm_load_si128((__m128i*)cb_buf); + cb1 = _mm_load_si128((const __m128i*)cb_buf); cb_buf += step; /* cr = cr_b_buf[i]; */ - cr1 = _mm_load_si128((__m128i*)cr_buf); + cr1 = _mm_load_si128((const __m128i*)cr_buf); cr_buf += step; /* (y + HIWORD(cr*22986)) >> 3 */ r1 = _mm_add_epi16(y1, _mm_mulhi_epi16(cr1, r_cr)); @@ -477,15 +477,15 @@ static pstatus_t sse2_yCbCrToRGB_16s8u_P3AC4R_RGBX(const INT16* const pSrc[3], U b1 = _mm_srai_epi16(b1, 3); /* b_buf[i] = CLIP(b); */ _mm_between_epi16(b1, zero, max); - y2 = _mm_load_si128((__m128i*)y_buf); + y2 = _mm_load_si128((const __m128i*)y_buf); y_buf += step; y2 = _mm_add_epi16(y2, c4096); y2 = _mm_srai_epi16(y2, 2); /* cb = cb_g_buf[i]; */ - cb2 = _mm_load_si128((__m128i*)cb_buf); + cb2 = _mm_load_si128((const __m128i*)cb_buf); cb_buf += step; /* cr = cr_b_buf[i]; */ - cr2 = _mm_load_si128((__m128i*)cr_buf); + cr2 = _mm_load_si128((const __m128i*)cr_buf); cr_buf += step; /* (y + HIWORD(cr*22986)) >> 3 */ r2 = _mm_add_epi16(y2, _mm_mulhi_epi16(cr2, r_cr)); @@ -615,9 +615,9 @@ static pstatus_t sse2_RGBToYCbCr_16s16s_P3P3(const INT16* const pSrc[3], int src min = _mm_set1_epi16(-128 * 32); max = _mm_set1_epi16(127 * 32); - r_buf = (__m128i*)(pSrc[0]); - g_buf = (__m128i*)(pSrc[1]); - b_buf = (__m128i*)(pSrc[2]); + r_buf = (const __m128i*)(pSrc[0]); + g_buf = (const __m128i*)(pSrc[1]); + b_buf = (const __m128i*)(pSrc[2]); y_buf = (__m128i*)(pDst[0]); cb_buf = (__m128i*)(pDst[1]); cr_buf = (__m128i*)(pDst[2]); @@ -749,25 +749,25 @@ sse2_RGBToRGB_16s8u_P3AC4R_BGRX(const INT16* const pSrc[3], /* 16-bit R,G, and B */ { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pb); + R0 = _mm_load_si128((const __m128i*)pb); pb += 8; /* R0 = 00B300B200B100B0 */ - R1 = _mm_load_si128((__m128i*)pb); + R1 = _mm_load_si128((const __m128i*)pb); pb += 8; /* R1 = 00B700B600B500B4 */ b = _mm_packus_epi16(R0, R1); /* b = B7B6B5B4B3B2B1B0 */ } { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pg); + R0 = _mm_load_si128((const __m128i*)pg); pg += 8; /* R1 = 00G300G200G100G0 */ - R1 = _mm_load_si128((__m128i*)pg); + R1 = _mm_load_si128((const __m128i*)pg); pg += 8; /* R2 = 00G700G600G500G4 */ g = _mm_packus_epi16(R0, R1); /* g = G7G6G5G4G3G2G1G0 */ } { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pr); + R0 = _mm_load_si128((const __m128i*)pr); pr += 8; /* R0 = 00R300R200R100R0 */ - R1 = _mm_load_si128((__m128i*)pr); + R1 = _mm_load_si128((const __m128i*)pr); pr += 8; /* R3 = 00R700R600R500R4 */ r = _mm_packus_epi16(R0, R1); /* r = R7R6R5R4R3R2R1R0 */ } @@ -853,25 +853,25 @@ sse2_RGBToRGB_16s8u_P3AC4R_RGBX(const INT16* const pSrc[3], /* 16-bit R,G, and B */ { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pb); + R0 = _mm_load_si128((const __m128i*)pb); pb += 8; /* R0 = 00B300B200B100B0 */ - R1 = _mm_load_si128((__m128i*)pb); + R1 = _mm_load_si128((const __m128i*)pb); pb += 8; /* R1 = 00B700B600B500B4 */ b = _mm_packus_epi16(R0, R1); /* b = B7B6B5B4B3B2B1B0 */ } { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pg); + R0 = _mm_load_si128((const __m128i*)pg); pg += 8; /* R1 = 00G300G200G100G0 */ - R1 = _mm_load_si128((__m128i*)pg); + R1 = _mm_load_si128((const __m128i*)pg); pg += 8; /* R2 = 00G700G600G500G4 */ g = _mm_packus_epi16(R0, R1); /* g = G7G6G5G4G3G2G1G0 */ } { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pr); + R0 = _mm_load_si128((const __m128i*)pr); pr += 8; /* R0 = 00R300R200R100R0 */ - R1 = _mm_load_si128((__m128i*)pr); + R1 = _mm_load_si128((const __m128i*)pr); pr += 8; /* R3 = 00R700R600R500R4 */ r = _mm_packus_epi16(R0, R1); /* r = R7R6R5R4R3R2R1R0 */ } @@ -957,25 +957,25 @@ sse2_RGBToRGB_16s8u_P3AC4R_XBGR(const INT16* const pSrc[3], /* 16-bit R,G, and B */ { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pb); + R0 = _mm_load_si128((const __m128i*)pb); pb += 8; /* R0 = 00B300B200B100B0 */ - R1 = _mm_load_si128((__m128i*)pb); + R1 = _mm_load_si128((const __m128i*)pb); pb += 8; /* R1 = 00B700B600B500B4 */ b = _mm_packus_epi16(R0, R1); /* b = B7B6B5B4B3B2B1B0 */ } { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pg); + R0 = _mm_load_si128((const __m128i*)pg); pg += 8; /* R1 = 00G300G200G100G0 */ - R1 = _mm_load_si128((__m128i*)pg); + R1 = _mm_load_si128((const __m128i*)pg); pg += 8; /* R2 = 00G700G600G500G4 */ g = _mm_packus_epi16(R0, R1); /* g = G7G6G5G4G3G2G1G0 */ } { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pr); + R0 = _mm_load_si128((const __m128i*)pr); pr += 8; /* R0 = 00R300R200R100R0 */ - R1 = _mm_load_si128((__m128i*)pr); + R1 = _mm_load_si128((const __m128i*)pr); pr += 8; /* R3 = 00R700R600R500R4 */ r = _mm_packus_epi16(R0, R1); /* r = R7R6R5R4R3R2R1R0 */ } @@ -1061,25 +1061,25 @@ sse2_RGBToRGB_16s8u_P3AC4R_XRGB(const INT16* const pSrc[3], /* 16-bit R,G, and B */ { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pb); + R0 = _mm_load_si128((const __m128i*)pb); pb += 8; /* R0 = 00B300B200B100B0 */ - R1 = _mm_load_si128((__m128i*)pb); + R1 = _mm_load_si128((const __m128i*)pb); pb += 8; /* R1 = 00B700B600B500B4 */ b = _mm_packus_epi16(R0, R1); /* b = B7B6B5B4B3B2B1B0 */ } { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pg); + R0 = _mm_load_si128((const __m128i*)pg); pg += 8; /* R1 = 00G300G200G100G0 */ - R1 = _mm_load_si128((__m128i*)pg); + R1 = _mm_load_si128((const __m128i*)pg); pg += 8; /* R2 = 00G700G600G500G4 */ g = _mm_packus_epi16(R0, R1); /* g = G7G6G5G4G3G2G1G0 */ } { __m128i R0, R1; - R0 = _mm_load_si128((__m128i*)pr); + R0 = _mm_load_si128((const __m128i*)pr); pr += 8; /* R0 = 00R300R200R100R0 */ - R1 = _mm_load_si128((__m128i*)pr); + R1 = _mm_load_si128((const __m128i*)pr); pr += 8; /* R3 = 00R700R600R500R4 */ r = _mm_packus_epi16(R0, R1); /* r = R7R6R5R4R3R2R1R0 */ } diff --git a/libfreerdp/primitives/prim_internal.h b/libfreerdp/primitives/prim_internal.h index 57a69d43e..abd80c3ed 100644 --- a/libfreerdp/primitives/prim_internal.h +++ b/libfreerdp/primitives/prim_internal.h @@ -42,9 +42,9 @@ #if defined(WITH_SSE2) /* Use lddqu for unaligned; load for 16-byte aligned. */ -#define LOAD_SI128(_ptr_) \ - (((ULONG_PTR)(_ptr_)&0x0f) ? _mm_lddqu_si128((__m128i*)(_ptr_)) \ - : _mm_load_si128((__m128i*)(_ptr_))) +#define LOAD_SI128(_ptr_) \ + (((const ULONG_PTR)(_ptr_)&0x0f) ? _mm_lddqu_si128((const __m128i*)(_ptr_)) \ + : _mm_load_si128((const __m128i*)(_ptr_))) #endif static INLINE BYTE* writePixelBGRA(BYTE* dst, DWORD formatSize, UINT32 format, BYTE R, BYTE G, diff --git a/libfreerdp/primitives/prim_sign_opt.c b/libfreerdp/primitives/prim_sign_opt.c index 47dad9b51..d124053aa 100644 --- a/libfreerdp/primitives/prim_sign_opt.c +++ b/libfreerdp/primitives/prim_sign_opt.c @@ -73,25 +73,25 @@ static pstatus_t ssse3_sign_16s(const INT16* pSrc, INT16* pDst, UINT32 len) xmm1 = _mm_set1_epi16(0x0001U); xmm2 = _mm_set1_epi16(0x0001U); xmm3 = _mm_set1_epi16(0x0001U); - xmm4 = _mm_lddqu_si128((__m128i*)sptr); + xmm4 = _mm_lddqu_si128((const __m128i*)sptr); sptr += 8; - xmm5 = _mm_lddqu_si128((__m128i*)sptr); + xmm5 = _mm_lddqu_si128((const __m128i*)sptr); sptr += 8; - xmm6 = _mm_lddqu_si128((__m128i*)sptr); + xmm6 = _mm_lddqu_si128((const __m128i*)sptr); sptr += 8; - xmm7 = _mm_lddqu_si128((__m128i*)sptr); + xmm7 = _mm_lddqu_si128((const __m128i*)sptr); sptr += 8; xmm0 = _mm_sign_epi16(xmm0, xmm4); xmm1 = _mm_sign_epi16(xmm1, xmm5); xmm2 = _mm_sign_epi16(xmm2, xmm6); xmm3 = _mm_sign_epi16(xmm3, xmm7); - _mm_store_si128((__m128i*)dptr, xmm0); + _mm_store_si128((const __m128i*)dptr, xmm0); dptr += 8; - _mm_store_si128((__m128i*)dptr, xmm1); + _mm_store_si128((const __m128i*)dptr, xmm1); dptr += 8; - _mm_store_si128((__m128i*)dptr, xmm2); + _mm_store_si128((const __m128i*)dptr, xmm2); dptr += 8; - _mm_store_si128((__m128i*)dptr, xmm3); + _mm_store_si128((const __m128i*)dptr, xmm3); dptr += 8; } } @@ -105,25 +105,25 @@ static pstatus_t ssse3_sign_16s(const INT16* pSrc, INT16* pDst, UINT32 len) xmm1 = _mm_set1_epi16(0x0001U); xmm2 = _mm_set1_epi16(0x0001U); xmm3 = _mm_set1_epi16(0x0001U); - xmm4 = _mm_load_si128((__m128i*)sptr); + xmm4 = _mm_load_si128((const __m128i*)sptr); sptr += 8; - xmm5 = _mm_load_si128((__m128i*)sptr); + xmm5 = _mm_load_si128((const __m128i*)sptr); sptr += 8; - xmm6 = _mm_load_si128((__m128i*)sptr); + xmm6 = _mm_load_si128((const __m128i*)sptr); sptr += 8; - xmm7 = _mm_load_si128((__m128i*)sptr); + xmm7 = _mm_load_si128((const __m128i*)sptr); sptr += 8; xmm0 = _mm_sign_epi16(xmm0, xmm4); xmm1 = _mm_sign_epi16(xmm1, xmm5); xmm2 = _mm_sign_epi16(xmm2, xmm6); xmm3 = _mm_sign_epi16(xmm3, xmm7); - _mm_store_si128((__m128i*)dptr, xmm0); + _mm_store_si128((const __m128i*)dptr, xmm0); dptr += 8; - _mm_store_si128((__m128i*)dptr, xmm1); + _mm_store_si128((const __m128i*)dptr, xmm1); dptr += 8; - _mm_store_si128((__m128i*)dptr, xmm2); + _mm_store_si128((const __m128i*)dptr, xmm2); dptr += 8; - _mm_store_si128((__m128i*)dptr, xmm3); + _mm_store_si128((const __m128i*)dptr, xmm3); dptr += 8; } } diff --git a/libfreerdp/primitives/prim_templates.h b/libfreerdp/primitives/prim_templates.h index 6227ffe40..02b64fff2 100644 --- a/libfreerdp/primitives/prim_templates.h +++ b/libfreerdp/primitives/prim_templates.h @@ -83,26 +83,26 @@ /* Use 8 128-bit SSE registers. */ \ count = len >> (8 - shifts); \ len -= count << (8 - shifts); \ - if ((ULONG_PTR)sptr & 0x0f) \ + if ((const ULONG_PTR)sptr & 0x0f) \ { \ while (count--) \ { \ __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; \ - xmm0 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm0 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm1 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm1 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm2 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm2 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm3 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm3 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm4 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm4 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm5 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm5 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm6 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm6 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm7 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm7 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ xmm0 = _op_(xmm0, val); \ xmm1 = _op_(xmm1, val); \ @@ -135,21 +135,21 @@ while (count--) \ { \ __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; \ - xmm0 = _mm_load_si128((__m128i*)sptr); \ + xmm0 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm1 = _mm_load_si128((__m128i*)sptr); \ + xmm1 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm2 = _mm_load_si128((__m128i*)sptr); \ + xmm2 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm3 = _mm_load_si128((__m128i*)sptr); \ + xmm3 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm4 = _mm_load_si128((__m128i*)sptr); \ + xmm4 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm5 = _mm_load_si128((__m128i*)sptr); \ + xmm5 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm6 = _mm_load_si128((__m128i*)sptr); \ + xmm6 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm7 = _mm_load_si128((__m128i*)sptr); \ + xmm7 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ xmm0 = _op_(xmm0, val); \ xmm1 = _op_(xmm1, val); \ @@ -238,18 +238,18 @@ count = len >> (7 - shifts); \ len -= count << (7 - shifts); \ xmm0 = _mm_set1_epi32(val); \ - if ((ULONG_PTR)sptr & 0x0f) \ + if ((const ULONG_PTR)sptr & 0x0f) \ { \ while (count--) \ { \ __m128i xmm1, xmm2, xmm3, xmm4; \ - xmm1 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm1 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm2 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm2 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm3 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm3 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm4 = _mm_lddqu_si128((__m128i*)sptr); \ + xmm4 = _mm_lddqu_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ xmm1 = _op_(xmm1, xmm0); \ xmm2 = _op_(xmm2, xmm0); \ @@ -270,13 +270,13 @@ while (count--) \ { \ __m128i xmm1, xmm2, xmm3, xmm4; \ - xmm1 = _mm_load_si128((__m128i*)sptr); \ + xmm1 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm2 = _mm_load_si128((__m128i*)sptr); \ + xmm2 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm3 = _mm_load_si128((__m128i*)sptr); \ + xmm3 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ - xmm4 = _mm_load_si128((__m128i*)sptr); \ + xmm4 = _mm_load_si128((const __m128i*)sptr); \ sptr += (16 / sizeof(_type_)); \ xmm1 = _op_(xmm1, xmm0); \ xmm2 = _op_(xmm2, xmm0); \ @@ -354,27 +354,27 @@ /* Use 4 128-bit SSE registers. */ \ count = len >> (7 - shifts); \ len -= count << (7 - shifts); \ - if (((ULONG_PTR)sptr1 & 0x0f) || ((ULONG_PTR)sptr2 & 0x0f)) \ + if (((const ULONG_PTR)sptr1 & 0x0f) || ((const ULONG_PTR)sptr2 & 0x0f)) \ { \ /* Unaligned loads */ \ while (count--) \ { \ __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; \ - xmm0 = _mm_lddqu_si128((__m128i*)sptr1); \ + xmm0 = _mm_lddqu_si128((const __m128i*)sptr1); \ sptr1 += (16 / sizeof(_type_)); \ - xmm1 = _mm_lddqu_si128((__m128i*)sptr1); \ + xmm1 = _mm_lddqu_si128((const __m128i*)sptr1); \ sptr1 += (16 / sizeof(_type_)); \ - xmm2 = _mm_lddqu_si128((__m128i*)sptr1); \ + xmm2 = _mm_lddqu_si128((const __m128i*)sptr1); \ sptr1 += (16 / sizeof(_type_)); \ - xmm3 = _mm_lddqu_si128((__m128i*)sptr1); \ + xmm3 = _mm_lddqu_si128((const __m128i*)sptr1); \ sptr1 += (16 / sizeof(_type_)); \ - xmm4 = _mm_lddqu_si128((__m128i*)sptr2); \ + xmm4 = _mm_lddqu_si128((const __m128i*)sptr2); \ sptr2 += (16 / sizeof(_type_)); \ - xmm5 = _mm_lddqu_si128((__m128i*)sptr2); \ + xmm5 = _mm_lddqu_si128((const __m128i*)sptr2); \ sptr2 += (16 / sizeof(_type_)); \ - xmm6 = _mm_lddqu_si128((__m128i*)sptr2); \ + xmm6 = _mm_lddqu_si128((const __m128i*)sptr2); \ sptr2 += (16 / sizeof(_type_)); \ - xmm7 = _mm_lddqu_si128((__m128i*)sptr2); \ + xmm7 = _mm_lddqu_si128((const __m128i*)sptr2); \ sptr2 += (16 / sizeof(_type_)); \ xmm0 = _op_(xmm0, xmm4); \ xmm1 = _op_(xmm1, xmm5); \ @@ -396,21 +396,21 @@ while (count--) \ { \ __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; \ - xmm0 = _mm_load_si128((__m128i*)sptr1); \ + xmm0 = _mm_load_si128((const __m128i*)sptr1); \ sptr1 += (16 / sizeof(_type_)); \ - xmm1 = _mm_load_si128((__m128i*)sptr1); \ + xmm1 = _mm_load_si128((const __m128i*)sptr1); \ sptr1 += (16 / sizeof(_type_)); \ - xmm2 = _mm_load_si128((__m128i*)sptr1); \ + xmm2 = _mm_load_si128((const __m128i*)sptr1); \ sptr1 += (16 / sizeof(_type_)); \ - xmm3 = _mm_load_si128((__m128i*)sptr1); \ + xmm3 = _mm_load_si128((const __m128i*)sptr1); \ sptr1 += (16 / sizeof(_type_)); \ - xmm4 = _mm_load_si128((__m128i*)sptr2); \ + xmm4 = _mm_load_si128((const __m128i*)sptr2); \ sptr2 += (16 / sizeof(_type_)); \ - xmm5 = _mm_load_si128((__m128i*)sptr2); \ + xmm5 = _mm_load_si128((const __m128i*)sptr2); \ sptr2 += (16 / sizeof(_type_)); \ - xmm6 = _mm_load_si128((__m128i*)sptr2); \ + xmm6 = _mm_load_si128((const __m128i*)sptr2); \ sptr2 += (16 / sizeof(_type_)); \ - xmm7 = _mm_load_si128((__m128i*)sptr2); \ + xmm7 = _mm_load_si128((const __m128i*)sptr2); \ sptr2 += (16 / sizeof(_type_)); \ xmm0 = _op_(xmm0, xmm4); \ xmm1 = _op_(xmm1, xmm5); \ diff --git a/libfreerdp/primitives/test/TestPrimitivesYCbCr.c b/libfreerdp/primitives/test/TestPrimitivesYCbCr.c index ff2401f87..b41bca268 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYCbCr.c +++ b/libfreerdp/primitives/test/TestPrimitivesYCbCr.c @@ -1528,8 +1528,8 @@ static int test_bmp_cmp_dump(const BYTE* actual, const BYTE* expected, int size, { if (*actual != *expected) { - const UINT32 pixel = *((UINT32*)&actual[-channel]); - const UINT32 ePixel = *((UINT32*)&expected[-channel]); + const UINT32 pixel = *((const UINT32*)&actual[-channel]); + const UINT32 ePixel = *((const UINT32*)&expected[-channel]); const INT16 Y = TEST_Y_COMPONENT[index]; const INT16 Cb = TEST_CB_COMPONENT[index]; const INT16 Cr = TEST_CR_COMPONENT[index]; @@ -1569,7 +1569,7 @@ static int test_PrimitivesYCbCr(const primitives_t* prims, UINT32 format, prim_s float err[3]; BYTE* actual; BYTE* actual1; - BYTE* expected; + const BYTE* expected; int margin = 1; INT16* pYCbCr[3] = { NULL, NULL, NULL }; const UINT32 srcStride = roi.width * 2; @@ -1580,7 +1580,7 @@ static int test_PrimitivesYCbCr(const primitives_t* prims, UINT32 format, prim_s PROFILER_DEFINE(prof1) PROFILER_DEFINE(prof2) // return test_YCbCr_pixels(); - expected = (BYTE*)TEST_XRGB_IMAGE; + expected = (const BYTE*)TEST_XRGB_IMAGE; actual = _aligned_malloc(dstSize, 16); actual1 = _aligned_malloc(dstSize, 16); PROFILER_CREATE(prof, "yCbCrToRGB_16s8u") diff --git a/server/proxy/pf_client.c b/server/proxy/pf_client.c index 44b4a5263..3f7b37c1c 100644 --- a/server/proxy/pf_client.c +++ b/server/proxy/pf_client.c @@ -265,7 +265,8 @@ static BOOL pf_client_receive_channel_data_hook(freerdp* instance, UINT16 channe if (!pf_modules_run_filter(FILTER_TYPE_CLIENT_PASSTHROUGH_CHANNEL_DATA, pdata, &ev)) return FALSE; - server_channel_id = (UINT64)HashTable_GetItemValue(ps->vc_ids, (void*)channel_name); + server_channel_id = + (UINT64)HashTable_GetItemValue(ps->vc_ids, (const void*)channel_name); return ps->context.peer->SendChannelData(ps->context.peer, (UINT16)server_channel_id, data, size); } diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index 5c5220773..e914e32db 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -870,7 +870,7 @@ extern "C" * Functions */ - WINPR_API char* GetVirtualKeyName(DWORD vkcode); + WINPR_API const char* GetVirtualKeyName(DWORD vkcode); WINPR_API DWORD GetVirtualKeyCodeFromName(const char* vkname); WINPR_API DWORD GetVirtualKeyCodeFromXkbKeyName(const char* xkbname); diff --git a/winpr/libwinpr/clipboard/posix.c b/winpr/libwinpr/clipboard/posix.c index fdbdf2357..f5ba8ea06 100644 --- a/winpr/libwinpr/clipboard/posix.c +++ b/winpr/libwinpr/clipboard/posix.c @@ -579,7 +579,7 @@ static void* convert_uri_list_to_filedescriptors(wClipboard* clipboard, UINT32 f static size_t count_special_chars(const WCHAR* str) { size_t count = 0; - WCHAR* start = (WCHAR*)str; + const WCHAR* start = (const WCHAR*)str; while (*start) { if (*start == L'#' || *start == L'?' || *start == L'*' || *start == L'!' || *start == L'%') @@ -591,9 +591,9 @@ static size_t count_special_chars(const WCHAR* str) return count; } -static char* stop_at_special_chars(const char* str) +static const char* stop_at_special_chars(const char* str) { - char* start = (char*)str; + const char* start = (const char*)str; while (*start) { if (*start == '#' || *start == '?' || *start == '*' || *start == '!' || *start == '%') diff --git a/winpr/libwinpr/clipboard/synthetic.c b/winpr/libwinpr/clipboard/synthetic.c index 239182f38..e3543ff5b 100644 --- a/winpr/libwinpr/clipboard/synthetic.c +++ b/winpr/libwinpr/clipboard/synthetic.c @@ -137,7 +137,7 @@ static void* clipboard_synthesize_cf_unicodetext(wClipboard* clipboard, UINT32 f return NULL; size = (int)*pSize; - crlfStr = ConvertLineEndingToCRLF((char*)data, &size); + crlfStr = ConvertLineEndingToCRLF((const char*)data, &size); if (!crlfStr) return NULL; @@ -170,7 +170,7 @@ static void* clipboard_synthesize_utf8_string(wClipboard* clipboard, UINT32 form { size_t wsize = _wcsnlen(data, (*pSize) / 2); size = - ConvertFromUnicode(CP_UTF8, 0, (LPWSTR)data, wsize, (CHAR**)&pDstData, 0, NULL, NULL); + ConvertFromUnicode(CP_UTF8, 0, (LPCWSTR)data, wsize, (CHAR**)&pDstData, 0, NULL, NULL); if (!pDstData) return NULL; @@ -234,7 +234,7 @@ static void* clipboard_synthesize_cf_dib(wClipboard* clipboard, UINT32 formatId, if (SrcSize < (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER))) return NULL; - pFileHeader = (BITMAPFILEHEADER*)data; + pFileHeader = (const BITMAPFILEHEADER*)data; if (pFileHeader->bfType != 0x4D42) return NULL; @@ -245,7 +245,7 @@ static void* clipboard_synthesize_cf_dib(wClipboard* clipboard, UINT32 formatId, if (!pDstData) return NULL; - data = (void*)&((BYTE*)data)[sizeof(BITMAPFILEHEADER)]; + data = (const void*)&((const BYTE*)data)[sizeof(BITMAPFILEHEADER)]; CopyMemory(pDstData, data, DstSize); *pSize = DstSize; return pDstData; @@ -296,7 +296,7 @@ static void* clipboard_synthesize_image_bmp(wClipboard* clipboard, UINT32 format if (SrcSize < sizeof(BITMAPINFOHEADER)) return NULL; - pInfoHeader = (BITMAPINFOHEADER*)data; + pInfoHeader = (const BITMAPINFOHEADER*)data; if ((pInfoHeader->biBitCount < 1) || (pInfoHeader->biBitCount > 32)) return NULL; @@ -343,7 +343,7 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form char* body; BYTE bom[2]; char num[20]; - WCHAR* wstr; + const WCHAR* wstr; if (SrcSize > 2) { @@ -353,12 +353,12 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form if ((bom[0] == 0xFE) && (bom[1] == 0xFF)) { - ByteSwapUnicode((WCHAR*)data, (int)(SrcSize / 2)); + ByteSwapUnicode((const WCHAR*)data, (int)(SrcSize / 2)); } if ((bom[0] == 0xFF) && (bom[1] == 0xFE)) { - wstr = (WCHAR*)&((BYTE*)data)[2]; + wstr = (const WCHAR*)&((BYTE*)data)[2]; ConvertFromUnicode(CP_UTF8, 0, wstr, (int)(SrcSize - 2) / 2, &pSrcData, 0, NULL, NULL); } @@ -434,7 +434,7 @@ static void* clipboard_synthesize_text_html(wClipboard* clipboard, UINT32 format { long beg; long end; - char* str; + const char* str; char* begStr; char* endStr; long DstSize = -1; @@ -443,7 +443,7 @@ static void* clipboard_synthesize_text_html(wClipboard* clipboard, UINT32 format if (formatId == ClipboardGetFormatId(clipboard, "HTML Format")) { INT64 SrcSize; - str = (char*)data; + str = (const char*)data; SrcSize = (INT64)*pSize; begStr = strstr(str, "StartHTML:"); endStr = strstr(str, "EndHTML:"); diff --git a/winpr/libwinpr/comm/comm_io.c b/winpr/libwinpr/comm/comm_io.c index 234d0cc89..1f244a6ad 100644 --- a/winpr/libwinpr/comm/comm_io.c +++ b/winpr/libwinpr/comm/comm_io.c @@ -512,7 +512,7 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite if (FD_ISSET(pComm->fd_write, &write_set)) { ssize_t nbWritten; - nbWritten = write(pComm->fd_write, ((BYTE*)lpBuffer) + (*lpNumberOfBytesWritten), + nbWritten = write(pComm->fd_write, ((const BYTE*)lpBuffer) + (*lpNumberOfBytesWritten), nNumberOfBytesToWrite - (*lpNumberOfBytesWritten)); if (nbWritten < 0) diff --git a/winpr/libwinpr/crt/string.c b/winpr/libwinpr/crt/string.c index 57e665766..f5f76ef2e 100644 --- a/winpr/libwinpr/crt/string.c +++ b/winpr/libwinpr/crt/string.c @@ -132,31 +132,31 @@ size_t _wcsnlen(const WCHAR* str, size_t max) WCHAR* _wcschr(const WCHAR* str, WCHAR c) { - WCHAR* p = (WCHAR*)str; + const WCHAR* p = (const WCHAR*)str; WCHAR value; Data_Write_UINT16(&value, c); while (*p && (*p != value)) p++; - return ((*p == value) ? p : NULL); + return ((*p == value) ? (WCHAR*)p : NULL); } /* _wcsrchr -> wcsrchr */ WCHAR* _wcsrchr(const WCHAR* str, WCHAR c) { - WCHAR* p; + const WCHAR* p; WCHAR ch; if (!str) return NULL; - for (p = (WCHAR*)0; (ch = *str); str++) + for (p = (const WCHAR*)0; (ch = *str); str++) if (ch == c) - p = (WCHAR*)str; + p = (const WCHAR*)str; - return p; + return (WCHAR*)p; } char* strtok_s(char* strToken, const char* strDelimit, char** context) @@ -449,12 +449,12 @@ int lstrlenA(LPCSTR lpString) int lstrlenW(LPCWSTR lpString) { - LPWSTR p; + LPCWSTR p; if (!lpString) return 0; - p = (LPWSTR)lpString; + p = (LPCWSTR)lpString; while (*p) p++; diff --git a/winpr/libwinpr/crt/test/TestUnicodeConversion.c b/winpr/libwinpr/crt/test/TestUnicodeConversion.c index cc2a2597d..4d47fd887 100644 --- a/winpr/libwinpr/crt/test/TestUnicodeConversion.c +++ b/winpr/libwinpr/crt/test/TestUnicodeConversion.c @@ -315,9 +315,9 @@ static BOOL test_ConvertFromUnicode_wrapper(void) */ printf("Input UTF16 String:\n"); - string_hexdump((BYTE*)src1, 19 * sizeof(WCHAR)); + string_hexdump((const BYTE*)src1, 19 * sizeof(WCHAR)); - i = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)src1, 16, &dst, 0, NULL, NULL); + i = ConvertFromUnicode(CP_UTF8, 0, (const WCHAR*)src1, 16, &dst, 0, NULL, NULL); if (i != 16) { fprintf(stderr, "ConvertFromUnicode failure A1: unexpectedly returned %d instead of 16\n", @@ -348,9 +348,9 @@ static BOOL test_ConvertFromUnicode_wrapper(void) /* Test null-terminated string */ printf("Input UTF16 String:\n"); - string_hexdump((BYTE*)src2, (_wcslen((WCHAR*)src2) + 1) * sizeof(WCHAR)); + string_hexdump((const BYTE*)src2, (_wcslen((const WCHAR*)src2) + 1) * sizeof(WCHAR)); - i = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)src2, -1, &dst, 0, NULL, NULL); + i = ConvertFromUnicode(CP_UTF8, 0, (const WCHAR*)src2, -1, &dst, 0, NULL, NULL); if (i != 17) { fprintf(stderr, "ConvertFromUnicode failure B1: unexpectedly returned %d instead of 17\n", @@ -483,7 +483,7 @@ static BOOL test_ConvertToUnicode_wrapper(void) fprintf(stderr, "ConvertToUnicode failure B3: dst length is %" PRIuz " instead of 16\n", i); goto fail; } - if (_wcscmp(dst, (WCHAR*)cmp0)) + if (_wcscmp(dst, (const WCHAR*)cmp0)) { fprintf(stderr, "ConvertToUnicode failure B: data mismatch\n"); goto fail; diff --git a/winpr/libwinpr/crt/unicode.c b/winpr/libwinpr/crt/unicode.c index a49197971..3bf7008a8 100644 --- a/winpr/libwinpr/crt/unicode.c +++ b/winpr/libwinpr/crt/unicode.c @@ -343,7 +343,7 @@ int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int if (cbMultiByte == 0) { - sourceStart = (WCHAR*)lpWideCharStr; + sourceStart = (const WCHAR*)lpWideCharStr; targetStart = (BYTE*)NULL; result = ConvertUTF16toUTF8(&sourceStart, &sourceStart[cchWideChar], &targetStart, NULL, strictConversion); @@ -351,7 +351,7 @@ int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int } else { - sourceStart = (WCHAR*)lpWideCharStr; + sourceStart = (const WCHAR*)lpWideCharStr; targetStart = (BYTE*)lpMultiByteStr; result = ConvertUTF16toUTF8(&sourceStart, &sourceStart[cchWideChar], &targetStart, &targetStart[cbMultiByte], strictConversion); diff --git a/winpr/libwinpr/input/virtualkey.c b/winpr/libwinpr/input/virtualkey.c index 20090f3c2..c4548b514 100644 --- a/winpr/libwinpr/input/virtualkey.c +++ b/winpr/libwinpr/input/virtualkey.c @@ -421,12 +421,12 @@ static XKB_KEYNAME XKB_KEYNAME_TABLE[] = { // { "LVL3", 0x54} }; -char* GetVirtualKeyName(DWORD vkcode) +const char* GetVirtualKeyName(DWORD vkcode) { - char* vkname = NULL; + const char* vkname = NULL; if (vkcode < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE)) - vkname = (char*)VIRTUAL_KEY_CODE_TABLE[vkcode].name; + vkname = VIRTUAL_KEY_CODE_TABLE[vkcode].name; if (!vkname) vkname = "VK_NONE"; diff --git a/winpr/libwinpr/path/path.c b/winpr/libwinpr/path/path.c index 547132c0d..b291c8c14 100644 --- a/winpr/libwinpr/path/path.c +++ b/winpr/libwinpr/path/path.c @@ -516,7 +516,7 @@ HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, HRESULT PathCchFindExtensionA(PCSTR pszPath, size_t cchPath, PCSTR* ppszExt) { - char* p = (char*)pszPath; + const char* p = (const char*)pszPath; if (!pszPath || !cchPath || !ppszExt) return E_INVALIDARG; diff --git a/winpr/libwinpr/pipe/pipe.c b/winpr/libwinpr/pipe/pipe.c index 8ebea61b0..f8222d7a9 100644 --- a/winpr/libwinpr/pipe/pipe.c +++ b/winpr/libwinpr/pipe/pipe.c @@ -123,7 +123,7 @@ static BOOL PipeCloseHandle(HANDLE handle) static BOOL PipeRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) { - int io_status; + SSIZE_T io_status; WINPR_PIPE* pipe; BOOL status = TRUE; @@ -162,7 +162,7 @@ static BOOL PipeRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, static BOOL PipeWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped) { - int io_status; + SSIZE_T io_status; WINPR_PIPE* pipe; if (lpOverlapped) @@ -263,7 +263,7 @@ static BOOL NamedPipeCloseHandle(HANDLE handle) BOOL NamedPipeRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) { - int io_status; + SSIZE_T io_status; WINPR_NAMED_PIPE* pipe; BOOL status = TRUE; @@ -356,7 +356,7 @@ BOOL NamedPipeRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, BOOL NamedPipeWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped) { - int io_status; + SSIZE_T io_status; WINPR_NAMED_PIPE* pipe; BOOL status = TRUE; diff --git a/winpr/libwinpr/rpc/ndr.c b/winpr/libwinpr/rpc/ndr.c index 41055b7f7..7ccc7c3ee 100644 --- a/winpr/libwinpr/rpc/ndr.c +++ b/winpr/libwinpr/rpc/ndr.c @@ -148,11 +148,11 @@ static void NdrProcessParams(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat void** fpuArgs, unsigned short numberParams) { unsigned int i; - NDR_PARAM* params; + const NDR_PARAM* params; PFORMAT_STRING fmt; unsigned char* arg; unsigned char type; - params = (NDR_PARAM*)pFormat; + params = (const NDR_PARAM*)pFormat; WLog_INFO(TAG, "Params = "); for (i = 0; i < numberParams; i++) @@ -255,11 +255,11 @@ static CLIENT_CALL_RETURN NdrClientCall(PMIDL_STUB_DESC pStubDescriptor, PFORMAT MIDL_STUB_MESSAGE stubMsg; INTERPRETER_FLAGS flags; INTERPRETER_OPT_FLAGS optFlags; - NDR_PROC_HEADER* procHeader; - NDR_OI2_PROC_HEADER* oi2ProcHeader; + const NDR_PROC_HEADER* procHeader; + const NDR_OI2_PROC_HEADER* oi2ProcHeader; CLIENT_CALL_RETURN client_call_return; procNum = stackSize = numberParams = 0; - procHeader = (NDR_PROC_HEADER*)&pFormat[0]; + procHeader = (const NDR_PROC_HEADER*)&pFormat[0]; client_call_return.Pointer = NULL; handleType = procHeader->HandleType; flags = procHeader->OldOiFlags; @@ -277,14 +277,14 @@ static CLIENT_CALL_RETURN NdrClientCall(PMIDL_STUB_DESC pStubDescriptor, PFORMAT { /* implicit handle */ WLog_INFO(TAG, "Implicit Handle"); - oi2ProcHeader = (NDR_OI2_PROC_HEADER*)&pFormat[0]; + oi2ProcHeader = (const NDR_OI2_PROC_HEADER*)&pFormat[0]; pFormat += sizeof(NDR_OI2_PROC_HEADER); } else { /* explicit handle */ WLog_INFO(TAG, "Explicit Handle"); - oi2ProcHeader = (NDR_OI2_PROC_HEADER*)&pFormat[6]; + oi2ProcHeader = (const NDR_OI2_PROC_HEADER*)&pFormat[6]; pFormat += sizeof(NDR_OI2_PROC_HEADER) + 6; } @@ -302,17 +302,17 @@ static CLIENT_CALL_RETURN NdrClientCall(PMIDL_STUB_DESC pStubDescriptor, PFORMAT if (optFlags.HasExtensions) { INTERPRETER_OPT_FLAGS2 extFlags; - NDR_PROC_HEADER_EXTS* extensions = (NDR_PROC_HEADER_EXTS*)pFormat; + const NDR_PROC_HEADER_EXTS* extensions = (const NDR_PROC_HEADER_EXTS*)pFormat; pFormat += extensions->Size; extFlags = extensions->Flags2; WLog_DBG(TAG, "Extensions: Size: %hhu, flags2: 0x%02X", extensions->Size, - *((unsigned char*)&extensions->Flags2)); + *((const unsigned char*)&extensions->Flags2)); #ifdef __x86_64__ if (extensions->Size > sizeof(*extensions) && fpuStack) { int i; - unsigned short fpuMask = *(unsigned short*)(extensions + 1); + unsigned short fpuMask = *(const unsigned short*)(extensions + 1); for (i = 0; i < 4; i++, fpuMask >>= 2) { diff --git a/winpr/libwinpr/rpc/ndr_array.c b/winpr/libwinpr/rpc/ndr_array.c index df00b8ee6..bdb407a00 100644 --- a/winpr/libwinpr/rpc/ndr_array.c +++ b/winpr/libwinpr/rpc/ndr_array.c @@ -48,7 +48,7 @@ void NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pM unsigned short element_size; type = pFormat[0]; alignment = pFormat[1] + 1; - element_size = *(unsigned short*)&pFormat[2]; + element_size = *(const unsigned short*)&pFormat[2]; if (type != FC_CARRAY) { diff --git a/winpr/libwinpr/rpc/ndr_correlation.c b/winpr/libwinpr/rpc/ndr_correlation.c index 1330a0dfa..34eba55ed 100644 --- a/winpr/libwinpr/rpc/ndr_correlation.c +++ b/winpr/libwinpr/rpc/ndr_correlation.c @@ -55,7 +55,7 @@ PFORMAT_STRING NdrpComputeCount(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem type = correlation_type & 0x0F; conformance = correlation_type & 0xF0; correlation_operator = pFormat[1]; - offset = *(unsigned short*)&pFormat[2]; + offset = *(const unsigned short*)&pFormat[2]; if (conformance == FC_NORMAL_CONFORMANCE) { diff --git a/winpr/libwinpr/rpc/ndr_pointer.c b/winpr/libwinpr/rpc/ndr_pointer.c index 0c3c0c0ef..601856967 100644 --- a/winpr/libwinpr/rpc/ndr_pointer.c +++ b/winpr/libwinpr/rpc/ndr_pointer.c @@ -77,7 +77,7 @@ PFORMAT_STRING NdrpSkipPointerLayout(PFORMAT_STRING pFormat) * { pointer_instance<8> }* */ pFormat += 8; - number_of_pointers = *(unsigned short*)pFormat; + number_of_pointers = *(const unsigned short*)pFormat; pFormat += 2 + (number_of_pointers * 8); } else if (*pFormat == FC_VARIABLE_REPEAT) @@ -92,7 +92,7 @@ PFORMAT_STRING NdrpSkipPointerLayout(PFORMAT_STRING pFormat) * { pointer_instance<8> }* */ pFormat += 6; - number_of_pointers = *(unsigned short*)pFormat; + number_of_pointers = *(const unsigned short*)pFormat; pFormat += 2 + (number_of_pointers * 8); } else @@ -134,7 +134,7 @@ void NdrpPointerBufferSize(unsigned char* pMemory, PFORMAT_STRING pFormat, if (attributes & FC_SIMPLE_POINTER) pNextFormat = pFormat; else - pNextFormat = pFormat + *(SHORT*)pFormat; + pNextFormat = pFormat + *(const SHORT*)pFormat; switch (type) { @@ -181,7 +181,7 @@ PFORMAT_STRING NdrpEmbeddedRepeatPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, if (*pFormat == FC_FIXED_REPEAT) { pFormat += 2; - MaxCount = *(unsigned short*)pFormat; + MaxCount = *(const unsigned short*)pFormat; } else { @@ -195,17 +195,17 @@ PFORMAT_STRING NdrpEmbeddedRepeatPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, if (pFormat[1] == FC_VARIABLE_OFFSET) { - pMemory += pStubMsg->Offset * (*(unsigned short*)&pFormat[1]); + pMemory += pStubMsg->Offset * (*(const unsigned short*)&pFormat[1]); } } pFormat += 2; - increment = *(unsigned short*)pFormat; + increment = *(const unsigned short*)pFormat; pFormat += 2; - offset_to_array = *(unsigned short*)pFormat; + offset_to_array = *(const unsigned short*)pFormat; pStubMsg->Memory = Memory + offset_to_array; pFormat += 2; - number_of_pointers = *(unsigned short*)pFormat; + number_of_pointers = *(const unsigned short*)pFormat; pFormat += 2; pFormatPointers = pFormat; @@ -222,7 +222,7 @@ PFORMAT_STRING NdrpEmbeddedRepeatPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, do { pointer_count--; - MemoryPointer = &pMemory[*(unsigned short*)pFormatNext]; + MemoryPointer = &pMemory[*(const unsigned short*)pFormatNext]; NdrpPointerBufferSize(MemoryPointer, pFormatNext + 4, pStubMsg); pFormatNext += 8; } while (pointer_count); diff --git a/winpr/libwinpr/rpc/ndr_structure.c b/winpr/libwinpr/rpc/ndr_structure.c index 8ef4bbd3f..d5ef109d8 100644 --- a/winpr/libwinpr/rpc/ndr_structure.c +++ b/winpr/libwinpr/rpc/ndr_structure.c @@ -57,7 +57,7 @@ void NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemo unsigned short memory_size; type = pFormat[0]; alignment = pFormat[1] + 1; - memory_size = *(unsigned short*)&pFormat[2]; + memory_size = *(const unsigned short*)&pFormat[2]; NdrpAlignLength(&(pStubMsg->BufferLength), alignment); NdrpIncrementLength(&(pStubMsg->BufferLength), memory_size); pFormat += 4; @@ -227,7 +227,7 @@ void NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem unsigned char type; unsigned char alignment; unsigned short memory_size; - unsigned char* pointer_layout; + const unsigned char* pointer_layout; unsigned char* conformant_array_description; unsigned short offset_to_pointer_layout; unsigned short offset_to_conformant_array_description; @@ -242,7 +242,7 @@ void NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem } alignment = pFormat[1] + 1; - memory_size = *(unsigned short*)&pFormat[2]; + memory_size = *(const unsigned short*)&pFormat[2]; NdrpAlignLength(&(pStubMsg->BufferLength), alignment); if (!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength) @@ -257,17 +257,17 @@ void NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem } pFormat += 4; - offset_to_conformant_array_description = *(unsigned short*)&pFormat[0]; + offset_to_conformant_array_description = *(const unsigned short*)&pFormat[0]; if (offset_to_conformant_array_description) conformant_array_description = - (unsigned char*)pFormat + offset_to_conformant_array_description; + (const unsigned char*)pFormat + offset_to_conformant_array_description; pFormat += 2; - offset_to_pointer_layout = *(unsigned short*)&pFormat[0]; + offset_to_pointer_layout = *(const unsigned short*)&pFormat[0]; if (offset_to_pointer_layout) - pointer_layout = (unsigned char*)pFormat + offset_to_pointer_layout; + pointer_layout = (const unsigned char*)pFormat + offset_to_pointer_layout; pFormat += 2; pStubMsg->Memory = pMemory; diff --git a/winpr/libwinpr/sspi/sspi_winpr.c b/winpr/libwinpr/sspi/sspi_winpr.c index ff10ceb59..deed4da90 100644 --- a/winpr/libwinpr/sspi/sspi_winpr.c +++ b/winpr/libwinpr/sspi/sspi_winpr.c @@ -490,7 +490,7 @@ void sspi_GlobalFinish(void) sspi_ContextBufferAllocTableFree(); } -static SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const SEC_CHAR* Name) +static const SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const SEC_CHAR* Name) { int index; UINT32 cPackages; @@ -500,7 +500,7 @@ static SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const SEC_C { if (strcmp(Name, SecurityFunctionTableA_NAME_LIST[index].Name) == 0) { - return (SecurityFunctionTableA*)SecurityFunctionTableA_NAME_LIST[index] + return (const SecurityFunctionTableA*)SecurityFunctionTableA_NAME_LIST[index] .SecurityFunctionTable; } } @@ -508,7 +508,7 @@ static SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const SEC_C return NULL; } -static SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const SEC_WCHAR* Name) +static const SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const SEC_WCHAR* Name) { int index; UINT32 cPackages; @@ -518,7 +518,7 @@ static SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const SEC_W { if (lstrcmpW(Name, SecurityFunctionTableW_NAME_LIST[index].Name) == 0) { - return (SecurityFunctionTableW*)SecurityFunctionTableW_NAME_LIST[index] + return (const SecurityFunctionTableW*)SecurityFunctionTableW_NAME_LIST[index] .SecurityFunctionTable; } } @@ -530,7 +530,7 @@ static SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameA(const SEC_C { int status; SEC_WCHAR* NameW = NULL; - SecurityFunctionTableW* table; + const SecurityFunctionTableW* table; status = ConvertToUnicode(CP_UTF8, 0, Name, -1, &NameW, 0); if (status <= 0) @@ -769,7 +769,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_AcquireCredentialsHandleW( PTimeStamp ptsExpiry) { SECURITY_STATUS status; - SecurityFunctionTableW* table = sspi_GetSecurityFunctionTableWByNameW(pszPackage); + const SecurityFunctionTableW* table = sspi_GetSecurityFunctionTableWByNameW(pszPackage); if (!table) return SEC_E_SECPKG_NOT_FOUND; @@ -799,7 +799,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_AcquireCredentialsHandleA( PTimeStamp ptsExpiry) { SECURITY_STATUS status; - SecurityFunctionTableA* table = sspi_GetSecurityFunctionTableAByNameA(pszPackage); + const SecurityFunctionTableA* table = sspi_GetSecurityFunctionTableAByNameA(pszPackage); if (!table) return SEC_E_SECPKG_NOT_FOUND; @@ -861,7 +861,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_FreeCredentialsHandle(PCredHandle phCrede { char* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phCredential); if (!Name) @@ -929,7 +929,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_ImportSecurityContextA(SEC_CHAR* pszPacka { char* Name = NULL; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) @@ -962,7 +962,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_QueryCredentialsAttributesW(PCredHandle p { SEC_WCHAR* Name; SECURITY_STATUS status; - SecurityFunctionTableW* table; + const SecurityFunctionTableW* table; Name = (SEC_WCHAR*)sspi_SecureHandleGetUpperPointer(phCredential); if (!Name) @@ -995,7 +995,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_QueryCredentialsAttributesA(PCredHandle p { char* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phCredential); if (!Name) @@ -1032,7 +1032,7 @@ winpr_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext, PSe { char* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phCredential); if (!Name) @@ -1067,7 +1067,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_ApplyControlToken(PCtxtHandle phContext, { char* Name = NULL; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) @@ -1100,7 +1100,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_CompleteAuthToken(PCtxtHandle phContext, { char* Name = NULL; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) @@ -1132,7 +1132,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_DeleteSecurityContext(PCtxtHandle phConte { char* Name = NULL; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) @@ -1245,7 +1245,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_InitializeSecurityContextA( { SEC_CHAR* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phCredential); if (!Name) @@ -1313,7 +1313,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_QueryContextAttributesA(PCtxtHandle phCon { SEC_CHAR* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) @@ -1414,7 +1414,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_SetContextAttributesA(PCtxtHandle phConte { char* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) @@ -1482,7 +1482,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_DecryptMessage(PCtxtHandle phContext, { char* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) @@ -1515,7 +1515,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_EncryptMessage(PCtxtHandle phContext, ULO { char* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) @@ -1548,7 +1548,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_MakeSignature(PCtxtHandle phContext, ULON { char* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) @@ -1582,7 +1582,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_VerifySignature(PCtxtHandle phContext, { char* Name; SECURITY_STATUS status; - SecurityFunctionTableA* table; + const SecurityFunctionTableA* table; Name = (char*)sspi_SecureHandleGetUpperPointer(phContext); if (!Name) diff --git a/winpr/libwinpr/thread/argv.c b/winpr/libwinpr/thread/argv.c index b5921d000..674b3e6c0 100644 --- a/winpr/libwinpr/thread/argv.c +++ b/winpr/libwinpr/thread/argv.c @@ -91,7 +91,7 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs) { - char* p; + const char* p; size_t length; char* pBeg; char* pEnd; @@ -123,7 +123,7 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs) { size_t i; size_t n; - char* pLastEnd = NULL; + const char* pLastEnd = NULL; lpEscapedCmdLine = (char*)calloc(cmdLineLength + 1, sizeof(char)); if (!lpEscapedCmdLine) @@ -132,8 +132,8 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs) return NULL; } - p = (char*)lpCmdLine; - pLastEnd = (char*)lpCmdLine; + p = (const char*)lpCmdLine; + pLastEnd = (const char*)lpCmdLine; pOutput = (char*)lpEscapedCmdLine; while (p < &lpCmdLine[cmdLineLength]) @@ -185,7 +185,7 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs) } maxNumArgs = 2; - p = (char*)lpCmdLine; + p = (const char*)lpCmdLine; while (p < lpCmdLine + cmdLineLength) { @@ -206,7 +206,7 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs) pArgs = (LPSTR*)buffer; pOutput = (char*)&buffer[maxNumArgs * (sizeof(char*))]; - p = (char*)lpCmdLine; + p = (const char*)lpCmdLine; while (p < lpCmdLine + cmdLineLength) { diff --git a/winpr/libwinpr/utils/lodepng/lodepng.c b/winpr/libwinpr/utils/lodepng/lodepng.c index de81586f7..1ead37b9f 100644 --- a/winpr/libwinpr/utils/lodepng/lodepng.c +++ b/winpr/libwinpr/utils/lodepng/lodepng.c @@ -403,7 +403,7 @@ unsigned lodepng_save_file(const unsigned char* buffer, size_t buffersize, const file = winpr_fopen(filename, "wb"); if (!file) return 79; - if (fwrite((char*)buffer, 1, buffersize, file) != buffersize) + if (fwrite((const char*)buffer, 1, buffersize, file) != buffersize) ret = 91; fclose(file); return ret; @@ -4761,7 +4761,7 @@ static unsigned readChunk_zTXt(LodePNGInfo* info, const LodePNGDecompressSetting length = chunkLength - string2_begin; /*will fail if zlib error, e.g. if length is too small*/ error = zlib_decompress(&decoded.data, &decoded.size, - (unsigned char*)(&data[string2_begin]), length, zlibsettings); + (const unsigned char*)(&data[string2_begin]), length, zlibsettings); if (error) break; if (!ucvector_push_back(&decoded, 0)) @@ -4858,8 +4858,8 @@ static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecompressSetting if (compressed) { /*will fail if zlib error, e.g. if length is too small*/ - error = zlib_decompress(&decoded.data, &decoded.size, (unsigned char*)(&data[begin]), - length, zlibsettings); + error = zlib_decompress(&decoded.data, &decoded.size, + (const unsigned char*)(&data[begin]), length, zlibsettings); if (error) break; if (decoded.allocsize < decoded.size) @@ -5454,8 +5454,8 @@ static unsigned addChunk_zTXt(ucvector* out, const char* keyword, const char* te ucvector_push_back(&data, 0); /*0 termination char*/ ucvector_push_back(&data, 0); /*compression method: 0*/ - error = zlib_compress(&compressed.data, &compressed.size, (unsigned char*)textstring, textsize, - zlibsettings); + error = zlib_compress(&compressed.data, &compressed.size, (const unsigned char*)textstring, + textsize, zlibsettings); if (!error) { for (i = 0; i < compressed.size; i++) @@ -5497,7 +5497,7 @@ static unsigned addChunk_iTXt(ucvector* out, unsigned compressed, const char* ke ucvector compressed_data; ucvector_init(&compressed_data); error = zlib_compress(&compressed_data.data, &compressed_data.size, - (unsigned char*)textstring, textsize, zlibsettings); + (const unsigned char*)textstring, textsize, zlibsettings); if (!error) { for (i = 0; i < compressed_data.size; i++) diff --git a/winpr/libwinpr/utils/trio/trio.c b/winpr/libwinpr/utils/trio/trio.c index 00d1a2c76..b64b7cd15 100644 --- a/winpr/libwinpr/utils/trio/trio.c +++ b/winpr/libwinpr/utils/trio/trio.c @@ -1857,7 +1857,7 @@ TRIO_PRIVATE int TrioParseSpecifier TRIO_ARGS4((type, format, offset, parameter) { unsigned int max; int without_namespace = TRUE; - char* tmpformat = (char*)&format[offset]; + const char* tmpformat = (const char*)&format[offset]; int ch; parameter->type = FORMAT_USER_DEFINED; @@ -1893,7 +1893,7 @@ TRIO_PRIVATE int TrioParseSpecifier TRIO_ARGS4((type, format, offset, parameter) if (max > MAX_USER_NAME) max = MAX_USER_NAME; trio_copy_max(parameter->user_defined.namespace, max, tmpformat); - tmpformat = (char*)&format[offset]; + tmpformat = (const char*)&format[offset]; } } diff --git a/winpr/libwinpr/utils/trio/trionan.c b/winpr/libwinpr/utils/trio/trionan.c index 61862bebe..9a8348f0e 100644 --- a/winpr/libwinpr/utils/trio/trionan.c +++ b/winpr/libwinpr/utils/trio/trionan.c @@ -242,7 +242,7 @@ * kind of endianess. The individual bytes are then used as an index * for the IEEE 754 bit-patterns and masks. */ -#define TRIO_DOUBLE_INDEX(x) (((unsigned char*)&internalEndianMagic)[7 - (x)]) +#define TRIO_DOUBLE_INDEX(x) (((const unsigned char*)&internalEndianMagic)[7 - (x)]) static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275; #endif @@ -292,9 +292,9 @@ static TRIO_CONST unsigned char ieee_754_qnan_array[] = { 0x7F, 0xF8, 0x00, 0x00 TRIO_PRIVATE_NAN double internal_make_double TRIO_ARGS1((values), TRIO_CONST unsigned char* values) { TRIO_VOLATILE double result = 0.0; - int i; + size_t i; - for (i = 0; i < (int)sizeof(double); i++) + for (i = 0; i < sizeof(double); i++) { ((TRIO_VOLATILE unsigned char*)&result)[TRIO_DOUBLE_INDEX(i)] = values[i]; } diff --git a/winpr/libwinpr/utils/wlog/wlog.c b/winpr/libwinpr/utils/wlog/wlog.c index b5afed25a..24953bd31 100644 --- a/winpr/libwinpr/utils/wlog/wlog.c +++ b/winpr/libwinpr/utils/wlog/wlog.c @@ -791,7 +791,7 @@ LONG WLog_GetFilterLogLevel(wLog* log) return log->FilterLevel; } -static BOOL WLog_ParseName(wLog* log, LPCSTR name) +static BOOL WLog_ParseName(wLog* log, LPSTR name) { char* p; size_t count; diff --git a/winpr/libwinpr/winsock/winsock.c b/winpr/libwinpr/winsock/winsock.c index 6e82be96e..1cc3d5b0e 100644 --- a/winpr/libwinpr/winsock/winsock.c +++ b/winpr/libwinpr/winsock/winsock.c @@ -1161,7 +1161,7 @@ int _select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, do { - status = select(nfds, readfds, writefds, exceptfds, (struct timeval*)timeout); + status = select(nfds, readfds, writefds, exceptfds, (const struct timeval*)timeout); } while ((status < 0) && (errno == EINTR)); return status; @@ -1172,7 +1172,7 @@ int _send(SOCKET s, const char* buf, int len, int flags) int status; int fd = (int)s; flags |= MSG_NOSIGNAL; - status = (int)send(fd, (void*)buf, (size_t)len, flags); + status = (int)send(fd, (const void*)buf, (size_t)len, flags); return status; } @@ -1180,7 +1180,7 @@ int _sendto(SOCKET s, const char* buf, int len, int flags, const struct sockaddr { int status; int fd = (int)s; - status = (int)sendto(fd, (void*)buf, (size_t)len, flags, to, (socklen_t)tolen); + status = (int)sendto(fd, (const void*)buf, (size_t)len, flags, to, (socklen_t)tolen); return status; } @@ -1188,7 +1188,7 @@ int _setsockopt(SOCKET s, int level, int optname, const char* optval, int optlen { int status; int fd = (int)s; - status = setsockopt(fd, level, optname, (void*)optval, (socklen_t)optlen); + status = setsockopt(fd, level, optname, (const void*)optval, (socklen_t)optlen); return status; } @@ -1236,7 +1236,7 @@ SOCKET _socket(int af, int type, int protocol) struct hostent* _gethostbyaddr(const char* addr, int len, int type) { struct hostent* host; - host = gethostbyaddr((void*)addr, (socklen_t)len, type); + host = gethostbyaddr((const void*)addr, (socklen_t)len, type); return host; }