diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2015-02-06 20:22:11 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2015-07-07 16:52:50 +0100 |
commit | e3cfeb949a9c9363beacdb00acdd9723ed54fac2 (patch) | |
tree | 36d94d9bc39ea3987f5d49877e995702f8f125a6 | |
parent | 4f8661fac985306c56330cae69ffc19e5dd0af61 (diff) |
hw/xwin: printf format fixes for WPARAM and LPARAM types
Some Win32 API types are different fundamental types in the 32-bit and 64-bit
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, so we use some macros to provide the correct specifier for
the target.
LPARAM and WPARAM are integer types which can contain a pointer
LPARAM is long in ILP32 and long long in LLP64
WPARAM is unsigned int in ILP32 and unsigned long long in LLP64
Generally, these are just used to passs integer parameters, so for simplicity,
cast to int and use an int-compatible format
In the specific case of WM_CHANGECBCHAIN, they are used to pass HWND, so cast to
that type and print using an appropriate format.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
-rw-r--r-- | hw/xwin/winclipboard/wndproc.c | 8 | ||||
-rw-r--r-- | hw/xwin/winkeybd.c | 2 | ||||
-rw-r--r-- | hw/xwin/winmsg.c | 8 | ||||
-rw-r--r-- | hw/xwin/winwndproc.c | 2 |
4 files changed, 10 insertions, 10 deletions
diff --git a/hw/xwin/winclipboard/wndproc.c b/hw/xwin/winclipboard/wndproc.c index e1517f207..d17cf2e86 100644 --- a/hw/xwin/winclipboard/wndproc.c +++ b/hw/xwin/winclipboard/wndproc.c @@ -194,9 +194,9 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CHANGECBCHAIN: { - winDebug("winClipboardWindowProc - WM_CHANGECBCHAIN: wParam(%x) " - "lParam(%x) s_hwndNextViewer(%p)\n", - wParam, lParam, s_hwndNextViewer); + winDebug("winClipboardWindowProc - WM_CHANGECBCHAIN: wParam(%p) " + "lParam(%p) s_hwndNextViewer(%p)\n", + (HWND)wParam, (HWND)lParam, s_hwndNextViewer); if ((HWND) wParam == s_hwndNextViewer) { s_hwndNextViewer = (HWND) lParam; @@ -441,7 +441,7 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) int best_target = 0; winDebug("winClipboardWindowProc - WM_RENDERFORMAT %d - Hello.\n", - wParam); + (int)wParam); /* Flag whether to convert to Unicode or not */ fConvertToUnicode = (CF_UNICODETEXT == wParam); diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index f0342259b..ab53af4ba 100644 --- a/hw/xwin/winkeybd.c +++ b/hw/xwin/winkeybd.c @@ -74,7 +74,7 @@ winTranslateKey(WPARAM wParam, LPARAM lParam) int iParamScanCode = LOBYTE(iParam); int iScanCode; - winDebug("winTranslateKey: wParam %08x lParam %08x\n", wParam, lParam); + winDebug("winTranslateKey: wParam %08x lParam %08x\n", (int)wParam, (int)lParam); /* WM_ key messages faked by Vista speech recognition (WSR) don't have a * scan code. diff --git a/hw/xwin/winmsg.c b/hw/xwin/winmsg.c index 79399a40f..575bc47b2 100644 --- a/hw/xwin/winmsg.c +++ b/hw/xwin/winmsg.c @@ -158,8 +158,8 @@ winDebugWin32Message(const char *function, HWND hwnd, UINT message, getenv("WIN_DEBUG_WM_USER")) { winDebug("%s - Message WM_USER + %d\n", function, message - WM_USER); - winDebug("\thwnd 0x%p wParam 0x%x lParam 0x%x\n", hwnd, wParam, - lParam); + winDebug("\thwnd 0x%p wParam 0x%x lParam 0x%x\n", hwnd, (int)wParam, + (int)lParam); } } else if (message < MESSAGE_NAMES_LEN && MESSAGE_NAMES[message]) { @@ -170,8 +170,8 @@ winDebugWin32Message(const char *function, HWND hwnd, UINT message, buffer[63] = 0; if (force || getenv("WIN_DEBUG_MESSAGES") || getenv(buffer)) { winDebug("%s - Message %s\n", function, MESSAGE_NAMES[message]); - winDebug("\thwnd 0x%p wParam 0x%x lParam 0x%x\n", hwnd, wParam, - lParam); + winDebug("\thwnd 0x%p wParam 0x%x lParam 0x%x\n", hwnd, (int)wParam, + (int)lParam); } } } diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index 3228fa481..123b84f31 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -168,7 +168,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ErrorF("winWindowProc - WM_DISPLAYCHANGE - new width: %d " "new height: %d new bpp: %d\n", - LOWORD(lParam), HIWORD(lParam), wParam); + LOWORD(lParam), HIWORD(lParam), (int)wParam); /* 0 bpp has no defined meaning, ignore this message */ if (wParam == 0) |