From df76b59da79e92d4e2fa7827b5d9794c995dee29 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 23 May 2023 09:10:36 +0200 Subject: [PATCH] [warnings] fix -Wshadow --- client/SDL/sdl_freerdp.cpp | 14 ++++++------ libfreerdp/crypto/privatekey.c | 4 ++-- winpr/include/winpr/assert.h | 38 +++++++++++++++++---------------- winpr/tools/makecert/makecert.c | 4 ++-- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/client/SDL/sdl_freerdp.cpp b/client/SDL/sdl_freerdp.cpp index 52193a09c..385ff6d56 100644 --- a/client/SDL/sdl_freerdp.cpp +++ b/client/SDL/sdl_freerdp.cpp @@ -797,8 +797,8 @@ static int sdl_run(sdlContext* sdl) break; case SDL_USEREVENT_CREATE_WINDOWS: { - auto sdl = static_cast(windowEvent.user.data1); - sdl_create_windows(sdl); + auto ctx = static_cast(windowEvent.user.data1); + sdl_create_windows(ctx); } break; case SDL_USEREVENT_WINDOW_RESIZEABLE: @@ -1038,12 +1038,12 @@ static DWORD WINAPI sdl_client_thread_proc(void* arg) */ if (freerdp_focus_required(instance)) { - sdlContext* sdl = reinterpret_cast(context); - WINPR_ASSERT(sdl); - WINPR_ASSERT(sdl->input); - if (!sdl->input->keyboard_focus_in()) + sdlContext* ctx = reinterpret_cast(context); + WINPR_ASSERT(ctx); + WINPR_ASSERT(ctx->input); + if (!ctx->input->keyboard_focus_in()) break; - if (!sdl->input->keyboard_focus_in()) + if (!ctx->input->keyboard_focus_in()) break; } diff --git a/libfreerdp/crypto/privatekey.c b/libfreerdp/crypto/privatekey.c index 77c99701d..24cb6c831 100644 --- a/libfreerdp/crypto/privatekey.c +++ b/libfreerdp/crypto/privatekey.c @@ -382,10 +382,10 @@ BOOL freerdp_key_generate(rdpPrivateKey* key, size_t key_length) } BN_set_word(bn, RSA_F4); - const int rc = RSA_generate_key_ex(rsa, key_length, bn, NULL); + const int res = RSA_generate_key_ex(rsa, key_length, bn, NULL); BN_clear_free(bn); - if (rc != 1) + if (res != 1) return FALSE; } #endif diff --git a/winpr/include/winpr/assert.h b/winpr/include/winpr/assert.h index 7e424236a..341f27b6c 100644 --- a/winpr/include/winpr/assert.h +++ b/winpr/include/winpr/assert.h @@ -28,31 +28,33 @@ #include #if defined(WITH_VERBOSE_WINPR_ASSERT) && (WITH_VERBOSE_WINPR_ASSERT != 0) -#define WINPR_ASSERT(cond) \ - do \ - { \ - if (!(cond)) \ - { \ - wLog* _log_cached_ptr = WLog_Get("com.freerdp.winpr.assert"); \ - const size_t line = __LINE__; \ - WLog_Print(_log_cached_ptr, WLOG_FATAL, "%s [%s:%s:%" PRIuz "]", #cond, __FILE__, \ - __FUNCTION__, line); \ - winpr_log_backtrace_ex(_log_cached_ptr, WLOG_FATAL, 20); \ - abort(); \ - } \ - } while (0) -#else -#include -#define WINPR_ASSERT(cond) assert(cond) -#endif - #ifdef __cplusplus extern "C" { #endif +#define WINPR_ASSERT(cond) \ + do \ + { \ + if (!(cond)) \ + winpr_int_assert(#cond, __FILE__, __FUNCTION__, __LINE__); \ + } while (0) + + static INLINE WINPR_NORETURN(void winpr_int_assert(const char* condstr, const char* file, + const char* fkt, size_t line)) + { + wLog* _log_cached_ptr = WLog_Get("com.freerdp.winpr.assert"); + WLog_Print(_log_cached_ptr, WLOG_FATAL, "%s [%s:%s:%" PRIuz "]", condstr, file, fkt, line); + winpr_log_backtrace_ex(_log_cached_ptr, WLOG_FATAL, 20); + abort(); + } #ifdef __cplusplus } #endif +#else +#include +#define WINPR_ASSERT(cond) assert(cond) +#endif + #endif /* WINPR_ERROR_H */ diff --git a/winpr/tools/makecert/makecert.c b/winpr/tools/makecert/makecert.c index 0a611417d..681709372 100644 --- a/winpr/tools/makecert/makecert.c +++ b/winpr/tools/makecert/makecert.c @@ -713,10 +713,10 @@ static BOOL makecert_create_rsa(EVP_PKEY** ppkey, size_t key_length) } BN_set_word(bn, RSA_F4); - const int rc = RSA_generate_key_ex(rsa, key_length, bn, NULL); + const int res = RSA_generate_key_ex(rsa, key_length, bn, NULL); BN_clear_free(bn); - if (rc != 1) + if (res != 1) return FALSE; } #endif