From 319daa7a9fa8bcfdefb08d7770912775af22ad99 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Wed, 19 Apr 2017 13:30:27 +0100 Subject: [PATCH] hw/xwin: Fix -Wmaybe-uninitialized warning in winWindowProc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is possibly an actual bug in failing to check we successfully retrieved the monitor size before using it to set the X screen size. ../hw/xwin/winwndproc.c: In function ‘winWindowProc’: ../hw/xwin/winwndproc.c:283:55: warning: ‘dwHeight’ may be used uninitialized in this function [-Wmaybe-uninitialized] ../hw/xwin/winwndproc.c:240:32: note: ‘dwHeight’ was declared here ../hw/xwin/winwndproc.c:281:54: warning: ‘dwWidth’ may be used uninitialized in this function [-Wmaybe-uninitialized] ../hw/xwin/winwndproc.c:240:23: note: ‘dwWidth’ was declared here Signed-off-by: Jon Turney Reviewed-by: Yaakov Selkowitz --- hw/xwin/winwndproc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index 7236a9520..ad9f1b337 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -237,7 +237,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) fMultiWindow #endif )) { - DWORD dwWidth, dwHeight; + DWORD dwWidth = 0, dwHeight = 0; if (s_pScreenInfo->fMultipleMonitors) { /* resize to new virtual desktop size */ @@ -273,8 +273,9 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) */ /* Set screen size to match new size, if it is different to current */ - if ((s_pScreenInfo->dwWidth != dwWidth) || - (s_pScreenInfo->dwHeight != dwHeight)) { + if (((dwWidth != 0) && (dwHeight != 0)) && + ((s_pScreenInfo->dwWidth != dwWidth) || + (s_pScreenInfo->dwHeight != dwHeight))) { winDoRandRScreenSetSize(s_pScreen, dwWidth, dwHeight,