From 6d541c8691c5b628225763f52459873bd8b395b6 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 3 Mar 2025 22:16:06 +0100 Subject: [PATCH] [warnings] eliminate dead code --- channels/audin/client/oss/audin_oss.c | 14 --- channels/encomsp/client/encomsp_main.c | 4 - channels/encomsp/server/encomsp_main.c | 32 +----- channels/rdpear/common/rdpear_common.c | 22 ++-- channels/rdpei/client/rdpei_main.c | 8 +- channels/rdpsnd/client/oss/rdpsnd_oss.c | 17 --- channels/remdesk/client/remdesk_main.c | 5 - channels/remdesk/server/remdesk_main.c | 4 - channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 13 --- channels/tsmf/client/oss/tsmf_oss.c | 14 --- client/SDL/SDL2/sdl_kbd.cpp | 33 +++--- client/SDL/SDL3/sdl_kbd.cpp | 35 +++--- client/Wayland/wlf_disp.c | 2 - client/X11/xf_client.c | 6 -- client/common/test/TestClientCmdLine.c | 8 -- client/common/test/TestClientRdpFile.c | 18 ---- include/freerdp/api.h | 11 +- include/freerdp/codec/color.h | 27 ++++- libfreerdp/codec/color.c | 35 +++++- libfreerdp/codec/h264_ffmpeg.c | 8 -- libfreerdp/codec/h264_openh264.c | 8 -- .../codec/test/TestFreeRDPCodecRemoteFX.c | 8 -- libfreerdp/core/license.c | 6 +- libfreerdp/core/orders.c | 19 ---- libfreerdp/gdi/gfx.c | 9 +- libfreerdp/utils/pcap.c | 6 +- scripts/test-scard.cpp | 7 -- winpr/libwinpr/crypto/cipher.c | 21 ---- winpr/libwinpr/file/namedPipeClient.c | 9 +- winpr/libwinpr/nt/ntstatus.c | 6 +- winpr/libwinpr/pipe/pipe.c | 9 +- .../test/TestPipeCreateNamedPipeOverlapped.c | 5 - winpr/libwinpr/synch/event.c | 10 -- winpr/libwinpr/utils/wlog/PacketMessage.c | 100 ------------------ .../test/TestWtsApiEnumerateProcesses.c | 12 ++- 35 files changed, 145 insertions(+), 406 deletions(-) diff --git a/channels/audin/client/oss/audin_oss.c b/channels/audin/client/oss/audin_oss.c index 8b6ad6cc5..83e0ae7cd 100644 --- a/channels/audin/client/oss/audin_oss.c +++ b/channels/audin/client/oss/audin_oss.c @@ -192,20 +192,6 @@ static DWORD WINAPI audin_oss_thread_func(LPVOID arg) close(mixer_handle); } -#if 0 /* FreeBSD OSS implementation at this moment (2015.03) does not set PCM_CAP_INPUT flag. */ - tmp = 0; - - if (ioctl(pcm_handle, SNDCTL_DSP_GETCAPS, &tmp) == -1) - { - OSS_LOG_ERR("SNDCTL_DSP_GETCAPS failed, try ignored", errno); - } - else if ((tmp & PCM_CAP_INPUT) == 0) - { - OSS_LOG_ERR("Device does not supports playback", EOPNOTSUPP); - goto err_out; - } - -#endif /* Set format. */ tmp = audin_oss_get_format(&oss->format); diff --git a/channels/encomsp/client/encomsp_main.c b/channels/encomsp/client/encomsp_main.c index 4bd7d84af..fb88f1b9c 100644 --- a/channels/encomsp/client/encomsp_main.c +++ b/channels/encomsp/client/encomsp_main.c @@ -123,10 +123,6 @@ static UINT encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s) return ERROR_INVALID_HANDLE; } -#if 0 - WLog_INFO(TAG, "EncomspWrite (%"PRIuz")", Stream_Length(s)); - winpr_HexDump(Stream_Buffer(s), Stream_Length(s)); -#endif const UINT status = encomsp->channelEntryPoints.pVirtualChannelWriteEx( encomsp->InitHandle, encomsp->OpenHandle, Stream_Buffer(s), (UINT32)Stream_Length(s), s); diff --git a/channels/encomsp/server/encomsp_main.c b/channels/encomsp/server/encomsp_main.c index 4613f9a5b..2ff7eb3a0 100644 --- a/channels/encomsp/server/encomsp_main.c +++ b/channels/encomsp/server/encomsp_main.c @@ -47,36 +47,6 @@ static UINT encomsp_read_header(wStream* s, ENCOMSP_ORDER_HEADER* header) return CHANNEL_RC_OK; } -#if 0 - -static int encomsp_write_header(wStream* s, ENCOMSP_ORDER_HEADER* header) -{ - Stream_Write_UINT16(s, header->Type); /* Type (2 bytes) */ - Stream_Write_UINT16(s, header->Length); /* Length (2 bytes) */ - return 1; -} - -static int encomsp_read_unicode_string(wStream* s, ENCOMSP_UNICODE_STRING* str) -{ - ZeroMemory(str, sizeof(ENCOMSP_UNICODE_STRING)); - - if (!Stream_CheckAndLogRequiredLength(TAG, s, 2)) - return -1; - - Stream_Read_UINT16(s, str->cchString); /* cchString (2 bytes) */ - - if (str->cchString > 1024) - return -1; - - if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, str->cchString, sizeof(WCHAR))) - return -1; - - Stream_Read(s, &(str->wString), (str->cchString * 2)); /* String (variable) */ - return 1; -} - -#endif - /** * Function description * @@ -134,10 +104,10 @@ static UINT encomsp_recv_change_participant_control_level_pdu(EncomspServerConte static UINT encomsp_server_receive_pdu(EncomspServerContext* context, wStream* s) { UINT error = CHANNEL_RC_OK; - ENCOMSP_ORDER_HEADER header; while (Stream_GetRemainingLength(s) > 0) { + ENCOMSP_ORDER_HEADER header = { 0 }; if ((error = encomsp_read_header(s, &header))) { WLog_ERR(TAG, "encomsp_read_header failed with error %" PRIu32 "!", error); diff --git a/channels/rdpear/common/rdpear_common.c b/channels/rdpear/common/rdpear_common.c index 6f80270ba..8811ceeb3 100644 --- a/channels/rdpear/common/rdpear_common.c +++ b/channels/rdpear/common/rdpear_common.c @@ -204,16 +204,24 @@ static BOOL ndr_descr_read_RPC_UNICODE_STRING(NdrContext* context, wStream* s, c return ndr_read_RPC_UNICODE_STRING(context, s, hints, res); } -#if 0 BOOL ndr_write_RPC_UNICODE_STRING(NdrContext* context, wStream* s, const void* hints, const RPC_UNICODE_STRING* res) { - return ndr_write_uint32(context, s, res->lenHints.length) && - ndr_write_uint32(context, s, res->lenHints.maxLength) /*&& - ndr_write_BYTE_ptr(context, s, (BYTE*)res->Buffer, res->Length)*/ - ; + WINPR_ASSERT(res); + if (!ndr_write_uint32(context, s, res->lenHints.length)) + return FALSE; + + if (!ndr_write_uint32(context, s, res->lenHints.maxLength)) + return FALSE; + + const BYTE* ptr = WINPR_CXX_COMPAT_CAST(const BYTE*, res->Buffer); + for (size_t x = 0; x < res->strLength; x++) + { + if (!ndr_write_uint8(context, s, ptr[x])) + return FALSE; + } + return TRUE; } -#endif void ndr_dump_RPC_UNICODE_STRING(wLog* logger, UINT32 lvl, size_t indentLevel, const RPC_UNICODE_STRING* obj) @@ -248,7 +256,7 @@ static void ndr_descr_destroy_RPC_UNICODE_STRING(NdrContext* context, const void static const NdrMessageDescr RPC_UNICODE_STRING_descr_s = { NDR_ARITY_SIMPLE, sizeof(RPC_UNICODE_STRING), ndr_descr_read_RPC_UNICODE_STRING, - /*ndr_write_RPC_UNICODE_STRING*/ NULL, + NULL, ndr_descr_destroy_RPC_UNICODE_STRING, ndr_descr_dump_RPC_UNICODE_STRING }; diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index db5a80c95..5c3ad0ba3 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -785,15 +785,13 @@ static UINT rdpei_recv_sc_ready_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* if (rdpei->version > protocolVersion) rdpei->version = protocolVersion; rdpei->features = features; -#if 0 - if (protocolVersion != RDPINPUT_PROTOCOL_V10) + if (protocolVersion > RDPINPUT_PROTOCOL_V300) { - WLog_Print(rdpei->base.log, WLOG_ERROR, "Unknown [MS-RDPEI] protocolVersion: 0x%08"PRIX32"", protocolVersion); - return -1; + WLog_Print(rdpei->base.log, WLOG_WARN, + "Unknown [MS-RDPEI] protocolVersion: 0x%08" PRIX32 "", protocolVersion); } -#endif return CHANNEL_RC_OK; } diff --git a/channels/rdpsnd/client/oss/rdpsnd_oss.c b/channels/rdpsnd/client/oss/rdpsnd_oss.c index 69f51650d..aaa2c0e84 100644 --- a/channels/rdpsnd/client/oss/rdpsnd_oss.c +++ b/channels/rdpsnd/client/oss/rdpsnd_oss.c @@ -227,23 +227,6 @@ static BOOL rdpsnd_oss_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* form return FALSE; } -#if 0 /* FreeBSD OSS implementation at this moment (2015.03) does not set PCM_CAP_OUTPUT flag. */ - int mask = 0; - - if (ioctl(oss->pcm_handle, SNDCTL_DSP_GETCAPS, &mask) == -1) - { - OSS_LOG_ERR("SNDCTL_DSP_GETCAPS failed, try ignored", errno); - } - else if ((mask & PCM_CAP_OUTPUT) == 0) - { - OSS_LOG_ERR("Device does not supports playback", EOPNOTSUPP); - close(oss->pcm_handle); - oss->pcm_handle = -1; - return; - } - -#endif - if (ioctl(oss->pcm_handle, SNDCTL_DSP_GETFMTS, &oss->supported_formats) == -1) { OSS_LOG_ERR("SNDCTL_DSP_GETFMTS failed", errno); diff --git a/channels/remdesk/client/remdesk_main.c b/channels/remdesk/client/remdesk_main.c index 62f27bfce..838868571 100644 --- a/channels/remdesk/client/remdesk_main.c +++ b/channels/remdesk/client/remdesk_main.c @@ -632,11 +632,6 @@ static UINT remdesk_process_receive(remdeskPlugin* remdesk, wStream* s) WINPR_ASSERT(remdesk); WINPR_ASSERT(s); -#if 0 - WLog_DBG(TAG, "RemdeskReceive: %"PRIuz"", Stream_GetRemainingLength(s)); - winpr_HexDump(Stream_ConstPointer(s), Stream_GetRemainingLength(s)); -#endif - if ((status = remdesk_read_channel_header(s, &header))) { WLog_ERR(TAG, "remdesk_read_channel_header failed with error %" PRIu32 "", status); diff --git a/channels/remdesk/server/remdesk_main.c b/channels/remdesk/server/remdesk_main.c index b843d1249..c9f448153 100644 --- a/channels/remdesk/server/remdesk_main.c +++ b/channels/remdesk/server/remdesk_main.c @@ -387,10 +387,6 @@ static UINT remdesk_server_receive_pdu(RemdeskServerContext* context, wStream* s { UINT error = CHANNEL_RC_OK; REMDESK_CHANNEL_HEADER header; -#if 0 - WLog_INFO(TAG, "RemdeskReceive: %"PRIuz"", Stream_GetRemainingLength(s)); - winpr_HexDump(WCHAR* expertBlobW = NULL;(s), Stream_GetRemainingLength(s)); -#endif if ((error = remdesk_read_channel_header(s, &header))) { diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c index bda0fba76..63e95311b 100644 --- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c +++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c @@ -461,19 +461,6 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI int len = 0; int frame_size = 0; -#if 0 - WLog_DBG(TAG, ("tsmf_ffmpeg_decode_audio: data_size %"PRIu32"", data_size)); - - for (int i = 0; i < data_size; i++) - { - WLog_DBG(TAG, ("%02"PRIX8"", data[i])); - - if (i % 16 == 15) - WLog_DBG(TAG, ("\n")); - } - -#endif - if (mdecoder->decoded_size_max == 0) mdecoder->decoded_size_max = MAX_AUDIO_FRAME_SIZE + 16; diff --git a/channels/tsmf/client/oss/tsmf_oss.c b/channels/tsmf/client/oss/tsmf_oss.c index 721620ebe..ad8033604 100644 --- a/channels/tsmf/client/oss/tsmf_oss.c +++ b/channels/tsmf/client/oss/tsmf_oss.c @@ -93,20 +93,6 @@ static BOOL tsmf_oss_open(ITSMFAudioDevice* audio, const char* device) return FALSE; } -#if 0 /* FreeBSD OSS implementation at this moment (2015.03) does not set PCM_CAP_OUTPUT flag. */ - if (ioctl(oss->pcm_handle, SNDCTL_DSP_GETCAPS, &mask) == -1) - { - OSS_LOG_ERR("SNDCTL_DSP_GETCAPS failed, try ignored", errno); - } - else if ((mask & PCM_CAP_OUTPUT) == 0) - { - OSS_LOG_ERR("Device does not supports playback", EOPNOTSUPP); - close(oss->pcm_handle); - oss->pcm_handle = -1; - return FALSE; - } - -#endif const int rc = ioctl(oss->pcm_handle, SNDCTL_DSP_GETFMTS, &tmp); if (rc == -1) { diff --git a/client/SDL/SDL2/sdl_kbd.cpp b/client/SDL/SDL2/sdl_kbd.cpp index 7648a4dd0..a80e37c1c 100644 --- a/client/SDL/SDL2/sdl_kbd.cpp +++ b/client/SDL/SDL2/sdl_kbd.cpp @@ -24,6 +24,7 @@ #include "sdl_freerdp.hpp" #include "sdl_utils.hpp" #include "sdl_prefs.hpp" +#include "sdl_touch.hpp" #include @@ -329,20 +330,24 @@ BOOL sdlInput::keyboard_focus_in() freerdp_input_send_focus_in_event(input, WINPR_ASSERTING_INT_CAST(UINT16, syncFlags)); /* finish with a mouse pointer position like mstsc.exe if required */ -#if 0 - if (xfc->remote_app) - return; - - if (XQueryPointer(xfc->display, xfc->window->handle, &w, &w, &d, &d, &x, &y, &state)) - { - if ((x >= 0) && (x < xfc->window->width) && (y >= 0) && (y < xfc->window->height)) - { - xf_event_adjust_coordinates(xfc, &x, &y); - freerdp_client_send_button_event(&xfc->common, FALSE, PTR_FLAGS_MOVE, x, y); - } - } -#endif - return TRUE; + // TODO: fullscreen/remote app + int x = 0; + int y = 0; + if (_sdl->fullscreen) + { + SDL_GetGlobalMouseState(&x, &y); + } + else + { + SDL_GetMouseState(&x, &y); + } + auto w = SDL_GetMouseFocus(); + if (w) + { + auto id = SDL_GetWindowID(w); + sdl_scale_coordinates(_sdl, id, &x, &y, TRUE, TRUE); + } + return freerdp_client_send_button_event(_sdl->common(), FALSE, PTR_FLAGS_MOVE, x, y); } /* This function is called to update the keyboard indicator LED */ diff --git a/client/SDL/SDL3/sdl_kbd.cpp b/client/SDL/SDL3/sdl_kbd.cpp index edd99784a..25f4a7965 100644 --- a/client/SDL/SDL3/sdl_kbd.cpp +++ b/client/SDL/SDL3/sdl_kbd.cpp @@ -22,6 +22,7 @@ #include "sdl_freerdp.hpp" #include "sdl_utils.hpp" #include "sdl_prefs.hpp" +#include "sdl_touch.hpp" #include @@ -313,20 +314,26 @@ BOOL sdlInput::keyboard_focus_in() freerdp_input_send_focus_in_event(input, WINPR_ASSERTING_INT_CAST(uint16_t, syncFlags)); /* finish with a mouse pointer position like mstsc.exe if required */ -#if 0 - if (xfc->remote_app) - return; - - if (XQueryPointer(xfc->display, xfc->window->handle, &w, &w, &d, &d, &x, &y, &state)) - { - if ((x >= 0) && (x < xfc->window->width) && (y >= 0) && (y < xfc->window->height)) - { - xf_event_adjust_coordinates(xfc, &x, &y); - freerdp_client_send_button_event(&xfc->common, FALSE, PTR_FLAGS_MOVE, x, y); - } - } -#endif - return TRUE; + // TODO: fullscreen/remote app + float fx = 0.0f; + float fy = 0.0f; + if (_sdl->fullscreen) + { + SDL_GetGlobalMouseState(&fx, &fy); + } + else + { + SDL_GetMouseState(&fx, &fy); + } + auto x = static_cast(fx); + auto y = static_cast(fy); + auto w = SDL_GetMouseFocus(); + if (w) + { + auto id = SDL_GetWindowID(w); + sdl_scale_coordinates(_sdl, id, &x, &y, TRUE, TRUE); + } + return freerdp_client_send_button_event(_sdl->common(), FALSE, PTR_FLAGS_MOVE, x, y); } /* This function is called to update the keyboard indicator LED */ diff --git a/client/Wayland/wlf_disp.c b/client/Wayland/wlf_disp.c index 276a412f8..2a3ad7538 100644 --- a/client/Wayland/wlf_disp.c +++ b/client/Wayland/wlf_disp.c @@ -161,8 +161,6 @@ static BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp) static BOOL wlf_disp_set_window_resizable(WINPR_ATTR_UNUSED wlfDispContext* wlfDisp) { WLog_ERR("TODO", "TODO: implement"); -#if 0 // TODO -#endif return TRUE; } diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 59191f2ed..6f0e521b1 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -891,12 +891,6 @@ static int xf_error_handler(Display* d, XErrorEvent* ev) WLog_ERR(TAG, "%s", buf); winpr_log_backtrace(TAG, WLOG_ERROR, 20); -#if 0 - const BOOL do_abort = TRUE; - if (do_abort) - abort(); -#endif - if (def_error_handler) return def_error_handler(d, ev); diff --git a/client/common/test/TestClientCmdLine.c b/client/common/test/TestClientCmdLine.c index 79ee06c5c..0c9c72c80 100644 --- a/client/common/test/TestClientCmdLine.c +++ b/client/common/test/TestClientCmdLine.c @@ -203,14 +203,6 @@ static const test tests[] = { check_settings_smartcard_no_redirection, { "testfreerdp", "/sound", "/drive:media,/foo/bar/blabla", "/v:test.freerdp.com", 0 }, { { 0 } } }, - -#if 0 - { - COMMAND_LINE_STATUS_PRINT, check_settings_smartcard_no_redirection, - {"testfreerdp", "-z", "--plugin", "cliprdr", "--plugin", "rdpsnd", "--data", "alsa", "latency:100", "--", "--plugin", "rdpdr", "--data", "disk:w7share:/home/w7share", "--", "--plugin", "drdynvc", "--data", "tsmf:decoder:gstreamer", "--", "-u", "test", "host.example.com", 0}, - {{0}} - }, -#endif }; // NOLINTEND(bugprone-suspicious-missing-comma) diff --git a/client/common/test/TestClientRdpFile.c b/client/common/test/TestClientRdpFile.c index 03f1bc3b6..c74587bfb 100644 --- a/client/common/test/TestClientRdpFile.c +++ b/client/common/test/TestClientRdpFile.c @@ -310,15 +310,6 @@ int TestClientRdpFile(int argc, char* argv[]) goto fail; } -#if 0 /* TODO: Currently unused */ - if (freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod) != 1) - { - printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n", - freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod)); - goto fail; - } -#endif - if (strcmp(freerdp_settings_get_string(settings, FreeRDP_GatewayHostname), "LAB1-W2K8R2-GW.lab1.awake.local") != 0) { @@ -369,15 +360,6 @@ int TestClientRdpFile(int argc, char* argv[]) return -1; } -#if 0 /* TODO: Currently unused */ - if (freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod) != 1) - { - printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n", - freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod)); - goto fail; - } -#endif - if (strcmp(freerdp_settings_get_string(settings, FreeRDP_ServerHostname), "LAB1-W7-DM-01.lab1.awake.global") != 0) { diff --git a/include/freerdp/api.h b/include/freerdp/api.h index b7655cf20..07003bc40 100644 --- a/include/freerdp/api.h +++ b/include/freerdp/api.h @@ -90,13 +90,14 @@ WLog_VRB("com.freerdp.api", "IFCALLRET(" #_cb ") == NULL"); \ } while (0) -#if 0 // defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) #define IFCALLRESULT(_default_return, _cb, ...) \ - ({ \ - (_cb != NULL) ? _cb(__VA_ARGS__) : ({ \ + __extension__({ \ + if (_cb == NULL) \ + { \ WLog_VRB("com.freerdp.api", "IFCALLRESULT(" #_cb ") == NULL"); \ - (_default_return); \ - }); \ + } \ + ((_cb != NULL) ? _cb(__VA_ARGS__) : (_default_return)); \ }) #else #define IFCALLRESULT(_default_return, _cb, ...) \ diff --git a/include/freerdp/codec/color.h b/include/freerdp/codec/color.h index 78f2d43d0..3b8708179 100644 --- a/include/freerdp/codec/color.h +++ b/include/freerdp/codec/color.h @@ -432,7 +432,7 @@ typedef struct gdi_palette gdiPalette; UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc, UINT32 nSrcWidth, UINT32 nSrcHeight); - /*** + /** @brief fill an area with the color provided. * * @param pDstData destination buffer * @param DstFormat destination buffer format @@ -450,6 +450,31 @@ typedef struct gdi_palette gdiPalette; UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 color); +#define FREERDP_IMAGE_FILL_IGNORE_ALPHA 1 /** @since version 3.13.0 */ + + /** @brief fill an area with the color provided. If flag \b FREERDP_IMAGE_FILL_IGNORE_ALPHA is + * set the destination alpha value will be kept. + * + * @param pDstData destination buffer + * @param DstFormat destination buffer format + * @param nDstStep destination buffer stride (line in bytes) 0 for default + * @param nXDst destination buffer offset x + * @param nYDst destination buffer offset y + * @param nWidth width to copy in pixels + * @param nHeight height to copy in pixels + * @param color Pixel color in DstFormat (internal representation format, + * use FreeRDPGetColor to create) + * @param flags \b FREERDP_IMAGE_FILL_* flags + * + * @return TRUE if success, FALSE otherwise + * + * @since version 3.13.0 + */ + FREERDP_API BOOL freerdp_image_fill_ex(BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat, + UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, + UINT32 nWidth, UINT32 nHeight, UINT32 color, + UINT32 flags); + #ifdef __cplusplus } #endif diff --git a/libfreerdp/codec/color.c b/libfreerdp/codec/color.c index 609d20df4..99f9d9602 100644 --- a/libfreerdp/codec/color.c +++ b/libfreerdp/codec/color.c @@ -322,7 +322,6 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* WINPR_RESTRICT pDstData, UINT32 Ds static INLINE UINT32 freerdp_image_inverted_pointer_color(UINT32 x, UINT32 y, UINT32 format) { -#if 1 /** * Inverted pointer colors (where individual pixels can change their * color to accommodate the background behind them) only seem to be @@ -333,9 +332,6 @@ static INLINE UINT32 freerdp_image_inverted_pointer_color(UINT32 x, UINT32 y, UI * pixel's position. */ BYTE fill = (x + y) & 1 ? 0x00 : 0xFF; -#else - BYTE fill = 0x00; -#endif return FreeRDPGetColor(format, fill, fill, fill, 0xFF); } @@ -1131,6 +1127,37 @@ BOOL freerdp_image_fill(BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat, UINT32 n return TRUE; } +BOOL freerdp_image_fill_ex(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32 nXDst, + UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 color, UINT32 flags) +{ + if (FreeRDPColorHasAlpha(DstFormat) && ((flags & FREERDP_IMAGE_FILL_IGNORE_ALPHA) != 0)) + { + const UINT32 bpp = FreeRDPGetBytesPerPixel(DstFormat); + BYTE r = 0; + BYTE g = 0; + BYTE b = 0; + FreeRDPSplitColor(color, DstFormat, &r, &g, &b, NULL, NULL); + + for (size_t y = 0; y < nHeight; y++) + { + BYTE* WINPR_RESTRICT line = &pDstData[(y + nYDst) * nDstStep]; + + for (size_t x = 0; x < nWidth; x++) + { + BYTE* WINPR_RESTRICT dst = &line[x * bpp]; + const UINT32 dcolor = FreeRDPReadColor_int(dst, DstFormat); + BYTE a = 0; + FreeRDPSplitColor(dcolor, DstFormat, NULL, NULL, NULL, &a, NULL); + const UINT32 scolor = FreeRDPGetColor(DstFormat, r, g, b, a); + if (!FreeRDPWriteColor_int(dst, DstFormat, scolor)) + return FALSE; + } + } + return TRUE; + } + return freerdp_image_fill(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth, nHeight, color); +} + #if defined(WITH_SWSCALE) static int av_format_for_buffer(UINT32 format) { diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c index 60ea30de9..fb901a4ed 100644 --- a/libfreerdp/codec/h264_ffmpeg.c +++ b/libfreerdp/codec/h264_ffmpeg.c @@ -346,14 +346,6 @@ static int libavcodec_decompress(H264_CONTEXT* WINPR_RESTRICT h264, goto fail; } -#endif -#if 0 - WLog_Print(h264->log, WLOG_INFO, - "libavcodec_decompress: frame decoded (status=%d, gotFrame=%d, width=%d, height=%d, Y=[%p,%d], U=[%p,%d], V=[%p,%d])", - status, gotFrame, sys->videoFrame->width, sys->videoFrame->height, - (void*) sys->videoFrame->data[0], sys->videoFrame->linesize[0], - (void*) sys->videoFrame->data[1], sys->videoFrame->linesize[1], - (void*) sys->videoFrame->data[2], sys->videoFrame->linesize[2]); #endif if (gotFrame) diff --git a/libfreerdp/codec/h264_openh264.c b/libfreerdp/codec/h264_openh264.c index bae3d48c6..59000bb97 100644 --- a/libfreerdp/codec/h264_openh264.c +++ b/libfreerdp/codec/h264_openh264.c @@ -169,14 +169,6 @@ static int openh264_decompress(H264_CONTEXT* WINPR_RESTRICT h264, return -2003; } -#if 0 - WLog_Print(h264->log, WLOG_INFO, - "h264_decompress: state=%u, pYUVData=[%p,%p,%p], bufferStatus=%d, width=%d, height=%d, format=%d, stride=[%d,%d]", - state, (void*) pYUVData[0], (void*) pYUVData[1], (void*) pYUVData[2], sBufferInfo.iBufferStatus, - pSystemBuffer->iWidth, pSystemBuffer->iHeight, pSystemBuffer->iFormat, - pSystemBuffer->iStride[0], pSystemBuffer->iStride[1]); -#endif - if (pSystemBuffer->iFormat != videoFormatI420) return -2004; diff --git a/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c b/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c index 61226486e..74359bc98 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c @@ -874,14 +874,6 @@ int TestFreeRDPCodecRemoteFX(int argc, char* argv[]) goto fail; region16_print(®ion); -#if 0 - FILE *f = fopen("/tmp/windows.data", "w"); - if (f) { - fwrite(dest, IMG_WIDTH * IMG_HEIGHT, FORMAT_SIZE, f); - fclose(f); - } -#endif - if (!fuzzyCompareImage(srefImage, dest, IMG_WIDTH * IMG_HEIGHT)) goto fail; diff --git a/libfreerdp/core/license.c b/libfreerdp/core/license.c index 99d32861f..e5be3fdac 100644 --- a/libfreerdp/core/license.c +++ b/libfreerdp/core/license.c @@ -45,10 +45,8 @@ #define TAG FREERDP_TAG("core.license") -#if 0 -#define LICENSE_NULL_CLIENT_RANDOM 1 -#define LICENSE_NULL_PREMASTER_SECRET 1 -#endif +// #define LICENSE_NULL_CLIENT_RANDOM 1 +// #define LICENSE_NULL_PREMASTER_SECRET 1 // #define WITH_LICENSE_DECRYPT_CHALLENGE_RESPONSE diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 3ad09ae69..7388f43a9 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -917,26 +917,7 @@ static INLINE BOOL update_read_delta(wStream* s, INT32* value) return TRUE; } -#if 0 -static INLINE void update_read_glyph_delta(wStream* s, UINT16* value) -{ - BYTE byte; - Stream_Read_UINT8(s, byte); - if (byte == 0x80) - Stream_Read_UINT16(s, *value); - else - *value = (byte & 0x3F); -} -static INLINE void update_seek_glyph_delta(wStream* s) -{ - BYTE byte; - Stream_Read_UINT8(s, byte); - - if (byte & 0x80) - Stream_Seek_UINT8(s); -} -#endif static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlags) { if (fieldFlags & ORDER_FIELD_01) diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index c07db50f3..fef85cd80 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -1285,15 +1285,11 @@ static UINT gdi_SolidFill(RdpgfxClientContext* context, const RDPGFX_SOLID_FILL_ const BYTE g = solidFill->fillPixel.G; const BYTE r = solidFill->fillPixel.R; -#if 0 /* [MS-RDPEGFX] 3.3.5.4 Processing an RDPGFX_SOLIDFILL_PDU message * https://learn.microsoft.com/en-us/windows/win32/gdi/binary-raster-operations * * this sounds like the alpha value is always ignored. */ - if (FreeRDPColorHasAlpha(surface->format)) - a = solidFill->fillPixel.XA; -#endif const UINT32 color = FreeRDPGetColor(surface->format, r, g, b, a); @@ -1307,8 +1303,9 @@ static UINT gdi_SolidFill(RdpgfxClientContext* context, const RDPGFX_SOLID_FILL_ const UINT32 nWidth = invalidRect.right - invalidRect.left; const UINT32 nHeight = invalidRect.bottom - invalidRect.top; - if (!freerdp_image_fill(surface->data, surface->format, surface->scanline, invalidRect.left, - invalidRect.top, nWidth, nHeight, color)) + if (!freerdp_image_fill_ex(surface->data, surface->format, surface->scanline, + invalidRect.left, invalidRect.top, nWidth, nHeight, color, + FREERDP_IMAGE_FILL_IGNORE_ALPHA)) goto fail; region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect); diff --git a/libfreerdp/utils/pcap.c b/libfreerdp/utils/pcap.c index c18ae96f5..8c93601ab 100644 --- a/libfreerdp/utils/pcap.c +++ b/libfreerdp/utils/pcap.c @@ -192,11 +192,9 @@ BOOL pcap_get_next_record(rdpPcap* pcap, pcap_record* record) rdpPcap* pcap_open(const char* name, BOOL write) { - rdpPcap* pcap = NULL; - WINPR_ASSERT(name); - pcap = (rdpPcap*)calloc(1, sizeof(rdpPcap)); + rdpPcap* pcap = (rdpPcap*)calloc(1, sizeof(rdpPcap)); if (!pcap) goto fail; @@ -242,7 +240,7 @@ void pcap_flush(rdpPcap* pcap) while (pcap->record != NULL) { - pcap_write_record(pcap, pcap->record); + (void)pcap_write_record(pcap, pcap->record); pcap->record = pcap->record->next; } diff --git a/scripts/test-scard.cpp b/scripts/test-scard.cpp index d22fca900..3577c7d47 100644 --- a/scripts/test-scard.cpp +++ b/scripts/test-scard.cpp @@ -205,13 +205,6 @@ static std::wstring err2wstr(LONG code) return converter.from_bytes(str); } -#if 0 -static bool test_listreadergroups(SCARDCONTEXT hContext) { - auto rc = SCardListReaderGroupsA(hContext, &groups, &foobar); - rc = SCardListReaderGroupsW(hContext, &groups, &foobar); -} -#endif - static bool test_valid(SCARDCONTEXT context) { auto rc = SCardIsValidContext(context); diff --git a/winpr/libwinpr/crypto/cipher.c b/winpr/libwinpr/crypto/cipher.c index c2224acb1..b9f64e065 100644 --- a/winpr/libwinpr/crypto/cipher.c +++ b/winpr/libwinpr/crypto/cipher.c @@ -607,27 +607,6 @@ WINPR_API WINPR_CIPHER_CTX* winpr_Cipher_NewEx(WINPR_CIPHER_TYPE cipher, WINPR_C if (!ctx->ectx) goto fail; -#if 0 - if (keylen != 0) - { - WINPR_ASSERT(keylen <= INT32_MAX); - const int len = EVP_CIPHER_CTX_key_length(ctx->ectx); - if ((len > 0) && (len != keylen)) - { - if (EVP_CIPHER_CTX_set_key_length(ctx->ectx, (int)keylen) != 1) - goto fail; - } - } - - if (ivlen != 0) - { - WINPR_ASSERT(ivlen <= INT32_MAX); - const int len = EVP_CIPHER_CTX_iv_length(ctx->ectx); - if ((len > 0) && (ivlen != len)) - goto fail; - } -#endif - const int operation = (op == WINPR_ENCRYPT) ? 1 : 0; if (EVP_CipherInit_ex(ctx->ectx, evp, NULL, key, iv, operation) != 1) diff --git a/winpr/libwinpr/file/namedPipeClient.c b/winpr/libwinpr/file/namedPipeClient.c index 76557c4b6..32dda3f29 100644 --- a/winpr/libwinpr/file/namedPipeClient.c +++ b/winpr/libwinpr/file/namedPipeClient.c @@ -190,13 +190,8 @@ NamedPipeClientCreateFileA(LPCSTR lpFileName, WINPR_ATTR_UNUSED DWORD dwDesiredA if (dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED) { -#if 0 - int flags = fcntl(pNamedPipe->clientfd, F_GETFL); - - if (flags != -1) - (void)fcntl(pNamedPipe->clientfd, F_SETFL, flags | O_NONBLOCK); - -#endif + // TODO: Implement + WLog_ERR(TAG, "TODO: implement this"); } return hNamedPipe; diff --git a/winpr/libwinpr/nt/ntstatus.c b/winpr/libwinpr/nt/ntstatus.c index 9abc42de6..cb593da2e 100644 --- a/winpr/libwinpr/nt/ntstatus.c +++ b/winpr/libwinpr/nt/ntstatus.c @@ -23,6 +23,8 @@ #include #include +#define HAVE_SORTED_STRUCT 1 + struct ntstatus_map { DWORD code; @@ -4616,7 +4618,7 @@ static int ntstatus_compare(const void* pKey, const void* pValue) const char* NtStatus2Tag(NTSTATUS ntstatus) { -#if 1 /* Requires sorted struct */ +#if defined(HAVE_SORTED_STRUCT) /* Requires sorted struct */ size_t count = ARRAYSIZE(ntstatusmap); size_t base = sizeof(ntstatusmap[0]); const struct ntstatus_map* found = @@ -4638,7 +4640,7 @@ const char* NtStatus2Tag(NTSTATUS ntstatus) const char* Win32ErrorCode2Tag(UINT16 code) { -#if 1 /* Requires sorted struct */ +#if defined(HAVE_SORTED_STRUCT) /* Requires sorted struct */ DWORD ntstatus = code; size_t count = ARRAYSIZE(win32errmap); size_t base = sizeof(win32errmap[0]); diff --git a/winpr/libwinpr/pipe/pipe.c b/winpr/libwinpr/pipe/pipe.c index 731feda19..cdf5d467c 100644 --- a/winpr/libwinpr/pipe/pipe.c +++ b/winpr/libwinpr/pipe/pipe.c @@ -706,13 +706,8 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD if (dwOpenMode & FILE_FLAG_OVERLAPPED) { -#if 0 - int flags = fcntl(pNamedPipe->serverfd, F_GETFL); - - if (flags != -1) - fcntl(pNamedPipe->serverfd, F_SETFL, flags | O_NONBLOCK); - -#endif + // TODO: Implement + WLog_ERR(TAG, "TODO: implement this"); } // NOLINTNEXTLINE(clang-analyzer-unix.Malloc): ArrayList_Append takes ownership of baseSocket diff --git a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c index 1fc2fdd0c..90954a86f 100644 --- a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c +++ b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c @@ -195,11 +195,6 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg) /* 3: connect named pipe */ -#if 0 - /* This sleep will most certainly cause ERROR_PIPE_CONNECTED below */ - Sleep(2000); -#endif - fConnected = ConnectNamedPipe(hNamedPipe, &overlapped); status = GetLastError(); diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c index 5a64644e1..7f896018e 100644 --- a/winpr/libwinpr/synch/event.c +++ b/winpr/libwinpr/synch/event.c @@ -56,17 +56,7 @@ static void dump_event(WINPR_EVENT* event, size_t index) { char** msg = NULL; size_t used = 0; -#if 0 - void* stack = winpr_backtrace(20); - WLog_DBG(TAG, "Called from:"); - msg = winpr_backtrace_symbols(stack, &used); - for (size_t i = 0; i < used; i++) - WLog_DBG(TAG, "[%" PRIdz "]: %s", i, msg[i]); - - free(msg); - winpr_backtrace_free(stack); -#endif WLog_DBG(TAG, "Event handle created still not closed! [%" PRIuz ", %p]", index, event); msg = winpr_backtrace_symbols(event->create_stack, &used); diff --git a/winpr/libwinpr/utils/wlog/PacketMessage.c b/winpr/libwinpr/utils/wlog/PacketMessage.c index ffa9479d8..c91f3f061 100644 --- a/winpr/libwinpr/utils/wlog/PacketMessage.c +++ b/winpr/libwinpr/utils/wlog/PacketMessage.c @@ -41,106 +41,6 @@ static BOOL Pcap_Read_Header(wPcap* pcap, wPcapHeader* header) return FALSE; } -/* currently unused code */ -#if 0 -static BOOL Pcap_Read_RecordHeader(wPcap* pcap, wPcapRecordHeader* record) -{ - if (pcap && pcap->fp && (fread((void*) record, sizeof(wPcapRecordHeader), 1, pcap->fp) == 1)) - return TRUE; - return FALSE; -} - -static BOOL Pcap_Read_Record(wPcap* pcap, wPcapRecord* record) -{ - if (pcap && pcap->fp) - { - if (!Pcap_Read_RecordHeader(pcap, &record->header)) - return FALSE; - record->length = record->header.incl_len; - record->data = malloc(record->length); - if (!record->data) - return FALSE; - if (fread(record->data, record->length, 1, pcap->fp) != 1) - { - free(record->data); - record->length = 0; - record->data = NULL; - return FALSE; - } - } - return TRUE; -} - -static BOOL Pcap_Add_Record(wPcap* pcap, void* data, UINT32 length) -{ - wPcapRecord* record = NULL; - - if (!pcap->tail) - { - pcap->tail = (wPcapRecord*) calloc(1, sizeof(wPcapRecord)); - if (!pcap->tail) - return FALSE; - pcap->head = pcap->tail; - pcap->record = pcap->head; - record = pcap->tail; - } - else - { - record = (wPcapRecord*) calloc(1, sizeof(wPcapRecord)); - if (!record) - return FALSE; - pcap->tail->next = record; - pcap->tail = record; - } - - if (!pcap->record) - pcap->record = record; - - record->data = data; - record->length = length; - record->header.incl_len = length; - record->header.orig_len = length; - - UINT64 ns = winpr_GetUnixTimeNS(); - record->header.ts_sec = WINPR_TIME_NS_TO_S(ns); - record->header.ts_usec = WINPR_TIME_NS_REM_US(ns); - return TRUE; -} - -static BOOL Pcap_HasNext_Record(wPcap* pcap) -{ - if (pcap->file_size - (_ftelli64(pcap->fp)) <= 16) - return FALSE; - - return TRUE; -} - -static BOOL Pcap_GetNext_RecordHeader(wPcap* pcap, wPcapRecord* record) -{ - if (!Pcap_HasNext_Record(pcap) || !Pcap_Read_RecordHeader(pcap, &record->header)) - return FALSE; - - record->length = record->header.incl_len; - return TRUE; -} - -static BOOL Pcap_GetNext_RecordContent(wPcap* pcap, wPcapRecord* record) -{ - if (pcap && pcap->fp && fread(record->data, record->length, 1, pcap->fp) == 1) - return TRUE; - - return FALSE; -} - -static BOOL Pcap_GetNext_Record(wPcap* pcap, wPcapRecord* record) -{ - if (!Pcap_HasNext_Record(pcap)) - return FALSE; - - return Pcap_Read_Record(pcap, record); -} -#endif - static BOOL Pcap_Write_Header(wPcap* pcap, wPcapHeader* header) { if (pcap && pcap->fp && fwrite((void*)header, sizeof(wPcapHeader), 1, pcap->fp) == 1) diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c index 4e0702f97..e48c0a394 100644 --- a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c +++ b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c @@ -35,15 +35,19 @@ int TestWtsApiEnumerateProcesses(int argc, char* argv[]) return -1; } -#if 0 + int rc = 0; { printf("WTSEnumerateProcesses enumerated %"PRIu32" process:\n", count); for (DWORD i = 0; i < count; i++) - printf("\t[%"PRIu32"]: %s (%"PRIu32")\n", i, pProcessInfo[i].pProcessName, pProcessInfo[i].ProcessId); + { + const WTS_PROCESS_INFOA* cur = &pProcessInfo[i]; + if (!cur->pProcessName) + rc = -1; + printf("\t[%" PRIu32 "]: %s (%" PRIu32 ")\n", i, cur->pProcessName, cur->ProcessId); + } } -#endif WTSFreeMemory(pProcessInfo); - return 0; + return rc; }