From 5353bff10443624084166689a90c47f66da2e405 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 16 Oct 2024 09:59:57 +0200 Subject: [PATCH] [assert] use WINPR_STATIC_ASSERT --- client/X11/xf_keyboard.c | 3 +++ libfreerdp/locale/keyboard.c | 3 +++ server/shadow/shadow_server.c | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index efd091c2f..6641257e2 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -23,7 +23,9 @@ #include #include #include +#include +#include #include #include #include @@ -191,6 +193,7 @@ void xf_keyboard_release_all_keypress(xfContext* xfc) { WINPR_ASSERT(xfc); + WINPR_STATIC_ASSERT(ARRAYSIZE(xfc->KeyboardState) <= UINT32_MAX); for (size_t keycode = 0; keycode < ARRAYSIZE(xfc->KeyboardState); keycode++) { if (xfc->KeyboardState[keycode]) diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index d8f00e0b1..9de4489eb 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -21,7 +21,9 @@ #include #include +#include +#include #include #include @@ -324,6 +326,7 @@ DWORD freerdp_keyboard_init(DWORD keyboardLayoutId) ZeroMemory(VIRTUAL_SCANCODE_TO_X11_KEYCODE, sizeof(VIRTUAL_SCANCODE_TO_X11_KEYCODE)); + WINPR_STATIC_ASSERT(ARRAYSIZE(VIRTUAL_SCANCODE_TO_X11_KEYCODE) <= UINT32_MAX); for (size_t keycode = 0; keycode < ARRAYSIZE(VIRTUAL_SCANCODE_TO_X11_KEYCODE); keycode++) { const DWORD x11 = X11_KEYCODE_TO_VIRTUAL_SCANCODE[keycode]; diff --git a/server/shadow/shadow_server.c b/server/shadow/shadow_server.c index a47d4a568..1045d3a99 100644 --- a/server/shadow/shadow_server.c +++ b/server/shadow/shadow_server.c @@ -21,7 +21,9 @@ #include #include +#include +#include #include #include #include @@ -797,6 +799,8 @@ static BOOL shadow_server_create_certificate(rdpShadowServer* server, const char { BOOL rc = FALSE; char* makecert_argv[6] = { "makecert", "-rdp", "-live", "-silent", "-y", "5" }; + + WINPR_STATIC_ASSERT(ARRAYSIZE(makecert_argv) <= INT_MAX); const size_t makecert_argc = ARRAYSIZE(makecert_argv); MAKECERT_CONTEXT* makecert = makecert_context_new(); @@ -804,7 +808,6 @@ static BOOL shadow_server_create_certificate(rdpShadowServer* server, const char if (!makecert) goto out_fail; - WINPR_ASSERT(makecert_argc <= INT_MAX); if (makecert_context_process(makecert, (int)makecert_argc, makecert_argv) < 0) goto out_fail;