Bug 1839762 - Cast scoped enums to their underlying type when printing them. r=media-playback-reviewers,necko-reviewers,application-update-reviewers,geckoview-reviewers,handyman,emilio,valentin,bytesized,owlish,karlt

There is no implicit conversion for scoped enums, so using them without
an explicit conversion in varargs functions is undefined behavior. GCC
has had a warning about this for a long while, but clang only gained
this a few days ago on trunk.

Differential Revision: https://phabricator.services.mozilla.com/D181723
This commit is contained in:
Mike Hommey 2023-06-24 20:14:31 +00:00
parent 3ddbce3c42
commit 5af31a8886
16 changed files with 39 additions and 35 deletions

View File

@ -125,7 +125,7 @@ bool WMFCDMImpl::GetCapabilities(nsTArray<KeySystemConfig>& aOutConfigs) {
ok = true;
},
[](nsresult rv) {
EME_LOG("Fail to get key system capabilities. rv=%x", rv);
EME_LOG("Fail to get key system capabilities. rv=%x", uint32_t(rv));
});
}
return ok;

View File

@ -192,7 +192,8 @@ RefPtr<GenericPromise> GMPParent::Init(GeckoMediaPluginServiceParent* aService,
uint32_t pluginArch = base::PROCESS_ARCH_INVALID;
rv = GetPluginFileArch(aPluginDir, mName, pluginArch);
if (NS_FAILED(rv)) {
GMP_PARENT_LOG_DEBUG("%s: Plugin arch error: %d", __FUNCTION__, rv);
GMP_PARENT_LOG_DEBUG("%s: Plugin arch error: %d", __FUNCTION__,
uint32_t(rv));
} else {
GMP_PARENT_LOG_DEBUG("%s: Plugin arch: 0x%x", __FUNCTION__, pluginArch);
}
@ -236,7 +237,8 @@ RefPtr<GenericPromise> GMPParent::Init(GeckoMediaPluginServiceParent* aService,
rv = nsMacUtilsImpl::GetArchitecturesForBundle(&bundleArch);
if (NS_FAILED(rv)) {
// If we fail here, continue as if this is not a univeral binary.
GMP_PARENT_LOG_DEBUG("%s: Bundle arch error: %d", __FUNCTION__, rv);
GMP_PARENT_LOG_DEBUG("%s: Bundle arch error: %d", __FUNCTION__,
uint32_t(rv));
} else {
GMP_PARENT_LOG_DEBUG("%s: Bundle arch: 0x%x", __FUNCTION__, bundleArch);
}

View File

@ -210,7 +210,7 @@ bool GMPProcessParent::FillMacSandboxInfo(MacSandboxInfo& aInfo) {
GMP_LOG_DEBUG(
"GMPProcessParent::FillMacSandboxInfo: "
"NS_NewLocalFile failed for plugin dir, rv=%d",
rv);
uint32_t(rv));
return false;
}
@ -219,7 +219,7 @@ bool GMPProcessParent::FillMacSandboxInfo(MacSandboxInfo& aInfo) {
GMP_LOG_DEBUG(
"GMPProcessParent::FillMacSandboxInfo: "
"failed to normalize plugin dir path, rv=%d",
rv);
uint32_t(rv));
return false;
}

View File

@ -112,7 +112,7 @@ RefPtr<MFCDMChild::CapabilitiesPromise> MFCDMChild::GetCapabilities(
}
if (mState != NS_OK && mState != NS_ERROR_NOT_INITIALIZED) {
LOG("error=%x", nsresult(mState));
LOG("error=%x", uint32_t(nsresult(mState)));
return CapabilitiesPromise::CreateAndReject(mState, __func__);
}
@ -159,7 +159,7 @@ already_AddRefed<PromiseType> MFCDMChild::InvokeAsync(
mRemotePromise->Then(
mManagerThread, __func__, std::move(aCall),
[self = RefPtr{this}, this, &aPromise, aCallerName](nsresult rv) {
LOG("error=%x", rv);
LOG("error=%x", uint32_t(rv));
mState = rv;
aPromise.RejectIfExists(rv, aCallerName);
});
@ -182,7 +182,7 @@ RefPtr<MFCDMChild::InitPromise> MFCDMChild::Init(
}
if (mState != NS_OK && mState != NS_ERROR_NOT_INITIALIZED) {
LOG("error=%x", nsresult(mState));
LOG("error=%x", uint32_t(nsresult(mState)));
return InitPromise::CreateAndReject(mState, __func__);
}

View File

@ -45,23 +45,23 @@ DEFINE_PROPERTYKEY(EME_CONTENTDECRYPTIONMODULE_ORIGIN_ID, 0x1218a3e2, 0xcfb0,
} \
} while (false)
#define MFCDM_REJECT_IF(pred, rv) \
do { \
if (MOZ_UNLIKELY(pred)) { \
MFCDM_PARENT_LOG("reject for [" #pred "], rv=%x", rv); \
aResolver(rv); \
return IPC_OK(); \
} \
#define MFCDM_REJECT_IF(pred, rv) \
do { \
if (MOZ_UNLIKELY(pred)) { \
MFCDM_PARENT_LOG("reject for [" #pred "], rv=%x", uint32_t(rv)); \
aResolver(rv); \
return IPC_OK(); \
} \
} while (false)
#define MFCDM_REJECT_IF_FAILED(op, rv) \
do { \
HRESULT hr = op; \
if (MOZ_UNLIKELY(FAILED(hr))) { \
MFCDM_PARENT_LOG("(" #op ") failed(hr=%lx), rv=%x", hr, rv); \
aResolver(rv); \
return IPC_OK(); \
} \
#define MFCDM_REJECT_IF_FAILED(op, rv) \
do { \
HRESULT hr = op; \
if (MOZ_UNLIKELY(FAILED(hr))) { \
MFCDM_PARENT_LOG("(" #op ") failed(hr=%lx), rv=%x", hr, uint32_t(rv)); \
aResolver(rv); \
return IPC_OK(); \
} \
} while (false)
// RAIIized PROPVARIANT. See

View File

@ -157,7 +157,7 @@ RefPtr<MediaDataEncoder::InitPromise> AppleVTEncoder::Init() {
return InitPromise::CreateAndReject(
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
nsPrintfCString("fail to configurate profile level:%d",
specific.mProfileLevel)),
int(specific.mProfileLevel))),
__func__);
}
}

View File

@ -288,7 +288,8 @@ Java_org_mozilla_gecko_mozglue_GeckoLoader_loadGeckoLibsNative(
auto msg = errorInfo.match(
[](const nsresult& aRv) {
return Smprintf("Error loading Gecko libraries: nsresult 0x%08X", aRv);
return Smprintf("Error loading Gecko libraries: nsresult 0x%08X",
uint32_t(aRv));
},
[](const DLErrorType& aErr) {
return Smprintf("Error loading Gecko libraries: %s", aErr.get());

View File

@ -174,7 +174,7 @@ NamedPipeService::AddDataObserver(void* aHandle,
if (mObservers.Length() == 1) {
rv = mThread->Dispatch(this, NS_DISPATCH_NORMAL);
if (NS_WARN_IF(NS_FAILED(rv))) {
LOG_NPS_ERROR("Dispatch to thread failed (%08x)", rv);
LOG_NPS_ERROR("Dispatch to thread failed (%08x)", uint32_t(rv));
mObservers.Clear();
return rv;
}

View File

@ -258,7 +258,8 @@ void nsNotifyAddrListener::calculateNetworkId(void) {
mNetworkId.Truncate();
}
Telemetry::Accumulate(Telemetry::NETWORK_ID2, 0);
LOG(("calculateNetworkId: no network ID Base64Encode error %X", rv));
LOG(("calculateNetworkId: no network ID Base64Encode error %X",
uint32_t(rv)));
return;
}

View File

@ -38,7 +38,7 @@ nsWindowsDHCPClient::GetOption(uint8_t aOption, nsACString& aRetVal) {
LOG(
("Failed to get network adapter name in nsWindowsDHCPClient::GetOption "
"due to error %d",
rv));
uint32_t(rv)));
return rv;
}
@ -64,7 +64,7 @@ nsWindowsDHCPClient::GetOption(uint8_t aOption, nsACString& aRetVal) {
LOG(
("Failed to get DHCP Option %d nsWindowsDHCPClient::GetOption due to "
"error %d",
aOption, rv));
aOption, uint32_t(rv)));
return rv;
}
aRetVal.Assign(optionValue.data(), sizeOptionValue);

View File

@ -95,7 +95,7 @@ static void UpdateDriverSetupMacCommandLine(int& argc, char**& argv,
LOG(
("Update driver error dispatching SetupMacCommandLine to main thread: "
"%d\n",
rv));
uint32_t(rv)));
return;
}

View File

@ -291,7 +291,7 @@ class GeckoJavaSampler
},
[result](nsresult aRv) {
char errorString[9];
sprintf(errorString, "%08x", aRv);
sprintf(errorString, "%08x", uint32_t(aRv));
result->CompleteExceptionally(
mozilla::java::sdk::IllegalStateException::New(errorString)
.Cast<jni::Throwable>());

View File

@ -33,7 +33,7 @@ class ImageCallbackHelper : public imgIContainerCallback,
NS_DECL_ISUPPORTS
void CompleteExceptionally(nsresult aRv) {
nsPrintfCString error("Could not process image: 0x%08X", aRv);
nsPrintfCString error("Could not process image: 0x%08X", uint32_t(aRv));
mResult->CompleteExceptionally(
java::Image::ImageProcessingException::New(error.get())
.Cast<jni::Throwable>());

View File

@ -127,7 +127,7 @@ BOOL CALLBACK CollectMonitors(HMONITOR aMon, HDC, LPRECT, LPARAM ioParam) {
("New screen [%s (%s) %d %u %f %f %f %d %d %d]",
ToString(rect).c_str(), ToString(availRect).c_str(), pixelDepth,
refreshRate, contentsScaleFactor.scale, defaultCssScaleFactor.scale,
dpi, isPseudoDisplay, orientation, angle));
dpi, isPseudoDisplay, uint32_t(orientation), angle));
auto screen = MakeRefPtr<Screen>(
rect, availRect, pixelDepth, pixelDepth, refreshRate, contentsScaleFactor,
defaultCssScaleFactor, dpi, Screen::IsPseudoDisplay(isPseudoDisplay),

View File

@ -348,7 +348,7 @@ void TaskbarConcealerImpl::MarkAsHidingTaskbar(HWND aWnd, bool aMark) {
if (FAILED(hr)) {
MOZ_LOG(sTaskbarConcealerLog, LogLevel::Error,
("Call to PrepareFullScreen(%p, %s) failed with nsresult %x", aWnd,
sMark, hr));
sMark, uint32_t(hr)));
}
};

View File

@ -51,7 +51,7 @@ using HandleWatcher = mozilla::HandleWatcher;
// implementation details from the MOZ_CRASH* family of macros
MOZ_Crash(file, static_cast<int>(line),
MOZ_CrashPrintf("%s gave nsresult %s(%" PRIX32 ")", expr,
mozilla::GetStaticErrorName(res), res));
mozilla::GetStaticErrorName(res), uint32_t(res)));
}
// UNWRAP: testing-oriented variant of Result::unwrap.