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 <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon TURNEY 2015-02-06 19:19:41 +00:00
parent aa83c61f51
commit 4f8661fac9
5 changed files with 36 additions and 34 deletions

View File

@ -357,10 +357,11 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen)
} }
winDebug("winCreateBoundingWindowWindowed - WindowClient " winDebug("winCreateBoundingWindowWindowed - WindowClient "
"w %ld h %ld r %ld l %ld b %ld t %ld\n", "w %d h %d r %d l %d b %d t %d\n",
rcClient.right - rcClient.left, (int)(rcClient.right - rcClient.left),
rcClient.bottom - rcClient.top, (int)(rcClient.bottom - rcClient.top),
rcClient.right, rcClient.left, 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 */ /* We adjust the visual size if the user did not specify it */
if (! if (!

View File

@ -220,7 +220,7 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
#if CYGMULTIWINDOW_DEBUG #if CYGMULTIWINDOW_DEBUG
lpRc = &rcNew; lpRc = &rcNew;
ErrorF("winPositionWindowMultiWindow - drawable (%d, %d)-(%d, %d)\n", 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 #endif
/* /*
@ -238,15 +238,15 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
lpRc = &rcNew; lpRc = &rcNew;
ErrorF("winPositionWindowMultiWindow - rcNew (%d, %d)-(%d, %d)\n", 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; lpRc = &rcOld;
ErrorF("winPositionWindowMultiWindow - rcOld (%d, %d)-(%d, %d)\n", 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; lpRc = &rcClient;
ErrorF("rcClient (%d, %d)-(%d, %d)\n", 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 #endif
/* Check if the old rectangle and new rectangle are the same */ /* Check if the old rectangle and new rectangle are the same */
@ -256,8 +256,8 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
#endif #endif
#if CYGWINDOWING_DEBUG #if CYGWINDOWING_DEBUG
ErrorF("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top, ErrorF("\tMoveWindow to (%d, %d) - %dx%d\n", (int)rcNew.left, (int)rcNew.top,
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top); (int)(rcNew.right - rcNew.left), (int)(rcNew.bottom - rcNew.top));
#endif #endif
/* Change the position and dimensions of the Windows window */ /* Change the position and dimensions of the Windows window */
MoveWindow(hWnd, MoveWindow(hWnd,
@ -948,8 +948,8 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
SetRect(&rcDraw, x, y, x + pDraw->width, y + pDraw->height); SetRect(&rcDraw, x, y, x + pDraw->width, y + pDraw->height);
#ifdef CYGMULTIWINDOW_DEBUG #ifdef CYGMULTIWINDOW_DEBUG
winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n", winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n",
rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom, (int)rcDraw.left, (int)rcDraw.top, (int)rcDraw.right, (int)rcDraw.bottom,
rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top); (int)(rcDraw.right - rcDraw.left), (int)(rcDraw.bottom - rcDraw.top));
#endif #endif
dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE); dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
@ -962,11 +962,11 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
GetWindowRect(hwnd, &rcWin); GetWindowRect(hwnd, &rcWin);
#ifdef CYGMULTIWINDOW_DEBUG #ifdef CYGMULTIWINDOW_DEBUG
winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n", winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
rcWin.left, rcWin.top, rcWin.right, rcWin.bottom, (int)rcWin.left, (int)rcWin.top, (int)rcWin.right, (int)rcWin.bottom,
rcWin.right - rcWin.left, rcWin.bottom - rcWin.top); (int)(rcWin.right - rcWin.left), (int)(rcWin.bottom - rcWin.top));
winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n", winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n",
rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom, (int)rcDraw.left, (int)rcDraw.top, (int)rcDraw.right, (int)rcDraw.bottom,
rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top); (int)(rcDraw.right - rcDraw.left), (int)(rcDraw.bottom - rcDraw.top));
#endif #endif
if (EqualRect(&rcDraw, &rcWin)) { if (EqualRect(&rcDraw, &rcWin)) {

View File

@ -770,20 +770,20 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
ErrorF("\nCYGWINDOWING Dump:\n" ErrorF("\nCYGWINDOWING Dump:\n"
"\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x, "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x,
pDraw->y, pDraw->width, pDraw->height); pDraw->y, pDraw->width, pDraw->height);
ErrorF("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left, ErrorF("\twindPlace: (%d, %d) - %dx%d\n", (int)pRect->left,
pRect->top, pRect->right - pRect->left, (int)pRect->top, (int)(pRect->right - pRect->left),
pRect->bottom - pRect->top); (int)(pRect->bottom - pRect->top));
if (GetClientRect(hwnd, &rc)) { if (GetClientRect(hwnd, &rc)) {
pRect = &rc; pRect = &rc;
ErrorF("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left, ErrorF("\tClientRect: (%d, %d) - %dx%d\n", (int)pRect->left,
pRect->top, pRect->right - pRect->left, (int)pRect->top, (int)(pRect->right - pRect->left),
pRect->bottom - pRect->top); (int)(pRect->bottom - pRect->top));
} }
if (GetWindowRect(hwnd, &rc)) { if (GetWindowRect(hwnd, &rc)) {
pRect = &rc; pRect = &rc;
ErrorF("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left, ErrorF("\tWindowRect: (%d, %d) - %dx%d\n", (int)pRect->left,
pRect->top, pRect->right - pRect->left, (int)pRect->top, (int)(pRect->right - pRect->left),
pRect->bottom - pRect->top); (int)(pRect->bottom - pRect->top));
} }
ErrorF("\n"); ErrorF("\n");
} }
@ -1081,9 +1081,9 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
winDebug winDebug
("winTopLevelWindowProc - WM_STYLECHANGING client area {%d, %d, %d, %d}, {%d x %d}\n", ("winTopLevelWindowProc - WM_STYLECHANGING client area {%d, %d, %d, %d}, {%d x %d}\n",
wi.rcClient.left, wi.rcClient.top, wi.rcClient.right, (int)wi.rcClient.left, (int)wi.rcClient.top, (int)wi.rcClient.right,
wi.rcClient.bottom, wi.rcClient.right - wi.rcClient.left, (int)wi.rcClient.bottom, (int)(wi.rcClient.right - wi.rcClient.left),
wi.rcClient.bottom - wi.rcClient.top); (int)(wi.rcClient.bottom - wi.rcClient.top));
newWinRect = wi.rcClient; newWinRect = wi.rcClient;
if (!AdjustWindowRectEx(&newWinRect, dwStyle, FALSE, dwExStyle)) if (!AdjustWindowRectEx(&newWinRect, dwStyle, FALSE, dwExStyle))
@ -1092,9 +1092,9 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
winDebug winDebug
("winTopLevelWindowProc - WM_STYLECHANGING window area should be {%d, %d, %d, %d}, {%d x %d}\n", ("winTopLevelWindowProc - WM_STYLECHANGING window area should be {%d, %d, %d, %d}, {%d x %d}\n",
newWinRect.left, newWinRect.top, newWinRect.right, (int)newWinRect.left, (int)newWinRect.top, (int)newWinRect.right,
newWinRect.bottom, newWinRect.right - newWinRect.left, (int)newWinRect.bottom, (int)(newWinRect.right - newWinRect.left),
newWinRect.bottom - newWinRect.top); (int)(newWinRect.bottom - newWinRect.top));
/* /*
Style change hasn't happened yet, so we can't adjust the window size yet, as the winAdjustXWindow() Style change hasn't happened yet, so we can't adjust the window size yet, as the winAdjustXWindow()

View File

@ -178,8 +178,9 @@ winRandRScreenSetSize(ScreenPtr pScreen,
*/ */
AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle); AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle);
ErrorF("winRandRScreenSetSize new window area w: %ld h: %ld\n", ErrorF("winRandRScreenSetSize new window area w: %d h: %d\n",
rcClient.right - rcClient.left, rcClient.bottom - rcClient.top); (int)(rcClient.right - rcClient.left),
(int)(rcClient.bottom - rcClient.top));
SetWindowPos(pScreenPriv->hwndScreen, NULL, SetWindowPos(pScreenPriv->hwndScreen, NULL,
0, 0, rcClient.right - rcClient.left, 0, 0, rcClient.right - rcClient.left,

View File

@ -199,7 +199,7 @@ winQueryRGBBitsAndMasks(ScreenPtr pScreen)
winDebug("%s - Masks: %08x %08x %08x\n", __FUNCTION__, winDebug("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
(unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]); (unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]);
winDebug("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__, 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); pbmih->biPlanes);
winDebug("%s - Compression: %u %s\n", __FUNCTION__, winDebug("%s - Compression: %u %s\n", __FUNCTION__,
(unsigned int)pbmih->biCompression, (unsigned int)pbmih->biCompression,