[PATCH xserver 2/4] hw/xwin: Fix -Wmaybe-uninitialized warning in winWindowProc
Jon Turney
jon.turney at dronecode.org.uk
Tue Apr 18 10:53:05 UTC 2017
This is possibly an actual bug in failing to check we successfuly 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 <jon.turney at dronecode.org.uk>
---
hw/xwin/winwndproc.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index 7236a95..53ef1f9 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 */
@@ -261,6 +261,9 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
ErrorF("Monitor number %d no longer exists!\n",
s_pScreenInfo->iMonitor);
}
+ ErrorF("QueryMonitor %d failed!\n",
+ s_pScreenInfo->iMonitor);
+
}
}
@@ -273,8 +276,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,
--
2.8.3
More information about the xorg-devel
mailing list