From 299c962b2800e52504ade6799f890213bc7741e8 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 16 Jun 2021 17:38:33 +0200 Subject: [PATCH] Fixed warnings --- client/Wayland/wlf_channels.c | 2 +- server/proxy/freerdp_proxy.c | 2 +- server/shadow/X11/x11_shadow.c | 4 ++-- server/shadow/shadow_lobby.c | 11 ++++++--- server/shadow/shadow_screen.c | 42 ++++++++++++++++++++++++++-------- winpr/include/winpr/winpr.h | 2 +- 6 files changed, 46 insertions(+), 17 deletions(-) diff --git a/client/Wayland/wlf_channels.c b/client/Wayland/wlf_channels.c index 9c49584c4..453693222 100644 --- a/client/Wayland/wlf_channels.c +++ b/client/Wayland/wlf_channels.c @@ -28,7 +28,7 @@ #include "wlf_disp.h" #include "wlfreerdp.h" -BOOL encomsp_toggle_control(EncomspClientContext* encomsp, BOOL control) +static BOOL encomsp_toggle_control(EncomspClientContext* encomsp, BOOL control) { ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu; diff --git a/server/proxy/freerdp_proxy.c b/server/proxy/freerdp_proxy.c index 7d72639d3..4f641a58c 100644 --- a/server/proxy/freerdp_proxy.c +++ b/server/proxy/freerdp_proxy.c @@ -34,7 +34,7 @@ static proxyServer* server = NULL; -static void cleanup_handler(int signum) +static WINPR_NORETURN(void cleanup_handler(int signum)) { printf("\n"); WLog_INFO(TAG, "[%s]: caught signal %d, starting cleanup...", __FUNCTION__, signum); diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index 96ce7d497..b775345a0 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -262,7 +262,7 @@ static BOOL x11_shadow_input_mouse_event(rdpShadowSubsystem* subsystem, rdpShado { #ifdef WITH_XTEST x11ShadowSubsystem* x11 = (x11ShadowSubsystem*)subsystem; - int button = 0; + unsigned int button = 0; BOOL down = FALSE; rdpShadowServer* server; rdpShadowSurface* surface; @@ -737,7 +737,7 @@ static int x11_shadow_error_handler_for_capture(Display* display, XErrorEvent* e static int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem) { int rc = 0; - int count; + size_t count; int status; int x, y; int width, height; diff --git a/server/shadow/shadow_lobby.c b/server/shadow/shadow_lobby.c index 23283153e..2001bc4c2 100644 --- a/server/shadow/shadow_lobby.c +++ b/server/shadow/shadow_lobby.c @@ -62,10 +62,15 @@ BOOL shadow_client_init_lobby(rdpShadowServer* server) width = invalidRect.right - invalidRect.left; height = invalidRect.bottom - invalidRect.top; - rdtk_surface_fill(surface, invalidRect.left, invalidRect.top, width, height, 0x3BB9FF); + WINPR_ASSERT(width <= UINT16_MAX); + WINPR_ASSERT(width >= 0); + WINPR_ASSERT(height <= UINT16_MAX); + WINPR_ASSERT(height >= 0); + rdtk_surface_fill(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height, + 0x3BB9FF); - rdtk_label_draw(surface, invalidRect.left, invalidRect.top, width, height, NULL, "Welcome", 0, - 0); + rdtk_label_draw(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height, NULL, + "Welcome", 0, 0); // rdtk_button_draw(surface, 16, 64, 128, 32, NULL, "button"); // rdtk_text_field_draw(surface, 16, 128, 128, 32, NULL, "text field"); diff --git a/server/shadow/shadow_screen.c b/server/shadow/shadow_screen.c index 049437942..aa15ebd78 100644 --- a/server/shadow/shadow_screen.c +++ b/server/shadow/shadow_screen.c @@ -20,6 +20,8 @@ #include "config.h" #endif +#include + #include "shadow_surface.h" #include "shadow_screen.h" @@ -33,6 +35,9 @@ rdpShadowScreen* shadow_screen_new(rdpShadowServer* server) rdpShadowSubsystem* subsystem; MONITOR_DEF* primary; + WINPR_ASSERT(server); + WINPR_ASSERT(server->subsystem); + screen = (rdpShadowScreen*)calloc(1, sizeof(rdpShadowScreen)); if (!screen) @@ -53,17 +58,27 @@ rdpShadowScreen* shadow_screen_new(rdpShadowServer* server) width = primary->right - primary->left; height = primary->bottom - primary->top; - screen->width = width; - screen->height = height; + WINPR_ASSERT(x >= 0); + WINPR_ASSERT(x <= UINT16_MAX); + WINPR_ASSERT(y >= 0); + WINPR_ASSERT(y <= UINT16_MAX); + WINPR_ASSERT(width >= 0); + WINPR_ASSERT(width <= UINT16_MAX); + WINPR_ASSERT(height >= 0); + WINPR_ASSERT(height <= UINT16_MAX); - screen->primary = shadow_surface_new(server, x, y, width, height); + screen->width = (UINT16)width; + screen->height = (UINT16)height; + + screen->primary = + shadow_surface_new(server, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height); if (!screen->primary) goto out_free_region; server->surface = screen->primary; - screen->lobby = shadow_surface_new(server, x, y, width, height); + screen->lobby = shadow_surface_new(server, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height); if (!screen->lobby) goto out_free_primary; @@ -128,14 +143,23 @@ BOOL shadow_screen_resize(rdpShadowScreen* screen) width = primary->right - primary->left; height = primary->bottom - primary->top; - if (shadow_surface_resize(screen->primary, x, y, width, height) && - shadow_surface_resize(screen->lobby, x, y, width, height)) + WINPR_ASSERT(x >= 0); + WINPR_ASSERT(x <= UINT16_MAX); + WINPR_ASSERT(y >= 0); + WINPR_ASSERT(y <= UINT16_MAX); + WINPR_ASSERT(width >= 0); + WINPR_ASSERT(width <= UINT16_MAX); + WINPR_ASSERT(height >= 0); + WINPR_ASSERT(height <= UINT16_MAX); + if (shadow_surface_resize(screen->primary, (UINT16)x, (UINT16)y, (UINT16)width, + (UINT16)height) && + shadow_surface_resize(screen->lobby, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height)) { - if ((width != screen->width) || (height != screen->height)) + if (((UINT32)width != screen->width) || ((UINT32)height != screen->height)) { /* screen size is changed. Store new size and reinit lobby */ - screen->width = width; - screen->height = height; + screen->width = (UINT32)width; + screen->height = (UINT32)height; shadow_client_init_lobby(screen->server); } return TRUE; diff --git a/winpr/include/winpr/winpr.h b/winpr/include/winpr/winpr.h index 34db1af1d..42beb12cf 100644 --- a/winpr/include/winpr/winpr.h +++ b/winpr/include/winpr/winpr.h @@ -54,7 +54,7 @@ #elif defined(__GNUC__) #define WINPR_DEPRECATED(obj) obj __attribute__((deprecated)) #define WINPR_DEPRECATED_VAR(text, obj) obj __attribute__((deprecated(text))) -#define WINPR_NORETURN(obj) obj __attribute__((__noreturn__)) +#define WINPR_NORETURN(obj) __attribute__((__noreturn__)) obj #else #define WINPR_DEPRECATED(obj) obj #define WINPR_DEPRECATED_VAR(text, obj) obj