Bug 1766561 - Use proper formatting directives for LPARAM and WPARAM. r=Jamie,rkraesig

Unfortunately, while with MSVC one would use the `I` modifier to format
LPARAM/LONG_PTR, it doesn't work with clang-cl on 32-bits, because
LONG_PTR there is long, but `I` expects an int.

Differential Revision: https://phabricator.services.mozilla.com/D144916
This commit is contained in:
Mike Hommey 2022-05-03 20:49:08 +00:00
Родитель 1663cab462
Коммит f047620639
6 изменённых файлов: 85 добавлений и 57 удалений

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/Telemetry.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/WindowsVersion.h"
#include "nsdefs.h"
#include "nspr/prenv.h"
#include "nsTHashMap.h"
@ -169,8 +170,8 @@ Maybe<bool> Compatibility::OnUIAMessage(WPARAM aWParam, LPARAM aLParam) {
// The section name always ends with this suffix, which is derived from the
// current thread id and the UIA message's WPARAM and LPARAM.
nsAutoString partialSectionSuffix;
partialSectionSuffix.AppendPrintf("_%08x_%08x_%08x", ::GetCurrentThreadId(),
static_cast<DWORD>(aLParam), aWParam);
partialSectionSuffix.AppendPrintf("_%08x_%08" PRIxLPTR "_%08zx",
::GetCurrentThreadId(), aLParam, aWParam);
// Find any named Section that matches the naming convention of the UIA shared
// memory.

Просмотреть файл

@ -595,7 +595,8 @@ bool IMMHandler::ProcessMessage(nsWindow* aWindow, UINT msg, WPARAM& wParam,
void IMMHandler::OnInputLangChange(nsWindow* aWindow, WPARAM wParam,
LPARAM lParam, MSGResult& aResult) {
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnInputLangChange, hWnd=%p, wParam=%08x, lParam=%08x",
("IMMHandler::OnInputLangChange, hWnd=%p, wParam=%08zx, "
"lParam=%08" PRIxLPTR,
aWindow->GetWindowHandle(), wParam, lParam));
aWindow->NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
@ -627,7 +628,8 @@ bool IMMHandler::OnIMEComposition(nsWindow* aWindow, WPARAM wParam,
LPARAM lParam, MSGResult& aResult) {
MOZ_LOG(
gIMELog, LogLevel::Info,
("IMMHandler::OnIMEComposition, hWnd=%p, lParam=%08x, mIsComposing=%s, "
("IMMHandler::OnIMEComposition, hWnd=%p, lParam=%08" PRIxLPTR
", mIsComposing=%s, "
"GCS_RESULTSTR=%s, GCS_COMPSTR=%s, GCS_COMPATTR=%s, GCS_COMPCLAUSE=%s, "
"GCS_CURSORPOS=%s,",
aWindow->GetWindowHandle(), lParam, GetBoolName(mIsComposing),
@ -685,7 +687,7 @@ bool IMMHandler::OnIMEEndComposition(nsWindow* aWindow, MSGResult& aResult) {
bool IMMHandler::OnIMEChar(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
MSGResult& aResult) {
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnIMEChar, hWnd=%p, char=%08x",
("IMMHandler::OnIMEChar, hWnd=%p, char=%08zx",
aWindow->GetWindowHandle(), wParam));
// We don't need to fire any compositionchange events from here. This method
@ -716,13 +718,13 @@ bool IMMHandler::OnIMENotify(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
case IMN_CHANGECANDIDATE:
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnIMENotify, hWnd=%p, IMN_CHANGECANDIDATE, "
"lParam=%08x",
"lParam=%08" PRIxLPTR,
aWindow->GetWindowHandle(), lParam));
break;
case IMN_CLOSECANDIDATE:
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnIMENotify, hWnd=%p, IMN_CLOSECANDIDATE, "
"lParam=%08x",
"lParam=%08" PRIxLPTR,
aWindow->GetWindowHandle(), lParam));
break;
case IMN_CLOSESTATUSWINDOW:
@ -736,10 +738,10 @@ bool IMMHandler::OnIMENotify(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
aWindow->GetWindowHandle()));
break;
case IMN_OPENCANDIDATE:
MOZ_LOG(
gIMELog, LogLevel::Info,
("IMMHandler::OnIMENotify, hWnd=%p, IMN_OPENCANDIDATE, lParam=%08x",
aWindow->GetWindowHandle(), lParam));
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnIMENotify, hWnd=%p, IMN_OPENCANDIDATE, "
"lParam=%08" PRIxLPTR,
aWindow->GetWindowHandle(), lParam));
break;
case IMN_OPENSTATUSWINDOW:
MOZ_LOG(gIMELog, LogLevel::Info,
@ -749,7 +751,7 @@ bool IMMHandler::OnIMENotify(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
case IMN_SETCANDIDATEPOS:
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnIMENotify, hWnd=%p, IMN_SETCANDIDATEPOS, "
"lParam=%08x",
"lParam=%08" PRIxLPTR,
aWindow->GetWindowHandle(), lParam));
break;
case IMN_SETCOMPOSITIONFONT:
@ -818,7 +820,7 @@ bool IMMHandler::OnIMERequest(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
return true;
default:
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnIMERequest, hWnd=%p, wParam=%08x",
("IMMHandler::OnIMERequest, hWnd=%p, wParam=%08zx",
aWindow->GetWindowHandle(), wParam));
aResult.mConsumed = false;
return true;
@ -828,9 +830,10 @@ bool IMMHandler::OnIMERequest(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
// static
bool IMMHandler::OnIMESelect(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
MSGResult& aResult) {
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnIMESelect, hWnd=%p, wParam=%08x, lParam=%08x",
aWindow->GetWindowHandle(), wParam, lParam));
MOZ_LOG(
gIMELog, LogLevel::Info,
("IMMHandler::OnIMESelect, hWnd=%p, wParam=%08zx, lParam=%08" PRIxLPTR,
aWindow->GetWindowHandle(), wParam, lParam));
// not implement yet
aResult.mConsumed = false;
@ -841,7 +844,7 @@ bool IMMHandler::OnIMESelect(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
bool IMMHandler::OnIMESetContext(nsWindow* aWindow, WPARAM wParam,
LPARAM lParam, MSGResult& aResult) {
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnIMESetContext, hWnd=%p, %s, lParam=%08x",
("IMMHandler::OnIMESetContext, hWnd=%p, %s, lParam=%08" PRIxLPTR,
aWindow->GetWindowHandle(), wParam ? "Active" : "Deactive", lParam));
aResult.mConsumed = false;
@ -902,10 +905,11 @@ bool IMMHandler::OnChar(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
WPARAM recWParam;
LPARAM recLParam;
DequeueIMECharRecords(recWParam, recLParam);
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnChar, aWindow=%p, wParam=%08x, lParam=%08x, "
"recorded: wParam=%08x, lParam=%08x",
aWindow->GetWindowHandle(), wParam, lParam, recWParam, recLParam));
MOZ_LOG(
gIMELog, LogLevel::Info,
("IMMHandler::OnChar, aWindow=%p, wParam=%08zx, lParam=%08" PRIxLPTR ", "
"recorded: wParam=%08zx, lParam=%08" PRIxLPTR,
aWindow->GetWindowHandle(), wParam, lParam, recWParam, recLParam));
// If an unexpected char message comes, we should reset the records,
// of course, this shouldn't happen.
if (recWParam != wParam || recLParam != lParam) {
@ -1281,7 +1285,8 @@ bool IMMHandler::HandleReconvert(nsWindow* aWindow, LPARAM lParam,
}
*oResult = needSize;
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::HandleReconvert, succeeded, result=%ld", *oResult));
("IMMHandler::HandleReconvert, succeeded, result=%" PRIdLPTR,
*oResult));
return true;
}
@ -1310,9 +1315,10 @@ bool IMMHandler::HandleReconvert(nsWindow* aWindow, LPARAM lParam,
len * sizeof(WCHAR));
}
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::HandleReconvert, SUCCEEDED, pReconv=%s, result=%ld",
GetReconvertStringLog(pReconv).get(), *oResult));
MOZ_LOG(
gIMELog, LogLevel::Info,
("IMMHandler::HandleReconvert, SUCCEEDED, pReconv=%s, result=%" PRIdLPTR,
GetReconvertStringLog(pReconv).get(), *oResult));
return true;
}
@ -1484,9 +1490,9 @@ bool IMMHandler::HandleDocumentFeed(nsWindow* aWindow, LPARAM lParam,
if (!pReconv) {
*oResult = needSize;
MOZ_LOG(
gIMELog, LogLevel::Info,
("IMMHandler::HandleDocumentFeed, succeeded, result=%ld", *oResult));
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::HandleDocumentFeed, succeeded, result=%" PRIdLPTR,
*oResult));
return true;
}
@ -1530,7 +1536,8 @@ bool IMMHandler::HandleDocumentFeed(nsWindow* aWindow, LPARAM lParam,
paragraph.BeginReading(), len * sizeof(WCHAR));
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::HandleDocumentFeed, SUCCEEDED, pReconv=%s, result=%ld",
("IMMHandler::HandleDocumentFeed, SUCCEEDED, pReconv=%s, "
"result=%" PRIdLPTR,
GetReconvertStringLog(pReconv).get(), *oResult));
return true;
@ -2326,9 +2333,10 @@ nsresult IMMHandler::OnMouseButtonEvent(
// static
bool IMMHandler::OnKeyDownEvent(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
MSGResult& aResult) {
MOZ_LOG(gIMELog, LogLevel::Info,
("IMMHandler::OnKeyDownEvent, hWnd=%p, wParam=%08x, lParam=%08x",
aWindow->GetWindowHandle(), wParam, lParam));
MOZ_LOG(
gIMELog, LogLevel::Info,
("IMMHandler::OnKeyDownEvent, hWnd=%p, wParam=%08zx, lParam=%08" PRIxLPTR,
aWindow->GetWindowHandle(), wParam, lParam));
aResult.mConsumed = false;
switch (wParam) {
case VK_TAB:

Просмотреть файл

@ -419,21 +419,21 @@ static const nsCString GetCharacterCodeName(WPARAM aCharCode) {
return "ZERO WIDTH NO-BREAK SPACE (0xFEFF)"_ns;
default: {
if (aCharCode < ' ' || (aCharCode >= 0x80 && aCharCode < 0xA0)) {
return nsPrintfCString("control (0x%04X)", aCharCode);
return nsPrintfCString("control (0x%04zX)", aCharCode);
}
if (NS_IS_HIGH_SURROGATE(aCharCode)) {
return nsPrintfCString("high surrogate (0x%04X)", aCharCode);
return nsPrintfCString("high surrogate (0x%04zX)", aCharCode);
}
if (NS_IS_LOW_SURROGATE(aCharCode)) {
return nsPrintfCString("low surrogate (0x%04X)", aCharCode);
return nsPrintfCString("low surrogate (0x%04zX)", aCharCode);
}
return IS_IN_BMP(aCharCode)
? nsPrintfCString(
"'%s' (0x%04X)",
"'%s' (0x%04zX)",
NS_ConvertUTF16toUTF8(nsAutoString(aCharCode)).get(),
aCharCode)
: nsPrintfCString(
"'%s' (0x%08X)",
"'%s' (0x%08zX)",
NS_ConvertUTF16toUTF8(nsAutoString(aCharCode)).get(),
aCharCode);
}
@ -555,7 +555,7 @@ static const nsCString GetMessageName(UINT aMessage) {
static const nsCString GetVirtualKeyCodeName(WPARAM aVK) {
if (aVK >= ArrayLength(kVirtualKeyName)) {
return nsPrintfCString("Invalid (0x%08X)", aVK);
return nsPrintfCString("Invalid (0x%08zX)", aVK);
}
return nsCString(kVirtualKeyName[aVK]);
}
@ -667,7 +667,7 @@ static const nsCString GetAppCommandName(WPARAM aCommand) {
case APPCOMMAND_VOLUME_UP:
return "APPCOMMAND_VOLUME_UP"_ns;
default:
return nsPrintfCString("Unknown app command (0x%08X)", aCommand);
return nsPrintfCString("Unknown app command (0x%08zX)", aCommand);
}
}
@ -680,7 +680,8 @@ static const nsCString GetAppCommandDeviceName(LPARAM aDevice) {
case FAPPCOMMAND_OEM:
return "FAPPCOMMAND_OEM"_ns;
default:
return nsPrintfCString("Unknown app command device (0x%04X)", aDevice);
return nsPrintfCString("Unknown app command device (0x%04" PRIXLPTR ")",
aDevice);
}
};
@ -723,7 +724,7 @@ class MOZ_STACK_CLASS GetAppCommandKeysName final : public nsAutoCString {
}
if (aKeys) {
MaybeAppendSeparator();
AppendPrintf("Unknown Flags (0x%04X)", aKeys);
AppendPrintf("Unknown Flags (0x%04zX)", aKeys);
}
if (IsEmpty()) {
AssignLiteral("none (0x0000)");
@ -749,7 +750,8 @@ static const nsCString ToString(const MSG& aMSG) {
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
result.AppendPrintf(
"virtual keycode=%s, repeat count=%d, "
"virtual keycode=%s, repeat count=%" PRIdLPTR
", "
"scancode=0x%02X, extended key=%s, "
"context code=%s, previous key state=%s, "
"transition state=%s",
@ -765,7 +767,8 @@ static const nsCString ToString(const MSG& aMSG) {
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
result.AppendPrintf(
"character code=%s, repeat count=%d, "
"character code=%s, repeat count=%" PRIdLPTR
", "
"scancode=0x%02X, extended key=%s, "
"context code=%s, previous key state=%s, "
"transition state=%s",
@ -778,14 +781,15 @@ static const nsCString ToString(const MSG& aMSG) {
break;
case WM_APPCOMMAND:
result.AppendPrintf(
"window handle=0x%p, app command=%s, device=%s, dwKeys=%s",
"window handle=0x%zx, app command=%s, device=%s, dwKeys=%s",
aMSG.wParam,
GetAppCommandName(GET_APPCOMMAND_LPARAM(aMSG.lParam)).get(),
GetAppCommandDeviceName(GET_DEVICE_LPARAM(aMSG.lParam)).get(),
GetAppCommandKeysName(GET_KEYSTATE_LPARAM(aMSG.lParam)).get());
break;
default:
result.AppendPrintf("wParam=%u, lParam=%u", aMSG.wParam, aMSG.lParam);
result.AppendPrintf("wParam=%zu, lParam=%" PRIdLPTR, aMSG.wParam,
aMSG.lParam);
break;
}
result.AppendPrintf(", hwnd=0x%p", aMSG.hwnd);

Просмотреть файл

@ -200,8 +200,10 @@ void SessionChangeObserver::OnWinEventProc(HWND aHwnd, UINT aMsg,
if (!::ProcessIdToSessionId(::GetCurrentProcessId(), &currentSessionId)) {
isCurrentSession = Nothing();
} else {
LOG("SessionChangeObserver::OnWinEventProc() aWParam %d aLParam %d "
"currentSessionId %d this %p",
LOG("SessionChangeObserver::OnWinEventProc() aWParam %zu aLParam "
"%" PRIdLPTR
" "
"currentSessionId %lu this %p",
aWParam, aLParam, currentSessionId, this);
isCurrentSession = Some(static_cast<DWORD>(aLParam) == currentSessionId);

Просмотреть файл

@ -209,7 +209,7 @@ bool MouseScrollHandler::ProcessMessage(nsWindow* aWidget, UINT msg,
case WM_KEYUP:
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
("MouseScroll::ProcessMessage(): aWidget=%p, "
"msg=%s(0x%04X), wParam=0x%02X, ::GetMessageTime()=%d",
"msg=%s(0x%04X), wParam=0x%02zX, ::GetMessageTime()=%ld",
aWidget,
msg == WM_KEYDOWN ? "WM_KEYDOWN"
: msg == WM_KEYUP ? "WM_KEYUP"
@ -374,7 +374,8 @@ void MouseScrollHandler::ProcessNativeMouseWheelMessage(nsWindow* aWidget,
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
("MouseScroll::ProcessNativeMouseWheelMessage: aWidget=%p, "
"aMessage=%s, wParam=0x%08X, lParam=0x%08X, point: { x=%d, y=%d }",
"aMessage=%s, wParam=0x%08zX, lParam=0x%08" PRIXLPTR
", point: { x=%d, y=%d }",
aWidget,
aMessage == WM_MOUSEWHEEL ? "WM_MOUSEWHEEL"
: aMessage == WM_MOUSEHWHEEL ? "WM_MOUSEHWHEEL"
@ -494,7 +495,7 @@ bool MouseScrollHandler::ProcessNativeScrollMessage(nsWindow* aWidget,
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
("MouseScroll::ProcessNativeScrollMessage: aWidget=%p, "
"aMessage=%s, wParam=0x%08X, lParam=0x%08X",
"aMessage=%s, wParam=0x%08zX, lParam=0x%08" PRIXLPTR,
aWidget, aMessage == WM_VSCROLL ? "WM_VSCROLL" : "WM_HSCROLL",
aWParam, aLParam));
@ -552,7 +553,7 @@ void MouseScrollHandler::HandleMouseWheelMessage(nsWindow* aWidget,
MOZ_LOG(
gMouseScrollLog, LogLevel::Info,
("MouseScroll::HandleMouseWheelMessage: aWidget=%p, "
"aMessage=MOZ_WM_MOUSE%sWHEEL, aWParam=0x%08X, aLParam=0x%08X",
"aMessage=MOZ_WM_MOUSE%sWHEEL, aWParam=0x%08zX, aLParam=0x%08" PRIXLPTR,
aWidget, aMessage == MOZ_WM_MOUSEVWHEEL ? "V" : "H", aWParam, aLParam));
mIsWaitingInternalMessage = false;
@ -657,7 +658,7 @@ void MouseScrollHandler::HandleScrollMessageAsMouseWheelMessage(
MOZ_LOG(
gMouseScrollLog, LogLevel::Info,
("MouseScroll::HandleScrollMessageAsMouseWheelMessage: aWidget=%p, "
"aMessage=MOZ_WM_%sSCROLL, aWParam=0x%08X, aLParam=0x%08X, "
"aMessage=MOZ_WM_%sSCROLL, aWParam=0x%08zX, aLParam=0x%08" PRIXLPTR ", "
"wheelEvent { mRefPoint: { x: %d, y: %d }, mDeltaX: %f, mDeltaY: %f, "
"mLineOrPageDeltaX: %d, mLineOrPageDeltaY: %d, "
"isShift: %s, isControl: %s, isAlt: %s, isMeta: %s }",
@ -1555,8 +1556,8 @@ nsresult MouseScrollHandler::SynthesizingEvent::Synthesize(
MOZ_LOG(
gMouseScrollLog, LogLevel::Info,
("MouseScrollHandler::SynthesizingEvent::Synthesize(): aCursorPoint: { "
"x: %d, y: %d }, aWnd=0x%p, aMessage=0x%04X, aWParam=0x%08X, "
"aLParam=0x%08X, IsSynthesized()=%s, mStatus=%s",
"x: %d, y: %d }, aWnd=0x%p, aMessage=0x%04X, aWParam=0x%08zX, "
"aLParam=0x%08" PRIXLPTR ", IsSynthesized()=%s, mStatus=%s",
aCursorPoint.x, aCursorPoint.y, aWnd, aMessage, aWParam, aLParam,
GetBoolName(IsSynthesizing()), GetStatusName()));
@ -1602,9 +1603,10 @@ void MouseScrollHandler::SynthesizingEvent::NativeMessageReceived(
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
("MouseScrollHandler::SynthesizingEvent::NativeMessageReceived(): "
"aWidget=%p, aWidget->GetWindowHandle()=0x%p, mWnd=0x%p, "
"aMessage=0x%04X, aWParam=0x%08X, aLParam=0x%08X, mStatus=%s",
aWidget, aWidget ? aWidget->GetWindowHandle() : 0, mWnd, aMessage,
aWParam, aLParam, GetStatusName()));
"aMessage=0x%04X, aWParam=0x%08zX, aLParam=0x%08" PRIXLPTR
", mStatus=%s",
aWidget, aWidget ? aWidget->GetWindowHandle() : nullptr, mWnd,
aMessage, aWParam, aLParam, GetStatusName()));
// We failed to receive our sent message, we failed to do the job.
Finish();

Просмотреть файл

@ -24,6 +24,17 @@
# define VERIFY(exp) (exp)
#endif // !_DEBUG
// inttypes.h-like macro for LONG_PTR/LPARAM formatting.
#ifdef HAVE_64BIT_BUILD
# define PRIdLPTR "lld"
# define PRIxLPTR "llx"
# define PRIXLPTR "llX"
#else
# define PRIdLPTR "ld"
# define PRIxLPTR "lx"
# define PRIXLPTR "lX"
#endif
// Win32 logging modules:
// nsWindow, nsSound, and nsClipboard
//