From aa83c61f510121da20b56e8f7de700193f7d16b5 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Fri, 6 Feb 2015 19:46:45 +0000 Subject: [PATCH] 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 Reviewed-by: Colin Harrison --- hw/xwin/glx/indirect.c | 12 ++++++------ hw/xwin/winclipboard/xevents.c | 6 +++--- hw/xwin/windialogs.c | 8 ++++---- hw/xwin/winkeybd.c | 2 +- hw/xwin/winkeyhook.c | 2 +- hw/xwin/winmultiwindowwindow.c | 2 +- hw/xwin/winmultiwindowwndproc.c | 4 ++-- hw/xwin/winscrinit.c | 4 ++-- hw/xwin/winshadddnl.c | 15 +++++++++------ hw/xwin/winshadgdi.c | 8 ++++---- 10 files changed, 33 insertions(+), 30 deletions(-) diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c index 93cdb29d65..e4be642284 100644 --- a/hw/xwin/glx/indirect.c +++ b/hw/xwin/glx/indirect.c @@ -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; } diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c index bf44ac9597..aee6c86a24 100644 --- a/hw/xwin/winclipboard/xevents.c +++ b/hw/xwin/winclipboard/xevents.c @@ -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; diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c index 6fe3fc4425..c83b49bab6 100644 --- a/hw/xwin/windialogs.c +++ b/hw/xwin/windialogs.c @@ -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 diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index e7202a6cb2..f0342259b3 100644 --- a/hw/xwin/winkeybd.c +++ b/hw/xwin/winkeybd.c @@ -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 diff --git a/hw/xwin/winkeyhook.c b/hw/xwin/winkeyhook.c index fe77b21909..66d68f63d6 100644 --- a/hw/xwin/winkeyhook.c +++ b/hw/xwin/winkeyhook.c @@ -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: diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 4a208dd6cf..91bd956f60 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -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); diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index ab892f2916..eb7b55e4d4 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -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); diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c index e68ee12271..735ce9325b 100644 --- a/hw/xwin/winscrinit.c +++ b/hw/xwin/winscrinit.c @@ -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 */ diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c index 48599b2665..d4f940ec10 100644 --- a/hw/xwin/winshadddnl.c +++ b/hw/xwin/winshadddnl.c @@ -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 */ diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c index 3d222ad4be..7c31175f4f 100644 --- a/hw/xwin/winshadgdi.c +++ b/hw/xwin/winshadgdi.c @@ -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->