From 4f8661fac985306c56330cae69ffc19e5dd0af61 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Fri, 6 Feb 2015 19:19:41 +0000 Subject: [PATCH] hw/xwin: printf format fixes for LONG type Some Win32 API types are different fundamental types in the 32-bit and 64-bit versions. This problem is then further compounded by the fact that whilst both 32-bit Cygwin and 32-bit MinGW use the ILP32 data model, 64-bit MinGW uses the LLP64 data model, but 64-bit Cygwin uses the LP64 data model. This makes it impossible to write printf format specifiers which are correct for all those targets In the Win32 API, DWORD is an signed, 32-bit type. It is defined in terms of a long, except in the LP64 data model, where it is an int. It should always be safe to cast it to int and use %d. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/wincreatewnd.c | 9 +++++---- hw/xwin/winmultiwindowwindow.c | 24 ++++++++++++------------ hw/xwin/winmultiwindowwndproc.c | 30 +++++++++++++++--------------- hw/xwin/winrandr.c | 5 +++-- hw/xwin/winshadgdi.c | 2 +- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/hw/xwin/wincreatewnd.c b/hw/xwin/wincreatewnd.c index 6c5b21dfa..b2f797c51 100644 --- a/hw/xwin/wincreatewnd.c +++ b/hw/xwin/wincreatewnd.c @@ -357,10 +357,11 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen) } winDebug("winCreateBoundingWindowWindowed - WindowClient " - "w %ld h %ld r %ld l %ld b %ld t %ld\n", - rcClient.right - rcClient.left, - rcClient.bottom - rcClient.top, - rcClient.right, rcClient.left, rcClient.bottom, rcClient.top); + "w %d h %d r %d l %d b %d t %d\n", + (int)(rcClient.right - rcClient.left), + (int)(rcClient.bottom - rcClient.top), + (int)rcClient.right, (int)rcClient.left, + (int)rcClient.bottom, (int)rcClient.top); /* We adjust the visual size if the user did not specify it */ if (! diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 91bd956f6..f4de91242 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -220,7 +220,7 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y) #if CYGMULTIWINDOW_DEBUG lpRc = &rcNew; ErrorF("winPositionWindowMultiWindow - drawable (%d, %d)-(%d, %d)\n", - lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); + (int)lpRc->left, (int)lpRc->top, (int)lpRc->right, (int)lpRc->bottom); #endif /* @@ -238,15 +238,15 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y) lpRc = &rcNew; ErrorF("winPositionWindowMultiWindow - rcNew (%d, %d)-(%d, %d)\n", - lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); + (int)lpRc->left, (int)lpRc->top, (int)lpRc->right, (int)lpRc->bottom); lpRc = &rcOld; ErrorF("winPositionWindowMultiWindow - rcOld (%d, %d)-(%d, %d)\n", - lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); + (int)lpRc->left, (int)lpRc->top, (int)lpRc->right, (int)lpRc->bottom); lpRc = &rcClient; ErrorF("rcClient (%d, %d)-(%d, %d)\n", - lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); + (int)lpRc->left, (int)lpRc->top, (int)lpRc->right, (int)lpRc->bottom); #endif /* Check if the old rectangle and new rectangle are the same */ @@ -256,8 +256,8 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y) #endif #if CYGWINDOWING_DEBUG - ErrorF("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top); + ErrorF("\tMoveWindow to (%d, %d) - %dx%d\n", (int)rcNew.left, (int)rcNew.top, + (int)(rcNew.right - rcNew.left), (int)(rcNew.bottom - rcNew.top)); #endif /* Change the position and dimensions of the Windows window */ MoveWindow(hWnd, @@ -948,8 +948,8 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd) SetRect(&rcDraw, x, y, x + pDraw->width, y + pDraw->height); #ifdef CYGMULTIWINDOW_DEBUG winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n", - rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom, - rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top); + (int)rcDraw.left, (int)rcDraw.top, (int)rcDraw.right, (int)rcDraw.bottom, + (int)(rcDraw.right - rcDraw.left), (int)(rcDraw.bottom - rcDraw.top)); #endif dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE); dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); @@ -962,11 +962,11 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd) GetWindowRect(hwnd, &rcWin); #ifdef CYGMULTIWINDOW_DEBUG winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n", - rcWin.left, rcWin.top, rcWin.right, rcWin.bottom, - rcWin.right - rcWin.left, rcWin.bottom - rcWin.top); + (int)rcWin.left, (int)rcWin.top, (int)rcWin.right, (int)rcWin.bottom, + (int)(rcWin.right - rcWin.left), (int)(rcWin.bottom - rcWin.top)); winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n", - rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom, - rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top); + (int)rcDraw.left, (int)rcDraw.top, (int)rcDraw.right, (int)rcDraw.bottom, + (int)(rcDraw.right - rcDraw.left), (int)(rcDraw.bottom - rcDraw.top)); #endif if (EqualRect(&rcDraw, &rcWin)) { diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index eb7b55e4d..656f6c2da 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -770,20 +770,20 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ErrorF("\nCYGWINDOWING Dump:\n" "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x, pDraw->y, pDraw->width, pDraw->height); - ErrorF("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left, - pRect->top, pRect->right - pRect->left, - pRect->bottom - pRect->top); + ErrorF("\twindPlace: (%d, %d) - %dx%d\n", (int)pRect->left, + (int)pRect->top, (int)(pRect->right - pRect->left), + (int)(pRect->bottom - pRect->top)); if (GetClientRect(hwnd, &rc)) { pRect = &rc; - ErrorF("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left, - pRect->top, pRect->right - pRect->left, - pRect->bottom - pRect->top); + ErrorF("\tClientRect: (%d, %d) - %dx%d\n", (int)pRect->left, + (int)pRect->top, (int)(pRect->right - pRect->left), + (int)(pRect->bottom - pRect->top)); } if (GetWindowRect(hwnd, &rc)) { pRect = &rc; - ErrorF("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left, - pRect->top, pRect->right - pRect->left, - pRect->bottom - pRect->top); + ErrorF("\tWindowRect: (%d, %d) - %dx%d\n", (int)pRect->left, + (int)pRect->top, (int)(pRect->right - pRect->left), + (int)(pRect->bottom - pRect->top)); } ErrorF("\n"); } @@ -1081,9 +1081,9 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) winDebug ("winTopLevelWindowProc - WM_STYLECHANGING client area {%d, %d, %d, %d}, {%d x %d}\n", - wi.rcClient.left, wi.rcClient.top, wi.rcClient.right, - wi.rcClient.bottom, wi.rcClient.right - wi.rcClient.left, - wi.rcClient.bottom - wi.rcClient.top); + (int)wi.rcClient.left, (int)wi.rcClient.top, (int)wi.rcClient.right, + (int)wi.rcClient.bottom, (int)(wi.rcClient.right - wi.rcClient.left), + (int)(wi.rcClient.bottom - wi.rcClient.top)); newWinRect = wi.rcClient; if (!AdjustWindowRectEx(&newWinRect, dwStyle, FALSE, dwExStyle)) @@ -1092,9 +1092,9 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) winDebug ("winTopLevelWindowProc - WM_STYLECHANGING window area should be {%d, %d, %d, %d}, {%d x %d}\n", - newWinRect.left, newWinRect.top, newWinRect.right, - newWinRect.bottom, newWinRect.right - newWinRect.left, - newWinRect.bottom - newWinRect.top); + (int)newWinRect.left, (int)newWinRect.top, (int)newWinRect.right, + (int)newWinRect.bottom, (int)(newWinRect.right - newWinRect.left), + (int)(newWinRect.bottom - newWinRect.top)); /* Style change hasn't happened yet, so we can't adjust the window size yet, as the winAdjustXWindow() diff --git a/hw/xwin/winrandr.c b/hw/xwin/winrandr.c index 1b340850c..73925070d 100644 --- a/hw/xwin/winrandr.c +++ b/hw/xwin/winrandr.c @@ -178,8 +178,9 @@ winRandRScreenSetSize(ScreenPtr pScreen, */ AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle); - ErrorF("winRandRScreenSetSize new window area w: %ld h: %ld\n", - rcClient.right - rcClient.left, rcClient.bottom - rcClient.top); + ErrorF("winRandRScreenSetSize new window area w: %d h: %d\n", + (int)(rcClient.right - rcClient.left), + (int)(rcClient.bottom - rcClient.top)); SetWindowPos(pScreenPriv->hwndScreen, NULL, 0, 0, rcClient.right - rcClient.left, diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c index 7c31175f4..bf655174d 100644 --- a/hw/xwin/winshadgdi.c +++ b/hw/xwin/winshadgdi.c @@ -199,7 +199,7 @@ winQueryRGBBitsAndMasks(ScreenPtr pScreen) winDebug("%s - Masks: %08x %08x %08x\n", __FUNCTION__, (unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]); winDebug("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__, - pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount, + (int)pbmih->biWidth, (int)pbmih->biHeight, pbmih->biBitCount, pbmih->biPlanes); winDebug("%s - Compression: %u %s\n", __FUNCTION__, (unsigned int)pbmih->biCompression,