hw/xwin: printf format fixes for DWORD 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 unsigned, 32-bit type.  It is defined in terms of
an unsigned long, except in the LP64 data model, where it is an unsigned int.

It should always be safe to cast it to unsigned int and use %u or %x.

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:46:45 +00:00
parent 487f2595c9
commit aa83c61f51
10 changed files with 33 additions and 30 deletions

View File

@ -253,7 +253,7 @@ pfdOut(const PIXELFORMATDESCRIPTOR * pfd)
ErrorF("PIXELFORMATDESCRIPTOR:\n");
ErrorF("nSize = %u\n", pfd->nSize);
ErrorF("nVersion = %u\n", pfd->nVersion);
ErrorF("dwFlags = %lu = {", pfd->dwFlags);
ErrorF("dwFlags = %u = {", (unsigned int)pfd->dwFlags);
DUMP_PFD_FLAG(PFD_DOUBLEBUFFER);
DUMP_PFD_FLAG(PFD_STEREO);
DUMP_PFD_FLAG(PFD_DRAW_TO_WINDOW);
@ -297,9 +297,9 @@ pfdOut(const PIXELFORMATDESCRIPTOR * pfd)
ErrorF("cAuxBuffers = %hhu\n", pfd->cAuxBuffers);
ErrorF("iLayerType = %hhu\n", pfd->iLayerType);
ErrorF("bReserved = %hhu\n", pfd->bReserved);
ErrorF("dwLayerMask = %lu\n", pfd->dwLayerMask);
ErrorF("dwVisibleMask = %lu\n", pfd->dwVisibleMask);
ErrorF("dwDamageMask = %lu\n", pfd->dwDamageMask);
ErrorF("dwLayerMask = %u\n", (unsigned int)pfd->dwLayerMask);
ErrorF("dwVisibleMask = %u\n", (unsigned int)pfd->dwVisibleMask);
ErrorF("dwDamageMask = %u\n", (unsigned int)pfd->dwDamageMask);
ErrorF("\n");
}
@ -1862,8 +1862,8 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen * screen)
if (!(pfd.dwFlags & (PFD_DRAW_TO_WINDOW | PFD_DRAW_TO_BITMAP)) ||
!(pfd.dwFlags & PFD_SUPPORT_OPENGL)) {
GLWIN_DEBUG_MSG
("pixelFormat %d has unsuitable flags 0x%08lx, skipping", i + 1,
pfd.dwFlags);
("pixelFormat %d has unsuitable flags 0x%08x, skipping", i + 1,
(unsigned int)pfd.dwFlags);
continue;
}

View File

@ -309,7 +309,7 @@ winClipboardFlushXEvents(HWND hwnd,
/* Access the clipboard */
if (!OpenClipboard(hwnd)) {
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
"OpenClipboard () failed: %08lx\n", GetLastError());
"OpenClipboard () failed: %08x\n", (unsigned int)GetLastError());
/* Abort */
fAbort = TRUE;
@ -369,7 +369,7 @@ winClipboardFlushXEvents(HWND hwnd,
}
if (!hGlobal) {
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
"GetClipboardData () failed: %08lx\n", GetLastError());
"GetClipboardData () failed: %08x\n", (unsigned int)GetLastError());
/* Abort */
fAbort = TRUE;
@ -706,7 +706,7 @@ winClipboardFlushXEvents(HWND hwnd,
/* Check that global memory was allocated */
if (!hGlobal) {
ErrorF("winClipboardFlushXEvents - SelectionNotify "
"GlobalAlloc failed, aborting: %ld\n", GetLastError());
"GlobalAlloc failed, aborting: %08x\n", (unsigned int)GetLastError());
/* Abort */
fAbort = TRUE;

View File

@ -443,9 +443,9 @@ winChangeDepthDlgProc(HWND hwndDialog, UINT message,
#endif
#if CYGDEBUG
winDebug("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %d, "
winDebug("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %u, "
"current bpp: %d\n",
s_pScreenInfo->dwBPP,
(unsigned int)s_pScreenInfo->dwBPP,
GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
#endif
@ -455,9 +455,9 @@ winChangeDepthDlgProc(HWND hwndDialog, UINT message,
case WM_DISPLAYCHANGE:
#if CYGDEBUG
winDebug("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %d, "
winDebug("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %u, "
"new bpp: %d\n",
s_pScreenInfo->dwBPP,
(unsigned int)s_pScreenInfo->dwBPP,
GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
#endif

View File

@ -504,7 +504,7 @@ winSendKeyEvent(DWORD dwKey, Bool fDown)
QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease,
dwKey + MIN_KEYCODE);
winDebug("winSendKeyEvent: dwKey: %d, fDown: %d\n", dwKey, fDown);
winDebug("winSendKeyEvent: dwKey: %u, fDown: %u\n", (unsigned int)dwKey, fDown);
}
BOOL

View File

@ -84,7 +84,7 @@ winKeyboardMessageHookLL(int iCode, WPARAM wParam, LPARAM lParam)
/* Pass keystrokes on to our main message loop */
if (iCode == HC_ACTION) {
winDebug("winKeyboardMessageHook: vkCode: %08x scanCode: %08x\n",
p->vkCode, p->scanCode);
(unsigned int)p->vkCode, (unsigned int)p->scanCode);
switch (wParam) {
case WM_KEYDOWN:

View File

@ -954,7 +954,7 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
#ifdef CYGMULTIWINDOW_DEBUG
winDebug("\tWindowStyle: %08x %08x\n", dwStyle, dwExStyle);
winDebug("\tWindowStyle: %08x %08x\n", (unsigned int)dwStyle, (unsigned int)dwExStyle);
#endif
AdjustWindowRectEx(&rcDraw, dwStyle, FALSE, dwExStyle);

View File

@ -1064,7 +1064,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
winDebug("winTopLevelWindowProc - WM_STYLECHANGING from %08x %08x\n",
dwStyle, dwExStyle);
(unsigned int)dwStyle, (unsigned int)dwExStyle);
if (wParam == GWL_EXSTYLE)
dwExStyle = newStyle;
@ -1073,7 +1073,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
dwStyle = newStyle;
winDebug("winTopLevelWindowProc - WM_STYLECHANGING to %08x %08x\n",
dwStyle, dwExStyle);
(unsigned int)dwStyle, (unsigned int)dwExStyle);
/* Get client rect in screen coordinates */
wi.cbSize = sizeof(WINDOWINFO);

View File

@ -89,8 +89,8 @@ winScreenInit(ScreenPtr pScreen, int argc, char **argv)
DWORD dwInitialBPP;
#if CYGDEBUG || YES
winDebug("winScreenInit - dwWidth: %ld dwHeight: %ld\n",
pScreenInfo->dwWidth, pScreenInfo->dwHeight);
winDebug("winScreenInit - dwWidth: %u dwHeight: %u\n",
(unsigned int)pScreenInfo->dwWidth, (unsigned int)pScreenInfo->dwHeight);
#endif
/* Allocate privates for this screen */

View File

@ -200,8 +200,10 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
DDPIXELFORMAT ddpfPrimary;
#if CYGDEBUG
winDebug("winAllocateFBShadowDDNL - w %d h %d d %d\n",
pScreenInfo->dwWidth, pScreenInfo->dwHeight, pScreenInfo->dwDepth);
winDebug("winAllocateFBShadowDDNL - w %u h %u d %u\n",
(unsigned int)pScreenInfo->dwWidth,
(unsigned int)pScreenInfo->dwHeight,
(unsigned int)pScreenInfo->dwDepth);
#endif
/* Set the padded screen width */
@ -400,10 +402,11 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
#if CYGDEBUG
winDebug("winAllocateFBShadowDDNL - Primary masks: %08x %08x %08x "
"dwRGBBitCount: %d\n",
ddpfPrimary.u2.dwRBitMask,
ddpfPrimary.u3.dwGBitMask,
ddpfPrimary.u4.dwBBitMask, ddpfPrimary.u1.dwRGBBitCount);
"dwRGBBitCount: %u\n",
(unsigned int)ddpfPrimary.u2.dwRBitMask,
(unsigned int)ddpfPrimary.u3.dwGBitMask,
(unsigned int)ddpfPrimary.u4.dwBBitMask,
(unsigned int)ddpfPrimary.u1.dwRGBBitCount);
#endif
/* Describe the shadow surface to be created */

View File

@ -121,7 +121,7 @@ winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih)
pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER));
winDebug("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
pdw[0], pdw[1], pdw[2]);
(unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]);
#endif
/* Get optimal color table, or the optimal bitfields */
@ -197,12 +197,12 @@ winQueryRGBBitsAndMasks(ScreenPtr pScreen)
#if CYGDEBUG
winDebug("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
pdw[0], pdw[1], 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__,
pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount,
pbmih->biPlanes);
winDebug("%s - Compression: %d %s\n", __FUNCTION__,
pbmih->biCompression,
winDebug("%s - Compression: %u %s\n", __FUNCTION__,
(unsigned int)pbmih->biCompression,
(pbmih->biCompression ==
BI_RGB ? "(BI_RGB)" : (pbmih->biCompression ==
BI_RLE8 ? "(BI_RLE8)" : (pbmih->