diff --git a/.clang-tidy b/.clang-tidy index bf8edbeba..743b256ca 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -28,6 +28,7 @@ Checks: > -cert-dcl16-c, -cert-env33-c, -cert-dcl50-cpp, + -clang-analyzer-webkit.NoUncountedMemberChecker, -clang-analyzer-optin.performance.Padding, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -clang-analyzer-valist.Uninitialized, diff --git a/client/Mac/main.m b/client/Mac/main.m index 6b1035f87..b4663f1f8 100644 --- a/client/Mac/main.m +++ b/client/Mac/main.m @@ -21,5 +21,5 @@ int main(int argc, char *argv[]) { - return NSApplicationMain(argc, argv); + return NSApplicationMain(argc, (const char *const *)argv); } diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index e97f4a015..c8fab2a8d 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -718,7 +718,7 @@ static DWORD wf_is_x509_certificate_trusted(const char* common_name, const char* CERT_CHAIN_POLICY_STATUS PolicyStatus = { 0 }; CERT_CHAIN_ENGINE_CONFIG EngineConfig = { 0 }; - DWORD derPubKeyLen = strlen(fingerprint); + DWORD derPubKeyLen = WINPR_ASSERTING_INT_CAST(uint32_t, strlen(fingerprint)); char* derPubKey = calloc(derPubKeyLen, sizeof(char)); if (NULL == derPubKey) { diff --git a/client/common/test/TestClientCmdLine.c b/client/common/test/TestClientCmdLine.c index 0c9c72c80..f1bca2acf 100644 --- a/client/common/test/TestClientCmdLine.c +++ b/client/common/test/TestClientCmdLine.c @@ -232,13 +232,14 @@ int TestClientCmdLine(int argc, char* argv[]) WINPR_UNUSED(argc); WINPR_UNUSED(argv); - for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) + for (size_t i = 0; i < ARRAYSIZE(tests); i++) { const test* current = &tests[i]; int failure = 0; char** command_line = string_list_copy(current->command_line); - if (!testcase(__func__, command_line, string_list_length((const char* const*)command_line), + const int len = string_list_length((const char* const*)command_line); + if (!testcase(__func__, command_line, WINPR_ASSERTING_INT_CAST(size_t, len), current->expected_status, current->validate_settings)) { TEST_FAILURE("parsing arguments.\n"); diff --git a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c index ac889bb08..e4a5bf9fc 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c @@ -1386,7 +1386,7 @@ static int test_dump(int argc, char* argv[]) const RECTANGLE_16* rects = region16_rects(&invalid, &nbRects); for (size_t x = 0; x < nbRects; x++) { - RECTANGLE_16* rect = &rects[x]; + const RECTANGLE_16* rect = &rects[x]; const UINT32 w = rect->right - rect->left; const UINT32 h = rect->bottom - rect->top; if (!freerdp_image_copy_no_overlap(output, DstFormat, stride, rect->left, diff --git a/libfreerdp/codec/test/cursor/cursor_dump_00000000.c b/libfreerdp/codec/test/cursor/cursor_dump_00000000.c index 475fceaa1..b9acebfa8 100644 --- a/libfreerdp/codec/test/cursor/cursor_dump_00000000.c +++ b/libfreerdp/codec/test/cursor/cursor_dump_00000000.c @@ -5,11 +5,11 @@ #include "cursor_dump_00000000.h" -static const uint8_t andmask[] = { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x80, 0xe3, 0x80, 0xe3, - 0x80, 0xe3, 0x80, 0xe3, 0x80, 0xe3, 0x80, 0xe3, 0x80, 0xe3, 0x80, - 0xe3, 0x80, 0xc1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00 }; +static uint8_t andmask[] = { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x80, 0xe3, 0x80, 0xe3, + 0x80, 0xe3, 0x80, 0xe3, 0x80, 0xe3, 0x80, 0xe3, 0x80, 0xe3, 0x80, + 0xe3, 0x80, 0xc1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00 }; -static const uint8_t xormask[] = { +static uint8_t xormask[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/libfreerdp/codec/test/cursor/cursor_dump_00000001.c b/libfreerdp/codec/test/cursor/cursor_dump_00000001.c index baffd6a9d..7d8778de2 100644 --- a/libfreerdp/codec/test/cursor/cursor_dump_00000001.c +++ b/libfreerdp/codec/test/cursor/cursor_dump_00000001.c @@ -5,7 +5,7 @@ #include "cursor_dump_00000001.h" -static const uint8_t andmask[] = { +static uint8_t andmask[] = { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, 0xff, 0xc0, 0xff, 0x00, 0xff, 0xc0, 0xff, 0x00, 0xff, 0xc0, 0xff, 0x00, 0xff, 0xc0, 0xff, 0x00, 0xff, 0xc0, 0xff, 0x00, 0xff, 0xc0, 0xff, 0x00, 0xff, 0xc0, 0xff, 0x00, 0xfc, 0x00, 0x07, 0x00, 0xf8, 0x00, 0x07, 0x00, @@ -14,7 +14,7 @@ static const uint8_t andmask[] = { 0xf0, 0x00, 0x07, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00 }; -static const uint8_t xormask[] = { +static uint8_t xormask[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/libfreerdp/codec/test/cursor/cursor_dump_00000002.c b/libfreerdp/codec/test/cursor/cursor_dump_00000002.c index 069e7bcf4..14dfa02b6 100644 --- a/libfreerdp/codec/test/cursor/cursor_dump_00000002.c +++ b/libfreerdp/codec/test/cursor/cursor_dump_00000002.c @@ -5,7 +5,7 @@ #include "cursor_dump_00000002.h" -static const uint8_t andmask[] = { +static uint8_t andmask[] = { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0x8f, 0xff, 0x00, 0xef, 0x87, 0xff, 0x00, 0xe3, 0x07, 0xff, 0x00, 0xe0, 0x07, 0xff, 0x00, 0xe0, 0x0f, 0xff, 0x00, 0xe0, 0x0f, 0xff, 0x00, 0xe0, 0x01, 0xff, 0x00, 0xe0, 0x00, 0xff, 0x00, 0xe0, 0x01, 0xff, 0x00, 0xe0, 0x03, 0xff, 0x00, @@ -14,7 +14,7 @@ static const uint8_t andmask[] = { 0xe7, 0xff, 0xff, 0x00, 0xef, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00 }; -static const uint8_t xormask[] = { +static uint8_t xormask[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/libfreerdp/codec/test/cursor/cursor_dump_00000003.c b/libfreerdp/codec/test/cursor/cursor_dump_00000003.c index 476c8e1d1..6b979a70c 100644 --- a/libfreerdp/codec/test/cursor/cursor_dump_00000003.c +++ b/libfreerdp/codec/test/cursor/cursor_dump_00000003.c @@ -5,7 +5,7 @@ #include "cursor_dump_00000003.h" -static const uint8_t andmask[] = { +static uint8_t andmask[] = { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xc7, 0xff, 0x00, 0xff, 0x83, 0xff, 0x00, 0xff, 0x01, 0xff, 0x00, 0xfe, 0x00, 0xff, 0x00, 0xfc, 0x00, 0x7f, 0x00, 0xf8, 0x00, 0x3f, 0x00, 0xf0, 0xc2, 0x1f, 0x00, 0xe0, 0x82, 0x0f, 0x00, 0xc0, 0x00, 0x07, 0x00, @@ -14,7 +14,7 @@ static const uint8_t andmask[] = { 0xff, 0x03, 0xff, 0x00, 0xff, 0x87, 0xff, 0x00, 0xff, 0xcf, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00 }; -static const uint8_t xormask[] = { +static uint8_t xormask[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/libfreerdp/codec/test/cursor/cursor_dump_00000004.c b/libfreerdp/codec/test/cursor/cursor_dump_00000004.c index 99121c759..bde34b7e3 100644 --- a/libfreerdp/codec/test/cursor/cursor_dump_00000004.c +++ b/libfreerdp/codec/test/cursor/cursor_dump_00000004.c @@ -5,7 +5,7 @@ #include "cursor_dump_00000004.h" -static const uint8_t andmask[] = { +static uint8_t andmask[] = { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xc7, 0xff, 0x00, 0xff, 0x83, 0xff, 0x00, 0xff, 0x01, 0xff, 0x00, 0xfe, 0x00, 0xff, 0x00, 0xfc, 0x00, 0x7f, 0x00, 0xf8, 0x00, 0x3f, 0x00, 0xf0, 0xc2, 0x1f, 0x00, 0xe0, 0x82, 0x0f, 0x00, 0xc0, 0x00, 0x07, 0x00, @@ -14,7 +14,7 @@ static const uint8_t andmask[] = { 0xff, 0x03, 0xff, 0x00, 0xff, 0x87, 0xff, 0x00, 0xff, 0xcf, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00 }; -static const uint8_t xormask[] = { +static uint8_t xormask[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/libfreerdp/codec/test/cursor/cursor_dump_00000005.c b/libfreerdp/codec/test/cursor/cursor_dump_00000005.c index 68bcf20ef..27f041c27 100644 --- a/libfreerdp/codec/test/cursor/cursor_dump_00000005.c +++ b/libfreerdp/codec/test/cursor/cursor_dump_00000005.c @@ -5,7 +5,7 @@ #include "cursor_dump_00000005.h" -static const uint8_t andmask[] = { +static uint8_t andmask[] = { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0x8f, 0xff, 0x00, 0xef, 0x87, 0xff, 0x00, 0xe3, 0x07, 0xff, 0x00, 0xe0, 0x07, 0xff, 0x00, 0xe0, 0x0f, 0xff, 0x00, 0xe0, 0x0f, 0xff, 0x00, 0xe0, 0x01, 0xff, 0x00, 0xe0, 0x00, 0xff, 0x00, 0xe0, 0x01, 0xff, 0x00, 0xe0, 0x03, 0xff, 0x00, @@ -14,7 +14,7 @@ static const uint8_t andmask[] = { 0xe7, 0xff, 0xff, 0x00, 0xef, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00 }; -static const uint8_t xormask[] = { +static uint8_t xormask[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/libfreerdp/primitives/test/TestPrimitivesYUV.c b/libfreerdp/primitives/test/TestPrimitivesYUV.c index 24c56bd79..9d33fe1ed 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYUV.c +++ b/libfreerdp/primitives/test/TestPrimitivesYUV.c @@ -1036,9 +1036,11 @@ static BOOL compare_yuv444_to_rgb(prim_size_t roi, DWORD type) if (!allocate_yuv(yuv, roi) || !rgb1 || !rgb2) goto fail; - if (soft->YUV444ToRGB_8u_P3AC4R(yuv, yuvStep, rgb1, stride, format, &roi) != PRIMITIVES_SUCCESS) + const BYTE* cyuv[] = { yuv[0], yuv[1], yuv[2] }; + if (soft->YUV444ToRGB_8u_P3AC4R(cyuv, yuvStep, rgb1, stride, format, &roi) != + PRIMITIVES_SUCCESS) goto fail; - if (prims->YUV444ToRGB_8u_P3AC4R(yuv, yuvStep, rgb2, stride, format, &roi) != + if (prims->YUV444ToRGB_8u_P3AC4R(cyuv, yuvStep, rgb2, stride, format, &roi) != PRIMITIVES_SUCCESS) goto fail; @@ -1207,9 +1209,11 @@ static BOOL compare_yuv420_to_rgb(prim_size_t roi, DWORD type) if (!allocate_yuv(yuv, roi) || !rgb1 || !rgb2) goto fail; - if (soft->YUV420ToRGB_8u_P3AC4R(yuv, yuvStep, rgb1, stride, format, &roi) != PRIMITIVES_SUCCESS) + const BYTE* cyuv[3] = { yuv[0], yuv[1], yuv[2] }; + if (soft->YUV420ToRGB_8u_P3AC4R(cyuv, yuvStep, rgb1, stride, format, &roi) != + PRIMITIVES_SUCCESS) goto fail; - if (prims->YUV420ToRGB_8u_P3AC4R(yuv, yuvStep, rgb2, stride, format, &roi) != + if (prims->YUV420ToRGB_8u_P3AC4R(cyuv, yuvStep, rgb2, stride, format, &roi) != PRIMITIVES_SUCCESS) goto fail; diff --git a/winpr/include/winpr/strlst.h b/winpr/include/winpr/strlst.h index 4e49d8b72..346946da1 100644 --- a/winpr/include/winpr/strlst.h +++ b/winpr/include/winpr/strlst.h @@ -30,9 +30,9 @@ extern "C" #endif WINPR_API void string_list_free(char** string_list); - WINPR_API int string_list_length(const char** string_list); - WINPR_API char** string_list_copy(const char** string_list); - WINPR_API void string_list_print(FILE* out, const char** string_list); + WINPR_API int string_list_length(const char* const* string_list); + WINPR_API char** string_list_copy(const char* const* string_list); + WINPR_API void string_list_print(FILE* out, const char* const* string_list); #ifdef __cplusplus } diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c b/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c index ea730f913..8dd801c22 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c @@ -554,7 +554,7 @@ fail: BOOL ntlm_construct_authenticate_target_info(NTLM_CONTEXT* context) { ULONG AvPairsCount = 0; - ULONG AvPairsValueLength = 0; + size_t AvPairsValueLength = 0; NTLM_AV_PAIR* AvTimestamp = NULL; NTLM_AV_PAIR* AvNbDomainName = NULL; NTLM_AV_PAIR* AvNbComputerName = NULL; @@ -575,7 +575,6 @@ BOOL ntlm_construct_authenticate_target_info(NTLM_CONTEXT* context) WINPR_ASSERT(context); AvPairsCount = 1; - AvPairsValueLength = 0; ChallengeTargetInfo = (NTLM_AV_PAIR*)context->ChallengeTargetInfo.pvBuffer; cbChallengeTargetInfo = context->ChallengeTargetInfo.cbBuffer; AvNbDomainName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvNbDomainName, diff --git a/winpr/libwinpr/utils/strlst.c b/winpr/libwinpr/utils/strlst.c index 44a213538..d60d11075 100644 --- a/winpr/libwinpr/utils/strlst.c +++ b/winpr/libwinpr/utils/strlst.c @@ -35,7 +35,7 @@ void string_list_free(char** string_list) free((void*)string_list); } -int string_list_length(const char** string_list) +int string_list_length(const char* const* string_list) { int i = 0; for (; string_list[i]; i++) @@ -44,7 +44,7 @@ int string_list_length(const char** string_list) return i; } -char** string_list_copy(const char** string_list) +char** string_list_copy(const char* const* string_list) { int length = string_list_length(string_list); char** copy = (char**)calloc(WINPR_ASSERTING_INT_CAST(size_t, length) + 1, sizeof(char*)); @@ -63,7 +63,7 @@ char** string_list_copy(const char** string_list) return copy; } -void string_list_print(FILE* out, const char** string_list) +void string_list_print(FILE* out, const char* const* string_list) { for (int j = 0; string_list[j]; j++) { diff --git a/winpr/libwinpr/utils/windows/debug.c b/winpr/libwinpr/utils/windows/debug.c index 7790d0af2..79cccded4 100644 --- a/winpr/libwinpr/utils/windows/debug.c +++ b/winpr/libwinpr/utils/windows/debug.c @@ -147,7 +147,8 @@ char* winpr_win_strerror(DWORD dw, char* dmsg, size_t size) if (rc > 0) { #if defined(UNICODE) - WideCharToMultiByte(CP_ACP, 0, msg, (int)rc, dmsg, (int)MIN(size - 1, INT_MAX), NULL, NULL); + (void)WideCharToMultiByte(CP_ACP, 0, msg, (int)rc, dmsg, (int)MIN(size - 1, INT_MAX), NULL, + NULL); #else /* defined(UNICODE) */ memcpy(dmsg, msg, MIN(rc, size - 1)); #endif /* defined(UNICODE) */