Bug 1060419 - make log_print use Printf.h, r?froydnj draft
authorTom Tromey <tom@tromey.com>
Thu, 15 Dec 2016 20:16:31 -0700
changeset 486153 57a08b93bb742e9581bfef1019ed0b9f2e2c0b63
parent 486152 e9310756cf58f321a21f0e26686d62cfc5d8e43f
child 486154 afd242e4fa3c14634dff726a548c84198e149392
push id45909
push userbmo:ttromey@mozilla.com
push dateFri, 17 Feb 2017 16:00:11 +0000
reviewersfroydnj
bugs1060419
milestone54.0a1
Bug 1060419 - make log_print use Printf.h, r?froydnj MozReview-Commit-ID: BIZ1GQEZ1vs
dom/audiochannel/AudioChannelService.cpp
dom/base/nsObjectLoadingContent.cpp
dom/browser-element/BrowserElementAudioChannel.cpp
dom/events/IMEStateManager.cpp
dom/flyweb/FlyWebPublishedServer.cpp
dom/flyweb/HttpServer.cpp
dom/html/HTMLMediaElement.cpp
dom/html/TextTrackManager.cpp
dom/indexedDB/ActorsParent.cpp
dom/ipc/TabChild.cpp
dom/media/ADTSDemuxer.cpp
dom/media/Latency.cpp
dom/media/MP3Demuxer.cpp
dom/media/MediaCache.cpp
dom/media/MediaDecoder.cpp
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaFormatReader.cpp
dom/media/MediaManager.cpp
dom/media/MediaResource.cpp
dom/media/MediaStreamGraph.cpp
dom/media/MediaTimer.cpp
dom/media/MediaTimer.h
dom/media/StreamTracks.cpp
dom/media/eme/DetailedPromise.cpp
dom/media/eme/MediaKeySession.cpp
dom/media/eme/MediaKeys.cpp
dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp
dom/media/encoder/MediaEncoder.cpp
dom/media/encoder/TrackEncoder.cpp
dom/media/encoder/VP8TrackEncoder.cpp
dom/media/flac/FlacDemuxer.cpp
dom/media/gmp/GMPDecryptorParent.cpp
dom/media/gmp/GMPServiceChild.cpp
dom/media/gmp/GMPServiceParent.cpp
dom/media/gmp/GMPStorageParent.cpp
dom/media/gmp/GMPVideoDecoderParent.cpp
dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
dom/media/gmp/widevine-adapter/WidevineVideoDecoder.cpp
dom/media/gmp/widevine-adapter/WidevineVideoFrame.cpp
dom/media/mediasink/DecodedAudioDataSink.cpp
dom/media/mediasink/VideoSink.cpp
dom/media/mediasource/ContainerParser.cpp
dom/media/mediasource/MediaSource.cpp
dom/media/mediasource/ResourceQueue.cpp
dom/media/mediasource/SourceBuffer.cpp
dom/media/mediasource/SourceBufferResource.cpp
dom/media/mediasource/TrackBuffersManager.cpp
dom/media/ogg/OggCodecState.cpp
dom/media/ogg/OggDemuxer.cpp
dom/media/platforms/agnostic/OpusDecoder.cpp
dom/media/platforms/agnostic/TheoraDecoder.cpp
dom/media/platforms/agnostic/VPXDecoder.cpp
dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp
dom/media/platforms/apple/AppleATDecoder.cpp
dom/media/platforms/apple/AppleVTDecoder.cpp
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
dom/media/platforms/omx/OmxDataDecoder.cpp
dom/media/platforms/omx/OmxPlatformLayer.cpp
dom/media/platforms/omx/OmxPromiseLayer.cpp
dom/media/systemservices/LoadManager.cpp
dom/media/systemservices/MediaChild.cpp
dom/media/systemservices/MediaParent.cpp
dom/media/systemservices/OpenSLESProvider.cpp
dom/media/systemservices/ShmemPool.cpp
dom/media/systemservices/ShmemPool.h
dom/media/webm/WebMBufferedParser.cpp
dom/media/webm/WebMDemuxer.cpp
dom/media/webrtc/MediaEngineCameraVideoSource.cpp
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
dom/media/webspeech/synth/SpeechSynthesis.cpp
dom/network/UDPSocketChild.cpp
dom/network/UDPSocketParent.cpp
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginStreamListenerPeer.cpp
dom/plugins/ipc/PluginInstanceChild.cpp
dom/presentation/PresentationConnection.cpp
dom/presentation/PresentationReceiver.cpp
dom/presentation/PresentationService.cpp
dom/presentation/PresentationSessionInfo.cpp
dom/presentation/PresentationTCPSessionTransport.cpp
dom/presentation/ipc/PresentationIPCService.cpp
dom/presentation/provider/MulticastDNSDeviceProvider.cpp
dom/security/SRICheck.cpp
dom/security/SRIMetadata.cpp
dom/security/nsCSPContext.cpp
dom/security/nsCSPParser.cpp
dom/security/nsCSPUtils.cpp
dom/u2f/U2F.cpp
dom/workers/WorkerPrivate.cpp
extensions/auth/nsAuthGSSAPI.cpp
extensions/pref/autoconfig/src/nsAutoConfig.cpp
extensions/pref/autoconfig/src/nsReadConfig.cpp
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/thebes/gfxFcPlatformFontList.cpp
gfx/thebes/gfxMacPlatformFontList.mm
gfx/thebes/gfxPlatformFontList.cpp
gfx/thebes/gfxTextRun.cpp
hal/fallback/FallbackThreadPriority.cpp
image/imgLoader.cpp
image/imgRequest.cpp
layout/base/AccessibleCaretManager.cpp
layout/base/nsRefreshDriver.cpp
layout/printing/nsPrintEngine.cpp
layout/style/Loader.cpp
layout/style/nsFontFaceLoader.cpp
media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
modules/libjar/nsJARChannel.cpp
netwerk/base/EventTokenBucket.cpp
netwerk/base/Predictor.cpp
netwerk/base/nsAsyncRedirectVerifyHelper.cpp
netwerk/base/nsAsyncStreamCopier.cpp
netwerk/base/nsInputStreamPump.cpp
netwerk/base/nsLoadGroup.cpp
netwerk/base/nsProtocolProxyService.cpp
netwerk/base/nsRequestObserverProxy.cpp
netwerk/base/nsSocketTransport2.cpp
netwerk/base/nsSocketTransportService2.cpp
netwerk/base/nsUDPSocket.cpp
netwerk/cache/nsCache.cpp
netwerk/cache/nsCacheEntryDescriptor.cpp
netwerk/cache/nsCacheService.cpp
netwerk/cache/nsDiskCacheBlockFile.cpp
netwerk/cache/nsDiskCacheDevice.cpp
netwerk/cache/nsDiskCacheDeviceSQL.cpp
netwerk/cache/nsDiskCacheStreams.cpp
netwerk/cache/nsMemoryCacheDevice.cpp
netwerk/cache2/CacheEntry.cpp
netwerk/cache2/CacheFile.cpp
netwerk/cache2/CacheFileChunk.cpp
netwerk/cache2/CacheFileContextEvictor.cpp
netwerk/cache2/CacheFileIOManager.cpp
netwerk/cache2/CacheFileInputStream.cpp
netwerk/cache2/CacheFileMetadata.cpp
netwerk/cache2/CacheFileOutputStream.cpp
netwerk/cache2/CacheFileUtils.cpp
netwerk/cache2/CacheIndex.cpp
netwerk/cache2/CacheIndex.h
netwerk/cache2/CacheIndexIterator.cpp
netwerk/cache2/CacheStorageService.cpp
netwerk/cache2/OldWrappers.cpp
netwerk/cookie/nsCookieService.cpp
netwerk/protocol/ftp/FTPChannelChild.cpp
netwerk/protocol/ftp/FTPChannelParent.cpp
netwerk/protocol/ftp/nsFtpConnectionThread.cpp
netwerk/protocol/ftp/nsFtpControlConnection.cpp
netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
netwerk/protocol/http/AlternateServices.cpp
netwerk/protocol/http/Http2Push.cpp
netwerk/protocol/http/Http2Session.cpp
netwerk/protocol/http/Http2Stream.cpp
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/HttpChannelParentListener.cpp
netwerk/protocol/http/TunnelUtils.cpp
netwerk/protocol/http/nsHttp.cpp
netwerk/protocol/http/nsHttpAuthCache.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpConnection.cpp
netwerk/protocol/http/nsHttpConnectionInfo.h
netwerk/protocol/http/nsHttpConnectionMgr.cpp
netwerk/protocol/http/nsHttpDigestAuth.cpp
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpPipeline.cpp
netwerk/protocol/http/nsHttpTransaction.cpp
netwerk/protocol/websocket/WebSocketChannel.cpp
netwerk/protocol/websocket/WebSocketChannelChild.cpp
netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
netwerk/sctp/datachannel/DataChannel.cpp
netwerk/streamconv/converters/nsFTPDirListingConv.cpp
netwerk/streamconv/converters/nsHTTPCompressConv.cpp
netwerk/wifi/nsWifiMonitor.cpp
parser/htmlparser/nsExpatDriver.cpp
rdf/base/nsRDFService.cpp
security/certverifier/CertVerifier.cpp
security/certverifier/NSSCertDBTrustDomain.cpp
security/manager/ssl/CertBlocklist.cpp
security/manager/ssl/RootCertificateTelemetryUtils.cpp
security/manager/ssl/nsNSSCallbacks.cpp
security/manager/ssl/nsSecureBrowserUIImpl.cpp
security/manager/ssl/nsSiteSecurityService.cpp
storage/mozStorageAsyncStatement.cpp
storage/mozStorageConnection.cpp
storage/mozStorageStatement.cpp
toolkit/components/downloads/ApplicationReputation.cpp
toolkit/components/url-classifier/Classifier.cpp
toolkit/components/url-classifier/HashStore.cpp
toolkit/components/url-classifier/ProtocolParser.cpp
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp
toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
uriloader/base/nsDocLoader.cpp
uriloader/base/nsURILoader.cpp
uriloader/exthandler/nsExternalHelperAppService.cpp
uriloader/prefetch/nsOfflineCacheUpdate.cpp
uriloader/prefetch/nsOfflineCacheUpdateService.cpp
uriloader/prefetch/nsPrefetchService.cpp
widget/ContentCache.cpp
widget/cocoa/NativeKeyBindings.mm
widget/cocoa/TextInputHandler.mm
widget/gtk/IMContextWrapper.cpp
widget/gtk/nsDragService.cpp
widget/gtk/nsGtkKeyUtils.cpp
widget/gtk/nsWindow.cpp
widget/nsIdleService.cpp
widget/xremoteclient/XRemoteClient.cpp
xpcom/base/Logging.cpp
xpcom/base/Logging.h
xpcom/io/nsInputStreamTee.cpp
xpcom/io/nsPipe3.cpp
xpcom/io/nsStorageStream.cpp
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -85,18 +85,18 @@ public:
     // TODO : remove b2g related event in bug1299390.
     observerService->NotifyObservers(wrapper,
                                      "media-playback",
                                      mActive
                                        ? u"active"
                                        : u"inactive");
 
     MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-           ("NotifyChannelActiveRunnable, type = %d, active = %d\n",
-            mAudioChannel, mActive));
+           ("NotifyChannelActiveRunnable, type = %" PRIu32 ", active = %d\n",
+            static_cast<uint32_t>(mAudioChannel), mActive));
 
     return NS_OK;
   }
 
 private:
   const uint64_t mWindowID;
   const AudioChannel mAudioChannel;
   const bool mActive;
@@ -842,18 +842,18 @@ AudioChannelService::SetAudioChannelVolu
                                            AudioChannel aAudioChannel,
                                            float aVolume)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aWindow->IsOuterWindow());
 
   MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
-         ("AudioChannelService, SetAudioChannelVolume, window = %p, type = %d, "
-          "volume = %f\n", aWindow, aAudioChannel, aVolume));
+         ("AudioChannelService, SetAudioChannelVolume, window = %p, type = %" PRIu32 ", "
+          "volume = %f\n", aWindow, static_cast<uint32_t>(aAudioChannel), aVolume));
 
   AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
   winData->mChannels[(uint32_t)aAudioChannel].mVolume = aVolume;
   RefreshAgentsVolumeAndPropagate(aAudioChannel, aWindow);
 }
 
 NS_IMETHODIMP
 AudioChannelService::SetAudioChannelVolume(mozIDOMWindowProxy* aWindow,
@@ -903,18 +903,18 @@ AudioChannelService::SetAudioChannelMute
                                           AudioChannel aAudioChannel,
                                           bool aMuted)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aWindow->IsOuterWindow());
 
   MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
-         ("AudioChannelService, SetAudioChannelMuted, window = %p, type = %d, "
-          "mute = %d\n", aWindow, aAudioChannel, aMuted));
+         ("AudioChannelService, SetAudioChannelMuted, window = %p, type = %" PRIu32 ", "
+          "mute = %d\n", aWindow, static_cast<uint32_t>(aAudioChannel), aMuted));
 
   if (aAudioChannel == AudioChannel::System) {
     // Workaround for bug1183033, system channel type can always playback.
     return;
   }
 
   AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
   winData->mChannels[(uint32_t)aAudioChannel].mMuted = aMuted;
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -80,16 +80,17 @@
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/PluginCrashedEvent.h"
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventStates.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/HTMLObjectElementBinding.h"
 #include "mozilla/dom/HTMLSharedObjectElement.h"
 #include "mozilla/dom/HTMLObjectElement.h"
 #include "nsChannelClassifier.h"
 
 #ifdef XP_WIN
 // Thanks so much, Microsoft! :(
@@ -807,17 +808,17 @@ nsObjectLoadingContent::InstantiatePlugi
     nsCOMPtr<nsIBlocklistService> blocklist =
       do_GetService("@mozilla.org/extensions/blocklist;1");
     if (blocklist) {
       uint32_t blockState = nsIBlocklistService::STATE_NOT_BLOCKED;
       blocklist->GetPluginBlocklistState(pluginTag, EmptyString(),
                                          EmptyString(), &blockState);
       if (blockState == nsIBlocklistService::STATE_OUTDATED) {
         // Fire plugin outdated event if necessary
-        LOG(("OBJLC [%p]: Dispatching plugin outdated event for content %p\n",
+        LOG(("OBJLC [%p]: Dispatching plugin outdated event for content\n",
              this));
         nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(thisContent,
                                                      NS_LITERAL_STRING("PluginOutdated"));
         nsresult rv = NS_DispatchToCurrentThread(ev);
         if (NS_FAILED(rv)) {
           NS_WARNING("failed to dispatch nsSimplePluginEvent");
         }
       }
@@ -2419,17 +2420,18 @@ nsObjectLoadingContent::LoadObject(bool 
                                   getter_AddRefs(finalListener));
       // finalListener will receive OnStartRequest below
     }
     break;
     case eType_Loading:
       // If our type remains Loading, we need a channel to proceed
       rv = OpenChannel();
       if (NS_FAILED(rv)) {
-        LOG(("OBJLC [%p]: OpenChannel returned failure (%u)", this, rv));
+        LOG(("OBJLC [%p]: OpenChannel returned failure (%" PRIu32 ")",
+             this, static_cast<uint32_t>(rv)));
       }
     break;
     case eType_Null:
       // Handled below, silence compiler warnings
     break;
   }
 
   //
@@ -2697,17 +2699,17 @@ nsObjectLoadingContent::UnloadObject(boo
 }
 
 void
 nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
                                            EventStates aOldState,
                                            bool aSync,
                                            bool aNotify)
 {
-  LOG(("OBJLC [%p]: Notifying about state change: (%u, %llx) -> (%u, %llx)"
+  LOG(("OBJLC [%p]: Notifying about state change: (%u, %" PRIx64 ") -> (%u, %" PRIx64 ")"
        " (sync %i, notify %i)", this, aOldType, aOldState.GetInternalValue(),
        mType, ObjectState().GetInternalValue(), aSync, aNotify));
 
   nsCOMPtr<nsIContent> thisContent =
     do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
   NS_ASSERTION(thisContent, "must be a content");
 
   NS_ASSERTION(thisContent->IsElement(), "Not an element?");
--- a/dom/browser-element/BrowserElementAudioChannel.cpp
+++ b/dom/browser-element/BrowserElementAudioChannel.cpp
@@ -50,18 +50,18 @@ BrowserElementAudioChannel::Create(nsPID
     new BrowserElementAudioChannel(aWindow, aFrameLoader, aAPI, aAudioChannel);
 
   aRv = ac->Initialize();
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-         ("BrowserElementAudioChannel, Create, channel = %p, type = %d\n",
-          ac.get(), aAudioChannel));
+         ("BrowserElementAudioChannel, Create, channel = %p, type = %" PRIu32 "\n",
+          ac.get(), static_cast<uint32_t>(aAudioChannel)));
 
   return ac.forget();
 }
 
 BrowserElementAudioChannel::BrowserElementAudioChannel(
 						nsPIDOMWindowInner* aWindow,
 						nsIFrameLoader* aFrameLoader,
                                                 nsIBrowserElementAPI* aAPI,
@@ -509,17 +509,17 @@ BrowserElementAudioChannel::Observe(nsIS
   return NS_OK;
 }
 
 void
 BrowserElementAudioChannel::ProcessStateChanged(const char16_t* aData)
 {
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
          ("BrowserElementAudioChannel, ProcessStateChanged, this = %p, "
-          "type = %d\n", this, mAudioChannel));
+          "type = %" PRIu32 "\n", this, static_cast<uint32_t>(mAudioChannel)));
 
   nsAutoString value(aData);
   mState = value.EqualsASCII("active") ? eStateActive : eStateInactive;
   DispatchTrustedEvent(NS_LITERAL_STRING("activestatechanged"));
 }
 
 bool
 BrowserElementAudioChannel::IsSystemAppWindow(nsPIDOMWindowOuter* aWindow) const
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -9,16 +9,17 @@
 #include "mozilla/IMEStateManager.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/HTMLFormElement.h"
 #include "mozilla/dom/TabParent.h"
 
 #include "HTMLInputElement.h"
 #include "IMEContentObserver.h"
@@ -157,17 +158,17 @@ IMEStateManager::Init()
     false);
 }
 
 // static
 void
 IMEStateManager::Shutdown()
 {
   MOZ_LOG(sISMLog, LogLevel::Info,
-    ("Shutdown(), sTextCompositions=0x%p, sTextCompositions->Length()=%u",
+    ("Shutdown(), sTextCompositions=0x%p, sTextCompositions->Length()=%" PRIuSIZE,
      sTextCompositions, sTextCompositions ? sTextCompositions->Length() : 0));
 
   MOZ_ASSERT(!sTextCompositions || !sTextCompositions->Length());
   delete sTextCompositions;
   sTextCompositions = nullptr;
 }
 
 // static
@@ -259,17 +260,17 @@ IMEStateManager::OnDestroyPresContext(ns
 
   // First, if there is a composition in the aPresContext, clean up it.
   if (sTextCompositions) {
     TextCompositionArray::index_type i =
       sTextCompositions->IndexOf(aPresContext);
     if (i != TextCompositionArray::NoIndex) {
       MOZ_LOG(sISMLog, LogLevel::Debug,
         ("  OnDestroyPresContext(), "
-         "removing TextComposition instance from the array (index=%u)", i));
+         "removing TextComposition instance from the array (index=%" PRIuSIZE ")", i));
       // there should be only one composition per presContext object.
       sTextCompositions->ElementAt(i)->Destroy();
       sTextCompositions->RemoveElementAt(i);
       if (sTextCompositions->IndexOf(aPresContext) !=
             TextCompositionArray::NoIndex) {
         MOZ_LOG(sISMLog, LogLevel::Error,
           ("  OnDestroyPresContext(), FAILED to remove "
            "TextComposition instance from the array"));
@@ -909,17 +910,17 @@ IMEStateManager::SetInputContextForChild
                    TabParent* aTabParent,
                    const InputContext& aInputContext,
                    const InputContextAction& aAction)
 {
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("SetInputContextForChildProcess(aTabParent=0x%p, "
      "aInputContext={ mIMEState={ mEnabled=%s, mOpen=%s }, "
      "mHTMLInputType=\"%s\", mHTMLInputInputmode=\"%s\", mActionHint=\"%s\" }, "
-     "aAction={ mCause=%s, mAction=%s }, aTabParent=0x%p), sPresContext=0x%p, "
+     "aAction={ mCause=%s, mAction=%s }), sPresContext=0x%p, "
      "sActiveTabParent=0x%p",
      aTabParent, GetIMEStateEnabledName(aInputContext.mIMEState.mEnabled),
      GetIMEStateSetOpenName(aInputContext.mIMEState.mOpen),
      NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputType).get(),
      NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputInputmode).get(),
      NS_ConvertUTF16toUTF8(aInputContext.mActionHint).get(),
      GetActionCauseName(aAction.mCause),
      GetActionFocusChangeName(aAction.mFocusChange),
@@ -1100,20 +1101,20 @@ IMEStateManager::DispatchCompositionEven
 {
   RefPtr<TabParent> tabParent =
     aEventTargetNode->IsContent() ?
       TabParent::GetFrom(aEventTargetNode->AsContent()) : nullptr;
 
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("DispatchCompositionEvent(aNode=0x%p, "
      "aPresContext=0x%p, aCompositionEvent={ mMessage=%s, "
-     "mNativeIMEContext={ mRawNativeIMEContext=0x%X, "
-     "mOriginProcessID=0x%X }, mWidget(0x%p)={ "
-     "GetNativeIMEContext()={ mRawNativeIMEContext=0x%X, "
-     "mOriginProcessID=0x%X }, Destroyed()=%s }, "
+     "mNativeIMEContext={ mRawNativeIMEContext=0x%" PRIXPTR ", "
+     "mOriginProcessID=0x%" PRIX64 " }, mWidget(0x%p)={ "
+     "GetNativeIMEContext()={ mRawNativeIMEContext=0x%" PRIXPTR ", "
+     "mOriginProcessID=0x%" PRIX64 " }, Destroyed()=%s }, "
      "mFlags={ mIsTrusted=%s, mPropagationStopped=%s } }, "
      "aIsSynthesized=%s), tabParent=%p",
      aEventTargetNode, aPresContext,
      ToChar(aCompositionEvent->mMessage),
      aCompositionEvent->mNativeIMEContext.mRawNativeIMEContext,
      aCompositionEvent->mNativeIMEContext.mOriginProcessID,
      aCompositionEvent->mWidget.get(),
      aCompositionEvent->mWidget->GetNativeIMEContext().mRawNativeIMEContext,
@@ -1250,20 +1251,20 @@ void
 IMEStateManager::OnCompositionEventDiscarded(
                    WidgetCompositionEvent* aCompositionEvent)
 {
   // Note that this method is never called for synthesized events for emulating
   // commit or cancel composition.
 
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("OnCompositionEventDiscarded(aCompositionEvent={ "
-     "mMessage=%s, mNativeIMEContext={ mRawNativeIMEContext=0x%X, "
-     "mOriginProcessID=0x%X }, mWidget(0x%p)={ "
-     "GetNativeIMEContext()={ mRawNativeIMEContext=0x%X, "
-     "mOriginProcessID=0x%X }, Destroyed()=%s }, "
+     "mMessage=%s, mNativeIMEContext={ mRawNativeIMEContext=0x%" PRIXPTR ", "
+     "mOriginProcessID=0x%" PRIX64 " }, mWidget(0x%p)={ "
+     "GetNativeIMEContext()={ mRawNativeIMEContext=0x%" PRIXPTR ", "
+     "mOriginProcessID=0x%" PRIX64 " }, Destroyed()=%s }, "
      "mFlags={ mIsTrusted=%s } })",
      ToChar(aCompositionEvent->mMessage),
      aCompositionEvent->mNativeIMEContext.mRawNativeIMEContext,
      aCompositionEvent->mNativeIMEContext.mOriginProcessID,
      aCompositionEvent->mWidget.get(),
      aCompositionEvent->mWidget->GetNativeIMEContext().mRawNativeIMEContext,
      aCompositionEvent->mWidget->GetNativeIMEContext().mOriginProcessID,
      GetBoolName(aCompositionEvent->mWidget->Destroyed()),
--- a/dom/flyweb/FlyWebPublishedServer.cpp
+++ b/dom/flyweb/FlyWebPublishedServer.cpp
@@ -176,17 +176,17 @@ FlyWebPublishedServerImpl::FlyWebPublish
         AbstractThread::MainThread()))
 {
   LOG_I("FlyWebPublishedServerImpl::FlyWebPublishedServerImpl(%p)", this);
 }
 
 void
 FlyWebPublishedServerImpl::PermissionGranted(bool aGranted)
 {
-  LOG_I("FlyWebPublishedServerImpl::PermissionGranted(%b)", aGranted);
+  LOG_I("FlyWebPublishedServerImpl::PermissionGranted(%d)", aGranted);
   if (!aGranted) {
     PublishedServerStarted(NS_ERROR_FAILURE);
     return;
   }
 
   mHttpServer->Init(-1, Preferences::GetBool("flyweb.use-tls", false), this);
 }
 
--- a/dom/flyweb/HttpServer.cpp
+++ b/dom/flyweb/HttpServer.cpp
@@ -148,17 +148,18 @@ HttpServer::OnSocketAccepted(nsIServerSo
 }
 
 NS_IMETHODIMP
 HttpServer::OnStopListening(nsIServerSocket* aServ,
                             nsresult aStatus)
 {
   MOZ_ASSERT(aServ == mServerSocket || !mServerSocket);
 
-  LOG_I("HttpServer::OnStopListening(%p) - status 0x%lx", this, aStatus);
+  LOG_I("HttpServer::OnStopListening(%p) - status 0x%" PRIx32,
+        this, static_cast<uint32_t>(aStatus));
 
   Close();
 
   return NS_OK;
 }
 
 void
 HttpServer::SendResponse(InternalRequest* aRequest, InternalResponse* aResponse)
@@ -1254,18 +1255,18 @@ HttpServer::Connection::OnOutputStreamRe
       RefPtr<Connection> self = this;
 
       mOutputCopy->
         Then(mServer->mAbstractMainThread,
              __func__,
              [self, this] (nsresult aStatus) {
                MOZ_ASSERT(mOutputBuffers[0].mStream);
                LOG_V("HttpServer::Connection::OnOutputStreamReady(%p) - "
-                     "Sent body. Status 0x%lx",
-                     this, aStatus);
+                     "Sent body. Status 0x%" PRIx32,
+                     this, static_cast<uint32_t>(aStatus));
 
                mOutputBuffers.RemoveElementAt(0);
                mOutputCopy = nullptr;
                OnOutputStreamReady(mOutput);
              },
              [] (bool) { MOZ_ASSERT_UNREACHABLE("Reject unexpected"); });
     }
   }
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -7226,22 +7226,22 @@ HTMLMediaElement::MarkAsContentSource(Ca
         }
       }
       break;
     }
   }
 
   LOG(LogLevel::Debug,
       ("%p Log VIDEO_AS_CONTENT_SOURCE: visibility = %u, API: '%d' and 'All'",
-       this, isVisible, aAPI));
+       this, isVisible, static_cast<int>(aAPI)));
 
   if (!isVisible) {
     LOG(LogLevel::Debug,
         ("%p Log VIDEO_AS_CONTENT_SOURCE_IN_TREE_OR_NOT: inTree = %u, API: '%d' and 'All'",
-         this, IsInUncomposedDoc(), aAPI));
+         this, IsInUncomposedDoc(), static_cast<int>(aAPI)));
   }
 }
 
 void
 HTMLMediaElement::UpdateCustomPolicyAfterPlayed()
 {
   OpenUnsupportedMediaWithExternalAppIfNeeded();
   if (mAudioChannelWrapper) {
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -7,16 +7,17 @@
 #include "mozilla/dom/TextTrackManager.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "mozilla/dom/HTMLTrackElement.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "mozilla/dom/TextTrack.h"
 #include "mozilla/dom/TextTrackCue.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/ClearOnShutdown.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Telemetry.h"
 #include "nsComponentManagerUtils.h"
 #include "nsVariant.h"
 #include "nsVideoFrame.h"
 #include "nsIFrame.h"
 #include "nsTArrayHelpers.h"
 #include "nsIWebVTTParserWrapper.h"
 
@@ -153,17 +154,18 @@ TextTrackManager::AddTextTrack(TextTrack
                                TextTrackMode aMode,
                                TextTrackReadyState aReadyState,
                                TextTrackSource aTextTrackSource)
 {
   if (!mMediaElement || !mTextTracks) {
     return nullptr;
   }
   WEBVTT_LOG("%p AddTextTrack",this);
-  WEBVTT_LOGV("AddTextTrack kind %d Label %s Language %s",aKind,
+  WEBVTT_LOGV("AddTextTrack kind %" PRIu32 " Label %s Language %s",
+    static_cast<uint32_t>(aKind),
     NS_ConvertUTF16toUTF8(aLabel).get(), NS_ConvertUTF16toUTF8(aLanguage).get());
   RefPtr<TextTrack> track =
     mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aMode, aReadyState,
                               aTextTrackSource, CompareTextTracks(mMediaElement));
   AddCues(track);
   ReportTelemetryForTrack(track);
 
   if (aTextTrackSource == TextTrackSource::Track) {
@@ -273,17 +275,17 @@ TextTrackManager::UpdateCueDisplay()
     return;
   }
 
   nsTArray<RefPtr<TextTrackCue> > activeCues;
   mTextTracks->GetShowingCues(activeCues);
 
   if (activeCues.Length() > 0) {
     WEBVTT_LOG("UpdateCueDisplay ProcessCues");
-    WEBVTT_LOGV("UpdateCueDisplay activeCues.Length() %d",activeCues.Length());
+    WEBVTT_LOGV("UpdateCueDisplay activeCues.Length() %" PRIuSIZE, activeCues.Length());
     RefPtr<nsVariantCC> jsCues = new nsVariantCC();
 
     jsCues->SetAsArray(nsIDataType::VTYPE_INTERFACE,
                        &NS_GET_IID(nsIDOMEventTarget),
                        activeCues.Length(),
                        static_cast<void*>(activeCues.Elements()));
     nsPIDOMWindowInner* window = mMediaElement->OwnerDoc()->GetInnerWindow();
     if (window) {
@@ -402,29 +404,31 @@ TextTrackManager::PerformTrackSelection(
                                         uint32_t size)
 {
   nsTArray<TextTrack*> candidates;
   GetTextTracksOfKinds(aTextTrackKinds, size, candidates);
 
   // Step 3: If any TextTracks in candidates are showing then abort these steps.
   for (uint32_t i = 0; i < candidates.Length(); i++) {
     if (candidates[i]->Mode() == TextTrackMode::Showing) {
-      WEBVTT_LOGV("PerformTrackSelection Showing return kind %d",candidates[i]->Kind());
+      WEBVTT_LOGV("PerformTrackSelection Showing return kind %d",
+                  static_cast<int>(candidates[i]->Kind()));
       return;
     }
   }
 
   // Step 4: Honor user preferences for track selection, otherwise, set the
   // first TextTrack in candidates with a default attribute to showing.
   // TODO: Bug 981691 - Honor user preferences for text track selection.
   for (uint32_t i = 0; i < candidates.Length(); i++) {
     if (TrackIsDefault(candidates[i]) &&
         candidates[i]->Mode() == TextTrackMode::Disabled) {
       candidates[i]->SetMode(TextTrackMode::Showing);
-      WEBVTT_LOGV("PerformTrackSelection set Showing kind %d", candidates[i]->Kind());
+      WEBVTT_LOGV("PerformTrackSelection set Showing kind %d",
+                  static_cast<int>(candidates[i]->Kind()));
       return;
     }
   }
 }
 
 void
 TextTrackManager::GetTextTracksOfKinds(TextTrackKind aTextTrackKinds[],
                                        uint32_t size,
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -12616,17 +12616,17 @@ ConnectionPool::ShutdownThread(ThreadInf
   MOZ_ASSERT(mTotalThreadCount);
 
   RefPtr<ThreadRunnable> runnable;
   aThreadInfo.mRunnable.swap(runnable);
 
   nsCOMPtr<nsIThread> thread;
   aThreadInfo.mThread.swap(thread);
 
-  IDB_DEBUG_LOG(("ConnectionPool shutting down thread %lu",
+  IDB_DEBUG_LOG(("ConnectionPool shutting down thread %" PRIu32,
                  runnable->SerialNumber()));
 
   // This should clean up the thread with the profiler.
   MOZ_ALWAYS_SUCCEEDS(thread->Dispatch(runnable.forget(),
                                        NS_DISPATCH_NORMAL));
 
   MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(
                         NewRunnableMethod(thread, &nsIThread::Shutdown)));
@@ -12717,17 +12717,17 @@ ConnectionPool::ScheduleTransaction(Tran
 
         nsCOMPtr<nsIThread> newThread;
         nsresult rv =
           NS_NewNamedThread(runnable->GetThreadName(),
                             getter_AddRefs(newThread), runnable);
         if (NS_SUCCEEDED(rv)) {
           MOZ_ASSERT(newThread);
 
-          IDB_DEBUG_LOG(("ConnectionPool created thread %lu",
+          IDB_DEBUG_LOG(("ConnectionPool created thread %" PRIu32,
                          runnable->SerialNumber()));
 
           dbInfo->mThreadInfo.mThread.swap(newThread);
           dbInfo->mThreadInfo.mRunnable.swap(runnable);
 
           mTotalThreadCount++;
           created = true;
         } else {
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -501,18 +501,18 @@ TabChild::Observe(nsISupports *aSubject,
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     // In theory a tabChild should contain just 1 top window, but let's double
     // check it comparing the windowID.
     if (window->WindowID() != windowID) {
       MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
-              ("TabChild, Observe, different windowID, owner ID = %lld, "
-               "ID from wrapper = %lld", window->WindowID(), windowID));
+              ("TabChild, Observe, different windowID, owner ID = %" PRIu64 ", "
+               "ID from wrapper = %" PRIu64, window->WindowID(), windowID));
       return NS_OK;
     }
 
     nsAutoString activeStr(aData);
     bool active = activeStr.EqualsLiteral("active");
     if (active != mAudioChannelsActive[audioChannel]) {
       mAudioChannelsActive[audioChannel] = active;
       Unused << SendAudioChannelActivityNotification(audioChannel, active);
--- a/dom/media/ADTSDemuxer.cpp
+++ b/dom/media/ADTSDemuxer.cpp
@@ -7,16 +7,17 @@
 #include "ADTSDemuxer.h"
 
 #include <inttypes.h>
 
 #include "nsAutoPtr.h"
 #include "VideoUtils.h"
 #include "TimeUnits.h"
 #include "prenv.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #ifdef PR_LOGGING
 extern mozilla::LazyLogModule gMediaDemuxerLog;
 #define ADTSLOG(msg, ...) \
   MOZ_LOG(gMediaDemuxerLog, LogLevel::Debug, ("ADTSDemuxer " msg, ##__VA_ARGS__))
 #define ADTSLOGV(msg, ...) \
   MOZ_LOG(gMediaDemuxerLog, LogLevel::Verbose, ("ADTSDemuxer " msg, ##__VA_ARGS__))
 #else
@@ -471,18 +472,18 @@ ADTSTrackDemuxer::FastSeek(const media::
   if (mOffset > firstFrameOffset && StreamLength() > 0) {
     mOffset = std::min(StreamLength() - 1, mOffset);
   }
 
   mFrameIndex = FrameIndexFromOffset(mOffset);
   mParser->EndFrameSession();
 
   ADTSLOG("FastSeek End avgFrameLen=%f mNumParsedFrames=%" PRIu64
-          " mFrameIndex=%" PRId64 " mFirstFrameOffset=%llu mOffset=%" PRIu64
-          " SL=%llu",
+          " mFrameIndex=%" PRId64 " mFirstFrameOffset=%" PRIu64 " mOffset=%" PRIu64
+          " SL=%" PRIu64 "",
           AverageFrameLength(), mNumParsedFrames, mFrameIndex,
           firstFrameOffset, mOffset, StreamLength());
 
   return Duration(mFrameIndex);
 }
 
 media::TimeUnit
 ADTSTrackDemuxer::ScanUntil(const media::TimeUnit& aTime)
@@ -531,17 +532,17 @@ ADTSTrackDemuxer::GetSamples(int32_t aNu
   while (aNumSamples--) {
     RefPtr<MediaRawData> frame(GetNextFrame(FindNextFrame()));
     if (!frame)
       break;
 
     frames->mSamples.AppendElement(frame);
   }
 
-  ADTSLOGV("GetSamples() End mSamples.Size()=%d aNumSamples=%d mOffset=%" PRIu64
+  ADTSLOGV("GetSamples() End mSamples.Size()=%" PRIuSIZE " aNumSamples=%d mOffset=%" PRIu64
            " mNumParsedFrames=%" PRIu64 " mFrameIndex=%" PRId64
            " mTotalFrameLen=%" PRIu64
            " mSamplesPerFrame=%d mSamplesPerSecond=%d "
            "mChannels=%d",
            frames->mSamples.Length(), aNumSamples, mOffset, mNumParsedFrames,
            mFrameIndex, mTotalFrameLen, mSamplesPerFrame, mSamplesPerSecond,
            mChannels);
 
@@ -687,24 +688,24 @@ ADTSTrackDemuxer::FindNextFrame(bool fin
     if (frameHeaderOffset + advance <= frameHeaderOffset) {
       break;
     }
 
     frameHeaderOffset += advance;
   }
 
   if (!foundFrame || !mParser->CurrentFrame().Length()) {
-    ADTSLOG("FindNext() Exit foundFrame=%d mParser->CurrentFrame().Length()=%d ",
+    ADTSLOG("FindNext() Exit foundFrame=%d mParser->CurrentFrame().Length()=%" PRIuSIZE " ",
            foundFrame, mParser->CurrentFrame().Length());
     mParser->Reset();
     return mParser->CurrentFrame();
   }
 
   ADTSLOGV("FindNext() End mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-          " mFrameIndex=%" PRId64 " frameHeaderOffset=%d"
+          " mFrameIndex=%" PRId64 " frameHeaderOffset=%" PRId64
           " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d"
           " mChannels=%d",
           mOffset, mNumParsedFrames, mFrameIndex, frameHeaderOffset,
           mTotalFrameLen, mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   return mParser->CurrentFrame();
 }
 
@@ -725,17 +726,18 @@ ADTSTrackDemuxer::SkipNextFrame(const ad
           mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   return true;
 }
 
 already_AddRefed<MediaRawData>
 ADTSTrackDemuxer::GetNextFrame(const adts::Frame& aFrame)
 {
-  ADTSLOG("GetNext() Begin({mOffset=%" PRId64 " HeaderSize()=%d Length()=%d})",
+  ADTSLOG("GetNext() Begin({mOffset=%" PRId64 " HeaderSize()=%" PRIuSIZE
+          " Length()=%" PRIuSIZE "})",
          aFrame.Offset(), aFrame.Header().HeaderSize(), aFrame.PayloadLength());
   if (!aFrame.IsValid())
     return nullptr;
 
   const int64_t offset = aFrame.PayloadOffset();
   const uint32_t length = aFrame.PayloadLength();
 
   RefPtr<MediaRawData> frame = new MediaRawData();
@@ -744,17 +746,17 @@ ADTSTrackDemuxer::GetNextFrame(const adt
   nsAutoPtr<MediaRawDataWriter> frameWriter(frame->CreateWriter());
   if (!frameWriter->SetSize(length)) {
     ADTSLOG("GetNext() Exit failed to allocated media buffer");
     return nullptr;
   }
 
   const uint32_t read = Read(frameWriter->Data(), offset, length);
   if (read != length) {
-    ADTSLOG("GetNext() Exit read=%u frame->Size()=%u", read, frame->Size());
+    ADTSLOG("GetNext() Exit read=%u frame->Size()=%" PRIuSIZE, read, frame->Size());
     return nullptr;
   }
 
   UpdateState(aFrame);
 
   frame->mTime = Duration(mFrameIndex - 1).ToMicroseconds();
   frame->mDuration = Duration(1).ToMicroseconds();
   frame->mTimecode = frame->mTime;
--- a/dom/media/Latency.cpp
+++ b/dom/media/Latency.cpp
@@ -185,21 +185,21 @@ AsyncLatencyLogger::Observe(nsISupports*
 }
 
 // aID is a sub-identifier (in particular a specific MediaStramTrack)
 void AsyncLatencyLogger::WriteLog(LatencyLogIndex aIndex, uint64_t aID, int64_t aValue,
                                   TimeStamp aTimeStamp)
 {
   if (aTimeStamp.IsNull()) {
     MOZ_LOG(GetLatencyLog(), LogLevel::Debug,
-      ("Latency: %s,%llu,%lld,%lld",
+      ("Latency: %s,%" PRIu64 ",%" PRId64 ",%" PRId64,
        LatencyLogIndex2Strings[aIndex], aID, GetTimeStamp(), aValue));
   } else {
     MOZ_LOG(GetLatencyLog(), LogLevel::Debug,
-      ("Latency: %s,%llu,%lld,%lld,%lld",
+      ("Latency: %s,%" PRIu64 ",%" PRId64 ",%" PRId64 ",%" PRId64,
        LatencyLogIndex2Strings[aIndex], aID, GetTimeStamp(), aValue,
        static_cast<int64_t>((aTimeStamp - gAsyncLogger->mStart).ToMilliseconds())));
   }
 }
 
 int64_t AsyncLatencyLogger::GetTimeStamp()
 {
   TimeDuration t = TimeStamp::Now() - mStart;
--- a/dom/media/MP3Demuxer.cpp
+++ b/dom/media/MP3Demuxer.cpp
@@ -6,16 +6,17 @@
 
 #include "MP3Demuxer.h"
 
 #include <inttypes.h>
 #include <algorithm>
 
 #include "mozilla/Assertions.h"
 #include "mozilla/EndianUtils.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "nsAutoPtr.h"
 #include "VideoUtils.h"
 #include "TimeUnits.h"
 #include "prenv.h"
 
 #ifdef PR_LOGGING
 extern mozilla::LazyLogModule gMediaDemuxerLog;
 #define MP3LOG(msg, ...) \
@@ -233,18 +234,18 @@ MP3TrackDemuxer::FastSeek(const TimeUnit
 
   if (mOffset > mFirstFrameOffset && StreamLength() > 0) {
     mOffset = std::min(StreamLength() - 1, mOffset);
   }
 
   mParser.EndFrameSession();
 
   MP3LOG("FastSeek End TOC=%d avgFrameLen=%f mNumParsedFrames=%" PRIu64
-         " mFrameIndex=%" PRId64 " mFirstFrameOffset=%llu mOffset=%" PRIu64
-         " SL=%llu NumBytes=%u",
+         " mFrameIndex=%" PRId64 " mFirstFrameOffset=%" PRId64 " mOffset=%" PRIu64
+         " SL=%" PRId64 " NumBytes=%u",
          vbr.IsTOCPresent(), AverageFrameLength(), mNumParsedFrames, mFrameIndex,
          mFirstFrameOffset, mOffset, StreamLength(), vbr.NumBytes().valueOr(0));
 
   return Duration(mFrameIndex);
 }
 
 TimeUnit
 MP3TrackDemuxer::ScanUntil(const TimeUnit& aTime)
@@ -304,17 +305,17 @@ MP3TrackDemuxer::GetSamples(int32_t aNum
     RefPtr<MediaRawData> frame(GetNextFrame(FindNextFrame()));
     if (!frame) {
       break;
     }
 
     frames->mSamples.AppendElement(frame);
   }
 
-  MP3LOGV("GetSamples() End mSamples.Size()=%d aNumSamples=%d mOffset=%" PRIu64
+  MP3LOGV("GetSamples() End mSamples.Size()=%" PRIuSIZE " aNumSamples=%d mOffset=%" PRIu64
           " mNumParsedFrames=%" PRIu64 " mFrameIndex=%" PRId64
           " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
           "mChannels=%d",
           frames->mSamples.Length(), aNumSamples, mOffset, mNumParsedFrames,
           mFrameIndex, mTotalFrameLen, mSamplesPerFrame, mSamplesPerSecond,
           mChannels);
 
   if (frames->mSamples.IsEmpty()) {
@@ -546,17 +547,17 @@ MP3TrackDemuxer::FindNextFrame()
 
   if (!foundFrame || !mParser.CurrentFrame().Length()) {
     MP3LOG("FindNext() Exit foundFrame=%d mParser.CurrentFrame().Length()=%d ",
            foundFrame, mParser.CurrentFrame().Length());
     return { 0, 0 };
   }
 
   MP3LOGV("FindNext() End mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-          " mFrameIndex=%" PRId64 " frameHeaderOffset=%d"
+          " mFrameIndex=%" PRId64 " frameHeaderOffset=%" PRId64
           " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d"
           " mChannels=%d",
           mOffset, mNumParsedFrames, mFrameIndex, frameHeaderOffset,
           mTotalFrameLen, mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   return { frameHeaderOffset, frameHeaderOffset + mParser.CurrentFrame().Length() };
 }
 
@@ -597,17 +598,17 @@ MP3TrackDemuxer::GetNextFrame(const Medi
     MP3LOG("GetNext() Exit failed to allocated media buffer");
     return nullptr;
   }
 
   const uint32_t read =
     Read(frameWriter->Data(), frame->mOffset, frame->Size());
 
   if (read != aRange.Length()) {
-    MP3LOG("GetNext() Exit read=%u frame->Size()=%u", read, frame->Size());
+    MP3LOG("GetNext() Exit read=%u frame->Size()=%" PRIuSIZE, read, frame->Size());
     return nullptr;
   }
 
   UpdateState(aRange);
 
   frame->mTime = Duration(mFrameIndex - 1).ToMicroseconds();
   frame->mDuration = Duration(1).ToMicroseconds();
   frame->mTimecode = frame->mTime;
@@ -831,17 +832,17 @@ FrameParser::Parse(ByteReader* aReader, 
       // ID3 tag found, skip past it.
       const uint32_t skipSize = tagSize - ID3Parser::ID3Header::SIZE;
 
       if (skipSize > aReader->Remaining()) {
         // Skipping across the ID3v2 tag would take us past the end of the
         // buffer, therefore we return immediately and let the calling function
         // handle skipping the rest of the tag.
         MP3LOGV("ID3v2 tag detected, size=%d,"
-                " needing to skip %d bytes past the current buffer",
+                " needing to skip %" PRIuSIZE " bytes past the current buffer",
                 tagSize, skipSize - aReader->Remaining());
         *aBytesToSkip = skipSize - aReader->Remaining();
         return false;
       }
       MP3LOGV("ID3v2 tag detected, size=%d", tagSize);
       aReader->Read(skipSize);
     } else {
       // No ID3v2 tag found, rewinding reader in order to search for a MPEG
@@ -1243,17 +1244,17 @@ FrameParser::VBRHeader::ParseVBRI(ByteRe
 }
 
 bool
 FrameParser::VBRHeader::Parse(ByteReader* aReader)
 {
   const bool rv = ParseVBRI(aReader) || ParseXing(aReader);
   if (rv) {
     MP3LOG("VBRHeader::Parse found valid VBR/CBR header: type=%s"
-           " NumAudioFrames=%u NumBytes=%u Scale=%u TOC-size=%u",
+           " NumAudioFrames=%u NumBytes=%u Scale=%u TOC-size=%" PRIuSIZE,
            vbr_header::TYPE_STR[Type()], NumAudioFrames().valueOr(0),
            NumBytes().valueOr(0), Scale().valueOr(0), mTOC.size());
   }
   return rv;
 }
 
 // FrameParser::Frame
 
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1269,17 +1269,18 @@ MediaCache::Update()
         for (uint32_t j = 0; j < i; ++j) {
           MediaCacheStream* other = mStreams[j];
           if (other->mResourceID == stream->mResourceID &&
               !other->mClosed && !other->mClient->IsSuspended() &&
               other->mChannelOffset/BLOCK_SIZE == desiredOffset/BLOCK_SIZE) {
             // This block is already going to be read by the other stream.
             // So don't try to read it from this stream as well.
             enableReading = false;
-            CACHE_LOG(LogLevel::Debug, ("Stream %p waiting on same block (%lld) from stream %p",
+            CACHE_LOG(LogLevel::Debug, ("Stream %p waiting on same block (%"
+                                        PRId64 ") from stream %p",
                                      stream, desiredOffset/BLOCK_SIZE, other));
             break;
           }
         }
       }
 
       if (stream->mChannelOffset != desiredOffset && enableReading) {
         // We need to seek now.
@@ -1832,18 +1833,18 @@ MediaCacheStream::FlushPartialBlockInter
                                             ReentrantMonitorAutoEnter& aReentrantMonitor)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
   int32_t blockOffset = int32_t(mChannelOffset%BLOCK_SIZE);
   if (blockOffset > 0) {
     CACHE_LOG(LogLevel::Debug,
               ("Stream %p writing partial block: [%d] bytes; "
-               "mStreamOffset [%lld] mChannelOffset[%lld] mStreamLength [%lld] "
-               "notifying: [%s]",
+               "mStreamOffset [%" PRId64 "] mChannelOffset[%"
+               PRId64 "] mStreamLength [%" PRId64 "] notifying: [%s]",
                this, blockOffset, mStreamOffset, mChannelOffset, mStreamLength,
                aNotifyAll ? "yes" : "no"));
 
     // Write back the partial block
     memset(reinterpret_cast<char*>(mPartialBlockBuffer.get()) + blockOffset, 0,
            BLOCK_SIZE - blockOffset);
     gMediaCache->AllocateAndWriteBlock(this, mPartialBlockBuffer.get(),
         mMetadataInPartialBlockBuffer ? MODE_METADATA : MODE_PLAYBACK);
@@ -2300,17 +2301,17 @@ MediaCacheStream::Read(char* aBuffer, ui
     count += bytes;
   }
 
   if (count > 0) {
     // Some data was read, so queue an update since block priorities may
     // have changed
     gMediaCache->QueueUpdate();
   }
-  CACHE_LOG(LogLevel::Debug, ("Stream %p Read at %lld count=%d", this, streamOffset-count, count));
+  CACHE_LOG(LogLevel::Debug, ("Stream %p Read at %" PRId64 " count=%d", this, streamOffset-count, count));
   *aBytes = count;
   mStreamOffset = streamOffset;
   return NS_OK;
 }
 
 nsresult
 MediaCacheStream::ReadAt(int64_t aOffset, char* aBuffer,
                          uint32_t aCount, uint32_t* aBytes)
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1114,17 +1114,17 @@ MediaDecoder::NotifyBytesDownloaded()
 }
 
 void
 MediaDecoder::NotifyDownloadEnded(nsresult aStatus)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
 
-  DECODER_LOG("NotifyDownloadEnded, status=%x", aStatus);
+  DECODER_LOG("NotifyDownloadEnded, status=%" PRIx32, static_cast<uint32_t>(aStatus));
 
   if (aStatus == NS_BINDING_ABORTED) {
     // Download has been cancelled by user.
     GetOwner()->LoadAborted();
     return;
   }
 
   UpdatePlaybackRate();
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -21,16 +21,17 @@
 #include "mediasink/OutputStreamManager.h"
 #include "mediasink/VideoSink.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Logging.h"
 #include "mozilla/mozalloc.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/SharedThreadPool.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/TaskQueue.h"
 
 #include "nsComponentManagerUtils.h"
 #include "nsContentUtils.h"
 #include "nsIEventTarget.h"
 #include "nsITimer.h"
 #include "nsPrintfCString.h"
@@ -797,18 +798,18 @@ private:
       mMaster->mLowAudioThresholdUsecs =
         std::min(adjustedTime, mMaster->mAmpleAudioThresholdUsecs);
 
       mMaster->mAmpleAudioThresholdUsecs =
         std::max(THRESHOLD_FACTOR * mMaster->mLowAudioThresholdUsecs,
                  mMaster->mAmpleAudioThresholdUsecs);
 
       SLOG("Slow video decode, set "
-           "mLowAudioThresholdUsecs=%lld "
-           "mAmpleAudioThresholdUsecs=%lld",
+           "mLowAudioThresholdUsecs=%" PRId64
+           " mAmpleAudioThresholdUsecs=%" PRId64,
            mMaster->mLowAudioThresholdUsecs,
            mMaster->mAmpleAudioThresholdUsecs);
     }
   }
 
   bool DonePrerollingAudio()
   {
     return !mMaster->IsAudioDecoding()
@@ -1352,36 +1353,36 @@ private:
 
     return NS_OK;
   }
 
   nsresult DropVideoUpToSeekTarget(MediaData* aSample)
   {
     RefPtr<VideoData> video(aSample->As<VideoData>());
     MOZ_ASSERT(video);
-    SLOG("DropVideoUpToSeekTarget() frame [%lld, %lld]",
+    SLOG("DropVideoUpToSeekTarget() frame [%" PRId64 ", %" PRId64 "]",
          video->mTime, video->GetEndTime());
     const int64_t target = mSeekJob.mTarget->GetTime().ToMicroseconds();
 
     // If the frame end time is less than the seek target, we won't want
     // to display this frame after the seek, so discard it.
     if (target >= video->GetEndTime()) {
-      SLOG("DropVideoUpToSeekTarget() pop video frame [%lld, %lld] target=%lld",
+      SLOG("DropVideoUpToSeekTarget() pop video frame [%" PRId64 ", %" PRId64 "] target=%" PRId64,
            video->mTime, video->GetEndTime(), target);
       mFirstVideoFrameAfterSeek = video;
     } else {
       if (target >= video->mTime && video->GetEndTime() >= target) {
         // The seek target lies inside this frame's time slice. Adjust the
         // frame's start time to match the seek target.
         video->UpdateTimestamp(target);
       }
       mFirstVideoFrameAfterSeek = nullptr;
 
-      SLOG("DropVideoUpToSeekTarget() found video frame [%lld, %lld] "
-           "containing target=%lld",
+      SLOG("DropVideoUpToSeekTarget() found video frame [%" PRId64 ", %" PRId64 "] "
+           "containing target=%" PRId64,
            video->mTime, video->GetEndTime(), target);
 
       MOZ_ASSERT(VideoQueue().GetSize() == 0,
                  "Should be the 1st sample after seeking");
       mMaster->PushVideo(video);
       mDoneVideoSeeking = true;
     }
 
@@ -1906,17 +1907,17 @@ public:
     MOZ_DIAGNOSTIC_ASSERT(false, "Already shutting down.");
   }
 };
 
 RefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::
 StateObject::HandleSeek(SeekTarget aTarget)
 {
-  SLOG("Changed state to SEEKING (to %lld)", aTarget.GetTime().ToMicroseconds());
+  SLOG("Changed state to SEEKING (to %" PRId64 ")", aTarget.GetTime().ToMicroseconds());
   SeekJob seekJob;
   seekJob.mTarget = Some(aTarget);
   return SetSeekingState(Move(seekJob), EventVisibility::Observable);
 }
 
 RefPtr<ShutdownPromise>
 MediaDecoderStateMachine::
 StateObject::HandleShutdown()
@@ -2367,17 +2368,17 @@ SeekingState::SeekCompleted()
   if (!target.IsVideoOnly()) {
     // Don't update playback position for video-only seek.
     // Otherwise we might have |newCurrentTime > mMediaSink->GetPosition()|
     // and fail the assertion in GetClock() since we didn't stop MediaSink.
     mMaster->UpdatePlaybackPositionInternal(newCurrentTime);
   }
 
   // Try to decode another frame to detect if we're at the end...
-  SLOG("Seek completed, mCurrentPosition=%lld",
+  SLOG("Seek completed, mCurrentPosition=%" PRId64,
        mMaster->mCurrentPosition.Ref());
 
   if (mMaster->VideoQueue().PeekFront()) {
     mMaster->mMediaSink->Redraw(Info().mVideo);
     mMaster->mOnPlaybackEvent.Notify(MediaEventType::Invalidate);
   }
 
   SetState<DecodingState>();
@@ -2864,17 +2865,17 @@ void MediaDecoderStateMachine::MaybeStar
     mMediaSink->SetPlaying(true);
     MOZ_ASSERT(IsPlaying());
   }
 }
 
 void MediaDecoderStateMachine::UpdatePlaybackPositionInternal(int64_t aTime)
 {
   MOZ_ASSERT(OnTaskQueue());
-  SAMPLE_LOG("UpdatePlaybackPositionInternal(%lld)", aTime);
+  SAMPLE_LOG("UpdatePlaybackPositionInternal(%" PRId64 ")", aTime);
 
   mCurrentPosition = aTime;
   NS_ASSERTION(mCurrentPosition >= 0, "CurrentTime should be positive!");
   mObservedDuration = std::max(mObservedDuration.Ref(),
                                TimeUnit::FromMicroseconds(mCurrentPosition.Ref()));
 }
 
 void MediaDecoderStateMachine::UpdatePlaybackPosition(int64_t aTime)
@@ -3082,33 +3083,33 @@ void MediaDecoderStateMachine::StopMedia
 
 void
 MediaDecoderStateMachine::RequestAudioData()
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(IsAudioDecoding());
   MOZ_ASSERT(!IsRequestingAudioData());
   MOZ_ASSERT(!IsWaitingAudioData());
-  SAMPLE_LOG("Queueing audio task - queued=%i, decoder-queued=%o",
+  SAMPLE_LOG("Queueing audio task - queued=%" PRIuSIZE ", decoder-queued=%" PRIuSIZE,
              AudioQueue().GetSize(), mReader->SizeOfAudioQueueInFrames());
 
   mReader->RequestAudioData()->Then(
     OwnerThread(), __func__,
     [this] (MediaData* aAudio) {
       MOZ_ASSERT(aAudio);
       mAudioDataRequest.Complete();
       // audio->GetEndTime() is not always mono-increasing in chained ogg.
       mDecodedAudioEndTime =
         std::max(aAudio->GetEndTime(), mDecodedAudioEndTime);
-      SAMPLE_LOG("OnAudioDecoded [%lld,%lld]", aAudio->mTime,
+      SAMPLE_LOG("OnAudioDecoded [%" PRId64 ",%" PRId64 "]", aAudio->mTime,
                  aAudio->GetEndTime());
       mStateObj->HandleAudioDecoded(aAudio);
     },
     [this] (const MediaResult& aError) {
-      SAMPLE_LOG("OnAudioNotDecoded aError=%u", aError.Code());
+      SAMPLE_LOG("OnAudioNotDecoded aError=%" PRIu32, static_cast<uint32_t>(aError.Code()));
       mAudioDataRequest.Complete();
       switch (aError.Code()) {
         case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
           mStateObj->HandleWaitingForAudio();
           break;
         case NS_ERROR_DOM_MEDIA_CANCELED:
           mStateObj->HandleAudioCanceled();
           break;
@@ -3125,35 +3126,36 @@ void
 MediaDecoderStateMachine::RequestVideoData(bool aSkipToNextKeyframe,
                                            const media::TimeUnit& aCurrentTime)
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(IsVideoDecoding());
   MOZ_ASSERT(!IsRequestingVideoData());
   MOZ_ASSERT(!IsWaitingVideoData());
   SAMPLE_LOG(
-    "Queueing video task - queued=%i, decoder-queued=%o, skip=%i, time=%lld",
+    "Queueing video task - queued=%" PRIuSIZE ", decoder-queued=%" PRIoSIZE
+    ", skip=%i, time=%" PRId64,
     VideoQueue().GetSize(), mReader->SizeOfVideoQueueInFrames(),
     aSkipToNextKeyframe, aCurrentTime.ToMicroseconds());
 
   TimeStamp videoDecodeStartTime = TimeStamp::Now();
   mReader->RequestVideoData(aSkipToNextKeyframe, aCurrentTime)->Then(
     OwnerThread(), __func__,
     [this, videoDecodeStartTime] (MediaData* aVideo) {
       MOZ_ASSERT(aVideo);
       mVideoDataRequest.Complete();
       // Handle abnormal or negative timestamps.
       mDecodedVideoEndTime =
         std::max(mDecodedVideoEndTime, aVideo->GetEndTime());
-      SAMPLE_LOG("OnVideoDecoded [%lld,%lld]", aVideo->mTime,
+      SAMPLE_LOG("OnVideoDecoded [%" PRId64 ",%" PRId64 "]", aVideo->mTime,
                  aVideo->GetEndTime());
       mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime);
     },
     [this] (const MediaResult& aError) {
-      SAMPLE_LOG("OnVideoNotDecoded aError=%u", aError.Code());
+      SAMPLE_LOG("OnVideoNotDecoded aError=%" PRIu32 , static_cast<uint32_t>(aError.Code()));
       mVideoDataRequest.Complete();
       switch (aError.Code()) {
         case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
           mStateObj->HandleWaitingForVideo();
           break;
         case NS_ERROR_DOM_MEDIA_CANCELED:
           mStateObj->HandleVideoCanceled();
           break;
@@ -3355,17 +3357,17 @@ void
 MediaDecoderStateMachine::FinishDecodeFirstFrame()
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(!mSentFirstFrameLoadedEvent);
   DECODER_LOG("FinishDecodeFirstFrame");
 
   mMediaSink->Redraw(Info().mVideo);
 
-  DECODER_LOG("Media duration %lld, "
+  DECODER_LOG("Media duration %" PRId64 ", "
               "transportSeekable=%d, mediaSeekable=%d",
               Duration().ToMicroseconds(), mResource->IsTransportSeekable(),
               mMediaSeekable);
 
   // Get potentially updated metadata
   mReader->ReadUpdatedMetadata(mInfo.ptr());
 
   EnqueueFirstFrameLoadedEvent();
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "AutoTaskQueue.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "Layers.h"
 #include "MediaData.h"
 #include "MediaInfo.h"
 #include "MediaFormatReader.h"
 #include "MediaPrefs.h"
 #include "MediaResource.h"
 #include "VideoUtils.h"
 #include "VideoFrameContainer.h"
@@ -1321,17 +1322,17 @@ MediaFormatReader::RequestVideoData(bool
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_DIAGNOSTIC_ASSERT(mSeekPromise.IsEmpty(),
                         "No sample requests allowed while seeking");
   MOZ_DIAGNOSTIC_ASSERT(!mVideo.HasPromise(), "No duplicate sample requests");
   MOZ_DIAGNOSTIC_ASSERT(!mVideo.mSeekRequest.Exists()
                         || mVideo.mTimeThreshold.isSome());
   MOZ_DIAGNOSTIC_ASSERT(!IsSeeking(), "called mid-seek");
-  LOGV("RequestVideoData(%d, %lld)", aSkipToNextKeyframe, aTimeThreshold);
+  LOGV("RequestVideoData(%d, %" PRId64 ")", aSkipToNextKeyframe, aTimeThreshold);
 
   if (!HasVideo()) {
     LOG("called with no video track");
     return MediaDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                                              __func__);
   }
 
   if (IsSeeking()) {
@@ -1362,18 +1363,19 @@ MediaFormatReader::RequestVideoData(bool
 
   return p;
 }
 
 void
 MediaFormatReader::OnDemuxFailed(TrackType aTrack, const MediaResult& aError)
 {
   MOZ_ASSERT(OnTaskQueue());
-  LOG("Failed to demux %s, failure:%u",
-      aTrack == TrackType::kVideoTrack ? "video" : "audio", aError.Code());
+  LOG("Failed to demux %s, failure:%" PRIu32,
+      aTrack == TrackType::kVideoTrack ? "video" : "audio",
+      static_cast<uint32_t>(aError.Code()));
   auto& decoder = GetDecoderData(aTrack);
   decoder.mDemuxRequest.Complete();
   switch (aError.Code()) {
     case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
       if (!decoder.mWaitingForData) {
         decoder.RequestDrain();
       }
       NotifyEndOfStream(aTrack);
@@ -1416,17 +1418,17 @@ MediaFormatReader::DoDemuxVideo()
           &MediaFormatReader::OnVideoDemuxFailed)
    ->Track(mVideo.mDemuxRequest);
 }
 
 void
 MediaFormatReader::OnVideoDemuxCompleted(
   RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples)
 {
-  LOGV("%d video samples demuxed (sid:%d)",
+  LOGV("%" PRIuSIZE " video samples demuxed (sid:%d)",
        aSamples->mSamples.Length(),
        aSamples->mSamples[0]->mTrackInfo
        ? aSamples->mSamples[0]->mTrackInfo->GetID()
        : 0);
   mVideo.mDemuxRequest.Complete();
   mVideo.mQueuedSamples.AppendElements(aSamples->mSamples);
   ScheduleUpdate(TrackInfo::kVideoTrack);
 }
@@ -1489,34 +1491,34 @@ MediaFormatReader::DoDemuxAudio()
           &MediaFormatReader::OnAudioDemuxFailed)
    ->Track(mAudio.mDemuxRequest);
 }
 
 void
 MediaFormatReader::OnAudioDemuxCompleted(
   RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples)
 {
-  LOGV("%d audio samples demuxed (sid:%d)",
+  LOGV("%" PRIuSIZE " audio samples demuxed (sid:%d)",
        aSamples->mSamples.Length(),
        aSamples->mSamples[0]->mTrackInfo
        ? aSamples->mSamples[0]->mTrackInfo->GetID()
        : 0);
   mAudio.mDemuxRequest.Complete();
   mAudio.mQueuedSamples.AppendElements(aSamples->mSamples);
   ScheduleUpdate(TrackInfo::kAudioTrack);
 }
 
 void
 MediaFormatReader::NotifyNewOutput(
   TrackType aTrack, const MediaDataDecoder::DecodedData& aResults)
 {
   MOZ_ASSERT(OnTaskQueue());
   auto& decoder = GetDecoderData(aTrack);
   for (auto& sample : aResults) {
-    LOGV("Received new %s sample time:%lld duration:%lld",
+    LOGV("Received new %s sample time:%" PRId64 " duration:%" PRId64,
         TrackTypeToStr(aTrack), sample->mTime, sample->mDuration);
     decoder.mOutput.AppendElement(sample);
     decoder.mNumSamplesOutput++;
     decoder.mNumOfConsecutiveError = 0;
   }
   LOG("Done processing new %s samples", TrackTypeToStr(aTrack));
   ScheduleUpdate(aTrack);
 }
@@ -1798,24 +1800,24 @@ MediaFormatReader::HandleDemuxedSamples(
       if (sample->mKeyframe) {
         ScheduleUpdate(aTrack);
       } else {
         TimeInterval time =
           TimeInterval(TimeUnit::FromMicroseconds(sample->mTime),
                        TimeUnit::FromMicroseconds(sample->GetEndTime()));
         InternalSeekTarget seekTarget =
           decoder.mTimeThreshold.refOr(InternalSeekTarget(time, false));
-        LOG("Stream change occurred on a non-keyframe. Seeking to:%lld",
+        LOG("Stream change occurred on a non-keyframe. Seeking to:%" PRId64,
             sample->mTime);
         InternalSeek(aTrack, seekTarget);
       }
       return;
     }
 
-    LOGV("Input:%lld (dts:%lld kf:%d)",
+    LOGV("Input:%" PRId64 " (dts:%" PRId64 " kf:%d)",
          sample->mTime, sample->mTimecode, sample->mKeyframe);
     decoder.mNumSamplesInput++;
     decoder.mSizeOfQueue++;
     if (aTrack == TrackInfo::kVideoTrack) {
       aA.mStats.mParsedFrames++;
     }
 
     DecodeDemuxedSamples(aTrack, sample);
@@ -1979,17 +1981,17 @@ MediaFormatReader::Update(TrackType aTra
            output->mKeyframe);
       decoder.mOutput.RemoveElementAt(0);
       decoder.mSizeOfQueue -= 1;
     }
   }
 
   while (decoder.mOutput.Length()
          && decoder.mOutput[0]->mType == MediaData::NULL_DATA) {
-    LOGV("Dropping null data. Time: %lld", decoder.mOutput[0]->mTime);
+    LOGV("Dropping null data. Time: %" PRId64, decoder.mOutput[0]->mTime);
     decoder.mOutput.RemoveElementAt(0);
     decoder.mSizeOfQueue -= 1;
   }
 
   if (decoder.HasPromise()) {
     needOutput = true;
     if (decoder.mOutput.Length()) {
       RefPtr<MediaData> output = decoder.mOutput[0];
@@ -2034,17 +2036,17 @@ MediaFormatReader::Update(TrackType aTra
         decoder.RejectPromise(NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
       } else if (decoder.mWaitingForData) {
         if (decoder.mDrainState == DrainState::DrainCompleted
             && decoder.mLastSampleTime
             && !decoder.mNextStreamSourceID) {
           // We have completed draining the decoder following WaitingForData.
           // Set up the internal seek machinery to be able to resume from the
           // last sample decoded.
-          LOG("Seeking to last sample time: %lld",
+          LOG("Seeking to last sample time: %" PRId64,
               decoder.mLastSampleTime.ref().mStart.ToMicroseconds());
           InternalSeek(aTrack,
                        InternalSeekTarget(decoder.mLastSampleTime.ref(), true));
         }
         if (!decoder.mReceivedNewData) {
           LOG("Rejecting %s promise: WAITING_FOR_DATA", TrackTypeToStr(aTrack));
           decoder.RejectPromise(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA, __func__);
         }
@@ -2106,17 +2108,18 @@ MediaFormatReader::Update(TrackType aTra
     } else if (aTrack == TrackType::kAudioTrack) {
       decoder.Flush();
     }
     return;
   }
 
   bool needInput = NeedInput(decoder);
 
-  LOGV("Update(%s) ni=%d no=%d in:%llu out:%llu qs=%u decoding:%d flushing:%d "
+  LOGV("Update(%s) ni=%d no=%d in:%" PRIu64 " out:%" PRIu64
+       " qs=%u decoding:%d flushing:%d "
        "shutdown:%d pending:%u waiting:%d promise:%d sid:%u",
        TrackTypeToStr(aTrack), needInput, needOutput, decoder.mNumSamplesInput,
        decoder.mNumSamplesOutput, uint32_t(size_t(decoder.mSizeOfQueue)),
        decoder.mDecodeRequest.Exists(), decoder.mFlushRequest.Exists(),
        decoder.mShutdownRequest.Exists(), uint32_t(decoder.mOutput.Length()),
        decoder.mWaitingForData, decoder.HasPromise(),
        decoder.mLastStreamSourceID);
 
@@ -2149,17 +2152,17 @@ MediaFormatReader::Update(TrackType aTra
   HandleDemuxedSamples(aTrack, a);
 }
 
 void
 MediaFormatReader::ReturnOutput(MediaData* aData, TrackType aTrack)
 {
   MOZ_ASSERT(GetDecoderData(aTrack).HasPromise());
   MOZ_DIAGNOSTIC_ASSERT(aData->mType != MediaData::NULL_DATA);
-  LOG("Resolved data promise for %s [%lld, %lld]", TrackTypeToStr(aTrack),
+  LOG("Resolved data promise for %s [%" PRId64 ", %" PRId64 "]", TrackTypeToStr(aTrack),
       aData->mTime, aData->GetEndTime());
 
   if (aTrack == TrackInfo::kAudioTrack) {
     AudioData* audioData = static_cast<AudioData*>(aData);
 
     if (audioData->mChannels != mInfo.mAudio.mChannels
         || audioData->mRate != mInfo.mAudio.mRate) {
       LOG("change of audio format (rate:%d->%d). "
@@ -2295,17 +2298,17 @@ MediaFormatReader::DropDecodedSamples(Tr
     mDecoder->NotifyDecodedFrames({ 0, 0, lengthDecodedQueue });
   }
 }
 
 void
 MediaFormatReader::SkipVideoDemuxToNextKeyFrame(media::TimeUnit aTimeThreshold)
 {
   MOZ_ASSERT(OnTaskQueue());
-  LOG("Skipping up to %lld", aTimeThreshold.ToMicroseconds());
+  LOG("Skipping up to %" PRId64, aTimeThreshold.ToMicroseconds());
 
   // We've reached SkipVideoDemuxToNextKeyFrame when our decoding is late.
   // As such we can drop all already decoded samples and discard all pending
   // samples.
   DropDecodedSamples(TrackInfo::kVideoTrack);
 
   mVideo.mTrackDemuxer->SkipToNextRandomAccessPoint(aTimeThreshold)
     ->Then(OwnerThread(), __func__, this,
@@ -2380,17 +2383,17 @@ MediaFormatReader::OnVideoSkipFailed(
   }
 }
 
 RefPtr<MediaDecoderReader::SeekPromise>
 MediaFormatReader::Seek(const SeekTarget& aTarget)
 {
   MOZ_ASSERT(OnTaskQueue());
 
-  LOG("aTarget=(%lld)", aTarget.GetTime().ToMicroseconds());
+  LOG("aTarget=(%" PRId64 ")", aTarget.GetTime().ToMicroseconds());
 
   MOZ_DIAGNOSTIC_ASSERT(mSeekPromise.IsEmpty());
   MOZ_DIAGNOSTIC_ASSERT(!mVideo.HasPromise());
   MOZ_DIAGNOSTIC_ASSERT(aTarget.IsVideoOnly() || !mAudio.HasPromise());
   MOZ_DIAGNOSTIC_ASSERT(mPendingSeekTime.isNothing());
   MOZ_DIAGNOSTIC_ASSERT(mVideo.mTimeThreshold.isNothing());
   MOZ_DIAGNOSTIC_ASSERT(aTarget.IsVideoOnly()
                         || mAudio.mTimeThreshold.isNothing());
@@ -2465,17 +2468,17 @@ MediaFormatReader::AttemptSeek()
     MOZ_CRASH();
   }
 }
 
 void
 MediaFormatReader::OnSeekFailed(TrackType aTrack, const MediaResult& aError)
 {
   MOZ_ASSERT(OnTaskQueue());
-  LOGV("%s failure:%u", TrackTypeToStr(aTrack), aError.Code());
+  LOGV("%s failure:%" PRIu32, TrackTypeToStr(aTrack), static_cast<uint32_t>(aError.Code()));
   if (aTrack == TrackType::kVideoTrack) {
     mVideo.mSeekRequest.Complete();
   } else {
     mAudio.mSeekRequest.Complete();
   }
 
   if (aError == NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA) {
     if (HasVideo()
@@ -2516,30 +2519,30 @@ MediaFormatReader::OnSeekFailed(TrackTyp
                                                : MediaData::VIDEO_DATA;
   mSeekPromise.Reject(SeekRejectValue(type, aError), __func__);
 }
 
 void
 MediaFormatReader::DoVideoSeek()
 {
   MOZ_ASSERT(mPendingSeekTime.isSome());
-  LOGV("Seeking video to %lld", mPendingSeekTime.ref().ToMicroseconds());
+  LOGV("Seeking video to %" PRId64, mPendingSeekTime.ref().ToMicroseconds());
   media::TimeUnit seekTime = mPendingSeekTime.ref();
   mVideo.mTrackDemuxer->Seek(seekTime)
     ->Then(OwnerThread(), __func__, this,
            &MediaFormatReader::OnVideoSeekCompleted,
            &MediaFormatReader::OnVideoSeekFailed)
     ->Track(mVideo.mSeekRequest);
 }
 
 void
 MediaFormatReader::OnVideoSeekCompleted(media::TimeUnit aTime)
 {
   MOZ_ASSERT(OnTaskQueue());
-  LOGV("Video seeked to %lld", aTime.ToMicroseconds());
+  LOGV("Video seeked to %" PRId64, aTime.ToMicroseconds());
   mVideo.mSeekRequest.Complete();
 
   mPreviousDecodedKeyframeTime_us = sNoPreviousDecodedKeyframe;
 
   SetVideoDecodeThreshold();
 
   if (HasAudio() && !mOriginalSeekTarget.IsVideoOnly()) {
     MOZ_ASSERT(mPendingSeekTime.isSome());
@@ -2591,38 +2594,38 @@ MediaFormatReader::SetVideoDecodeThresho
     if (!keyframe.IsValid() || keyframe.IsInfinite()) {
       return;
     }
     threshold = mOriginalSeekTarget.GetTime();
   } else {
     return;
   }
 
-  LOG("Set seek threshold to %lld", threshold.ToMicroseconds());
+  LOG("Set seek threshold to %" PRId64, threshold.ToMicroseconds());
   mVideo.mDecoder->SetSeekThreshold(threshold);
 }
 
 void
 MediaFormatReader::DoAudioSeek()
 {
   MOZ_ASSERT(mPendingSeekTime.isSome());
-  LOGV("Seeking audio to %lld", mPendingSeekTime.ref().ToMicroseconds());
+  LOGV("Seeking audio to %" PRId64, mPendingSeekTime.ref().ToMicroseconds());
   media::TimeUnit seekTime = mPendingSeekTime.ref();
   mAudio.mTrackDemuxer->Seek(seekTime)
     ->Then(OwnerThread(), __func__, this,
            &MediaFormatReader::OnAudioSeekCompleted,
            &MediaFormatReader::OnAudioSeekFailed)
     ->Track(mAudio.mSeekRequest);
 }
 
 void
 MediaFormatReader::OnAudioSeekCompleted(media::TimeUnit aTime)
 {
   MOZ_ASSERT(OnTaskQueue());
-  LOGV("Audio seeked to %lld", aTime.ToMicroseconds());
+  LOGV("Audio seeked to %" PRId64, aTime.ToMicroseconds());
   mAudio.mSeekRequest.Complete();
   mPendingSeekTime.reset();
   mSeekPromise.Resolve(aTime, __func__);
 }
 
 void
 MediaFormatReader::OnAudioSeekFailed(const MediaResult& aError)
 {
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -893,17 +893,17 @@ nsresult MediaDevice::Restart(const dom:
 
 nsresult MediaDevice::Deallocate() {
   return GetSource()->Deallocate(mAllocationHandle);
 }
 
 void
 MediaOperationTask::ReturnCallbackError(nsresult rv, const char* errorLog)
 {
-  MM_LOG(("%s , rv=%d", errorLog, rv));
+  MM_LOG(("%s , rv=%" PRIu32, errorLog, static_cast<uint32_t>(rv)));
   NS_DispatchToMainThread(do_AddRef(new ReleaseMediaOperationResource(mStream.forget(),
     mOnTracksAvailableCallback.forget())));
   nsString log;
 
   log.AssignASCII(errorLog);
   nsCOMPtr<nsIDOMGetUserMediaSuccessCallback> onSuccess;
   RefPtr<MediaMgrError> error = new MediaMgrError(
     NS_LITERAL_STRING("InternalError"), log);
@@ -1467,17 +1467,17 @@ public:
               NormalizedConstraints(constraints), videos, mIsChrome);
         }
         if (mAudioDevice) {
           mAudioDevice->Deallocate();
         }
       }
     }
     if (errorMsg) {
-      LOG(("%s %d", errorMsg, rv));
+      LOG(("%s %" PRIu32, errorMsg, static_cast<uint32_t>(rv)));
       if (badConstraint) {
         Fail(NS_LITERAL_STRING("OverconstrainedError"),
              NS_LITERAL_STRING(""),
              NS_ConvertUTF8toUTF16(badConstraint));
       } else {
         Fail(NS_LITERAL_STRING("NotReadableError"),
              NS_ConvertUTF8toUTF16(errorMsg));
       }
@@ -2667,17 +2667,17 @@ StopSharingCallback(MediaManager *aThis,
   }
 }
 
 
 void
 MediaManager::OnNavigation(uint64_t aWindowID)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  LOG(("OnNavigation for %llu", aWindowID));
+  LOG(("OnNavigation for %" PRIu64, aWindowID));
 
   // Stop the streams for this window. The runnables check this value before
   // making a call to content.
 
   nsTArray<nsString>* callIDs;
   if (mCallIds.Get(aWindowID, &callIDs)) {
     for (auto& callID : *callIDs) {
       mActiveCallbacks.Remove(callID);
@@ -2735,36 +2735,36 @@ MediaManager::AddWindowID(uint64_t aWind
 void
 MediaManager::RemoveWindowID(uint64_t aWindowId)
 {
   mActiveWindows.Remove(aWindowId);
 
   // get outer windowID
   auto* window = nsGlobalWindow::GetInnerWindowWithId(aWindowId);
   if (!window) {
-    LOG(("No inner window for %llu", aWindowId));
+    LOG(("No inner window for %" PRIu64, aWindowId));
     return;
   }
 
   nsPIDOMWindowOuter* outer = window->AsInner()->GetOuterWindow();
   if (!outer) {
-    LOG(("No outer window for inner %llu", aWindowId));
+    LOG(("No outer window for inner %" PRIu64, aWindowId));
     return;
   }
 
   uint64_t outerID = outer->WindowID();
 
   // Notify the UI that this window no longer has gUM active
   char windowBuffer[32];
   SprintfLiteral(windowBuffer, "%" PRIu64, outerID);
   nsString data = NS_ConvertUTF8toUTF16(windowBuffer);
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   obs->NotifyObservers(nullptr, "recording-window-ended", data.get());
-  LOG(("Sent recording-window-ended for window %llu (outer %llu)",
+  LOG(("Sent recording-window-ended for window %" PRIu64 " (outer %" PRIu64 ")",
        aWindowId, outerID));
 }
 
 void
 MediaManager::RemoveFromWindowList(uint64_t aWindowID,
   GetUserMediaCallbackMediaStreamListener *aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -3121,24 +3121,24 @@ MediaManager::Observe(nsISupports* aSubj
   } else if (!strcmp(aTopic, "getUserMedia:revoke")) {
     nsresult rv;
     // may be windowid or screen:windowid
     nsDependentString data(aData);
     if (Substring(data, 0, strlen("screen:")).EqualsLiteral("screen:")) {
       uint64_t windowID = PromiseFlatString(Substring(data, strlen("screen:"))).ToInteger64(&rv);
       MOZ_ASSERT(NS_SUCCEEDED(rv));
       if (NS_SUCCEEDED(rv)) {
-        LOG(("Revoking Screen/windowCapture access for window %llu", windowID));
+        LOG(("Revoking Screen/windowCapture access for window %" PRIu64, windowID));
         StopScreensharing(windowID);
       }
     } else {
       uint64_t windowID = nsString(aData).ToInteger64(&rv);
       MOZ_ASSERT(NS_SUCCEEDED(rv));
       if (NS_SUCCEEDED(rv)) {
-        LOG(("Revoking MediaCapture access for window %llu", windowID));
+        LOG(("Revoking MediaCapture access for window %" PRIu64, windowID));
         OnNavigation(windowID);
       }
     }
     return NS_OK;
   }
 #ifdef MOZ_WIDGET_GONK
   else if (!strcmp(aTopic, "phone-state-changed")) {
     nsString state(aData);
@@ -3267,29 +3267,29 @@ MediaManager::MediaCaptureWindowState(ns
   *aAppShare = false;
   *aBrowserShare = false;
 
   nsCOMPtr<nsPIDOMWindowInner> piWin = do_QueryInterface(aWindow);
   if (piWin) {
     IterateWindowListeners(piWin, CaptureWindowStateCallback, &data);
   }
 #ifdef DEBUG
-  LOG(("%s: window %lld capturing %s %s %s %s %s %s", __FUNCTION__, piWin ? piWin->WindowID() : -1,
+  LOG(("%s: window %" PRIu64 " capturing %s %s %s %s %s %s", __FUNCTION__, piWin ? piWin->WindowID() : -1,
        *aVideo ? "video" : "", *aAudio ? "audio" : "",
        *aScreenShare ? "screenshare" : "",  *aWindowShare ? "windowshare" : "",
        *aAppShare ? "appshare" : "", *aBrowserShare ? "browsershare" : ""));
 #endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MediaManager::SanitizeDeviceIds(int64_t aSinceWhen)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  LOG(("%s: sinceWhen = %llu", __FUNCTION__, aSinceWhen));
+  LOG(("%s: sinceWhen = %" PRId64, __FUNCTION__, aSinceWhen));
 
   media::SanitizeOriginKeys(aSinceWhen, false); // we fire and forget
   return NS_OK;
 }
 
 static void
 StopScreensharingCallback(MediaManager *aThis,
                           uint64_t aWindowID,
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -353,17 +353,17 @@ ChannelMediaResource::ParseContentRangeH
   if (aRangeTotalText[0] == '*') {
     aRangeTotal = -1;
   } else {
     aRangeTotal = aRangeTotalText.ToInteger64(&rv);
     NS_ENSURE_TRUE(aRangeEnd < aRangeTotal, NS_ERROR_ILLEGAL_VALUE);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  CMLOG("Received bytes [%lld] to [%lld] of [%lld] for decoder[%p]",
+  CMLOG("Received bytes [%" PRId64 "] to [%" PRId64 "] of [%" PRId64 "] for decoder[%p]",
         aRangeStart, aRangeEnd, aRangeTotal, mCallback.get());
 
   return NS_OK;
 }
 
 nsresult
 ChannelMediaResource::OnStopRequest(nsIRequest* aRequest, nsresult aStatus)
 {
@@ -435,17 +435,17 @@ ChannelMediaResource::CopySegmentToCache
                                          uint32_t aCount,
                                          uint32_t *aWriteCount)
 {
   CopySegmentClosure* closure = static_cast<CopySegmentClosure*>(aClosure);
 
   closure->mResource->mCallback->NotifyDataArrived();
 
   // Keep track of where we're up to.
-  RESOURCE_LOG("%p [ChannelMediaResource]: CopySegmentToCache at mOffset [%lld] add "
+  RESOURCE_LOG("%p [ChannelMediaResource]: CopySegmentToCache at mOffset [%" PRId64 "] add "
                "[%d] bytes for decoder[%p]",
                closure->mResource, closure->mResource->mOffset, aCount,
                closure->mResource->mCallback.get());
   closure->mResource->mOffset += aCount;
 
   closure->mResource->mCacheStream.NotifyDataReceived(aCount, aFromSegment,
                                                       closure->mPrincipal);
   *aWriteCount = aCount;
@@ -891,17 +891,17 @@ ChannelMediaResource::CacheClientNotifyS
   mCallback->NotifySuspendedStatusChanged();
 }
 
 nsresult
 ChannelMediaResource::CacheClientSeek(int64_t aOffset, bool aResume)
 {
   NS_ASSERTION(NS_IsMainThread(), "Don't call on non-main thread");
 
-  CMLOG("CacheClientSeek requested for aOffset [%lld] for decoder [%p]",
+  CMLOG("CacheClientSeek requested for aOffset [%" PRId64 "] for decoder [%p]",
         aOffset, mCallback.get());
 
   CloseChannel();
 
   mOffset = aOffset;
 
   // Don't report close of the channel because the channel is not closed for
   // download ended, but for internal changes in the read position.
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaStreamGraphImpl.h"
 #include "mozilla/MathAlgorithms.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Unused.h"
 
 #include "AudioSegment.h"
 #include "VideoSegment.h"
 #include "nsContentUtils.h"
 #include "nsIObserver.h"
 #include "nsPrintfCString.h"
 #include "nsServiceManagerUtils.h"
@@ -111,25 +112,25 @@ MediaStreamGraphImpl::AddStreamGraphThre
   if (aStream->IsSuspended()) {
     mSuspendedStreams.AppendElement(aStream);
     LOG(LogLevel::Debug,
         ("Adding media stream %p to the graph, in the suspended stream array",
          aStream));
   } else {
     mStreams.AppendElement(aStream);
     LOG(LogLevel::Debug,
-        ("Adding media stream %p to graph %p, count %lu",
+        ("Adding media stream %p to graph %p, count %" PRIuSIZE,
          aStream,
          this,
          mStreams.Length()));
     LOG(LogLevel::Debug,
-        ("Adding media stream %p to graph %p, count %lu",
+        ("Adding media stream %p to graph %p, count %" PRIuSIZE,
          aStream,
          this,
-         (long)mStreams.Length()));
+         mStreams.Length()));
   }
 
   SetStreamOrderDirty();
 }
 
 void
 MediaStreamGraphImpl::RemoveStreamGraphThread(MediaStream* aStream)
 {
@@ -150,25 +151,25 @@ MediaStreamGraphImpl::RemoveStreamGraphT
 
   if (aStream->IsSuspended()) {
     mSuspendedStreams.RemoveElement(aStream);
   } else {
     mStreams.RemoveElement(aStream);
   }
 
   LOG(LogLevel::Debug,
-      ("Removed media stream %p from graph %p, count %lu",
+      ("Removed media stream %p from graph %p, count %" PRIuSIZE,
        aStream,
        this,
        mStreams.Length()));
   LOG(LogLevel::Debug,
-      ("Removed media stream %p from graph %p, count %lu",
+      ("Removed media stream %p from graph %p, count %" PRIuSIZE,
        aStream,
        this,
-       (long)mStreams.Length()));
+       mStreams.Length()));
 
   NS_RELEASE(aStream); // probably destroying it
 }
 
 void
 MediaStreamGraphImpl::ExtractPendingInput(SourceMediaStream* aStream,
                                           GraphTime aDesiredUpToTime,
                                           bool* aEnsureNextIteration)
@@ -264,34 +265,35 @@ MediaStreamGraphImpl::ExtractPendingInpu
         b.mListener->NotifyQueuedChanges(this, offset, *data->mData);
         if (data->mCommands & SourceMediaStream::TRACK_END) {
           b.mListener->NotifyEnded();
         }
       }
       if (data->mCommands & SourceMediaStream::TRACK_CREATE) {
         MediaSegment* segment = data->mData.forget();
         LOG(LogLevel::Debug,
-            ("SourceMediaStream %p creating track %d, start %lld, initial end "
-             "%lld",
+            ("SourceMediaStream %p creating track %d, start %" PRId64
+             ", initial end %" PRId64,
              aStream,
              data->mID,
              int64_t(data->mStart),
              int64_t(segment->GetDuration())));
 
         data->mEndOfFlushedData += segment->GetDuration();
         aStream->mTracks.AddTrack(data->mID, data->mStart, segment);
         // The track has taken ownership of data->mData, so let's replace
         // data->mData with an empty clone.
         data->mData = segment->CreateEmptyClone();
         data->mCommands &= ~SourceMediaStream::TRACK_CREATE;
         shouldNotifyTrackCreated = true;
       } else if (data->mData->GetDuration() > 0) {
         MediaSegment* dest = aStream->mTracks.FindTrack(data->mID)->GetSegment();
         LOG(LogLevel::Verbose,
-            ("SourceMediaStream %p track %d, advancing end from %lld to %lld",
+            ("SourceMediaStream %p track %d, advancing end from %" PRId64
+             " to %" PRId64,
              aStream,
              data->mID,
              int64_t(dest->GetDuration()),
              int64_t(dest->GetDuration() + data->mData->GetDuration())));
         data->mEndOfFlushedData += data->mData->GetDuration();
         dest->AppendFrom(data->mData);
       }
       if (data->mCommands & SourceMediaStream::TRACK_END) {
@@ -471,17 +473,18 @@ MediaStreamGraphImpl::WillUnderrun(Media
   // This stream isn't finished or suspended. We don't need to call
   // StreamTimeToGraphTime since an underrun is the only thing that can block
   // it.
   GraphTime bufferEnd = aStream->GetTracksEnd() + aStream->mTracksStartTime;
 #ifdef DEBUG
   if (bufferEnd < mProcessedTime) {
     LOG(LogLevel::Error,
         ("MediaStream %p underrun, "
-         "bufferEnd %f < mProcessedTime %f (%lld < %lld), Streamtime %lld",
+         "bufferEnd %f < mProcessedTime %f (%" PRId64 " < %" PRId64
+         "), Streamtime %" PRId64,
          aStream,
          MediaTimeToSeconds(bufferEnd),
          MediaTimeToSeconds(mProcessedTime),
          bufferEnd,
          mProcessedTime,
          aStream->GetTracksEnd()));
     aStream->DumpTrackInfo();
     NS_ASSERTION(bufferEnd >= mProcessedTime, "Buffer underran");
@@ -896,32 +899,32 @@ MediaStreamGraphImpl::PlayAudio(MediaStr
       // Check how many ticks of sound we can provide if we are blocked some
       // time in the middle of this cycle.
       StreamTime toWrite = end - t;
 
       if (blocked) {
         output.InsertNullDataAtStart(toWrite);
         ticksWritten += toWrite;
         LOG(LogLevel::Verbose,
-            ("MediaStream %p writing %ld blocking-silence samples for "
-             "%f to %f (%ld to %ld)",
+            ("MediaStream %p writing %" PRId64 " blocking-silence samples for "
+             "%f to %f (%" PRId64 " to %" PRId64 ")",
              aStream,
              toWrite,
              MediaTimeToSeconds(t),
              MediaTimeToSeconds(end),
              offset,
              offset + toWrite));
       } else {
         StreamTime endTicksNeeded = offset + toWrite;
         StreamTime endTicksAvailable = audio->GetDuration();
 
         if (endTicksNeeded <= endTicksAvailable) {
           LOG(LogLevel::Verbose,
-              ("MediaStream %p writing %ld samples for %f to %f "
-               "(samples %ld to %ld)",
+              ("MediaStream %p writing %" PRId64 " samples for %f to %f "
+               "(samples %" PRId64 " to %" PRId64 ")",
                aStream,
                toWrite,
                MediaTimeToSeconds(t),
                MediaTimeToSeconds(end),
                offset,
                endTicksNeeded));
           output.AppendSlice(*audio, offset, endTicksNeeded);
           ticksWritten += toWrite;
@@ -929,33 +932,33 @@ MediaStreamGraphImpl::PlayAudio(MediaStr
         } else {
           // MOZ_ASSERT(track->IsEnded(), "Not enough data, and track not ended.");
           // If we are at the end of the track, maybe write the remaining
           // samples, and pad with/output silence.
           if (endTicksNeeded > endTicksAvailable &&
               offset < endTicksAvailable) {
             output.AppendSlice(*audio, offset, endTicksAvailable);
             LOG(LogLevel::Verbose,
-                ("MediaStream %p writing %ld samples for %f to %f "
-                 "(samples %ld to %ld)",
+                ("MediaStream %p writing %" PRId64 " samples for %f to %f "
+                 "(samples %" PRId64 " to %" PRId64 ")",
                  aStream,
                  toWrite,
                  MediaTimeToSeconds(t),
                  MediaTimeToSeconds(end),
                  offset,
                  endTicksNeeded));
             uint32_t available = endTicksAvailable - offset;
             ticksWritten += available;
             toWrite -= available;
             offset = endTicksAvailable;
           }
           output.AppendNullData(toWrite);
           LOG(LogLevel::Verbose,
-              ("MediaStream %p writing %ld padding slsamples for %f to "
-               "%f (samples %ld to %ld)",
+              ("MediaStream %p writing %" PRId64 " padding slsamples for %f to "
+               "%f (samples %" PRId64 " to %" PRId64 ")",
                aStream,
                toWrite,
                MediaTimeToSeconds(t),
                MediaTimeToSeconds(end),
                offset,
                endTicksNeeded));
           ticksWritten += toWrite;
         }
@@ -3849,17 +3852,17 @@ MediaStreamGraphImpl::SuspendOrResumeStr
     if (aAudioContextOperation == AudioContextOperation::Resume) {
       DecrementSuspendCount(stream);
     } else {
       IncrementSuspendCount(stream);
     }
   }
   LOG(LogLevel::Debug,
       ("Moving streams between suspended and running"
-       "state: mStreams: %d, mSuspendedStreams: %d",
+       "state: mStreams: %" PRIuSIZE ", mSuspendedStreams: %" PRIuSIZE,
        mStreams.Length(),
        mSuspendedStreams.Length()));
 #ifdef DEBUG
   // The intersection of the two arrays should be null.
   for (uint32_t i = 0; i < mStreams.Length(); i++) {
     for (uint32_t j = 0; j < mSuspendedStreams.Length(); j++) {
       MOZ_ASSERT(
         mStreams[i] != mSuspendedStreams[j],
--- a/dom/media/MediaTimer.cpp
+++ b/dom/media/MediaTimer.cpp
@@ -75,17 +75,17 @@ MediaTimer::OnMediaTimerThread()
   mThread->IsOnCurrentThread(&rv);
   return rv;
 }
 
 RefPtr<MediaTimerPromise>
 MediaTimer::WaitUntil(const TimeStamp& aTimeStamp, const char* aCallSite)
 {
   MonitorAutoLock mon(mMonitor);
-  TIMER_LOG("MediaTimer::WaitUntil %lld", RelativeMicroseconds(aTimeStamp));
+  TIMER_LOG("MediaTimer::WaitUntil %" PRId64, RelativeMicroseconds(aTimeStamp));
   Entry e(aTimeStamp, aCallSite);
   RefPtr<MediaTimerPromise> p = e.mPromise.get();
   mEntries.push(e);
   ScheduleUpdate();
   return p;
 }
 
 void
--- a/dom/media/MediaTimer.h
+++ b/dom/media/MediaTimer.h
@@ -2,32 +2,33 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #if !defined(MediaTimer_h_)
 #define MediaTimer_h_
 
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/TimeStamp.h"
 
 #include <queue>
 
 #include "nsITimer.h"
 #include "mozilla/RefPtr.h"
 
 namespace mozilla {
 
 extern LazyLogModule gMediaTimerLog;
 
 #define TIMER_LOG(x, ...) \
   MOZ_ASSERT(gMediaTimerLog); \
-  MOZ_LOG(gMediaTimerLog, LogLevel::Debug, ("[MediaTimer=%p relative_t=%lld]" x, this, \
+  MOZ_LOG(gMediaTimerLog, LogLevel::Debug, ("[MediaTimer=%p relative_t=%" PRId64 "]" x, this, \
                                         RelativeMicroseconds(TimeStamp::Now()), ##__VA_ARGS__))
 
 // This promise type is only exclusive because so far there isn't a reason for
 // it not to be. Feel free to change that.
 typedef MozPromise<bool, bool, /* IsExclusive = */ true> MediaTimerPromise;
 
 // Timers only know how to fire at a given thread, which creates an impedence
 // mismatch with code that operates with TaskQueues. This class solves
--- a/dom/media/StreamTracks.cpp
+++ b/dom/media/StreamTracks.cpp
@@ -11,23 +11,23 @@ namespace mozilla {
 
 extern LazyLogModule gMediaStreamGraphLog;
 #define STREAM_LOG(type, msg) MOZ_LOG(gMediaStreamGraphLog, type, msg)
 
 #ifdef DEBUG
 void
 StreamTracks::DumpTrackInfo() const
 {
-  STREAM_LOG(LogLevel::Info, ("DumpTracks: mTracksKnownTime %lld", mTracksKnownTime));
+  STREAM_LOG(LogLevel::Info, ("DumpTracks: mTracksKnownTime %" PRId64, mTracksKnownTime));
   for (uint32_t i = 0; i < mTracks.Length(); ++i) {
     Track* track = mTracks[i];
     if (track->IsEnded()) {
       STREAM_LOG(LogLevel::Info, ("Track[%d] %d: ended", i, track->GetID()));
     } else {
-      STREAM_LOG(LogLevel::Info, ("Track[%d] %d: %lld", i, track->GetID(),
+      STREAM_LOG(LogLevel::Info, ("Track[%d] %d: %" PRId64 "", i, track->GetID(),
                                  track->GetEnd()));
     }
   }
 }
 #endif
 
 StreamTime
 StreamTracks::GetEnd() const
--- a/dom/media/eme/DetailedPromise.cpp
+++ b/dom/media/eme/DetailedPromise.cpp
@@ -39,17 +39,17 @@ DetailedPromise::~DetailedPromise()
   MaybeReportTelemetry(Failed);
 }
 
 void
 DetailedPromise::MaybeReject(nsresult aArg, const nsACString& aReason)
 {
   nsPrintfCString msg("%s promise rejected 0x%x '%s'", mName.get(), aArg,
                       PromiseFlatCString(aReason).get());
-  EME_LOG(msg.get());
+  EME_LOG("%s", msg.get());
 
   MaybeReportTelemetry(Failed);
 
   LogToBrowserConsole(NS_ConvertUTF8toUTF16(msg));
 
   ErrorResult rv;
   rv.ThrowDOMException(aArg, aReason);
   Promise::MaybeReject(rv);
--- a/dom/media/eme/MediaKeySession.cpp
+++ b/dom/media/eme/MediaKeySession.cpp
@@ -150,17 +150,18 @@ MediaKeySession::UpdateKeyStatusMap()
       nsPrintfCString("MediaKeySession[%p,'%s'] key statuses change {",
                       this, NS_ConvertUTF16toUTF8(mSessionId).get()));
     using IntegerType = typename std::underlying_type<MediaKeyStatus>::type;
     for (const CDMCaps::KeyStatus& status : keyStatuses) {
       message.Append(nsPrintfCString(" (%s,%s)", ToHexString(status.mId).get(),
         MediaKeyStatusValues::strings[static_cast<IntegerType>(status.mStatus)].value));
     }
     message.Append(" }");
-    EME_LOG(message.get());
+    // Use %s so we aren't exposing random strings to printf interpolation.
+    EME_LOG("%s", message.get());
   }
 }
 
 MediaKeyStatusMap*
 MediaKeySession::KeyStatuses() const
 {
   return mKeyStatusMap;
 }
--- a/dom/media/eme/MediaKeys.cpp
+++ b/dom/media/eme/MediaKeys.cpp
@@ -216,17 +216,18 @@ MediaKeys::RetrievePromise(PromiseId aId
   Release();
   return promise.forget();
 }
 
 void
 MediaKeys::RejectPromise(PromiseId aId, nsresult aExceptionCode,
                          const nsCString& aReason)
 {
-  EME_LOG("MediaKeys[%p]::RejectPromise(%d, 0x%x)", this, aId, aExceptionCode);
+  EME_LOG("MediaKeys[%p]::RejectPromise(%d, 0x%" PRIx32 ")",
+          this, aId, static_cast<uint32_t>(aExceptionCode));
 
   RefPtr<DetailedPromise> promise(RetrievePromise(aId));
   if (!promise) {
     return;
   }
 
   // This promise could be a createSession or loadSession promise,
   // so we might have a pending session waiting to be resolved into
@@ -477,17 +478,17 @@ IsSessionTypeSupported(const MediaKeySes
 }
 
 already_AddRefed<MediaKeySession>
 MediaKeys::CreateSession(JSContext* aCx,
                          MediaKeySessionType aSessionType,
                          ErrorResult& aRv)
 {
   if (!IsSessionTypeSupported(aSessionType, mConfig)) {
-    EME_LOG("MediaKeys[%p,'%s'] CreateSession() failed, unsupported session type", this);
+    EME_LOG("MediaKeys[%p] CreateSession() failed, unsupported session type", this);
     aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     return nullptr;
   }
 
   if (!mProxy) {
     NS_WARNING("Tried to use a MediaKeys which lost its CDM");
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
--- a/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp
+++ b/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp
@@ -48,17 +48,18 @@ MediaDrmCDMProxy::Init(PromiseId aPromis
                        const nsAString& aTopLevelOrigin,
                        const nsAString& aName)
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
 
   EME_LOG("MediaDrmCDMProxy::Init (%s, %s) %s",
           NS_ConvertUTF16toUTF8(aOrigin).get(),
-          NS_ConvertUTF16toUTF8(aTopLevelOrigin).get());
+          NS_ConvertUTF16toUTF8(aTopLevelOrigin).get(),
+          NS_ConvertUTF16toUTF8(aName).get());
 
   // Create a thread to work with cdm.
   if (!mOwnerThread) {
     nsresult rv = NS_NewNamedThread("MDCDMThread", getter_AddRefs(mOwnerThread));
     if (NS_FAILED(rv)) {
       RejectPromise(aPromiseId, NS_ERROR_DOM_INVALID_STATE_ERR,
                     NS_LITERAL_CSTRING("Couldn't create CDM thread MediaDrmCDMProxy::Init"));
       return;
--- a/dom/media/encoder/MediaEncoder.cpp
+++ b/dom/media/encoder/MediaEncoder.cpp
@@ -186,17 +186,17 @@ MediaEncoder::CreateEncoder(const nsAStr
     mimeType = NS_LITERAL_STRING(AUDIO_OGG);
   }
   else {
     LOG(LogLevel::Error, ("Can not find any encoder to record this media stream"));
     return nullptr;
   }
   LOG(LogLevel::Debug, ("Create encoder result:a[%d] v[%d] w[%d] mimeType = %s.",
                       audioEncoder != nullptr, videoEncoder != nullptr,
-                      writer != nullptr, mimeType.get()));
+                      writer != nullptr, NS_ConvertUTF16toUTF8(mimeType).get()));
   if (videoEncoder && aVideoBitrate != 0) {
     videoEncoder->SetBitrate(aVideoBitrate);
   }
   if (audioEncoder && aAudioBitrate != 0) {
     audioEncoder->SetBitrate(aAudioBitrate);
   }
   encoder = new MediaEncoder(writer.forget(), audioEncoder.forget(),
                              videoEncoder.forget(), mimeType, aAudioBitrate,
--- a/dom/media/encoder/TrackEncoder.cpp
+++ b/dom/media/encoder/TrackEncoder.cpp
@@ -300,17 +300,17 @@ VideoTrackEncoder::AppendVideoSegment(co
       // This is the first real chunk in the track. Use its timestamp as the
       // starting point for this track.
       MOZ_ASSERT(!chunk.mTimeStamp.IsNull());
       const StreamTime nullDuration = mLastChunk.mDuration;
       mLastChunk = chunk;
       chunk.mDuration = 0;
 
       TRACK_LOG(LogLevel::Verbose,
-                ("[VideoTrackEncoder]: Got first video chunk after %lld ticks.",
+                ("[VideoTrackEncoder]: Got first video chunk after %" PRId64 " ticks.",
                  nullDuration));
       // Adapt to the time before the first frame. This extends the first frame
       // from [start, end] to [0, end], but it'll do for now.
       CheckedInt64 diff = FramesToUsecs(nullDuration, mTrackRate);
       if (!diff.isValid()) {
         NS_ERROR("null duration overflow");
         return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
       }
@@ -324,24 +324,24 @@ VideoTrackEncoder::AppendVideoSegment(co
       TRACK_LOG(LogLevel::Verbose,
                 ("[VideoTrackEncoder]: Got dupe or null chunk."));
       // This is the same frame as before (or null). We extend the last chunk
       // with its duration.
       mLastChunk.mDuration += chunk.mDuration;
 
       if (mLastChunk.mDuration < mTrackRate) {
         TRACK_LOG(LogLevel::Verbose,
-                  ("[VideoTrackEncoder]: Ignoring dupe/null chunk of duration "
-                   "%lld", chunk.mDuration));
+                  ("[VideoTrackEncoder]: Ignoring dupe/null chunk of duration %" PRId64,
+                   chunk.mDuration));
         continue;
       }
 
       TRACK_LOG(LogLevel::Verbose,
-                ("[VideoTrackEncoder]: Chunk >1 second. duration=%lld, "
-                 "trackRate=%lld", mLastChunk.mDuration, mTrackRate));
+                ("[VideoTrackEncoder]: Chunk >1 second. duration=%" PRId64 ", "
+                 "trackRate=%" PRId32, mLastChunk.mDuration, mTrackRate));
 
       // If we have gotten dupes for over a second, we force send one
       // to the encoder to make sure there is some output.
       chunk.mTimeStamp = mLastChunk.mTimeStamp + TimeDuration::FromSeconds(1);
 
       // chunk's duration has already been accounted for.
       chunk.mDuration = 0;
 
@@ -377,17 +377,17 @@ VideoTrackEncoder::AppendVideoSegment(co
     if (duration.isValid()) {
       if (duration.value() <= 0) {
         // The timestamp for mLastChunk is newer than for chunk.
         // This means the durations reported from MediaStreamGraph for
         // mLastChunk were larger than the timestamp diff - and durations were
         // used to trigger the 1-second frame above. This could happen due to
         // drift or underruns in the graph.
         TRACK_LOG(LogLevel::Warning,
-                  ("[VideoTrackEncoder]: Underrun detected. Diff=%lld",
+                  ("[VideoTrackEncoder]: Underrun detected. Diff=%" PRId64,
                    duration.value()));
         chunk.mTimeStamp = mLastChunk.mTimeStamp;
       } else {
         mEncodedTicks += duration.value();
         mRawSegment.AppendFrame(lastImage.forget(),
                                 duration.value(),
                                 mLastChunk.mFrame.GetIntrinsicSize(),
                                 PRINCIPAL_HANDLE_NONE,
--- a/dom/media/encoder/VP8TrackEncoder.cpp
+++ b/dom/media/encoder/VP8TrackEncoder.cpp
@@ -246,17 +246,17 @@ VP8TrackEncoder::GetEncodedPartitions(En
       NS_ERROR("Duration overflow");
       return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
     }
 
     mExtractedDurationUs = totalDuration;
     videoData->SetDuration((uint64_t)duration.value());
     videoData->SwapInFrameData(frameData);
     VP8LOG(LogLevel::Verbose,
-           "GetEncodedPartitions TimeStamp %lld, Duration %lld, FrameType %d",
+           "GetEncodedPartitions TimeStamp %" PRIu64 ", Duration %" PRIu64 ", FrameType %d",
            videoData->GetTimeStamp(), videoData->GetDuration(),
            videoData->GetFrameType());
     aData.AppendEncodedFrame(videoData);
   }
 
   return pkt ? NS_OK : NS_ERROR_NOT_AVAILABLE;
 }
 
@@ -545,17 +545,17 @@ VP8TrackEncoder::GetEncodedTrack(Encoded
 
   StreamTime totalProcessedDuration = 0;
   TimeStamp timebase = TimeStamp::Now();
   EncodeOperation nextEncodeOperation = ENCODE_NORMAL_FRAME;
 
   for (VideoSegment::ChunkIterator iter(mSourceSegment);
        !iter.IsEnded(); iter.Next()) {
     VideoChunk &chunk = *iter;
-    VP8LOG(LogLevel::Verbose, "nextEncodeOperation is %d for frame of duration %lld",
+    VP8LOG(LogLevel::Verbose, "nextEncodeOperation is %d for frame of duration %" PRId64,
              nextEncodeOperation, chunk.GetDuration());
 
     // Encode frame.
     if (nextEncodeOperation != SKIP_FRAME) {
       nsresult rv = PrepareRawFrame(chunk);
       NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
       // Encode the data with VP8 encoder
--- a/dom/media/flac/FlacDemuxer.cpp
+++ b/dom/media/flac/FlacDemuxer.cpp
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "FlacDemuxer.h"
 
 #include "mozilla/Maybe.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mp4_demuxer/BitReader.h"
 #include "nsAutoPtr.h"
 #include "prenv.h"
 #include "FlacFrameParser.h"
 #include "VideoUtils.h"
 #include "TimeUnits.h"
 
 #ifdef PR_LOGGING
@@ -733,17 +734,17 @@ FlacTrackDemuxer::Seek(const TimeUnit& a
   const TimeUnit seekTime = ScanUntil(aTime);
 
   return SeekPromise::CreateAndResolve(seekTime, __func__);
 }
 
 TimeUnit
 FlacTrackDemuxer::FastSeek(const TimeUnit& aTime)
 {
-  LOG("FastSeek(%f) avgFrameLen=%f mParsedFramesDuration=%f offset=%lld",
+  LOG("FastSeek(%f) avgFrameLen=%f mParsedFramesDuration=%f offset=%" PRId64,
       aTime.ToSeconds(), AverageFrameLength(),
       mParsedFramesDuration.ToSeconds(), GetResourceOffset());
 
   // Invalidate current frames in the parser.
   mParser->EndFrameSession();
 
   if (!mParser->FirstFrame().IsValid()) {
     // Something wrong, and there's nothing to seek to anyway, so we can
@@ -780,17 +781,17 @@ FlacTrackDemuxer::FastSeek(const TimeUni
     mSource.Seek(SEEK_SET, pivot);
     flac::Frame frame;
     if (!frame.FindNext(mSource)) {
       NS_WARNING("We should have found a point");
       break;
     }
     timeSeekedTo = frame.Time();
 
-    LOGV("FastSeek: interation:%u found:%f @ %lld",
+    LOGV("FastSeek: interation:%u found:%f @ %" PRId64,
          iterations, timeSeekedTo.ToSeconds(), frame.Offset());
 
     if (lastFoundOffset && lastFoundOffset.ref() == frame.Offset()) {
       // Same frame found twice. We're done.
       break;
     }
     lastFoundOffset = Some(frame.Offset());
 
@@ -817,17 +818,17 @@ FlacTrackDemuxer::FastSeek(const TimeUni
   }
 
   return timeSeekedTo;
 }
 
 TimeUnit
 FlacTrackDemuxer::ScanUntil(const TimeUnit& aTime)
 {
-  LOG("ScanUntil(%f avgFrameLen=%f mParsedFramesDuration=%f offset=%lld",
+  LOG("ScanUntil(%f avgFrameLen=%f mParsedFramesDuration=%f offset=%" PRId64,
       aTime.ToSeconds(), AverageFrameLength(),
       mParsedFramesDuration.ToSeconds(), mParser->CurrentFrame().Offset());
 
    if (!mParser->FirstFrame().IsValid()
        || aTime <= mParser->FirstFrame().Time()) {
      return FastSeek(aTime);
    }
 
@@ -847,18 +848,18 @@ FlacTrackDemuxer::ScanUntil(const TimeUn
   mParser->EndFrameSession();
   mSource.Seek(SEEK_SET, previousOffset);
   return previousTime;
 }
 
 RefPtr<FlacTrackDemuxer::SamplesPromise>
 FlacTrackDemuxer::GetSamples(int32_t aNumSamples)
 {
-  LOGV("GetSamples(%d) Begin offset=%lld mParsedFramesDuration=%f"
-       " mTotalFrameLen=%llu",
+  LOGV("GetSamples(%d) Begin offset=%" PRId64 " mParsedFramesDuration=%f"
+       " mTotalFrameLen=%" PRIu64,
        aNumSamples, GetResourceOffset(), mParsedFramesDuration.ToSeconds(),
        mTotalFrameLen);
 
   if (!aNumSamples) {
     return SamplesPromise::CreateAndReject(
       NS_ERROR_DOM_MEDIA_DEMUXER_ERR, __func__);
   }
 
@@ -867,18 +868,18 @@ FlacTrackDemuxer::GetSamples(int32_t aNu
   while (aNumSamples--) {
     RefPtr<MediaRawData> frame(GetNextFrame(FindNextFrame()));
     if (!frame)
       break;
 
     frames->mSamples.AppendElement(frame);
   }
 
-  LOGV("GetSamples() End mSamples.Length=%u aNumSamples=%d offset=%lld"
-       " mParsedFramesDuration=%f mTotalFrameLen=%llu",
+  LOGV("GetSamples() End mSamples.Length=%" PRIuSIZE " aNumSamples=%d offset=%" PRId64
+       " mParsedFramesDuration=%f mTotalFrameLen=%" PRIu64,
        frames->mSamples.Length(), aNumSamples, GetResourceOffset(),
        mParsedFramesDuration.ToSeconds(), mTotalFrameLen);
 
   if (frames->mSamples.IsEmpty()) {
     return SamplesPromise::CreateAndReject(
       NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
   }
 
@@ -925,67 +926,67 @@ FlacTrackDemuxer::GetBuffered()
   // However, for now this will do.
   AutoPinned<MediaResource> stream(mSource.GetResource());
   return GetEstimatedBufferedTimeRanges(stream, duration.ToMicroseconds());
 }
 
 const flac::Frame&
 FlacTrackDemuxer::FindNextFrame()
 {
-  LOGV("FindNext() Begin offset=%lld mParsedFramesDuration=%f"
-       " mTotalFrameLen=%llu",
+  LOGV("FindNext() Begin offset=%" PRId64 " mParsedFramesDuration=%f"
+       " mTotalFrameLen=%" PRIu64,
        GetResourceOffset(), mParsedFramesDuration.ToSeconds(), mTotalFrameLen);
 
   if (mParser->FindNextFrame(mSource)) {
     // Update our current progress stats.
     mParsedFramesDuration =
       std::max(mParsedFramesDuration,
                mParser->CurrentFrame().Time() - mParser->FirstFrame().Time()
                + mParser->CurrentFrame().Duration());
     mTotalFrameLen =
       std::max<uint64_t>(mTotalFrameLen,
                          mParser->CurrentFrame().Offset()
                          - mParser->FirstFrame().Offset()
                          + mParser->CurrentFrame().Size());
 
-    LOGV("FindNext() End time=%f offset=%lld mParsedFramesDuration=%f"
-         " mTotalFrameLen=%llu",
+    LOGV("FindNext() End time=%f offset=%" PRId64 " mParsedFramesDuration=%f"
+         " mTotalFrameLen=%" PRIu64,
          mParser->CurrentFrame().Time().ToSeconds(), GetResourceOffset(),
          mParsedFramesDuration.ToSeconds(), mTotalFrameLen);
   }
 
   return mParser->CurrentFrame();
 }
 
 already_AddRefed<MediaRawData>
 FlacTrackDemuxer::GetNextFrame(const flac::Frame& aFrame)
 {
   if (!aFrame.IsValid()) {
     LOG("GetNextFrame() EOS");
     return nullptr;
   }
 
-  LOG("GetNextFrame() Begin(time=%f offset=%lld size=%u)",
+  LOG("GetNextFrame() Begin(time=%f offset=%" PRId64 " size=%u)",
       aFrame.Time().ToSeconds(), aFrame.Offset(), aFrame.Size());
 
   const int64_t offset = aFrame.Offset();
   const uint32_t size = aFrame.Size();
 
   RefPtr<MediaRawData> frame = new MediaRawData();
   frame->mOffset = offset;
 
   nsAutoPtr<MediaRawDataWriter> frameWriter(frame->CreateWriter());
   if (!frameWriter->SetSize(size)) {
     LOG("GetNext() Exit failed to allocated media buffer");
     return nullptr;
   }
 
   const uint32_t read = Read(frameWriter->Data(), offset, size);
   if (read != size) {
-    LOG("GetNextFrame() Exit read=%u frame->Size=%u", read, frame->Size());
+    LOG("GetNextFrame() Exit read=%u frame->Size=%" PRIuSIZE, read, frame->Size());
     return nullptr;
   }
 
   frame->mTime = aFrame.Time().ToMicroseconds();
   frame->mDuration = aFrame.Duration().ToMicroseconds();
   frame->mTimecode = frame->mTime;
   frame->mOffset = aFrame.Offset();
   frame->mKeyframe = true;
--- a/dom/media/gmp/GMPDecryptorParent.cpp
+++ b/dom/media/gmp/GMPDecryptorParent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GMPDecryptorParent.h"
 #include "GMPContentParent.h"
 #include "MediaData.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Unused.h"
 
 namespace mozilla {
 
 #ifdef LOG
 #undef LOG
 #endif
 
@@ -369,17 +370,17 @@ ToMediaKeyStatus(GMPMediaKeyStatus aStat
     default: return dom::MediaKeyStatus::Internal_error;
   }
 }
 
 mozilla::ipc::IPCResult
 GMPDecryptorParent::RecvBatchedKeyStatusChanged(const nsCString& aSessionId,
                                                 InfallibleTArray<GMPKeyInformation>&& aKeyInfos)
 {
-  LOGD(("GMPDecryptorParent[%p]::RecvBatchedKeyStatusChanged(sessionId='%s', KeyInfos len='%d')",
+  LOGD(("GMPDecryptorParent[%p]::RecvBatchedKeyStatusChanged(sessionId='%s', KeyInfos len='%" PRIuSIZE "')",
         this, aSessionId.get(), aKeyInfos.Length()));
 
   if (mIsOpen) {
     nsTArray<CDMKeyInfo> cdmKeyInfos(aKeyInfos.Length());
     for (uint32_t i = 0; i < aKeyInfos.Length(); i++) {
       LOGD(("GMPDecryptorParent[%p]::RecvBatchedKeyStatusChanged(keyId=%s, gmp-status=%d)",
             this, ToHexString(aKeyInfos[i].keyId()).get(), aKeyInfos[i].status()));
       // If the status is kGMPUnknown, we're going to forget(remove) that key info.
--- a/dom/media/gmp/GMPServiceChild.cpp
+++ b/dom/media/gmp/GMPServiceChild.cpp
@@ -97,17 +97,18 @@ GeckoMediaPluginServiceChild::GetContent
         // helper so that if the launch failed due to the plugin crashing,
         // we can report the crash via the crash reporter. The crash
         // handling notification will arrive shortly if the launch failed
         // due to the plugin crashing.
         self->ConnectCrashHelper(pluginId, helper);
       }
 
       if (!ok || NS_FAILED(rv)) {
-        LOGD(("GeckoMediaPluginServiceChild::GetContentParent SendLaunchGMP failed rv=%d", rv));
+        LOGD(("GeckoMediaPluginServiceChild::GetContentParent SendLaunchGMP failed rv=%" PRIu32,
+              static_cast<uint32_t>(rv)));
         holder->Reject(rv, __func__);
         return;
       }
 
       RefPtr<GMPContentParent> parent = child->GetBridgedGMPContentParent(otherProcess,
                                                                           Move(endpoint));
       if (!alreadyBridgedTo.Contains(otherProcess)) {
         parent->SetDisplayName(displayName);
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -12,16 +12,17 @@
 #include "mozilla/dom/ContentParent.h"
 #include "GMPParent.h"
 #include "GMPVideoDecoderParent.h"
 #include "nsAutoPtr.h"
 #include "nsIObserverService.h"
 #include "GeckoChildProcessHost.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ClearOnShutdown.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/SyncRunnable.h"
 #include "nsXPCOMPrivate.h"
 #include "mozilla/Services.h"
 #include "nsNativeCharsetUtils.h"
 #include "nsIConsoleService.h"
 #include "mozilla/Unused.h"
 #include "GMPDecryptorParent.h"
 #include "nsComponentManagerUtils.h"
@@ -442,17 +443,17 @@ GeckoMediaPluginServiceParent::UnloadPlu
   nsTArray<RefPtr<GMPParent>> plugins;
   {
     MutexAutoLock lock(mMutex);
     // Move all plugins references to a local array. This way mMutex won't be
     // locked when calling CloseActive (to avoid inter-locking).
     Swap(plugins, mPlugins);
   }
 
-  LOGD(("%s::%s plugins:%u", __CLASS__, __FUNCTION__,
+  LOGD(("%s::%s plugins:%" PRIuSIZE, __CLASS__, __FUNCTION__,
         plugins.Length()));
 #ifdef DEBUG
   for (const auto& plugin : plugins) {
     LOGD(("%s::%s plugin: '%s'", __CLASS__, __FUNCTION__,
           plugin->GetDisplayName().get()));
   }
 #endif
   // Note: CloseActive may be async; it could actually finish
@@ -826,17 +827,18 @@ GeckoMediaPluginServiceParent::AddOnGMPT
     LOGD(("%s::%s: %s No GMP Thread", __CLASS__, __FUNCTION__, dir.get()));
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
   LOGD(("%s::%s: %s", __CLASS__, __FUNCTION__, dir.get()));
 
   nsCOMPtr<nsIFile> directory;
   nsresult rv = NS_NewLocalFile(aDirectory, false, getter_AddRefs(directory));
   if (NS_WARN_IF(NS_FAILED(rv))) {
-    LOGD(("%s::%s: failed to create nsIFile for dir=%s rv=%x", __CLASS__, __FUNCTION__, dir.get(), rv));
+    LOGD(("%s::%s: failed to create nsIFile for dir=%s rv=%" PRIx32,
+          __CLASS__, __FUNCTION__, dir.get(), static_cast<uint32_t>(rv)));
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   RefPtr<GMPParent> gmp = CreateGMPParent();
   if (!gmp) {
     NS_WARNING("Can't Create GMPParent");
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
@@ -1473,17 +1475,17 @@ GeckoMediaPluginServiceParent::ForgetThi
 
   ClearNodeIdAndPlugin(filter);
 }
 
 void
 GeckoMediaPluginServiceParent::ClearRecentHistoryOnGMPThread(PRTime aSince)
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
-  LOGD(("%s::%s: since=%lld", __CLASS__, __FUNCTION__, (int64_t)aSince));
+  LOGD(("%s::%s: since=%" PRId64, __CLASS__, __FUNCTION__, (int64_t)aSince));
 
   struct MTimeFilter : public DirectoryFilter {
     explicit MTimeFilter(PRTime aSince)
       : mSince(aSince) {}
 
     // Return true if any files under aPath is modified after |mSince|.
     bool IsModifiedAfter(nsIFile* aPath) {
       PRTime lastModified;
--- a/dom/media/gmp/GMPStorageParent.cpp
+++ b/dom/media/gmp/GMPStorageParent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GMPStorageParent.h"
 #include "GMPParent.h"
 #include "gmp-storage.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Unused.h"
 #include "mozIGeckoMediaPluginService.h"
 
 namespace mozilla {
 
 #ifdef LOG
 #undef LOG
 #endif
@@ -114,29 +115,29 @@ GMPStorageParent::RecvRead(const nsCStri
 
   nsTArray<uint8_t> data;
   if (!mStorage->IsOpen(aRecordName)) {
     LOGD(("GMPStorageParent[%p]::RecvRead(record='%s') failed; record not open",
          this, aRecordName.get()));
     Unused << SendReadComplete(aRecordName, GMPClosedErr, data);
   } else {
     GMPErr rv = mStorage->Read(aRecordName, data);
-    LOGD(("GMPStorageParent[%p]::RecvRead(record='%s') read %d bytes rv=%d",
-      this, aRecordName.get(), data.Length(), rv));
+    LOGD(("GMPStorageParent[%p]::RecvRead(record='%s') read %" PRIuSIZE " bytes rv=%" PRIu32,
+          this, aRecordName.get(), data.Length(), static_cast<uint32_t>(rv)));
     Unused << SendReadComplete(aRecordName, rv, data);
   }
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GMPStorageParent::RecvWrite(const nsCString& aRecordName,
                             InfallibleTArray<uint8_t>&& aBytes)
 {
-  LOGD(("GMPStorageParent[%p]::RecvWrite(record='%s') %d bytes",
+  LOGD(("GMPStorageParent[%p]::RecvWrite(record='%s') %" PRIuSIZE " bytes",
         this, aRecordName.get(), aBytes.Length()));
 
   if (mShutdown) {
     return IPC_FAIL_NO_REASON(this);
   }
 
   if (!mStorage->IsOpen(aRecordName)) {
     LOGD(("GMPStorageParent[%p]::RecvWrite(record='%s') failed record not open",
--- a/dom/media/gmp/GMPVideoDecoderParent.cpp
+++ b/dom/media/gmp/GMPVideoDecoderParent.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GMPVideoDecoderParent.h"
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Unused.h"
 #include "nsAutoRef.h"
 #include "nsThreadUtils.h"
 #include "GMPUtils.h"
 #include "GMPVideoEncodedFrameImpl.h"
 #include "GMPVideoi420FrameImpl.h"
 #include "GMPContentParent.h"
 #include "GMPMessageUtils.h"
@@ -134,17 +135,17 @@ CryptoInfo(const GMPUniquePtr<GMPVideoEn
 }
 
 nsresult
 GMPVideoDecoderParent::Decode(GMPUniquePtr<GMPVideoEncodedFrame> aInputFrame,
                               bool aMissingFrames,
                               const nsTArray<uint8_t>& aCodecSpecificInfo,
                               int64_t aRenderTimeMs)
 {
-  LOGV(("GMPVideoDecoderParent[%p]::Decode() timestamp=%lld keyframe=%d%s",
+  LOGV(("GMPVideoDecoderParent[%p]::Decode() timestamp=%" PRId64 " keyframe=%d%s",
         this, aInputFrame->TimeStamp(),
         aInputFrame->FrameType() == kGMPKeyFrame,
         CryptoInfo(aInputFrame).get()));
 
   if (!mIsOpen) {
     LOGE(("GMPVideoDecoderParent[%p]::Decode() ERROR; dead GMPVideoDecoder", this));
     NS_WARNING("Trying to use an dead GMP video decoder");
     return NS_ERROR_FAILURE;
@@ -314,26 +315,27 @@ GMPVideoDecoderParent::ActorDestroy(Acto
   mVideoHost.ActorDestroyed();
   MaybeDisconnect(aWhy == AbnormalShutdown);
 }
 
 mozilla::ipc::IPCResult
 GMPVideoDecoderParent::RecvDecoded(const GMPVideoi420FrameData& aDecodedFrame)
 {
   --mFrameCount;
-  LOGV(("GMPVideoDecoderParent[%p]::RecvDecoded() timestamp=%lld frameCount=%d",
+  LOGV(("GMPVideoDecoderParent[%p]::RecvDecoded() timestamp=%" PRId64 " frameCount=%d",
     this, aDecodedFrame.mTimestamp(), mFrameCount));
 
   if (!mCallback) {
     return IPC_FAIL_NO_REASON(this);
   }
 
   if (!GMPVideoi420FrameImpl::CheckFrameData(aDecodedFrame)) {
     LOGE(("GMPVideoDecoderParent[%p]::RecvDecoded() "
-       "timestamp=%lld decoded frame corrupt, ignoring"));
+          "timestamp=%" PRId64 " decoded frame corrupt, ignoring",
+          this, aDecodedFrame.mTimestamp()));
     return IPC_FAIL_NO_REASON(this);
   }
   auto f = new GMPVideoi420FrameImpl(aDecodedFrame, &mVideoHost);
 
   // Ignore any return code. It is OK for this to fail without killing the process.
   mCallback->Decoded(f);
 
   return IPC_OK();
--- a/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
@@ -103,17 +103,17 @@ WidevineAdapter::GMPGetAPI(const char* a
              kEMEKeySystemWidevine.Length(),
              &GetCdmHost,
              decryptor));
     if (!cdm) {
       Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p FAILED to create cdm",
           aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this);
       return GMPGenericErr;
     }
-    Log("cdm: 0x%x", cdm);
+    Log("cdm: 0x%p", cdm);
     RefPtr<CDMWrapper> wrapper(new CDMWrapper(cdm, decryptor));
     decryptor->SetCDM(wrapper, aDecryptorId);
     *aPluginAPI = decryptor;
 
   } else if (!strcmp(aAPIName, GMP_API_VIDEO_DECODER)) {
     RefPtr<CDMWrapper> wrapper = WidevineDecryptor::GetInstance(aDecryptorId);
 
     // There is a possible race condition, where the decryptor will be destroyed
--- a/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
@@ -286,17 +286,17 @@ WidevineDecryptor::DecryptBuffer(const P
 {
   GMPBuffer* buffer = aJob.mBuffer;
   const GMPEncryptedBufferMetadata* crypto = aJob.mMetadata;
   InputBuffer sample;
   nsTArray<SubsampleEntry> subsamples;
   InitInputBuffer(crypto, buffer->Id(), buffer->Data(), buffer->Size(), sample, subsamples);
   WidevineDecryptedBlock decrypted;
   Status rv = CDM()->Decrypt(sample, &decrypted);
-  Log("Decryptor::Decrypt(timestamp=%lld) rv=%d sz=%d",
+  Log("Decryptor::Decrypt(timestamp=%" PRId64 ") rv=%d sz=%d",
       sample.timestamp, rv, decrypted.DecryptedBuffer()->Size());
   if (rv == kSuccess) {
     buffer->Resize(decrypted.DecryptedBuffer()->Size());
     memcpy(buffer->Data(),
            decrypted.DecryptedBuffer()->Data(),
            decrypted.DecryptedBuffer()->Size());
   }
   mCallback->Decrypted(buffer, ToGMPErr(rv));
@@ -324,21 +324,21 @@ WidevineDecryptor::DecryptingComplete()
   sDecryptors.erase(mInstanceId);
   mCallback = nullptr;
   Release();
 }
 
 class WidevineBuffer : public cdm::Buffer {
 public:
   explicit WidevineBuffer(size_t aSize) {
-    Log("WidevineBuffer(size=" PRIuSIZE ") created", aSize);
+    Log("WidevineBuffer(size=%" PRIuSIZE ") created", aSize);
     mBuffer.SetLength(aSize);
   }
   ~WidevineBuffer() override {
-    Log("WidevineBuffer(size=" PRIuSIZE ") destroyed", Size());
+    Log("WidevineBuffer(size=%" PRIu32 ") destroyed", Size());
   }
   void Destroy() override { delete this; }
   uint32_t Capacity() const override { return mBuffer.Length(); };
   uint8_t* Data() override { return mBuffer.Elements(); }
   void SetSize(uint32_t aSize) override { mBuffer.SetLength(aSize); }
   uint32_t Size() const override { return mBuffer.Length(); }
 
 private:
@@ -374,17 +374,17 @@ private:
   RefPtr<WidevineDecryptor> mDecryptor;
   RefPtr<CDMWrapper> mCDM;
   void* mContext;
 };
 
 void
 WidevineDecryptor::SetTimer(int64_t aDelayMs, void* aContext)
 {
-  Log("Decryptor::SetTimer(delay_ms=%lld, context=0x%x)", aDelayMs, aContext);
+  Log("Decryptor::SetTimer(delay_ms=%" PRId64 ", context=0x%p)", aDelayMs, aContext);
   if (mCDM) {
     GMPSetTimerOnMainThread(new TimerTask(this, mCDM, aContext), aDelayMs);
   }
 }
 
 Time
 WidevineDecryptor::GetCurrentWallTime()
 {
--- a/dom/media/gmp/widevine-adapter/WidevineVideoDecoder.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineVideoDecoder.cpp
@@ -136,17 +136,17 @@ WidevineVideoDecoder::Decode(GMPVideoEnc
   if (raw->mKeyframe
       && !subsamples.IsEmpty()
       && mCodecType == kGMPVideoCodecH264) {
     subsamples[0].clear_bytes += mAnnexB->Length();
   }
 
   WidevineVideoFrame frame;
   Status rv = CDM()->DecryptAndDecodeFrame(sample, &frame);
-  Log("WidevineVideoDecoder::Decode(timestamp=%lld) rv=%d", sample.timestamp,
+  Log("WidevineVideoDecoder::Decode(timestamp=%" PRId64 ") rv=%d", sample.timestamp,
       rv);
 
   // Destroy frame, so that the shmem is now free to be used to return
   // output to the Gecko process.
   aInputFrame->Destroy();
   aInputFrame = nullptr;
 
   if (rv == kSuccess) {
--- a/dom/media/gmp/widevine-adapter/WidevineVideoFrame.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineVideoFrame.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WidevineVideoFrame.h"
 
 #include "WidevineUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
 
 using namespace cdm;
 
 namespace mozilla {
 
 WidevineVideoFrame::WidevineVideoFrame()
   : mFormat(kUnknownVideoFormat)
   , mSize(0,0)
@@ -108,17 +109,17 @@ uint32_t
 WidevineVideoFrame::Stride(cdm::VideoFrame::VideoPlane aPlane)
 {
   return mPlaneStrides[aPlane];
 }
 
 void
 WidevineVideoFrame::SetTimestamp(int64_t timestamp)
 {
-  Log("WidevineVideoFrame::SetTimestamp(%lld) this=%p", timestamp, this);
+  Log("WidevineVideoFrame::SetTimestamp(%" PRId64 ") this=%p", timestamp, this);
   mTimestamp = timestamp;
 }
 
 int64_t
 WidevineVideoFrame::Timestamp() const
 {
   return mTimestamp;
 }
--- a/dom/media/mediasink/DecodedAudioDataSink.cpp
+++ b/dom/media/mediasink/DecodedAudioDataSink.cpp
@@ -7,16 +7,17 @@
 #include "nsPrintfCString.h"
 #include "MediaQueue.h"
 #include "DecodedAudioDataSink.h"
 #include "VideoUtils.h"
 #include "AudioConverter.h"
 
 #include "mozilla/CheckedInt.h"
 #include "mozilla/DebugOnly.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "MediaPrefs.h"
 
 namespace mozilla {
 
 extern LazyLogModule gMediaDecoderLog;
 #define SINK_LOG(msg, ...) \
   MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, \
     ("DecodedAudioDataSink=%p " msg, this, ##__VA_ARGS__))
@@ -302,17 +303,17 @@ DecodedAudioDataSink::PopFrames(uint32_t
     }
     MOZ_ASSERT(mCurrentData->mFrames > 0);
     mProcessedQueueLength -=
       FramesToUsecs(mCurrentData->mFrames, mOutputRate).value();
   }
 
   auto framesToPop = std::min(aFrames, mCursor->Available());
 
-  SINK_LOG_V("playing audio at time=%lld offset=%u length=%u",
+  SINK_LOG_V("playing audio at time=%" PRId64 " offset=%u length=%u",
              mCurrentData->mTime, mCurrentData->mFrames - mCursor->Available(), framesToPop);
 
   UniquePtr<AudioStream::Chunk> chunk =
     MakeUnique<Chunk>(mCurrentData, framesToPop, mCursor->Ptr());
 
   {
     MonitorAutoLock mon(mMonitor);
     mWritten += framesToPop;
--- a/dom/media/mediasink/VideoSink.cpp
+++ b/dom/media/mediasink/VideoSink.cpp
@@ -3,16 +3,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaQueue.h"
 #include "VideoSink.h"
 #include "MediaPrefs.h"
 
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/SizePrintfMacros.h"
+
 namespace mozilla {
 
 extern LazyLogModule gMediaDecoderLog;
 
 #undef FMT
 
 #define FMT(x, ...) "VideoSink=%p " x, this, ##__VA_ARGS__
 #define VSINK_LOG(x, ...)   MOZ_LOG(gMediaDecoderLog, LogLevel::Debug,   (FMT(x, ##__VA_ARGS__)))
@@ -389,17 +392,17 @@ VideoSink::RenderVideoFrames(int32_t aMa
     }
 
     ImageContainer::NonOwningImage* img = images.AppendElement();
     img->mTimeStamp = t;
     img->mImage = frame->mImage;
     img->mFrameID = frame->mFrameID;
     img->mProducerID = mProducerID;
 
-    VSINK_LOG_V("playing video frame %lld (id=%x) (vq-queued=%i)",
+    VSINK_LOG_V("playing video frame %" PRId64 " (id=%x) (vq-queued=%" PRIuSIZE ")",
                 frame->mTime, frame->mFrameID, VideoQueue().GetSize());
   }
   mContainer->SetCurrentFrames(frames[0]->As<VideoData>()->mDisplay, images);
 }
 
 void
 VideoSink::UpdateRenderedVideoFrames()
 {
@@ -416,17 +419,17 @@ VideoSink::UpdateRenderedVideoFrames()
   while (VideoQueue().GetSize() > mMinVideoQueueSize &&
          clockTime >= VideoQueue().PeekFront()->GetEndTime()) {
     RefPtr<MediaData> frame = VideoQueue().PopFront();
     lastFrameEndTime = frame->GetEndTime();
     if (frame->As<VideoData>()->IsSentToCompositor()) {
       mFrameStats.NotifyPresentedFrame();
     } else {
       mFrameStats.NotifyDecodedFrames({ 0, 0, 1 });
-      VSINK_LOG_V("discarding video frame mTime=%lld clock_time=%lld",
+      VSINK_LOG_V("discarding video frame mTime=%" PRId64 " clock_time=%" PRId64,
                   frame->mTime, clockTime);
     }
   }
 
   // The presentation end time of the last video frame displayed is either
   // the end time of the current frame, or if we dropped all frames in the
   // queue, the end time of the last frame we removed from the queue.
   RefPtr<MediaData> currentFrame = VideoQueue().PeekFront();
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -3,17 +3,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ContainerParser.h"
 
 #include "WebMBufferedParser.h"
 #include "mozilla/EndianUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/ErrorResult.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mp4_demuxer/MoofParser.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Maybe.h"
 #include "MediaData.h"
 #ifdef MOZ_FMP4
 #include "MP4Stream.h"
 #include "mp4_demuxer/AtomType.h"
 #include "mp4_demuxer/ByteReader.h"
@@ -37,29 +39,29 @@ ContainerParser::ContainerParser(const M
 {
 }
 
 ContainerParser::~ContainerParser() = default;
 
 MediaResult
 ContainerParser::IsInitSegmentPresent(MediaByteBuffer* aData)
 {
-  MSE_DEBUG(ContainerParser, "aLength=%u [%x%x%x%x]",
+  MSE_DEBUG(ContainerParser, "aLength=%" PRIuSIZE " [%x%x%x%x]",
             aData->Length(),
             aData->Length() > 0 ? (*aData)[0] : 0,
             aData->Length() > 1 ? (*aData)[1] : 0,
             aData->Length() > 2 ? (*aData)[2] : 0,
             aData->Length() > 3 ? (*aData)[3] : 0);
   return NS_ERROR_NOT_AVAILABLE;
 }
 
 MediaResult
 ContainerParser::IsMediaSegmentPresent(MediaByteBuffer* aData)
 {
-  MSE_DEBUG(ContainerParser, "aLength=%u [%x%x%x%x]",
+  MSE_DEBUG(ContainerParser, "aLength=%" PRIuSIZE " [%x%x%x%x]",
             aData->Length(),
             aData->Length() > 0 ? (*aData)[0] : 0,
             aData->Length() > 1 ? (*aData)[1] : 0,
             aData->Length() > 2 ? (*aData)[2] : 0,
             aData->Length() > 3 ? (*aData)[3] : 0);
   return NS_ERROR_NOT_AVAILABLE;
 }
 
@@ -230,17 +232,17 @@ public:
         MOZ_ASSERT(mParser.mInitEndOffset <= mResource->GetLength());
         if (!mInitData->SetLength(mParser.mInitEndOffset, fallible)) {
           // Super unlikely OOM
           return NS_ERROR_OUT_OF_MEMORY;
         }
         mCompleteInitSegmentRange = MediaByteRange(0, mParser.mInitEndOffset);
         char* buffer = reinterpret_cast<char*>(mInitData->Elements());
         mResource->ReadFromCache(buffer, 0, mParser.mInitEndOffset);
-        MSE_DEBUG(WebMContainerParser, "Stashed init of %u bytes.",
+        MSE_DEBUG(WebMContainerParser, "Stashed init of %" PRId64 " bytes.",
                   mParser.mInitEndOffset);
         mResource = nullptr;
       } else {
         MSE_DEBUG(WebMContainerParser, "Incomplete init found.");
       }
       mHasInitData = true;
     }
     mOffset += aData->Length();
@@ -256,17 +258,17 @@ public:
     bool foundNewCluster = false;
     while (mapping[0].mSyncOffset != mapping[endIdx].mSyncOffset) {
       endIdx -= 1;
       foundNewCluster = true;
     }
 
     int32_t completeIdx = endIdx;
     while (completeIdx >= 0 && mOffset < mapping[completeIdx].mEndOffset) {
-      MSE_DEBUG(WebMContainerParser, "block is incomplete, missing: %lld",
+      MSE_DEBUG(WebMContainerParser, "block is incomplete, missing: %" PRId64,
                 mapping[completeIdx].mEndOffset - mOffset);
       completeIdx -= 1;
     }
 
     // Save parsed blocks for which we do not have all data yet.
     mOverlappedMapping.AppendElements(mapping.Elements() + completeIdx + 1,
                                       mapping.Length() - completeIdx - 1);
 
@@ -312,17 +314,18 @@ public:
 
     uint64_t frameDuration =
       (completeIdx + 1u < mapping.Length())
       ? mapping[completeIdx + 1].mTimecode - mapping[completeIdx].mTimecode
       : mapping[completeIdx].mTimecode - previousMapping.ref().mTimecode;
     aStart = mapping[0].mTimecode / NS_PER_USEC;
     aEnd = (mapping[completeIdx].mTimecode + frameDuration) / NS_PER_USEC;
 
-    MSE_DEBUG(WebMContainerParser, "[%lld, %lld] [fso=%lld, leo=%lld, l=%u processedIdx=%u fs=%lld]",
+    MSE_DEBUG(WebMContainerParser, "[%" PRId64 ", %" PRId64 "] [fso=%" PRId64
+              ", leo=%" PRId64 ", l=%" PRIuSIZE " processedIdx=%u fs=%" PRId64 "]",
               aStart, aEnd, mapping[0].mSyncOffset,
               mapping[completeIdx].mEndOffset, mapping.Length(), completeIdx,
               mCompleteMediaSegmentRange.mEnd);
 
     return NS_OK;
   }
 
   int64_t GetRoundingError() override
@@ -497,17 +500,17 @@ public:
       if (range.Length()) {
         mCompleteInitSegmentRange = range;
         if (!mInitData->SetLength(range.Length(), fallible)) {
           // Super unlikely OOM
           return NS_ERROR_OUT_OF_MEMORY;
         }
         char* buffer = reinterpret_cast<char*>(mInitData->Elements());
         mResource->ReadFromCache(buffer, range.mStart, range.Length());
-        MSE_DEBUG(MP4ContainerParser ,"Stashed init of %u bytes.",
+        MSE_DEBUG(MP4ContainerParser ,"Stashed init of %" PRIu64 " bytes.",
                   range.Length());
       } else {
         MSE_DEBUG(MP4ContainerParser, "Incomplete init found.");
       }
       mHasInitData = true;
     }
 
     mp4_demuxer::Interval<mp4_demuxer::Microseconds> compositionRange =
@@ -524,17 +527,17 @@ public:
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     if (compositionRange.IsNull()) {
       return NS_ERROR_NOT_AVAILABLE;
     }
     aStart = compositionRange.start;
     aEnd = compositionRange.end;
-    MSE_DEBUG(MP4ContainerParser, "[%lld, %lld]",
+    MSE_DEBUG(MP4ContainerParser, "[%" PRId64 ", %" PRId64 "]",
               aStart, aEnd);
     return NS_OK;
   }
 
   // Gaps of up to 35ms (marginally longer than a single frame at 30fps) are considered
   // to be sequential frames.
   int64_t GetRoundingError() override
   {
@@ -674,17 +677,17 @@ public:
     }
     mCompleteMediaSegmentRange = MediaByteRange(header.header_length,
                                                 header.frame_length);
     // The ADTS MediaSource Byte Stream Format document doesn't
     // define media header. Just treat it the same as the whole
     // media segment.
     mCompleteMediaHeaderRange = mCompleteMediaSegmentRange;
 
-    MSE_DEBUG(ADTSContainerParser, "[%lld, %lld]",
+    MSE_DEBUG(ADTSContainerParser, "[%" PRId64 ", %" PRId64 "]",
               aStart, aEnd);
     // We don't update timestamps, regardless.
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Audio shouldn't have gaps.
   // Especially when we generate the timestamps ourselves.
   int64_t GetRoundingError() override
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -330,17 +330,17 @@ MediaSource::EndOfStream(const Optional<
     aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
   }
 }
 
 void
 MediaSource::EndOfStream(const MediaResult& aError)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MSE_API("EndOfStream(aError=%d)", aError.Code());
+  MSE_API("EndOfStream(aError=%" PRId32")", static_cast<uint32_t>(aError.Code()));
 
   SetReadyState(MediaSourceReadyState::Ended);
   mSourceBuffers->Ended();
   mDecoder->DecodeError(aError);
 }
 
 /* static */ bool
 MediaSource::IsTypeSupported(const GlobalObject& aOwner, const nsAString& aType)
@@ -470,17 +470,18 @@ MediaSource::MediaSource(nsPIDOMWindowIn
           aWindow, mSourceBuffers.get(), mActiveSourceBuffers.get());
 }
 
 void
 MediaSource::SetReadyState(MediaSourceReadyState aState)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aState != mReadyState);
-  MSE_DEBUG("SetReadyState(aState=%d) mReadyState=%d", aState, mReadyState);
+  MSE_DEBUG("SetReadyState(aState=%" PRIu32 ") mReadyState=%" PRIu32,
+            static_cast<uint32_t>(aState), static_cast<uint32_t>(mReadyState));
 
   MediaSourceReadyState oldState = mReadyState;
   mReadyState = aState;
 
   if (mReadyState == MediaSourceReadyState::Open &&
       (oldState == MediaSourceReadyState::Closed ||
        oldState == MediaSourceReadyState::Ended)) {
     QueueAsyncSimpleEvent("sourceopen");
--- a/dom/media/mediasource/ResourceQueue.cpp
+++ b/dom/media/mediasource/ResourceQueue.cpp
@@ -3,18 +3,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ResourceQueue.h"
 #include "nsDeque.h"
 #include "MediaData.h"
 #include "mozilla/ErrorResult.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Sprintf.h"
+#include "mozilla/SizePrintfMacros.h"
 
 extern mozilla::LogModule* GetSourceBufferResourceLog();
 
 #define SBR_DEBUG(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Debug, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 #define SBR_DEBUGV(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Verbose, ("ResourceQueue(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 
 namespace mozilla {
 
@@ -85,27 +87,27 @@ ResourceQueue::AppendItem(MediaByteBuffe
   mLogicalLength += aData->Length();
   Push(new ResourceItem(aData));
 }
 
 uint32_t
 ResourceQueue::Evict(uint64_t aOffset, uint32_t aSizeToEvict,
                      ErrorResult& aRv)
 {
-  SBR_DEBUG("Evict(aOffset=%llu, aSizeToEvict=%u)",
+  SBR_DEBUG("Evict(aOffset=%" PRIu64 ", aSizeToEvict=%u)",
             aOffset, aSizeToEvict);
   return EvictBefore(std::min(aOffset, mOffset + (uint64_t)aSizeToEvict), aRv);
 }
 
 uint32_t ResourceQueue::EvictBefore(uint64_t aOffset, ErrorResult& aRv)
 {
-  SBR_DEBUG("EvictBefore(%llu)", aOffset);
+  SBR_DEBUG("EvictBefore(%" PRIu64 ")", aOffset);
   uint32_t evicted = 0;
   while (ResourceItem* item = ResourceAt(0)) {
-    SBR_DEBUG("item=%p length=%d offset=%llu",
+    SBR_DEBUG("item=%p length=%" PRIuSIZE " offset=%" PRIu64,
               item, item->mData->Length(), mOffset);
     if (item->mData->Length() + mOffset >= aOffset) {
       if (aOffset <= mOffset) {
         break;
       }
       uint32_t offset = aOffset - mOffset;
       mOffset += offset;
       evicted += offset;
@@ -128,17 +130,17 @@ uint32_t ResourceQueue::EvictBefore(uint
 }
 
 uint32_t
 ResourceQueue::EvictAll()
 {
   SBR_DEBUG("EvictAll()");
   uint32_t evicted = 0;
   while (ResourceItem* item = ResourceAt(0)) {
-    SBR_DEBUG("item=%p length=%d offset=%llu",
+    SBR_DEBUG("item=%p length=%" PRIuSIZE " offset=%" PRIu64,
               item, item->mData->Length(), mOffset);
     mOffset += item->mData->Length();
     evicted += item->mData->Length();
     delete PopFront();
   }
   return evicted;
 }
 
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -45,17 +45,17 @@ using media::TimeUnit;
 typedef SourceBufferAttributes::AppendState AppendState;
 
 namespace dom {
 
 void
 SourceBuffer::SetMode(SourceBufferAppendMode aMode, ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MSE_API("SetMode(aMode=%d)", aMode);
+  MSE_API("SetMode(aMode=%" PRIu32 ")", static_cast<uint32_t>(aMode));
   if (!IsAttached() || mUpdating) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
   if (mCurrentAttributes.mGenerateTimestamps &&
       aMode == SourceBufferAppendMode::Segments) {
     aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
     return;
--- a/dom/media/mediasource/SourceBufferResource.cpp
+++ b/dom/media/mediasource/SourceBufferResource.cpp
@@ -6,16 +6,17 @@
 
 #include "SourceBufferResource.h"
 
 #include <algorithm>
 
 #include "nsISeekableStream.h"
 #include "nsISupports.h"
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "MediaData.h"
 
 mozilla::LogModule* GetSourceBufferResourceLog()
 {
   static mozilla::LazyLogModule sLogModule("SourceBufferResource");
   return sLogModule;
 }
 
@@ -33,17 +34,17 @@ SourceBufferResource::Close()
   mClosed = true;
   mon.NotifyAll();
   return NS_OK;
 }
 
 nsresult
 SourceBufferResource::ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes)
 {
-  SBR_DEBUG("ReadAt(aOffset=%lld, aBuffer=%p, aCount=%u, aBytes=%p)",
+  SBR_DEBUG("ReadAt(aOffset=%" PRId64 ", aBuffer=%p, aCount=%u, aBytes=%p)",
             aOffset, aBytes, aCount, aBytes);
   ReentrantMonitorAutoEnter mon(mMonitor);
   return ReadAtInternal(aOffset, aBuffer, aCount, aBytes, /* aMayBlock = */ true);
 }
 
 nsresult
 SourceBufferResource::ReadAtInternal(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes,
                                      bool aMayBlock)
@@ -73,64 +74,64 @@ SourceBufferResource::ReadAtInternal(int
 
   uint32_t available = GetLength() - aOffset;
   uint32_t count = std::min(aCount, available);
 
   // Keep the position of the last read to have Tell() approximately give us
   // the position we're up to in the stream.
   mOffset = aOffset + count;
 
-  SBR_DEBUGV("offset=%llu GetLength()=%u available=%u count=%u mEnded=%d",
+  SBR_DEBUGV("offset=%" PRId64 " GetLength()=%" PRId64 " available=%u count=%u mEnded=%d",
              aOffset, GetLength(), available, count, mEnded);
   if (available == 0) {
     SBR_DEBUGV("reached EOF");
     *aBytes = 0;
     return NS_OK;
   }
 
   mInputBuffer.CopyData(aOffset, count, aBuffer);
   *aBytes = count;
 
   return NS_OK;
 }
 
 nsresult
 SourceBufferResource::ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount)
 {
-  SBR_DEBUG("ReadFromCache(aBuffer=%p, aOffset=%lld, aCount=%u)",
+  SBR_DEBUG("ReadFromCache(aBuffer=%p, aOffset=%" PRId64 ", aCount=%u)",
             aBuffer, aOffset, aCount);
   ReentrantMonitorAutoEnter mon(mMonitor);
   uint32_t bytesRead;
   nsresult rv = ReadAtInternal(aOffset, aBuffer, aCount, &bytesRead, /* aMayBlock = */ false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // ReadFromCache return failure if not all the data is cached.
   return bytesRead == aCount ? NS_OK : NS_ERROR_FAILURE;
 }
 
 uint32_t
 SourceBufferResource::EvictData(uint64_t aPlaybackOffset, int64_t aThreshold,
                                 ErrorResult& aRv)
 {
-  SBR_DEBUG("EvictData(aPlaybackOffset=%llu,"
-            "aThreshold=%u)", aPlaybackOffset, aThreshold);
+  SBR_DEBUG("EvictData(aPlaybackOffset=%" PRIu64 ","
+            "aThreshold=%" PRId64 ")", aPlaybackOffset, aThreshold);
   ReentrantMonitorAutoEnter mon(mMonitor);
   uint32_t result = mInputBuffer.Evict(aPlaybackOffset, aThreshold, aRv);
   if (result > 0) {
     // Wake up any waiting threads in case a ReadInternal call
     // is now invalid.
     mon.NotifyAll();
   }
   return result;
 }
 
 void
 SourceBufferResource::EvictBefore(uint64_t aOffset, ErrorResult& aRv)
 {
-  SBR_DEBUG("EvictBefore(aOffset=%llu)", aOffset);
+  SBR_DEBUG("EvictBefore(aOffset=%" PRIu64 ")", aOffset);
   ReentrantMonitorAutoEnter mon(mMonitor);
 
   mInputBuffer.EvictBefore(aOffset, aRv);
 
   // Wake up any waiting threads in case a ReadInternal call
   // is now invalid.
   mon.NotifyAll();
 }
@@ -141,17 +142,17 @@ SourceBufferResource::EvictAll()
   SBR_DEBUG("EvictAll()");
   ReentrantMonitorAutoEnter mon(mMonitor);
   return mInputBuffer.EvictAll();
 }
 
 void
 SourceBufferResource::AppendData(MediaByteBuffer* aData)
 {
-  SBR_DEBUG("AppendData(aData=%p, aLength=%u)",
+  SBR_DEBUG("AppendData(aData=%p, aLength=%" PRIuSIZE ")",
             aData->Elements(), aData->Length());
   ReentrantMonitorAutoEnter mon(mMonitor);
   mInputBuffer.AppendItem(aData);
   mEnded = false;
   mon.NotifyAll();
 }
 
 void
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "TrackBuffersManager.h"
 #include "ContainerParser.h"
 #include "MediaSourceDemuxer.h"
 #include "MediaSourceUtils.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/StateMirroring.h"
 #include "SourceBufferResource.h"
 #include "SourceBuffer.h"
 #include "WebMDemuxer.h"
 #include "SourceBufferTask.h"
 
 #ifdef MOZ_FMP4
 #include "MP4Demuxer.h"
@@ -113,17 +114,17 @@ TrackBuffersManager::~TrackBuffersManage
   ShutdownDemuxers();
 }
 
 RefPtr<TrackBuffersManager::AppendPromise>
 TrackBuffersManager::AppendData(MediaByteBuffer* aData,
                                 const SourceBufferAttributes& aAttributes)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MSE_DEBUG("Appending %lld bytes", aData->Length());
+  MSE_DEBUG("Appending %" PRIuSIZE " bytes", aData->Length());
 
   mEnded = false;
 
   return InvokeAsync<RefPtr<MediaByteBuffer>, SourceBufferAttributes&&>(
            GetTaskQueue(), this, __func__,
            &TrackBuffersManager::DoAppendData, aData, aAttributes);
 }
 
@@ -269,18 +270,18 @@ TrackBuffersManager::EvictData(const Tim
     // We're adding more data than we can hold.
     return EvictDataResult::BUFFER_FULL;
   }
   const int64_t toEvict = GetSize() + aSize - EvictionThreshold();
 
   const uint32_t canEvict =
     Evictable(HasVideo() ? TrackInfo::kVideoTrack : TrackInfo::kAudioTrack);
 
-  MSE_DEBUG("currentTime=%lld buffered=%lldkB, eviction threshold=%ukB, "
-            "evict=%lldkB canevict=%ukB",
+  MSE_DEBUG("currentTime=%" PRId64 " buffered=%" PRId64 "kB, eviction threshold=%" PRId64 "kB, "
+            "evict=%" PRId64 "kB canevict=%" PRIu32 "kB",
             aPlaybackTime.ToMicroseconds(), GetSize() / 1024,
             EvictionThreshold() / 1024, toEvict / 1024, canEvict / 1024);
 
   if (toEvict <= 0) {
     mEvictionState = EvictionState::NO_EVICTION_NEEDED;
     return EvictDataResult::NO_DATA_EVICTED;
   }
 
@@ -292,17 +293,17 @@ TrackBuffersManager::EvictData(const Tim
     // However, the current appendBuffer will fail as we can't know ahead of
     // time if the eviction will later succeed.
     result = EvictDataResult::BUFFER_FULL;
   } else {
     mEvictionState = EvictionState::EVICTION_NEEDED;
     result = EvictDataResult::NO_DATA_EVICTED;
   }
   MSE_DEBUG(
-    "Reached our size limit, schedule eviction of %lld bytes (%s)", toEvict,
+    "Reached our size limit, schedule eviction of %" PRId64 " bytes (%s)", toEvict,
     result == EvictDataResult::BUFFER_FULL ? "buffer full" : "no data evicted");
   QueueTask(new EvictDataTask(aPlaybackTime, toEvict));
 
   return result;
 }
 
 TimeIntervals
 TrackBuffersManager::Buffered() const
@@ -449,17 +450,17 @@ TrackBuffersManager::DoEvictData(const T
       break;
     }
     partialEvict += frame->ComputedSizeOfIncludingThis();
   }
 
   const int64_t finalSize = mSizeSourceBuffer - aSizeToEvict;
 
   if (lastKeyFrameIndex > 0) {
-    MSE_DEBUG("Step1. Evicting %lld bytes prior currentTime",
+    MSE_DEBUG("Step1. Evicting %" PRId64 " bytes prior currentTime",
               aSizeToEvict - toEvict);
     CodedFrameRemoval(
       TimeInterval(TimeUnit::FromMicroseconds(0),
                    TimeUnit::FromMicroseconds(buffer[lastKeyFrameIndex]->mTime - 1)));
   }
 
   if (mSizeSourceBuffer <= finalSize) {
     return;
@@ -489,17 +490,17 @@ TrackBuffersManager::DoEvictData(const T
       // We've reached a frame that shouldn't be evicted -> Evict after it -> i+1.
       // Or the previous loop reached the eviction threshold -> Evict from it -> i+1.
       evictedFramesStartIndex = i + 1;
       break;
     }
     toEvict -= frame->ComputedSizeOfIncludingThis();
   }
   if (evictedFramesStartIndex < buffer.Length()) {
-    MSE_DEBUG("Step2. Evicting %lld bytes from trailing data",
+    MSE_DEBUG("Step2. Evicting %" PRId64 " bytes from trailing data",
               mSizeSourceBuffer - finalSize - toEvict);
     CodedFrameRemoval(
       TimeInterval(TimeUnit::FromMicroseconds(buffer[evictedFramesStartIndex]->mTime),
                    TimeUnit::FromInfinity()));
   }
 }
 
 RefPtr<TrackBuffersManager::RangeRemovalPromise>
@@ -768,17 +769,17 @@ TrackBuffersManager::NeedMoreData()
   mSourceBufferAttributes = nullptr;
   mCurrentTask = nullptr;
   ProcessTasks();
 }
 
 void
 TrackBuffersManager::RejectAppend(const MediaResult& aRejectValue, const char* aName)
 {
-  MSE_DEBUG("rv=%u", aRejectValue.Code());
+  MSE_DEBUG("rv=%" PRIu32, static_cast<uint32_t>(aRejectValue.Code()));
   MOZ_DIAGNOSTIC_ASSERT(mCurrentTask && mCurrentTask->GetType() == SourceBufferTask::Type::AppendBuffer);
 
   mCurrentTask->As<AppendBufferTask>()->mPromise.Reject(aRejectValue, __func__);
   mSourceBufferAttributes = nullptr;
   mCurrentTask = nullptr;
   ProcessTasks();
 }
 
@@ -1174,18 +1175,19 @@ TrackBuffersManager::CodedFrameProcessin
   return p;
 }
 
 void
 TrackBuffersManager::OnDemuxFailed(TrackType aTrack,
                                    const MediaResult& aError)
 {
   MOZ_ASSERT(OnTaskQueue());
-  MSE_DEBUG("Failed to demux %s, failure:%u",
-            aTrack == TrackType::kVideoTrack ? "video" : "audio", aError.Code());
+  MSE_DEBUG("Failed to demux %s, failure:%" PRIu32,
+            aTrack == TrackType::kVideoTrack ? "video" : "audio",
+            static_cast<uint32_t>(aError.Code()));
   switch (aError.Code()) {
     case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
     case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
       if (aTrack == TrackType::kVideoTrack) {
         DoDemuxAudio();
       } else {
         CompleteCodedFrameProcessing();
       }
@@ -1210,17 +1212,17 @@ TrackBuffersManager::DoDemuxVideo()
            &TrackBuffersManager::OnVideoDemuxFailed)
     ->Track(mVideoTracks.mDemuxRequest);
 }
 
 void
 TrackBuffersManager::OnVideoDemuxCompleted(RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples)
 {
   MOZ_ASSERT(OnTaskQueue());
-  MSE_DEBUG("%d video samples demuxed", aSamples->mSamples.Length());
+  MSE_DEBUG("%" PRIuSIZE " video samples demuxed", aSamples->mSamples.Length());
   mVideoTracks.mDemuxRequest.Complete();
   mVideoTracks.mQueuedSamples.AppendElements(aSamples->mSamples);
   DoDemuxAudio();
 }
 
 void
 TrackBuffersManager::DoDemuxAudio()
 {
@@ -1235,17 +1237,17 @@ TrackBuffersManager::DoDemuxAudio()
            &TrackBuffersManager::OnAudioDemuxFailed)
     ->Track(mAudioTracks.mDemuxRequest);
 }
 
 void
 TrackBuffersManager::OnAudioDemuxCompleted(RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples)
 {
   MOZ_ASSERT(OnTaskQueue());
-  MSE_DEBUG("%d audio samples demuxed", aSamples->mSamples.Length());
+  MSE_DEBUG("%" PRIuSIZE " audio samples demuxed", aSamples->mSamples.Length());
   mAudioTracks.mDemuxRequest.Complete();
   mAudioTracks.mQueuedSamples.AppendElements(aSamples->mSamples);
   CompleteCodedFrameProcessing();
 }
 
 void
 TrackBuffersManager::CompleteCodedFrameProcessing()
 {
@@ -1436,17 +1438,17 @@ TrackBuffersManager::ProcessFrames(Track
   // Highest presentation time seen in samples block.
   TimeUnit highestSampleTime;
 
   if (aSamples.Length()) {
     aTrackData.mLastParsedEndTime = TimeUnit();
   }
 
   for (auto& sample : aSamples) {
-    SAMPLE_DEBUG("Processing %s frame(pts:%lld end:%lld, dts:%lld, duration:%lld, "
+    SAMPLE_DEBUG("Processing %s frame(pts:%" PRId64 " end:%" PRId64 ", dts:%" PRId64 ", duration:%" PRId64 ", "
                "kf:%d)",
                aTrackData.mInfo->mMimeType.get(),
                sample->mTime,
                sample->GetEndTime(),
                sample->mTimecode,
                sample->mDuration,
                sample->mKeyframe);
 
@@ -1664,17 +1666,17 @@ TrackBuffersManager::CheckNextInsertionI
 void
 TrackBuffersManager::InsertFrames(TrackBuffer& aSamples,
                                   const TimeIntervals& aIntervals,
                                   TrackData& aTrackData)
 {
   // 5. Let track buffer equal the track buffer that the coded frame will be added to.
   auto& trackBuffer = aTrackData;
 
-  MSE_DEBUGV("Processing %d %s frames(start:%lld end:%lld)",
+  MSE_DEBUGV("Processing %" PRIuSIZE " %s frames(start:%" PRId64 " end:%" PRId64 ")",
              aSamples.Length(),
              aTrackData.mInfo->mMimeType.get(),
              aIntervals.GetStart().ToMicroseconds(),
              aIntervals.GetEnd().ToMicroseconds());
 
   // TODO: Handle splicing of audio (and text) frames.
   // 11. Let spliced audio frame be an unset variable for holding audio splice information
   // 12. Let spliced timed text frame be an unset variable for holding timed text splice information
@@ -2131,17 +2133,17 @@ TrackBuffersManager::Seek(TrackInfo::Tra
       lastKeyFrameTime = Some(sampleTime);
       lastKeyFrameIndex = i;
     }
     if (sampleTime == aTime ||
         (sampleTime > aTime && lastKeyFrameTime.isSome())) {
       break;
     }
   }
-  MSE_DEBUG("Keyframe %s found at %lld @ %u",
+  MSE_DEBUG("Keyframe %s found at %" PRId64 " @ %u",
             lastKeyFrameTime.isSome() ? "" : "not",
             lastKeyFrameTime.refOr(TimeUnit()).ToMicroseconds(),
             lastKeyFrameIndex);
 
   trackBuffer.mNextGetSampleIndex = Some(lastKeyFrameIndex);
   trackBuffer.mNextSampleTimecode = lastKeyFrameTimecode;
   trackBuffer.mNextSampleTime = lastKeyFrameTime.refOr(TimeUnit());
   ResetEvictionIndex(trackBuffer);
@@ -2346,17 +2348,17 @@ TrackBuffersManager::GetSample(TrackInfo
     trackData.mNextGetSampleIndex = Some(uint32_t(track.Length()));
     aResult = NS_ERROR_DOM_MEDIA_END_OF_STREAM;
     return nullptr;
   }
 
   // Our previous index has been overwritten, attempt to find the new one.
   int32_t pos = FindCurrentPosition(aTrack, aFuzz);
   if (pos < 0) {
-    MSE_DEBUG("Couldn't find sample (pts:%lld dts:%lld)",
+    MSE_DEBUG("Couldn't find sample (pts:%" PRId64 " dts:%" PRId64 ")",
               trackData.mNextSampleTime.ToMicroseconds(),
               trackData.mNextSampleTimecode.ToMicroseconds());
     return nullptr;
   }
 
   const RefPtr<MediaRawData>& sample = track[pos];
   RefPtr<MediaRawData> p = sample->Clone();
   if (!p) {
--- a/dom/media/ogg/OggCodecState.cpp
+++ b/dom/media/ogg/OggCodecState.cpp
@@ -1609,17 +1609,17 @@ SkeletonState::DecodeIndex(ogg_packet* a
       || numKeyPoints < 0) {
     // Packet size is less than the theoretical minimum size, or the packet is
     // claiming to store more keypoints than it's capable of storing. This means
     // that the numKeyPoints field is too large or small for the packet to
     // possibly contain as many packets as it claims to, so the numKeyPoints
     // field is possibly malicious. Don't try decoding this index, we may run
     // out of memory.
     LOG(LogLevel::Debug, ("Possibly malicious number of key points reported "
-                       "(%lld) in index packet for stream %u.",
+                       "(%" PRId64 ") in index packet for stream %u.",
                        numKeyPoints,
                        serialno));
     return (mActive = false);
   }
 
   nsAutoPtr<nsKeyFrameIndex> keyPoints(new nsKeyFrameIndex(startTime, endTime));
 
   p = aPacket->packet + INDEX_KEYPOINT_OFFSET;
@@ -1716,17 +1716,17 @@ SkeletonState::IndexedSeekTarget(int64_t
         && k.mOffset < r.mKeyPoint.mOffset) {
       r.mKeyPoint = k;
       r.mSerial = aTracks[i];
     }
   }
   if (r.IsNull()) {
     return NS_ERROR_FAILURE;
   }
-  LOG(LogLevel::Debug, ("Indexed seek target for time %lld is offset %lld",
+  LOG(LogLevel::Debug, ("Indexed seek target for time %" PRId64 " is offset %" PRId64,
                      aTarget, r.mKeyPoint.mOffset));
   aResult = r;
   return NS_OK;
 }
 
 nsresult
 SkeletonState::GetDuration(const nsTArray<uint32_t>& aTracks,
                            int64_t& aDuration)
@@ -1869,17 +1869,17 @@ SkeletonState::DecodeHeader(OggPacketPtr
         || aPacket->bytes < SKELETON_4_0_MIN_HEADER_LEN) {
       return false;
     }
 
     // Extract the segment length.
     mLength =
       LittleEndian::readInt64(aPacket->packet + SKELETON_FILE_LENGTH_OFFSET);
 
-    LOG(LogLevel::Debug, ("Skeleton segment length: %lld", mLength));
+    LOG(LogLevel::Debug, ("Skeleton segment length: %" PRId64, mLength));
 
     // Initialize the serialno-to-index map.
     return true;
   } else if (IsSkeletonIndex(aPacket.get()) && mVersion >= SKELETON_VERSION(4,0)) {
     return DecodeIndex(aPacket.get());
   } else if (IsSkeletonFisbone(aPacket.get())) {
     return DecodeFisbone(aPacket.get());
   } else if (aPacket->e_o_s) {
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -302,25 +302,25 @@ OggDemuxer::Reset(TrackInfo::TrackType a
 bool
 OggDemuxer::ReadHeaders(TrackInfo::TrackType aType,
                         OggCodecState* aState)
 {
   while (!aState->DoneReadingHeaders()) {
     DemuxUntilPacketAvailable(aType, aState);
     OggPacketPtr packet = aState->PacketOut();
     if (!packet) {
-      OGG_DEBUG("Ran out of header packets early; deactivating stream %ld", aState->mSerial);
+      OGG_DEBUG("Ran out of header packets early; deactivating stream %" PRIu32, aState->mSerial);
       aState->Deactivate();
       return false;
     }
 
     // Local OggCodecState needs to decode headers in order to process
     // packet granulepos -> time mappings, etc.
     if (!aState->DecodeHeader(Move(packet))) {
-      OGG_DEBUG("Failed to decode ogg header packet; deactivating stream %ld", aState->mSerial);
+      OGG_DEBUG("Failed to decode ogg header packet; deactivating stream %" PRIu32, aState->mSerial);
       aState->Deactivate();
       return false;
     }
   }
 
   return aState->Init();
 }
 
@@ -359,29 +359,29 @@ void
 OggDemuxer::SetupTargetSkeleton()
 {
   // Setup skeleton related information after mVorbisState & mTheroState
   // being set (if they exist).
   if (mSkeletonState) {
     if (!HasAudio() && !HasVideo()) {
       // We have a skeleton track, but no audio or video, may as well disable
       // the skeleton, we can't do anything useful with this media.
-      OGG_DEBUG("Deactivating skeleton stream %ld", mSkeletonState->mSerial);
+      OGG_DEBUG("Deactivating skeleton stream %" PRIu32, mSkeletonState->mSerial);
       mSkeletonState->Deactivate();
     } else if (ReadHeaders(TrackInfo::kAudioTrack, mSkeletonState) &&
                mSkeletonState->HasIndex()) {
       // We don't particularly care about which track we are currently using
       // as both MediaResource points to the same content.
       // Extract the duration info out of the index, so we don't need to seek to
       // the end of resource to get it.
       nsTArray<uint32_t> tracks;
       BuildSerialList(tracks);
       int64_t duration = 0;
       if (NS_SUCCEEDED(mSkeletonState->GetDuration(tracks, duration))) {
-        OGG_DEBUG("Got duration from Skeleton index %lld", duration);
+        OGG_DEBUG("Got duration from Skeleton index %" PRId64, duration);
         mInfo.mMetadataDuration.emplace(TimeUnit::FromMicroseconds(duration));
       }
     }
   }
 }
 
 void
 OggDemuxer::SetupMediaTracksInfo(const nsTArray<uint32_t>& aSerials)
@@ -546,34 +546,34 @@ OggDemuxer::ReadMetadata()
 
   SetupTargetSkeleton();
   SetupMediaTracksInfo(serials);
 
   if (HasAudio() || HasVideo()) {
     int64_t startTime = -1;
     FindStartTime(startTime);
     if (startTime >= 0) {
-      OGG_DEBUG("Detected stream start time %lld", startTime);
+      OGG_DEBUG("Detected stream start time %" PRId64, startTime);
       mStartTime.emplace(startTime);
     }
 
     if (mInfo.mMetadataDuration.isNothing() &&
         Resource(TrackInfo::kAudioTrack)->GetLength() >= 0) {
       // We didn't get a duration from the index or a Content-Duration header.
       // Seek to the end of file to find the end time.
       int64_t length = Resource(TrackInfo::kAudioTrack)->GetLength();
 
       NS_ASSERTION(length > 0, "Must have a content length to get end time");
 
       int64_t endTime = RangeEndTime(TrackInfo::kAudioTrack, length);
 
       if (endTime != -1) {
         mInfo.mUnadjustedMetadataEndTime.emplace(TimeUnit::FromMicroseconds(endTime));
         mInfo.mMetadataDuration.emplace(TimeUnit::FromMicroseconds(endTime - mStartTime.refOr(0)));
-        OGG_DEBUG("Got Ogg duration from seeking to end %lld", endTime);
+        OGG_DEBUG("Got Ogg duration from seeking to end %" PRId64, endTime);
       }
     }
     if (mInfo.mMetadataDuration.isNothing()) {
       mInfo.mMetadataDuration.emplace(TimeUnit::FromInfinity());
     }
     if (HasAudio()) {
       mInfo.mAudio.mDuration = mInfo.mMetadataDuration->ToMicroseconds();
     }
@@ -996,25 +996,25 @@ OggDemuxer::FindStartTime(int64_t& aOutS
   // Extract the start times of the bitstreams in order to calculate
   // the duration.
   int64_t videoStartTime = INT64_MAX;
   int64_t audioStartTime = INT64_MAX;
 
   if (HasVideo()) {
     FindStartTime(TrackInfo::kVideoTrack, videoStartTime);
     if (videoStartTime != INT64_MAX) {
-      OGG_DEBUG("OggDemuxer::FindStartTime() video=%lld", videoStartTime);
+      OGG_DEBUG("OggDemuxer::FindStartTime() video=%" PRId64, videoStartTime);
       mVideoOggState.mStartTime =
         Some(TimeUnit::FromMicroseconds(videoStartTime));
     }
   }
   if (HasAudio()) {
     FindStartTime(TrackInfo::kAudioTrack, audioStartTime);
     if (audioStartTime != INT64_MAX) {
-      OGG_DEBUG("OggDemuxer::FindStartTime() audio=%lld", audioStartTime);
+      OGG_DEBUG("OggDemuxer::FindStartTime() audio=%" PRId64, audioStartTime);
       mAudioOggState.mStartTime =
         Some(TimeUnit::FromMicroseconds(audioStartTime));
     }
   }
 
   int64_t startTime = std::min(videoStartTime, audioStartTime);
   if (startTime != INT64_MAX) {
     aOutStartTime = startTime;
@@ -1036,17 +1036,17 @@ OggDemuxer::FindStartTime(TrackInfo::Tra
     aOutStartTime = startTime;
   }
 }
 
 nsresult
 OggDemuxer::SeekInternal(TrackInfo::TrackType aType, const TimeUnit& aTarget)
 {
   int64_t target = aTarget.ToMicroseconds();
-  OGG_DEBUG("About to seek to %lld", target);
+  OGG_DEBUG("About to seek to %" PRId64, target);
   nsresult res;
   int64_t adjustedTarget = target;
   int64_t startTime = StartTime(aType);
   int64_t endTime = mInfo.mMetadataDuration->ToMicroseconds();
   if (aType == TrackInfo::kAudioTrack && mOpusState){
     adjustedTarget = std::max(startTime, target - OGG_SEEK_OPUS_PREROLL);
   }
 
@@ -1107,17 +1107,17 @@ OggDemuxer::SeekInternal(TrackInfo::Trac
       OGG_DEBUG("End of stream reached before keyframe found in indexed seek");
       break;
     }
     int64_t startTstamp = state->PacketStartTime(packet);
     if (foundKeyframe && startTstamp > adjustedTarget) {
       break;
     }
     if (state->IsKeyframe(packet)) {
-      OGG_DEBUG("keyframe found after seeking at %lld", startTstamp);
+      OGG_DEBUG("keyframe found after seeking at %" PRId64, startTstamp);
       tempPackets.Erase();
       foundKeyframe = true;
     }
     if (foundKeyframe && startTstamp == adjustedTarget) {
       break;
     }
     if (foundKeyframe) {
       tempPackets.Append(state->PacketOut());
@@ -1164,17 +1164,17 @@ OggDemuxer::SeekToKeyframeUsingIndex(Tra
   int64_t tell = Resource(aType)->Tell();
 
   // Seek to the keypoint returned by the index.
   if (keyframe.mKeyPoint.mOffset > Resource(aType)->GetLength() ||
       keyframe.mKeyPoint.mOffset < 0) {
     // Index must be invalid.
     return RollbackIndexedSeek(aType, tell);
   }
-  LOG(LogLevel::Debug, ("Seeking using index to keyframe at offset %lld\n",
+  LOG(LogLevel::Debug, ("Seeking using index to keyframe at offset %" PRId64 "\n",
                      keyframe.mKeyPoint.mOffset));
   nsresult res = Resource(aType)->Seek(nsISeekableStream::NS_SEEK_SET,
                                        keyframe.mKeyPoint.mOffset);
   NS_ENSURE_SUCCESS(res, SEEK_FATAL_ERROR);
 
   // We've moved the read set, so reset decode.
   res = Reset(aType);
   NS_ENSURE_SUCCESS(res, SEEK_FATAL_ERROR);
@@ -1307,17 +1307,17 @@ OggTrackDemuxer::Seek(const TimeUnit& aT
   mQueuedSample = nullptr;
   TimeUnit seekTime = aTime;
   if (mParent->SeekInternal(mType, aTime) == NS_OK) {
     RefPtr<MediaRawData> sample(NextSample());
 
     // Check what time we actually seeked to.
     if (sample != nullptr) {
       seekTime = TimeUnit::FromMicroseconds(sample->mTime);
-      OGG_DEBUG("%p seeked to time %lld", this, seekTime.ToMicroseconds());
+      OGG_DEBUG("%p seeked to time %" PRId64, this, seekTime.ToMicroseconds());
     }
     mQueuedSample = sample;
 
     return SeekPromise::CreateAndResolve(seekTime, __func__);
   } else {
     return SeekPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR, __func__);
   }
 }
@@ -1676,17 +1676,17 @@ nsresult
 OggDemuxer::SeekInBufferedRange(TrackInfo::TrackType aType,
                                 int64_t aTarget,
                                 int64_t aAdjustedTarget,
                                 int64_t aStartTime,
                                 int64_t aEndTime,
                                 const nsTArray<SeekRange>& aRanges,
                                 const SeekRange& aRange)
 {
-  OGG_DEBUG("Seeking in buffered data to %lld using bisection search", aTarget);
+  OGG_DEBUG("Seeking in buffered data to %" PRId64 " using bisection search", aTarget);
   if (aType == TrackInfo::kVideoTrack || aAdjustedTarget >= aTarget) {
     // We know the exact byte range in which the target must lie. It must
     // be buffered in the media cache. Seek there.
     nsresult res = SeekBisection(aType, aTarget, aRange, 0);
     if (NS_FAILED(res) || aType != TrackInfo::kVideoTrack) {
       return res;
     }
 
@@ -1723,17 +1723,17 @@ OggDemuxer::SeekInBufferedRange(TrackInf
 
 nsresult
 OggDemuxer::SeekInUnbuffered(TrackInfo::TrackType aType,
                              int64_t aTarget,
                              int64_t aStartTime,
                              int64_t aEndTime,
                              const nsTArray<SeekRange>& aRanges)
 {
-  OGG_DEBUG("Seeking in unbuffered data to %lld using bisection search", aTarget);
+  OGG_DEBUG("Seeking in unbuffered data to %" PRId64 " using bisection search", aTarget);
 
   // If we've got an active Theora bitstream, determine the maximum possible
   // time in usecs which a keyframe could be before a given interframe. We
   // subtract this from our seek target, seek to the new target, and then
   // will decode forward to the original seek target. We should encounter a
   // keyframe in that interval. This prevents us from needing to run two
   // bisections; one for the seek target frame, and another to find its
   // keyframe. It's usually faster to just download this extra data, rather
--- a/dom/media/platforms/agnostic/OpusDecoder.cpp
+++ b/dom/media/platforms/agnostic/OpusDecoder.cpp
@@ -7,16 +7,17 @@
 #include "OpusDecoder.h"
 #include "OpusParser.h"
 #include "TimeUnits.h"
 #include "VorbisUtils.h"
 #include "VorbisDecoder.h" // For VorbisLayout
 #include "mozilla/EndianUtils.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/SyncRunnable.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #include <inttypes.h>  // For PRId64
 
 #include "opus/opus.h"
 extern "C" {
 #include "opus/opus_multistream.h"
 }
 
@@ -171,17 +172,17 @@ OpusDataDecoder::ProcessDecode(MediaRawD
     mFrames = 0;
     mLastFrameTime = Some(aSample->mTime);
   }
 
   // Maximum value is 63*2880, so there's no chance of overflow.
   uint32_t frames_number = opus_packet_get_nb_frames(aSample->Data(),
                                                     aSample->Size());
   if (frames_number <= 0) {
-    OPUS_DEBUG("Invalid packet header: r=%ld length=%ld", frames_number,
+    OPUS_DEBUG("Invalid packet header: r=%" PRIu32 " length=%" PRIuSIZE, frames_number,
                aSample->Size());
     return DecodePromise::CreateAndReject(
       MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
                   RESULT_DETAIL("Invalid packet header: r=%d length=%u",
                                 frames_number, uint32_t(aSample->Size()))),
       __func__);
   }
 
--- a/dom/media/platforms/agnostic/TheoraDecoder.cpp
+++ b/dom/media/platforms/agnostic/TheoraDecoder.cpp
@@ -175,17 +175,17 @@ TheoraDecoder::ProcessDecode(MediaRawDat
                                    aSample->mDuration,
                                    b,
                                    aSample->mKeyframe,
                                    aSample->mTimecode,
                                    mInfo.ScaledImageRect(mTheoraInfo.frame_width,
                                                          mTheoraInfo.frame_height));
     if (!v) {
       LOG(
-        "Image allocation error source %ldx%ld display %ldx%ld picture %ldx%ld",
+        "Image allocation error source %ux%u display %ux%u picture %ux%u",
         mTheoraInfo.frame_width,
         mTheoraInfo.frame_height,
         mInfo.mDisplay.width,
         mInfo.mDisplay.height,
         mInfo.mImage.width,
         mInfo.mImage.height);
       return DecodePromise::CreateAndReject(
         MediaResult(NS_ERROR_OUT_OF_MEMORY,
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp
+++ b/dom/media/platforms/agnostic/VPXDecoder.cpp
@@ -232,17 +232,17 @@ VPXDecoder::ProcessDecode(MediaRawData* 
                                        aSample->mTimecode,
                                        mInfo.ScaledImageRect(img->d_w,
                                                              img->d_h));
 
     }
 
     if (!v) {
       LOG(
-        "Image allocation error source %ldx%ld display %ldx%ld picture %ldx%ld",
+        "Image allocation error source %ux%u display %ux%u picture %ux%u",
         img->d_w, img->d_h, mInfo.mDisplay.width, mInfo.mDisplay.height,
         mInfo.mImage.width, mInfo.mImage.height);
       return DecodePromise::CreateAndReject(
         MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__);
     }
     results.AppendElement(Move(v));
   }
   return DecodePromise::CreateAndResolve(Move(results), __func__);
--- a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp
+++ b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp
@@ -326,17 +326,18 @@ GMPVideoDecoder::Decode(MediaRawData* aS
                   RESULT_DETAIL("CreateFrame returned null")),
       __func__);
   }
   RefPtr<DecodePromise> p = mDecodePromise.Ensure(__func__);
   nsTArray<uint8_t> info; // No codec specific per-frame info to pass.
   nsresult rv = mGMP->Decode(Move(frame), false, info, 0);
   if (NS_FAILED(rv)) {
     mDecodePromise.Reject(MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
-                                      RESULT_DETAIL("mGMP->Decode:%x", rv)),
+                                      RESULT_DETAIL("mGMP->Decode:%" PRIx32,
+                                                    static_cast<uint32_t>(rv))),
                           __func__);
   }
   return p;
 }
 
 RefPtr<MediaDataDecoder::FlushPromise>
 GMPVideoDecoder::Flush()
 {
--- a/dom/media/platforms/apple/AppleATDecoder.cpp
+++ b/dom/media/platforms/apple/AppleATDecoder.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "AppleUtils.h"
 #include "MP4Decoder.h"
 #include "mp4_demuxer/Adts.h"
 #include "MediaInfo.h"
 #include "AppleATDecoder.h"
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/SyncRunnable.h"
 #include "mozilla/UniquePtr.h"
 
 #define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
 #define FourCC2Str(n) ((char[5]){(char)(n >> 24), (char)(n >> 16), (char)(n >> 8), (char)(n), 0})
 
 namespace mozilla {
 
@@ -80,17 +81,17 @@ AppleATDecoder::ProcessFlush()
 {
   MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
   mQueuedSamples.Clear();
   mDecodedSamples.Clear();
 
   if (mConverter) {
     OSStatus rv = AudioConverterReset(mConverter);
     if (rv) {
-      LOG("Error %d resetting AudioConverter", rv);
+      LOG("Error %d resetting AudioConverter", static_cast<int>(rv));
     }
   }
   if (mErrored) {
     mParsedFramesForAACMagicCookie = 0;
     mMagicCookie.Clear();
     ProcessShutdown();
     mErrored = false;
   }
@@ -127,27 +128,27 @@ AppleATDecoder::Shutdown()
 void
 AppleATDecoder::ProcessShutdown()
 {
   MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
 
   if (mStream) {
     OSStatus rv = AudioFileStreamClose(mStream);
     if (rv) {
-      LOG("error %d disposing of AudioFileStream", rv);
+      LOG("error %d disposing of AudioFileStream", static_cast<int>(rv));
       return;
     }
     mStream = nullptr;
   }
 
   if (mConverter) {
     LOG("Shutdown: Apple AudioToolbox AAC decoder");
     OSStatus rv = AudioConverterDispose(mConverter);
     if (rv) {
-      LOG("error %d disposing of AudioConverter", rv);
+      LOG("error %d disposing of AudioConverter", static_cast<int>(rv));
     }
     mConverter = nullptr;
   }
 }
 
 struct PassthroughUserData {
   UInt32 mChannels;
   UInt32 mDataSize;
@@ -260,17 +261,17 @@ AppleATDecoder::DecodeSample(MediaRawDat
     OSStatus rv = AudioConverterFillComplexBuffer(mConverter,
                                                   _PassthroughInputDataCallback,
                                                   &userData,
                                                   &numFrames /* in/out */,
                                                   &decBuffer,
                                                   packets.get());
 
     if (rv && rv != kNoMoreDataErr) {
-      LOG("Error decoding audio sample: %d\n", rv);
+      LOG("Error decoding audio sample: %d\n", static_cast<int>(rv));
       return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
                          RESULT_DETAIL("Error decoding audio sample: %d @ %lld",
                                        rv, aSample->mTime));
     }
 
     if (numFrames) {
       outputData.AppendElements(decoded.get(), numFrames * channels);
     }
@@ -382,17 +383,17 @@ AppleATDecoder::GetInputAudioDescription
   rv = AudioFormatGetProperty(kAudioFormatProperty_FormatList,
                               sizeof(formatInfo),
                               &formatInfo,
                               &formatListSize,
                               formatList.get());
   if (rv) {
     return NS_OK;
   }
-  LOG("found %u available audio stream(s)",
+  LOG("found %" PRIuSIZE " available audio stream(s)",
       formatListSize / sizeof(AudioFormatListItem));
   // Get the index number of the first playable format.
   // This index number will be for the highest quality layer the platform
   // is capable of playing.
   UInt32 itemIndex;
   UInt32 indexSize = sizeof(itemIndex);
   rv = AudioFormatGetProperty(kAudioFormatProperty_FirstPlayableFormatFromList,
                               formatListSize,
@@ -590,17 +591,17 @@ AppleATDecoder::SetupDecoder(MediaRawDat
 #endif
   // Set up the decoder so it gives us one sample per frame
   mOutputFormat.mFramesPerPacket = 1;
   mOutputFormat.mBytesPerPacket = mOutputFormat.mBytesPerFrame
         = mOutputFormat.mChannelsPerFrame * mOutputFormat.mBitsPerChannel / 8;
 
   OSStatus status = AudioConverterNew(&inputFormat, &mOutputFormat, &mConverter);
   if (status) {
-    LOG("Error %d constructing AudioConverter", status);
+    LOG("Error %d constructing AudioConverter", static_cast<int>(status));
     mConverter = nullptr;
     return MediaResult(
       NS_ERROR_FAILURE,
       RESULT_DETAIL("Error constructing AudioConverter:%lld", int64_t(status)));
   }
 
   if (NS_FAILED(SetupChannelLayout())) {
     NS_WARNING("Couldn't retrieve channel layout, will use default layout");
--- a/dom/media/platforms/apple/AppleVTDecoder.cpp
+++ b/dom/media/platforms/apple/AppleVTDecoder.cpp
@@ -12,16 +12,17 @@
 #include "AppleVTDecoder.h"
 #include "AppleVTLinker.h"
 #include "MediaData.h"
 #include "mozilla/ArrayUtils.h"
 #include "mp4_demuxer/H264.h"
 #include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "VideoUtils.h"
 #include "gfxPlatform.h"
 
 #define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
 
 namespace mozilla {
 
 AppleVTDecoder::AppleVTDecoder(const VideoInfo& aConfig,
@@ -70,17 +71,17 @@ AppleVTDecoder::Init()
   }
 
   return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
 }
 
 RefPtr<MediaDataDecoder::DecodePromise>
 AppleVTDecoder::Decode(MediaRawData* aSample)
 {
-  LOG("mp4 input sample %p pts %lld duration %lld us%s %d bytes",
+  LOG("mp4 input sample %p pts %lld duration %lld us%s %" PRIuSIZE " bytes",
       aSample,
       aSample->mTime,
       aSample->mDuration,
       aSample->mKeyframe ? " keyframe" : "",
       aSample->Size());
 
   RefPtr<AppleVTDecoder> self = this;
   RefPtr<MediaRawData> sample = aSample;
@@ -285,17 +286,17 @@ static void
 PlatformCallback(void* decompressionOutputRefCon,
                  void* sourceFrameRefCon,
                  OSStatus status,
                  VTDecodeInfoFlags flags,
                  CVImageBufferRef image,
                  CMTime presentationTimeStamp,
                  CMTime presentationDuration)
 {
-  LOG("AppleVideoDecoder %s status %d flags %d", __func__, status, flags);
+  LOG("AppleVideoDecoder %s status %d flags %d", __func__, static_cast<int>(status), flags);
 
   AppleVTDecoder* decoder =
     static_cast<AppleVTDecoder*>(decompressionOutputRefCon);
   nsAutoPtr<AppleVTDecoder::AppleFrameRef> frameRef(
     static_cast<AppleVTDecoder::AppleFrameRef*>(sourceFrameRefCon));
 
   // Validate our arguments.
   if (status != noErr || !image) {
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -243,18 +243,18 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(
   // Required with old version of FFmpeg/LibAV
   mFrame->reordered_opaque = AV_NOPTS_VALUE;
 
   int decoded;
   int bytesConsumed =
     mLib->avcodec_decode_video2(mCodecContext, mFrame, &decoded, &packet);
 
   FFMPEG_LOG("DoDecodeFrame:decode_video: rv=%d decoded=%d "
-             "(Input: pts(%lld) dts(%lld) Output: pts(%lld) "
-             "opaque(%lld) pkt_pts(%lld) pkt_dts(%lld))",
+             "(Input: pts(%" PRId64 ") dts(%" PRId64 ") Output: pts(%" PRId64 ") "
+             "opaque(%" PRId64 ") pkt_pts(%" PRId64 ") pkt_dts(%" PRId64 "))",
              bytesConsumed, decoded, packet.pts, packet.dts, mFrame->pts,
              mFrame->reordered_opaque, mFrame->pkt_pts, mFrame->pkt_dts);
 
   if (bytesConsumed < 0) {
     return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
                        RESULT_DETAIL("FFmpeg video error:%d", bytesConsumed));
   }
 
@@ -276,17 +276,18 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(
     NS_WARNING("Unable to retrieve duration from map");
     duration = aSample->mDuration;
     // dts are probably incorrectly reported ; so clear the map as we're
     // unlikely to find them in the future anyway. This also guards
     // against the map becoming extremely big.
     mDurationMap.Clear();
   }
   FFMPEG_LOG(
-    "Got one frame output with pts=%lld dts=%lld duration=%lld opaque=%lld",
+    "Got one frame output with pts=%" PRId64 " dts=%" PRId64
+    " duration=%" PRId64 " opaque=%" PRId64,
     pts, mFrame->pkt_dts, duration, mCodecContext->reordered_opaque);
 
   VideoData::YCbCrBuffer b;
   b.mPlanes[0].mData = mFrame->data[0];
   b.mPlanes[1].mData = mFrame->data[1];
   b.mPlanes[2].mData = mFrame->data[2];
 
   b.mPlanes[0].mStride = mFrame->linesize[0];
--- a/dom/media/platforms/omx/OmxDataDecoder.cpp
+++ b/dom/media/platforms/omx/OmxDataDecoder.cpp
@@ -7,16 +7,18 @@
 #include "OmxDataDecoder.h"
 
 #include "OMX_Audio.h"
 #include "OMX_Component.h"
 #include "OMX_Types.h"
 
 #include "OmxPlatformLayer.h"
 
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #ifdef LOG
 #undef LOG
 #undef LOGL
 #endif
 
 #define LOG(arg, ...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, ("OmxDataDecoder(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 
@@ -401,17 +403,18 @@ void
 OmxDataDecoder::EmptyBufferFailure(OmxBufferFailureHolder aFailureHolder)
 {
   NotifyError(aFailureHolder.mError, __func__);
 }
 
 void
 OmxDataDecoder::NotifyError(OMX_ERRORTYPE aOmxError, const char* aLine, const MediaResult& aError)
 {
-  LOG("NotifyError %d (%d) at %s", aOmxError, aError.Code(), aLine);
+  LOG("NotifyError %d (%" PRIu32 ") at %s", static_cast<int>(aOmxError),
+      static_cast<uint32_t>(aError.Code()), aLine);
   mDecodedData.Clear();
   mDecodePromise.RejectIfExists(aError, __func__);
   mDrainPromise.RejectIfExists(aError, __func__);
   mFlushPromise.RejectIfExists(aError, __func__);
 }
 
 void
 OmxDataDecoder::FillAndEmptyBuffers()
@@ -445,17 +448,17 @@ OmxDataDecoder::FillAndEmptyBuffers()
     inbuf->mBuffer->nTimeStamp = data->mTime;
     if (data->Size()) {
       inbuf->mRawData = mMediaRawDatas[0];
     } else {
        LOG("send EOS buffer");
       inbuf->mBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
     }
 
-    LOG("feed sample %p to omx component, len %d, flag %X", data.get(),
+    LOG("feed sample %p to omx component, len %ld, flag %lX", data.get(),
         inbuf->mBuffer->nFilledLen, inbuf->mBuffer->nFlags);
     mOmxLayer->EmptyBuffer(inbuf)->Then(mOmxTaskQueue, __func__, this,
                                         &OmxDataDecoder::EmptyBufferDone,
                                         &OmxDataDecoder::EmptyBufferFailure);
     mMediaRawDatas.RemoveElementAt(0);
   }
 
   // Trigger output port.
@@ -656,17 +659,17 @@ OmxDataDecoder::Event(OMX_EVENTTYPE aEve
     default:
     {
       // Got error during decoding, send msg to MFR skipping to next key frame.
       if (aEvent == OMX_EventError && mOmxState == OMX_StateExecuting) {
         NotifyError((OMX_ERRORTYPE)aData1, __func__,
                     MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR, __func__));
         return true;
       }
-      LOG("WARNING: got none handle event: %d, aData1: %d, aData2: %d",
+      LOG("WARNING: got none handle event: %d, aData1: %ld, aData2: %ld",
           aEvent, aData1, aData2);
       return false;
     }
   }
 
   return true;
 }
 
@@ -719,17 +722,17 @@ OmxDataDecoder::CollectBufferPromises(OM
           // OmxBufferPromise is not exclusive, it can be multiple "Then"s, so it
           // is safe to call "Ensure" here.
           promises.AppendElement(buf->mPromise.Ensure(__func__));
         }
       }
     }
   }
 
-  LOG("CollectBufferPromises: type %d, total %d promiese", aType, promises.Length());
+  LOG("CollectBufferPromises: type %d, total %" PRIuSIZE " promiese", aType, promises.Length());
   if (promises.Length()) {
     return OmxBufferPromise::All(mOmxTaskQueue, promises);
   }
 
   nsTArray<BufferData*> headers;
   return OmxBufferPromise::AllPromiseType::CreateAndResolve(headers, __func__);
 }
 
@@ -758,17 +761,17 @@ OmxDataDecoder::PortSettingsChanged()
   OMX_ERRORTYPE err = mOmxLayer->GetParameter(OMX_IndexParamPortDefinition,
                                               &def,
                                               sizeof(def));
   CHECK_OMX_ERR(err);
 
   RefPtr<OmxDataDecoder> self = this;
   if (def.bEnabled) {
     // 1. disable port.
-    LOG("PortSettingsChanged: disable port %d", def.nPortIndex);
+    LOG("PortSettingsChanged: disable port %lu", def.nPortIndex);
     mOmxLayer->SendCommand(OMX_CommandPortDisable, mPortSettingsChanged, nullptr)
       ->Then(mOmxTaskQueue, __func__,
              [self, def] () -> RefPtr<OmxCommandPromise> {
                // 3. enable port.
                // Send enable port command.
                RefPtr<OmxCommandPromise> p =
                  self->mOmxLayer->SendCommand(OMX_CommandPortEnable,
                                               self->mPortSettingsChanged,
@@ -993,16 +996,16 @@ MediaDataHelper::CreateYUV420VideoData(B
                                  0, // Filled later by caller.
                                  0, // Filled later by caller.
                                  1, // We don't know the duration.
                                  b,
                                  0, // Filled later by caller.
                                  -1,
                                  info.ImageRect());
 
-  LOG("YUV420 VideoData: disp width %d, height %d, pic width %d, height %d, time %ld",
+  LOG("YUV420 VideoData: disp width %d, height %d, pic width %d, height %d, time %lld",
       info.mDisplay.width, info.mDisplay.height, info.mImage.width,
       info.mImage.height, aBufferData->mBuffer->nTimeStamp);
 
   return data.forget();
 }
 
 }
--- a/dom/media/platforms/omx/OmxPlatformLayer.cpp
+++ b/dom/media/platforms/omx/OmxPlatformLayer.cpp
@@ -72,17 +72,17 @@ ConfigAudioOutputPort(OmxPlatformLayer& 
   pcmParams.eNumData = OMX_NumericalDataSigned;
   pcmParams.bInterleaved = OMX_TRUE;
   pcmParams.nBitPerSample = 16;
   pcmParams.nSamplingRate = aInfo.mRate;
   pcmParams.ePCMMode = OMX_AUDIO_PCMModeLinear;
   err = aOmx.SetParameter(OMX_IndexParamAudioPcm, &pcmParams, sizeof(pcmParams));
   RETURN_IF_ERR(err);
 
-  LOG("Config OMX_IndexParamAudioPcm, channel %d, sample rate %d",
+  LOG("Config OMX_IndexParamAudioPcm, channel %lu, sample rate %lu",
       pcmParams.nChannels, pcmParams.nSamplingRate);
 
   return OMX_ErrorNone;
 }
 
 class OmxAacConfig : public OmxAudioConfig
 {
 public:
@@ -97,17 +97,17 @@ public:
     RETURN_IF_ERR(err);
 
     aacProfile.nChannels = aInfo.mChannels;
     aacProfile.nSampleRate = aInfo.mRate;
     aacProfile.eAACProfile = static_cast<OMX_AUDIO_AACPROFILETYPE>(aInfo.mProfile);
     err = aOmx.SetParameter(OMX_IndexParamAudioAac, &aacProfile, sizeof(aacProfile));
     RETURN_IF_ERR(err);
 
-    LOG("Config OMX_IndexParamAudioAac, channel %d, sample rate %d, profile %d",
+    LOG("Config OMX_IndexParamAudioAac, channel %lu, sample rate %lu, profile %d",
         aacProfile.nChannels, aacProfile.nSampleRate, aacProfile.eAACProfile);
 
     return ConfigAudioOutputPort(aOmx, aInfo);
   }
 };
 
 class OmxMp3Config : public OmxAudioConfig
 {
@@ -122,17 +122,17 @@ public:
     err = aOmx.GetParameter(OMX_IndexParamAudioMp3, &mp3Param, sizeof(mp3Param));
     RETURN_IF_ERR(err);
 
     mp3Param.nChannels = aInfo.mChannels;
     mp3Param.nSampleRate = aInfo.mRate;
     err = aOmx.SetParameter(OMX_IndexParamAudioMp3, &mp3Param, sizeof(mp3Param));
     RETURN_IF_ERR(err);
 
-    LOG("Config OMX_IndexParamAudioMp3, channel %d, sample rate %d",
+    LOG("Config OMX_IndexParamAudioMp3, channel %lu, sample rate %lu",
         mp3Param.nChannels, mp3Param.nSampleRate);
 
     return ConfigAudioOutputPort(aOmx, aInfo);
   }
 };
 
 enum OmxAmrSampleRate {
   kNarrowBand = 8000,
@@ -214,17 +214,17 @@ public:
       def.format.video.nStride = aInfo.mImage.width;
       def.format.video.nSliceHeight = aInfo.mImage.height;
 
       if (def.eDir == OMX_DirInput) {
         def.format.video.eCompressionFormat = aOmx.CompressionFormat();
         def.format.video.eColorFormat = OMX_COLOR_FormatUnused;
         if (def.nBufferSize < MIN_VIDEO_INPUT_BUFFER_SIZE) {
           def.nBufferSize = aInfo.mImage.width * aInfo.mImage.height;
-          LOG("Change input buffer size to %d", def.nBufferSize);
+          LOG("Change input buffer size to %lu", def.nBufferSize);
         }
       } else {
         def.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
       }
 
       err = aOmx.SetParameter(OMX_IndexParamPortDefinition, &def, sizeof(def));
     }
     return err;
--- a/dom/media/platforms/omx/OmxPromiseLayer.cpp
+++ b/dom/media/platforms/omx/OmxPromiseLayer.cpp
@@ -82,17 +82,17 @@ OmxPromiseLayer::FillBuffer(BufferData* 
 
   return p;
 }
 
 RefPtr<OmxPromiseLayer::OmxBufferPromise>
 OmxPromiseLayer::EmptyBuffer(BufferData* aData)
 {
   MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
-  LOG("buffer %p, size %d", aData->mBuffer, aData->mBuffer->nFilledLen);
+  LOG("buffer %p, size %lu", aData->mBuffer, aData->mBuffer->nFilledLen);
 
   RefPtr<OmxBufferPromise> p = aData->mPromise.Ensure(__func__);
 
   OMX_ERRORTYPE err = mPlatformLayer->EmptyThisBuffer(aData);
 
   if (err != OMX_ErrorNone) {
     OmxBufferFailureHolder failure(err, aData);
     aData->mPromise.Reject(Move(failure), __func__);
@@ -262,17 +262,17 @@ OmxPromiseLayer::Event(OMX_EVENTTYPE aEv
   OMX_COMMANDTYPE cmd = (OMX_COMMANDTYPE) aData1;
   switch (aEvent) {
     case OMX_EventCmdComplete:
     {
       if (cmd == OMX_CommandStateSet) {
         mCommandStatePromise.Resolve(OMX_CommandStateSet, __func__);
       } else if (cmd == OMX_CommandFlush) {
         MOZ_RELEASE_ASSERT(mFlushCommands.ElementAt(0).type == aData2);
-        LOG("OMX_CommandFlush completed port type %d", aData2);
+        LOG("OMX_CommandFlush completed port type %lu", aData2);
         mFlushCommands.RemoveElementAt(0);
 
         // Sending next flush command.
         if (mFlushCommands.Length()) {
           OMX_ERRORTYPE err =
             mPlatformLayer->SendCommand(OMX_CommandFlush,
                                         mFlushCommands.ElementAt(0).type,
                                         mFlushCommands.ElementAt(0).cmd);
--- a/dom/media/systemservices/LoadManager.cpp
+++ b/dom/media/systemservices/LoadManager.cpp
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "LoadManager.h"
 #include "LoadMonitor.h"
 #include "nsString.h"
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "prtime.h"
 #include "prinrval.h"
 #include "prsystem.h"
 
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "nsReadableUtils.h"
 #include "nsIObserverService.h"
@@ -148,17 +149,17 @@ LoadManagerSingleton::NormalUsage()
   MutexAutoLock lock(mLock);
   mOveruseActive = false;
 }
 
 void
 LoadManagerSingleton::LoadHasChanged(webrtc::CPULoadState aNewState)
 {
   mLock.AssertCurrentThreadOwns();
-  LOG(("LoadManager - Signaling LoadHasChanged from %d to %d to %d listeners",
+  LOG(("LoadManager - Signaling LoadHasChanged from %d to %d to %" PRIuSIZE " listeners",
        mCurrentState, aNewState, mObservers.Length()));
 
   // Record how long we spent in this state for later Telemetry or display
   TimeStamp now = TimeStamp::Now();
   mTimeInState[mCurrentState] += (now - mLastStateChange).ToMilliseconds();
   mLastStateChange = now;
 
   mCurrentState = aNewState;
--- a/dom/media/systemservices/MediaChild.cpp
+++ b/dom/media/systemservices/MediaChild.cpp
@@ -34,17 +34,17 @@ GetPrincipalKey(const ipc::PrincipalInfo
     Child::Get()->SendGetPrincipalKey(id, aPrincipalInfo, aPersist);
   }
   return p.forget();
 }
 
 void
 SanitizeOriginKeys(const uint64_t& aSinceWhen, bool aOnlyPrivateBrowsing)
 {
-  LOG(("SanitizeOriginKeys since %llu %s", aSinceWhen,
+  LOG(("SanitizeOriginKeys since %" PRIu64 " %s", aSinceWhen,
        (aOnlyPrivateBrowsing? "in Private Browsing." : ".")));
 
   if (XRE_GetProcessType() == GeckoProcessType_Default) {
     // Avoid opening MediaManager in this case, since this is called by
     // sanitize.js when cookies are cleared, which can happen on startup.
     RefPtr<Parent<NonE10s>> tmpParent = new Parent<NonE10s>();
     tmpParent->RecvSanitizeOriginKeys(aSinceWhen, aOnlyPrivateBrowsing);
   } else {
--- a/dom/media/systemservices/MediaParent.cpp
+++ b/dom/media/systemservices/MediaParent.cpp
@@ -88,18 +88,18 @@ class OriginKeyStore : public nsISupport
 
     void Clear(int64_t aSinceWhen)
     {
       // Avoid int64_t* <-> void* casting offset
       OriginKey since(nsCString(), aSinceWhen  / PR_USEC_PER_SEC);
       for (auto iter = mKeys.Iter(); !iter.Done(); iter.Next()) {
         nsAutoPtr<OriginKey>& originKey = iter.Data();
         LOG((((originKey->mSecondsStamp >= since.mSecondsStamp)?
-              "%s: REMOVE %lld >= %lld" :
-              "%s: KEEP   %lld < %lld"),
+              "%s: REMOVE %" PRId64 " >= %" PRId64 :
+              "%s: KEEP   %" PRId64 " < %" PRId64),
               __FUNCTION__, originKey->mSecondsStamp, since.mSecondsStamp));
 
         if (originKey->mSecondsStamp >= since.mSecondsStamp) {
           iter.Remove();
         }
       }
       mPersistCount = 0;
     }
--- a/dom/media/systemservices/OpenSLESProvider.cpp
+++ b/dom/media/systemservices/OpenSLESProvider.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "OpenSLESProvider.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 #include "nsDebug.h"
 
 #include <dlfcn.h>
 #include <SLES/OpenSLES_Android.h>
 #include <SLES/OpenSLES_AndroidConfiguration.h>
 
 // MOZ_LOG=OpenSLESProvider:5
@@ -64,24 +65,24 @@ SLresult OpenSLESProvider::GetEngine(SLO
   LOG(("Getting OpenSLES engine"));
   // Bug 1042051: Validate options are the same
   if (mSLEngine != nullptr) {
     *aObjectm = mSLEngine;
     mSLEngineUsers++;
     LOG(("Returning existing engine, %d users", mSLEngineUsers));
     return SL_RESULT_SUCCESS;
   } else {
-    int res = ConstructEngine(aObjectm, aOptionCount, aOptions);
+    SLresult res = ConstructEngine(aObjectm, aOptionCount, aOptions);
     if (res == SL_RESULT_SUCCESS) {
       // Bug 1042051: Store engine options
       mSLEngine = *aObjectm;
       mSLEngineUsers++;
       LOG(("Returning new engine"));
     } else {
-      LOG(("Error getting engine: %d", res));
+      LOG(("Error getting engine: %lu", static_cast<unsigned long>(res)));
     }
     return res;
   }
 }
 
 SLresult OpenSLESProvider::ConstructEngine(SLObjectItf * aObjectm,
                                            SLuint32 aOptionCount,
                                            const SLEngineOption *aOptions)
@@ -151,17 +152,17 @@ SLresult OpenSLESProvider::RealizeEngine
   NS_ASSERTION(aObjectm != nullptr, "OpenSLES realize engine with empty ObjectItf");
 
   if (mIsRealized) {
     LOG(("Not realizing already realized engine"));
     return SL_RESULT_SUCCESS;
   } else {
     SLresult res = (*aObjectm)->Realize(aObjectm, SL_BOOLEAN_FALSE);
     if (res != SL_RESULT_SUCCESS) {
-      LOG(("Error realizing OpenSLES engine: %d", res));
+      LOG(("Error realizing OpenSLES engine: %lu", static_cast<unsigned long>(res)));
     } else {
       LOG(("Realized OpenSLES engine"));
       mIsRealized = true;
     }
     return res;
   }
 }
 
--- a/dom/media/systemservices/ShmemPool.cpp
+++ b/dom/media/systemservices/ShmemPool.cpp
@@ -45,32 +45,32 @@ mozilla::ShmemBuffer ShmemPool::GetIfAva
     return ShmemBuffer();
   }
 
   mPoolFree--;
 #ifdef DEBUG
   size_t poolUse = mShmemPool.Length() - mPoolFree;
   if (poolUse > mMaxPoolUse) {
     mMaxPoolUse = poolUse;
-    LOG(("Maximum ShmemPool use increased: %d buffers", mMaxPoolUse));
+    LOG(("Maximum ShmemPool use increased: %" PRIuSIZE " buffers", mMaxPoolUse));
   }
 #endif
   return Move(res);
 }
 
 void ShmemPool::Put(ShmemBuffer&& aShmem)
 {
   MutexAutoLock lock(mMutex);
   MOZ_ASSERT(mPoolFree < mShmemPool.Length());
   mShmemPool[mPoolFree] = Move(aShmem);
   mPoolFree++;
 #ifdef DEBUG
   size_t poolUse = mShmemPool.Length() - mPoolFree;
   if (poolUse > 0) {
-    LOG_VERBOSE(("ShmemPool usage reduced to %d buffers", poolUse));
+    LOG_VERBOSE(("ShmemPool usage reduced to %" PRIuSIZE " buffers", poolUse));
   }
 #endif
 }
 
 ShmemPool::~ShmemPool()
 {
 #ifdef DEBUG
   for (size_t i = 0; i < mShmemPool.Length(); i++) {
--- a/dom/media/systemservices/ShmemPool.h
+++ b/dom/media/systemservices/ShmemPool.h
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_ShmemPool_h
 #define mozilla_ShmemPool_h
 
 #include "mozilla/ipc/Shmem.h"
 #include "mozilla/Mutex.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #undef LOG
 #undef LOG_ENABLED
 extern mozilla::LazyLogModule gCamerasParentLog;
 #define LOG(args) MOZ_LOG(gCamerasParentLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gCamerasParentLog, mozilla::LogLevel::Debug)
 
 namespace mozilla {
@@ -127,17 +128,17 @@ public:
 
     MOZ_ASSERT(res.mShmem.IsWritable(), "Shmem in Pool is not writable post resize?");
 
     mPoolFree--;
 #ifdef DEBUG
     size_t poolUse = mShmemPool.Length() - mPoolFree;
     if (poolUse > mMaxPoolUse) {
       mMaxPoolUse = poolUse;
-      LOG(("Maximum ShmemPool use increased: %d buffers", mMaxPoolUse));
+      LOG(("Maximum ShmemPool use increased: %" PRIuSIZE " buffers", mMaxPoolUse));
     }
 #endif
     return Move(res);
   }
 
 private:
   Mutex mMutex;
   size_t mPoolFree;
--- a/dom/media/webm/WebMBufferedParser.cpp
+++ b/dom/media/webm/WebMBufferedParser.cpp
@@ -200,17 +200,17 @@ bool WebMBufferedParser::Append(const un
               if (idx == 0 ||
                   aMapping[idx - 1].mTimecode <= absTimecode ||
                   (idx + 1 < aMapping.Length() &&
                    aMapping[idx + 1].mTimecode >= absTimecode)) {
                 WebMTimeDataOffset entry(endOffset, absTimecode, mLastInitStartOffset,
                                          mClusterOffset, mClusterEndOffset);
                 aMapping.InsertElementAt(idx, entry);
               } else {
-                WEBM_DEBUG("Out of order timecode %llu in Cluster at %lld ignored",
+                WEBM_DEBUG("Out of order timecode %" PRIu64 " in Cluster at %" PRId64 " ignored",
                            absTimecode, mClusterOffset);
               }
             }
           }
         }
 
         // Skip rest of block header and the block's payload.
         mBlockSize -= mVInt.mLength;
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -16,16 +16,18 @@
 #include "mozilla/EndianUtils.h"
 #include "mozilla/SharedThreadPool.h"
 #include "MediaDataDemuxer.h"
 #include "nsAutoPtr.h"
 #include "nsAutoRef.h"
 #include "NesteggPacketHolder.h"
 #include "XiphExtradata.h"
 #include "prprf.h"           // leaving it for PR_vsnprintf()
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Sprintf.h"
 
 #include <algorithm>
 #include <stdint.h>
 
 #define VPX_DONT_DEFINE_STDINT_TYPES
 #include "vpx/vp8dx.h"
 #include "vpx/vpx_decoder.h"
@@ -123,17 +125,17 @@ static void webmdemux_log(nestegg* aCont
       sevStr = "UNK";
       break;
   }
 
   va_start(args, aFormat);
 
   SprintfLiteral(msg, "%p [Nestegg-%s] ", aContext, sevStr);
   PR_vsnprintf(msg+strlen(msg), sizeof(msg)-strlen(msg), aFormat, args);
-  MOZ_LOG(gNesteggLog, LogLevel::Debug, (msg));
+  MOZ_LOG(gNesteggLog, LogLevel::Debug, ("%s", msg));
 
   va_end(args);
 }
 
 WebMDemuxer::NestEggContext::~NestEggContext()
 {
   if (mContext) {
     nestegg_destroy(mContext);
@@ -692,17 +694,17 @@ WebMDemuxer::GetNextPacket(TrackInfo::Tr
               new TrackInfoSharedPtr(mInfo.mVideo, ++sStreamSourceID);
           }
           mLastSeenFrameWidth = Some(si.w);
           mLastSeenFrameHeight = Some(si.h);
         }
       }
     }
 
-    WEBM_DEBUG("push sample tstamp: %ld next_tstamp: %ld length: %ld kf: %d",
+    WEBM_DEBUG("push sample tstamp: %" PRId64 " next_tstamp: %" PRId64 " length: %" PRIuSIZE " kf: %d",
                tstamp, next_tstamp, length, isKeyframe);
     RefPtr<MediaRawData> sample;
     if (mInfo.mVideo.HasAlpha() && alphaLength != 0) {
       sample = new MediaRawData(data, length, alphaData, alphaLength);
       if ((length && !sample->Data()) || (alphaLength && !sample->AlphaData())) {
         // OOM.
         return false;
       }
--- a/dom/media/webrtc/MediaEngineCameraVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineCameraVideoSource.cpp
@@ -1,14 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaEngineCameraVideoSource.h"
 
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/SizePrintfMacros.h"
+
 #include <limits>
 
 namespace mozilla {
 
 using namespace mozilla::gfx;
 using namespace mozilla::dom;
 
 extern LogModule* GetMediaManagerLog();
@@ -138,31 +141,40 @@ MediaEngineCameraVideoSource::GetBestFit
   return candidateSet[0].mDistance;
 }
 
 void
 MediaEngineCameraVideoSource::LogConstraints(
     const NormalizedConstraintSet& aConstraints)
 {
   auto& c = aConstraints;
-  LOG(((c.mWidth.mIdeal.isSome()?
-        "Constraints: width: { min: %d, max: %d, ideal: %d }" :
-        "Constraints: width: { min: %d, max: %d }"),
-       c.mWidth.mMin, c.mWidth.mMax,
-       c.mWidth.mIdeal.valueOr(0)));
-  LOG(((c.mHeight.mIdeal.isSome()?
-        "             height: { min: %d, max: %d, ideal: %d }" :
-        "             height: { min: %d, max: %d }"),
-       c.mHeight.mMin, c.mHeight.mMax,
-       c.mHeight.mIdeal.valueOr(0)));
-  LOG(((c.mFrameRate.mIdeal.isSome()?
-        "             frameRate: { min: %f, max: %f, ideal: %f }" :
-        "             frameRate: { min: %f, max: %f }"),
-       c.mFrameRate.mMin, c.mFrameRate.mMax,
-       c.mFrameRate.mIdeal.valueOr(0)));
+  if (c.mWidth.mIdeal.isSome()) {
+    LOG(("Constraints: width: { min: %d, max: %d, ideal: %d }",
+         c.mWidth.mMin, c.mWidth.mMax,
+         c.mWidth.mIdeal.valueOr(0)));
+  } else {
+    LOG(("Constraints: width: { min: %d, max: %d }",
+         c.mWidth.mMin, c.mWidth.mMax));
+  }
+  if (c.mHeight.mIdeal.isSome()) {
+    LOG(("             height: { min: %d, max: %d, ideal: %d }",
+         c.mHeight.mMin, c.mHeight.mMax,
+         c.mHeight.mIdeal.valueOr(0)));
+  } else {
+    LOG(("             height: { min: %d, max: %d }",
+         c.mHeight.mMin, c.mHeight.mMax));
+  }
+  if (c.mFrameRate.mIdeal.isSome()) {
+    LOG(("             frameRate: { min: %f, max: %f, ideal: %f }",
+         c.mFrameRate.mMin, c.mFrameRate.mMax,
+         c.mFrameRate.mIdeal.valueOr(0)));
+  } else {
+    LOG(("             frameRate: { min: %f, max: %f }",
+         c.mFrameRate.mMin, c.mFrameRate.mMax));
+  }
 }
 
 void
 MediaEngineCameraVideoSource::LogCapability(const char* aHeader,
     const webrtc::CaptureCapability &aCapability, uint32_t aDistance)
 {
   // RawVideoType and VideoCodecType media/webrtc/trunk/webrtc/common_types.h
   static const char* const types[] = {
@@ -189,17 +201,17 @@ MediaEngineCameraVideoSource::LogCapabil
     "H264",
     "I420",
     "RED",
     "ULPFEC",
     "Generic codec",
     "Unknown codec"
   };
 
-  LOG(("%s: %4u x %4u x %2u maxFps, %s, %s. Distance = %lu",
+  LOG(("%s: %4u x %4u x %2u maxFps, %s, %s. Distance = %" PRIu32,
        aHeader, aCapability.width, aCapability.height, aCapability.maxFPS,
        types[std::min(std::max(uint32_t(0), uint32_t(aCapability.rawType)),
                       uint32_t(sizeof(types) / sizeof(*types) - 1))],
        codec[std::min(std::max(uint32_t(0), uint32_t(aCapability.codecType)),
                       uint32_t(sizeof(codec) / sizeof(*codec) - 1))],
        aDistance));
 }
 
@@ -210,17 +222,17 @@ MediaEngineCameraVideoSource::ChooseCapa
     const nsString& aDeviceId)
 {
   if (MOZ_LOG_TEST(GetMediaManagerLog(), LogLevel::Debug)) {
     LOG(("ChooseCapability: prefs: %dx%d @%d-%dfps",
          aPrefs.GetWidth(), aPrefs.GetHeight(),
          aPrefs.mFPS, aPrefs.mMinFPS));
     LogConstraints(aConstraints);
     if (aConstraints.mAdvanced.size()) {
-      LOG(("Advanced array[%u]:", aConstraints.mAdvanced.size()));
+      LOG(("Advanced array[%" PRIuSIZE "]:", aConstraints.mAdvanced.size()));
       for (auto& advanced : aConstraints.mAdvanced) {
         LogConstraints(advanced);
       }
     }
   }
 
   size_t num = NumCapabilities();
 
@@ -240,17 +252,17 @@ MediaEngineCameraVideoSource::ChooseCapa
     if (candidate.mDistance == UINT32_MAX) {
       candidateSet.RemoveElementAt(i);
     } else {
       ++i;
     }
   }
 
   if (!candidateSet.Length()) {
-    LOG(("failed to find capability match from %d choices",num));
+    LOG(("failed to find capability match from %" PRIuSIZE " choices",num));
     return false;
   }
 
   // Filter further with all advanced constraints (that don't overconstrain).
 
   for (const auto &cs : aConstraints.mAdvanced) {
     CapabilitySet rejects;
     for (size_t i = 0; i < candidateSet.Length();) {
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -520,17 +520,17 @@ MediaEngineWebRTCMicrophoneSource::Stop(
 void
 MediaEngineWebRTCMicrophoneSource::NotifyPull(MediaStreamGraph *aGraph,
                                               SourceMediaStream *aSource,
                                               TrackID aID,
                                               StreamTime aDesiredTime,
                                               const PrincipalHandle& aPrincipalHandle)
 {
   // Ignore - we push audio data
-  LOG_FRAMES(("NotifyPull, desired = %ld", (int64_t) aDesiredTime));
+  LOG_FRAMES(("NotifyPull, desired = %" PRId64, (int64_t) aDesiredTime));
 }
 
 void
 MediaEngineWebRTCMicrophoneSource::NotifyOutputData(MediaStreamGraph* aGraph,
                                                     AudioDataValue* aBuffer,
                                                     size_t aFrames,
                                                     TrackRate aRate,
                                                     uint32_t aChannels)
--- a/dom/media/webspeech/synth/SpeechSynthesis.cpp
+++ b/dom/media/webspeech/synth/SpeechSynthesis.cpp
@@ -2,16 +2,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupportsPrimitives.h"
 #include "nsSpeechTask.h"
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/Element.h"
 
 #include "mozilla/dom/SpeechSynthesisBinding.h"
 #include "SpeechSynthesis.h"
 #include "nsSynthVoiceRegistry.h"
 #include "nsIDocument.h"
@@ -150,17 +151,17 @@ SpeechSynthesis::Speak(SpeechSynthesisUt
     AdvanceQueue();
   }
 }
 
 void
 SpeechSynthesis::AdvanceQueue()
 {
   LOG(LogLevel::Debug,
-      ("SpeechSynthesis::AdvanceQueue length=%d", mSpeechQueue.Length()));
+      ("SpeechSynthesis::AdvanceQueue length=%" PRIuSIZE, mSpeechQueue.Length()));
 
   if (mSpeechQueue.IsEmpty()) {
     return;
   }
 
   RefPtr<SpeechSynthesisUtterance> utterance = mSpeechQueue.ElementAt(0);
 
   nsAutoString docLang;
--- a/dom/network/UDPSocketChild.cpp
+++ b/dom/network/UDPSocketChild.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "UDPSocketChild.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Unused.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/dom/PermissionMessageUtils.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
@@ -374,17 +375,17 @@ UDPSocketChild::RecvCallbackClosed()
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 UDPSocketChild::RecvCallbackReceivedData(const UDPAddressInfo& aAddressInfo,
                                          InfallibleTArray<uint8_t>&& aData)
 {
-  UDPSOCKET_LOG(("%s: %s:%u length %u", __FUNCTION__,
+  UDPSOCKET_LOG(("%s: %s:%u length %" PRIuSIZE, __FUNCTION__,
                  aAddressInfo.addr().get(), aAddressInfo.port(), aData.Length()));
   nsresult rv = mSocket->CallListenerReceivedData(aAddressInfo.addr(), aAddressInfo.port(),
                                                   aData.Elements(), aData.Length());
   mozilla::Unused << NS_WARN_IF(NS_FAILED(rv));
 
   return IPC_OK();
 }
 
--- a/dom/network/UDPSocketParent.cpp
+++ b/dom/network/UDPSocketParent.cpp
@@ -136,17 +136,18 @@ UDPSocketParent::RecvBind(const UDPAddre
 nsresult
 UDPSocketParent::BindInternal(const nsCString& aHost, const uint16_t& aPort,
                               const bool& aAddressReuse, const bool& aLoopback,
                               const uint32_t& recvBufferSize,
                               const uint32_t& sendBufferSize)
 {
   nsresult rv;
 
-  UDPSOCKET_LOG(("%s: [this=%p] %s:%u addressReuse: %d loopback: %d recvBufferSize: %lu, sendBufferSize: %lu",
+  UDPSOCKET_LOG(("%s: [this=%p] %s:%u addressReuse: %d loopback: %d recvBufferSize: %"
+                 PRIu32 ", sendBufferSize: %" PRIu32,
                 __FUNCTION__, this, nsCString(aHost).get(), aPort,
                 aAddressReuse, aLoopback, recvBufferSize, sendBufferSize));
 
   nsCOMPtr<nsIUDPSocket> sock =
       do_CreateInstance("@mozilla.org/network/udp-socket;1", &rv);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -188,23 +189,23 @@ UDPSocketParent::BindInternal(const nsCS
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
   // TODO: once bug 1252759 is fixed query buffer first and only increase
   if (recvBufferSize != 0) {
     rv = sock->SetRecvBufferSize(recvBufferSize);
     if (NS_WARN_IF(NS_FAILED(rv))) {
-      UDPSOCKET_LOG(("%s: [this=%p] %s:%u failed to set recv buffer size to: %lu", __FUNCTION__, this, nsCString(aHost).get(), aPort, recvBufferSize));
+      UDPSOCKET_LOG(("%s: [this=%p] %s:%u failed to set recv buffer size to: %" PRIu32, __FUNCTION__, this, nsCString(aHost).get(), aPort, recvBufferSize));
     }
   }
   if (sendBufferSize != 0) {
     rv = sock->SetSendBufferSize(sendBufferSize);
     if (NS_WARN_IF(NS_FAILED(rv))) {
-      UDPSOCKET_LOG(("%s: [this=%p] %s:%u failed to set send buffer size to: %lu", __FUNCTION__, this, nsCString(aHost).get(), aPort, sendBufferSize));
+      UDPSOCKET_LOG(("%s: [this=%p] %s:%u failed to set send buffer size to: %" PRIu32, __FUNCTION__, this, nsCString(aHost).get(), aPort, sendBufferSize));
     }
   }
 
   // register listener
   rv = sock->AsyncListen(this);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -646,17 +646,17 @@ nsresult nsNPAPIPluginInstance::GetValue
 
   if (pluginFunctions->getvalue && RUNNING == mRunning) {
     PluginDestructionGuard guard(this);
 
     NPError pluginError = NPERR_GENERIC_ERROR;
     NS_TRY_SAFE_CALL_RETURN(pluginError, (*pluginFunctions->getvalue)(&mNPP, variable, value), this,
                             NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
     NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
-    ("NPP GetValue called: this=%p, npp=%p, var=%d, value=%d, return=%d\n",
+    ("NPP GetValue called: this=%p, npp=%p, var=%d, value=%p, return=%d\n",
     this, &mNPP, variable, value, pluginError));
 
     if (pluginError == NPERR_NO_ERROR) {
       rv = NS_OK;
     }
   }
 
   return rv;
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -764,18 +764,18 @@ nsPluginHost::InstantiatePluginInstance(
   // At this point we consider instantiation to be successful. Do not return an error.
   instanceOwner.forget(aOwner);
 
 #ifdef PLUGIN_LOGGING
   nsAutoCString urlSpec2;
   if (aURL != nullptr) aURL->GetAsciiSpec(urlSpec2);
 
   MOZ_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_NORMAL,
-        ("nsPluginHost::InstantiatePlugin Finished mime=%s, rv=%d, url=%s\n",
-         PromiseFlatCString(aMimeType).get(), rv, urlSpec2.get()));
+        ("nsPluginHost::InstantiatePlugin Finished mime=%s, rv=%" PRIu32 ", url=%s\n",
+         PromiseFlatCString(aMimeType).get(), static_cast<uint32_t>(rv), urlSpec2.get()));
 
   PR_LogFlush();
 #endif
 
   return NS_OK;
 }
 
 nsPluginTag*
@@ -901,18 +901,18 @@ nsPluginHost::TrySetUpPluginInstance(con
   // Cancel the plugin unload timer since we are creating
   // an instance for it.
   if (pluginTag->mUnloadTimer) {
     pluginTag->mUnloadTimer->Cancel();
   }
 
 #ifdef PLUGIN_LOGGING
   MOZ_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_BASIC,
-        ("nsPluginHost::TrySetupPluginInstance Finished mime=%s, rv=%d, owner=%p, url=%s\n",
-         PromiseFlatCString(aMimeType).get(), rv, aOwner,
+        ("nsPluginHost::TrySetupPluginInstance Finished mime=%s, rv=%" PRIu32 ", owner=%p, url=%s\n",
+         PromiseFlatCString(aMimeType).get(), static_cast<uint32_t>(rv), aOwner,
          aURL ? aURL->GetSpecOrDefault().get() : ""));
 
   PR_LogFlush();
 #endif
 
   return rv;
 }
 
@@ -1368,18 +1368,18 @@ nsresult nsPluginHost::GetPlugin(const n
       return rv;
     }
 
     NS_ADDREF(*aPlugin = pluginTag->mPlugin);
     return NS_OK;
   }
 
   PLUGIN_LOG(PLUGIN_LOG_NORMAL,
-  ("nsPluginHost::GetPlugin End mime=%s, rv=%d, plugin=%p name=%s\n",
-   PromiseFlatCString(aMimeType).get(), rv, *aPlugin,
+  ("nsPluginHost::GetPlugin End mime=%s, rv=%" PRIu32 ", plugin=%p name=%s\n",
+   PromiseFlatCString(aMimeType).get(), static_cast<uint32_t>(rv), *aPlugin,
    (pluginTag ? pluginTag->FileName().get() : "(not found)")));
 
   return rv;
 }
 
 // Normalize 'host' to ACE.
 nsresult
 nsPluginHost::NormalizeHostname(nsCString& host)
--- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp
+++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp
@@ -915,17 +915,17 @@ NS_IMETHODIMP nsPluginStreamListenerPeer
 
   if (!mPStreamListener)
     return NS_ERROR_FAILURE;
 
   const char * url = nullptr;
   GetURL(&url);
 
   PLUGIN_LOG(PLUGIN_LOG_NOISY,
-             ("nsPluginStreamListenerPeer::OnDataAvailable this=%p request=%p, offset=%llu, length=%u, url=%s\n",
+             ("nsPluginStreamListenerPeer::OnDataAvailable this=%p request=%p, offset=%" PRIu64 ", length=%u, url=%s\n",
               this, request, sourceOffset, aLength, url ? url : "no url set"));
 
   // if the plugin has requested an AsFileOnly stream, then don't
   // call OnDataAvailable
   if (mStreamType != NP_ASFILEONLY) {
     // get the absolute offset of the request, if one exists.
     nsCOMPtr<nsIByteRangeRequest> brr = do_QueryInterface(request);
     if (brr) {
@@ -1000,18 +1000,18 @@ NS_IMETHODIMP nsPluginStreamListenerPeer
   if (!mp) {
     bool found = mRequests.RemoveObject(request);
     if (!found) {
       NS_ERROR("Received OnStopRequest for untracked request.");
     }
   }
 
   PLUGIN_LOG(PLUGIN_LOG_NOISY,
-             ("nsPluginStreamListenerPeer::OnStopRequest this=%p aStatus=%d request=%p\n",
-              this, aStatus, request));
+             ("nsPluginStreamListenerPeer::OnStopRequest this=%p aStatus=%" PRIu32 " request=%p\n",
+              this, static_cast<uint32_t>(aStatus), request));
 
   // for ByteRangeRequest we're just updating the mDataForwardToRequest hash and return.
   nsCOMPtr<nsIByteRangeRequest> brr = do_QueryInterface(request);
   if (brr) {
     int64_t absoluteOffset64 = 0;
     brr->GetStartRange(&absoluteOffset64);
     // XXX support 64-bit offsets
     int32_t absoluteOffset = (int32_t)int64_t(absoluteOffset64);
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -1180,17 +1180,17 @@ PluginInstanceChild::RecvContentsScaleFa
     return IPC_FAIL_NO_REASON(this);
 #endif
 }
 
 #if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
 // Create a new window from NPWindow
 bool PluginInstanceChild::CreateWindow(const NPRemoteWindow& aWindow)
 { 
-    PLUGIN_LOG_DEBUG(("%s (aWindow=<window: 0x%lx, x: %d, y: %d, width: %d, height: %d>)",
+    PLUGIN_LOG_DEBUG(("%s (aWindow=<window: 0x%" PRIx64 ", x: %d, y: %d, width: %d, height: %d>)",
                       FULLFUNCTION,
                       aWindow.window,
                       aWindow.x, aWindow.y,
                       aWindow.width, aWindow.height));
 
 #ifdef MOZ_WIDGET_GTK
     if (mXEmbed) {
         mWindow.window = reinterpret_cast<void*>(aWindow.window);
@@ -1206,17 +1206,17 @@ bool PluginInstanceChild::CreateWindow(c
 #endif
 
     return true;
 }
 
 // Destroy window
 void PluginInstanceChild::DeleteWindow()
 {
-  PLUGIN_LOG_DEBUG(("%s (aWindow=<window: 0x%lx, x: %d, y: %d, width: %d, height: %d>)",
+  PLUGIN_LOG_DEBUG(("%s (aWindow=<window: 0x%p, x: %d, y: %d, width: %d, height: %d>)",
                     FULLFUNCTION,
                     mWindow.window,
                     mWindow.x, mWindow.y,
                     mWindow.width, mWindow.height));
 
   if (!mWindow.window)
       return;
 
@@ -1264,17 +1264,17 @@ PluginInstanceChild::RecvCreateChildPopu
     NS_NOTREACHED("PluginInstanceChild::CreateChildPluginWindow not implemented!");
     return IPC_FAIL_NO_REASON(this);
 #endif
 }
 
 mozilla::ipc::IPCResult
 PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
 {
-    PLUGIN_LOG_DEBUG(("%s (aWindow=<window: 0x%lx, x: %d, y: %d, width: %d, height: %d>)",
+    PLUGIN_LOG_DEBUG(("%s (aWindow=<window: 0x%" PRIx64 ", x: %d, y: %d, width: %d, height: %d>)",
                       FULLFUNCTION,
                       aWindow.window,
                       aWindow.x, aWindow.y,
                       aWindow.width, aWindow.height));
     NS_ASSERTION(!mLayersRendering && !mPendingPluginCall,
                  "Shouldn't be receiving NPP_SetWindow with layer rendering");
     AssertPluginThread();
     AutoStackHelper guard(this);
--- a/dom/presentation/PresentationConnection.cpp
+++ b/dom/presentation/PresentationConnection.cpp
@@ -10,16 +10,17 @@
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/PresentationConnectionCloseEvent.h"
 #include "mozilla/ErrorNames.h"
 #include "mozilla/DebugOnly.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIPresentationService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStringStream.h"
 #include "PresentationConnectionList.h"
 #include "PresentationLog.h"
 
@@ -349,19 +350,20 @@ PresentationConnection::Equals(uint64_t 
          mId.Equals(aId);
 }
 
 NS_IMETHODIMP
 PresentationConnection::NotifyStateChange(const nsAString& aSessionId,
                                           uint16_t aState,
                                           nsresult aReason)
 {
-  PRES_DEBUG("connection state change:id[%s], state[%x], reason[%x], role[%d]\n",
+  PRES_DEBUG("connection state change:id[%s], state[%" PRIx32
+             "], reason[%" PRIx32 "], role[%d]\n",
              NS_ConvertUTF16toUTF8(aSessionId).get(), aState,
-             aReason, mRole);
+             static_cast<uint32_t>(aReason), mRole);
 
   if (!aSessionId.Equals(mId)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   // A terminated connection should always remain in terminated.
   if (mState == PresentationConnectionState::Terminated) {
     return NS_OK;
--- a/dom/presentation/PresentationReceiver.cpp
+++ b/dom/presentation/PresentationReceiver.cpp
@@ -64,17 +64,17 @@ PresentationReceiver::Init()
   MOZ_ASSERT(docShell);
 
   nsContentUtils::GetPresentationURL(docShell, mUrl);
   return !mUrl.IsEmpty();
 }
 
 void PresentationReceiver::Shutdown()
 {
-  PRES_DEBUG("receiver shutdown:windowId[%d]\n", mWindowId);
+  PRES_DEBUG("receiver shutdown:windowId[%" PRId64 "]\n", mWindowId);
 
   // Unregister listener for incoming sessions.
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return;
   }
 
@@ -88,17 +88,17 @@ PresentationReceiver::WrapObject(JSConte
 {
   return PresentationReceiverBinding::Wrap(aCx, this, aGivenProto);
 }
 
 NS_IMETHODIMP
 PresentationReceiver::NotifySessionConnect(uint64_t aWindowId,
                                            const nsAString& aSessionId)
 {
-  PRES_DEBUG("receiver session connect:id[%s], windowId[%x]\n",
+  PRES_DEBUG("receiver session connect:id[%s], windowId[%" PRIx64 "]\n",
              NS_ConvertUTF16toUTF8(aSessionId).get(), aWindowId);
 
   if (NS_WARN_IF(!mOwner)) {
     return NS_ERROR_FAILURE;
   }
 
   if (NS_WARN_IF(aWindowId != mWindowId)) {
     return NS_ERROR_INVALID_ARG;
--- a/dom/presentation/PresentationService.cpp
+++ b/dom/presentation/PresentationService.cpp
@@ -516,17 +516,17 @@ PresentationService::HandleSessionReques
 
     info->SetControlChannel(ctrlChannel);
     info->SetDevice(device);
     return static_cast<PresentationPresentingInfo*>(
       info.get())->DoReconnect();
   }
 
   // This is the case for a new session.
-  PRES_DEBUG("handle new session:url[%d], id[%s]\n",
+  PRES_DEBUG("handle new session:url[%s], id[%s]\n",
              NS_ConvertUTF16toUTF8(url).get(),
              NS_ConvertUTF16toUTF8(sessionId).get());
 
   info = new PresentationPresentingInfo(url, sessionId, device);
   rv = info->Init(ctrlChannel);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     ctrlChannel->Disconnect(rv);
     return rv;
@@ -597,18 +597,18 @@ PresentationService::HandleTerminateRequ
 
   // Check if terminate request comes from known device.
   RefPtr<nsIPresentationDevice> knownDevice = info->GetDevice();
   if (NS_WARN_IF(!IsSameDevice(device, knownDevice))) {
     ctrlChannel->Disconnect(NS_ERROR_DOM_OPERATION_ERR);
     return NS_ERROR_DOM_ABORT_ERR;
   }
 
-  PRES_DEBUG("handle termination:id[%s], receiver[%d]\n", __func__,
-             sessionId.get(), isFromReceiver);
+  PRES_DEBUG("%s:handle termination:id[%s], receiver[%d]\n", __func__,
+             NS_ConvertUTF16toUTF8(sessionId).get(), isFromReceiver);
 
   return info->OnTerminate(ctrlChannel);
 }
 
 nsresult
 PresentationService::HandleReconnectRequest(nsIPresentationSessionRequest* aRequest)
 {
   nsCOMPtr<nsIPresentationControlChannel> ctrlChannel;
@@ -1002,17 +1002,17 @@ PresentationService::UnregisterSessionLi
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationService::RegisterRespondingListener(
   uint64_t aWindowId,
   nsIPresentationRespondingListener* aListener)
 {
-  PRES_DEBUG("%s:windowId[%lld]\n", __func__, aWindowId);
+  PRES_DEBUG("%s:windowId[%" PRIu64 "]\n", __func__, aWindowId);
 
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aListener);
 
   nsCOMPtr<nsIPresentationRespondingListener> listener;
   if (mRespondingListeners.Get(aWindowId, getter_AddRefs(listener))) {
     return (listener == aListener) ? NS_OK : NS_ERROR_DOM_INVALID_STATE_ERR;
   }
@@ -1030,32 +1030,32 @@ PresentationService::RegisterRespondingL
 
   mRespondingListeners.Put(aWindowId, aListener);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationService::UnregisterRespondingListener(uint64_t aWindowId)
 {
-  PRES_DEBUG("%s:windowId[%lld]\n", __func__, aWindowId);
+  PRES_DEBUG("%s:windowId[%" PRIu64 "]\n", __func__, aWindowId);
 
   MOZ_ASSERT(NS_IsMainThread());
 
   mRespondingListeners.Remove(aWindowId);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationService::NotifyReceiverReady(
                const nsAString& aSessionId,
                uint64_t aWindowId,
                bool aIsLoading,
                nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
 {
-  PRES_DEBUG("%s:id[%s], windowId[%lld], loading[%d]\n", __func__,
+  PRES_DEBUG("%s:id[%s], windowId[%" PRIu64 "], loading[%d]\n", __func__,
              NS_ConvertUTF16toUTF8(aSessionId).get(), aWindowId, aIsLoading);
 
   RefPtr<PresentationSessionInfo> info =
     GetSessionInfo(aSessionId, nsIPresentationService::ROLE_RECEIVER);
   if (NS_WARN_IF(!info)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
@@ -1080,18 +1080,19 @@ PresentationService::NotifyReceiverReady
   return static_cast<PresentationPresentingInfo*>(info.get())->NotifyResponderReady();
 }
 
 nsresult
 PresentationService::NotifyTransportClosed(const nsAString& aSessionId,
                                            uint8_t aRole,
                                            nsresult aReason)
 {
-  PRES_DEBUG("%s:id[%s], reason[%x], role[%d]\n", __func__,
-             NS_ConvertUTF16toUTF8(aSessionId).get(), aReason, aRole);
+  PRES_DEBUG("%s:id[%s], reason[%" PRIx32 "], role[%d]\n", __func__,
+             NS_ConvertUTF16toUTF8(aSessionId).get(), static_cast<uint32_t>(aReason),
+             aRole);
 
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!aSessionId.IsEmpty());
   MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
              aRole == nsIPresentationService::ROLE_RECEIVER);
 
   RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
   if (NS_WARN_IF(!info)) {
@@ -1114,17 +1115,17 @@ PresentationService::UntrackSessionInfo(
   if (nsIPresentationService::ROLE_CONTROLLER == aRole) {
     mSessionInfoAtController.Remove(aSessionId);
   } else {
     // Terminate receiver page.
     uint64_t windowId;
     nsresult rv = GetWindowIdBySessionIdInternal(aSessionId, aRole, &windowId);
     if (NS_SUCCEEDED(rv)) {
       NS_DispatchToMainThread(NS_NewRunnableFunction([windowId]() -> void {
-        PRES_DEBUG("Attempt to close window[%d]\n", windowId);
+        PRES_DEBUG("Attempt to close window[%" PRIu64 "]\n", windowId);
 
         if (auto* window = nsGlobalWindow::GetInnerWindowWithId(windowId)) {
           window->Close();
         }
       }));
     }
 
     mSessionInfoAtReceiver.Remove(aSessionId);
--- a/dom/presentation/PresentationSessionInfo.cpp
+++ b/dom/presentation/PresentationSessionInfo.cpp
@@ -216,18 +216,19 @@ PresentationSessionInfo::Init(nsIPresent
 {
   SetControlChannel(aControlChannel);
   return NS_OK;
 }
 
 /* virtual */ void
 PresentationSessionInfo::Shutdown(nsresult aReason)
 {
-  PRES_DEBUG("%s:id[%s], reason[%x], role[%d]\n", __func__,
-             NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole);
+  PRES_DEBUG("%s:id[%s], reason[%" PRIx32 "], role[%d]\n", __func__,
+             NS_ConvertUTF16toUTF8(mSessionId).get(), static_cast<uint32_t>(aReason),
+             mRole);
 
   NS_WARNING_ASSERTION(NS_SUCCEEDED(aReason), "bad reason");
 
   // Close the control channel if any.
   if (mControlChannel) {
     Unused << NS_WARN_IF(NS_FAILED(mControlChannel->Disconnect(aReason)));
   }
 
@@ -455,18 +456,19 @@ PresentationSessionInfo::NotifyTransport
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationSessionInfo::NotifyTransportClosed(nsresult aReason)
 {
-  PRES_DEBUG("%s:id[%s], reason[%x], role[%d]\n", __func__,
-             NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole);
+  PRES_DEBUG("%s:id[%s], reason[%" PRIx32 "], role[%d]\n", __func__,
+             NS_ConvertUTF16toUTF8(mSessionId).get(), static_cast<uint32_t>(aReason),
+             mRole);
 
   MOZ_ASSERT(NS_IsMainThread());
 
   // Nullify |mTransport| here so it won't try to re-close |mTransport| in
   // potential subsequent |Shutdown| calls.
   mTransport = nullptr;
 
   if (NS_WARN_IF(!IsSessionReady() &&
@@ -538,18 +540,19 @@ PresentationSessionInfo::OnSessionTransp
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationSessionInfo::OnError(nsresult aReason)
 {
-  PRES_DEBUG("%s:id[%s], reason[%x], role[%d]\n", __func__,
-             NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole);
+  PRES_DEBUG("%s:id[%s], reason[%" PRIx32 "], role[%d]\n", __func__,
+             NS_ConvertUTF16toUTF8(mSessionId).get(), static_cast<uint32_t>(aReason),
+             mRole);
 
   ResetBuilder();
   return ReplyError(aReason);
 }
 
 NS_IMETHODIMP
 PresentationSessionInfo::SendOffer(nsIPresentationChannelDescription* aOffer)
 {
@@ -894,18 +897,19 @@ PresentationControllingInfo::BuildTransp
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationControllingInfo::NotifyDisconnected(nsresult aReason)
 {
-  PRES_DEBUG("%s:id[%s], reason[%x], role[%d]\n", __func__,
-             NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole);
+  PRES_DEBUG("%s:id[%s], reason[%" PRIx32 "], role[%d]\n", __func__,
+             NS_ConvertUTF16toUTF8(mSessionId).get(), static_cast<uint32_t>(aReason),
+             mRole);
 
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mTransportType == nsIPresentationChannelDescription::TYPE_DATACHANNEL) {
     nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder>
       builder = do_QueryInterface(mBuilder);
     if (builder) {
       Unused << NS_WARN_IF(NS_FAILED(builder->NotifyDisconnected(aReason)));
@@ -977,17 +981,18 @@ PresentationControllingInfo::OnSocketAcc
   mTransportType = nsIPresentationChannelDescription::TYPE_TCP;
   return builder->BuildTCPSenderTransport(aTransport, this);
 }
 
 NS_IMETHODIMP
 PresentationControllingInfo::OnStopListening(nsIServerSocket* aServerSocket,
                                            nsresult aStatus)
 {
-  PRES_DEBUG("controller %s:status[%x]\n",__func__, aStatus);
+  PRES_DEBUG("controller %s:status[%" PRIx32 "]\n",__func__,
+             static_cast<uint32_t>(aStatus));
 
   MOZ_ASSERT(NS_IsMainThread());
 
   if (aStatus == NS_BINDING_ABORTED) { // The server socket was manually closed.
     return NS_OK;
   }
 
   Shutdown(aStatus);
@@ -1537,18 +1542,19 @@ PresentationPresentingInfo::NotifyReconn
 {
   MOZ_ASSERT(false, "NotifyReconnected should not be called at receiver side.");
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationPresentingInfo::NotifyDisconnected(nsresult aReason)
 {
-  PRES_DEBUG("%s:id[%s], reason[%x], role[%d]\n", __func__,
-             NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole);
+  PRES_DEBUG("%s:id[%s], reason[%" PRIx32 "], role[%d]\n", __func__,
+             NS_ConvertUTF16toUTF8(mSessionId).get(), static_cast<uint32_t>(aReason),
+             mRole);
 
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mTransportType == nsIPresentationChannelDescription::TYPE_DATACHANNEL) {
     nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder>
       builder = do_QueryInterface(mBuilder);
     if (builder) {
       Unused << NS_WARN_IF(NS_FAILED(builder->NotifyDisconnected(aReason)));
--- a/dom/presentation/PresentationTCPSessionTransport.cpp
+++ b/dom/presentation/PresentationTCPSessionTransport.cpp
@@ -427,17 +427,17 @@ NS_IMETHODIMP
 PresentationTCPSessionTransport::SendBlob(nsIDOMBlob* aBlob)
 {
   return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
 }
 
 NS_IMETHODIMP
 PresentationTCPSessionTransport::Close(nsresult aReason)
 {
-  PRES_DEBUG("%s:reason[%x]\n", __func__, aReason);
+  PRES_DEBUG("%s:reason[%" PRIx32 "]\n", __func__, static_cast<uint32_t>(aReason));
 
   if (mReadyState == ReadyState::CLOSED || mReadyState == ReadyState::CLOSING) {
     return NS_OK;
   }
 
   mCloseStatus = aReason;
   SetReadyState(ReadyState::CLOSING);
 
@@ -485,17 +485,17 @@ PresentationTCPSessionTransport::SetRead
 
 // nsITransportEventSink
 NS_IMETHODIMP
 PresentationTCPSessionTransport::OnTransportStatus(nsITransport* aTransport,
                                                    nsresult aStatus,
                                                    int64_t aProgress,
                                                    int64_t aProgressMax)
 {
-  PRES_DEBUG("%s:aStatus[%x]\n", __func__, aStatus);
+  PRES_DEBUG("%s:aStatus[%" PRIx32 "]\n", __func__, static_cast<uint32_t>(aStatus));
 
   MOZ_ASSERT(NS_IsMainThread());
 
   if (aStatus != NS_NET_STATUS_CONNECTED_TO) {
     return NS_OK;
   }
 
   SetReadyState(ReadyState::OPEN);
@@ -531,17 +531,17 @@ PresentationTCPSessionTransport::OnStart
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationTCPSessionTransport::OnStopRequest(nsIRequest* aRequest,
                                                nsISupports* aContext,
                                                nsresult aStatusCode)
 {
-  PRES_DEBUG("%s:aStatusCode[%x]\n", __func__, aStatusCode);
+  PRES_DEBUG("%s:aStatusCode[%" PRIx32 "]\n", __func__, static_cast<uint32_t>(aStatusCode));
 
   MOZ_ASSERT(NS_IsMainThread());
 
   uint32_t count;
   nsresult rv = mMultiplexStream->GetCount(&count);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
--- a/dom/presentation/ipc/PresentationIPCService.cpp
+++ b/dom/presentation/ipc/PresentationIPCService.cpp
@@ -481,17 +481,17 @@ PresentationIPCService::UntrackSessionIn
 
   if (nsIPresentationService::ROLE_RECEIVER == aRole) {
     // Terminate receiver page.
     uint64_t windowId;
     if (NS_SUCCEEDED(GetWindowIdBySessionIdInternal(aSessionId,
                                                     aRole,
                                                     &windowId))) {
       NS_DispatchToMainThread(NS_NewRunnableFunction([windowId]() -> void {
-        PRES_DEBUG("Attempt to close window[%d]\n", windowId);
+        PRES_DEBUG("Attempt to close window[%" PRIu64 "]\n", windowId);
 
         if (auto* window = nsGlobalWindow::GetInnerWindowWithId(windowId)) {
           window->Close();
         }
       }));
     }
   }
 
--- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
+++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
@@ -2,19 +2,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MulticastDNSDeviceProvider.h"
 
 #include "DeviceProviderHelpers.h"
 #include "MainThreadUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Unused.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIObserverService.h"
 #include "nsIWritablePropertyBag2.h"
 #include "nsServiceManagerUtils.h"
 #include "nsTCPDeviceInfo.h"
 #include "nsThreadUtils.h"
 
@@ -344,31 +346,32 @@ MulticastDNSDeviceProvider::RegisterMDNS
   return mMulticastDNS->RegisterService(serviceInfo,
                                         mWrappedListener,
                                         getter_AddRefs(mRegisterRequest));
 }
 
 nsresult
 MulticastDNSDeviceProvider::UnregisterMDNSService(nsresult aReason)
 {
-  LOG_I("UnregisterMDNSService: %s (0x%08x)", mServiceName.get(), aReason);
+  LOG_I("UnregisterMDNSService: %s (0x%08" PRIx32 ")", mServiceName.get(),
+        static_cast<uint32_t>(aReason));
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mRegisterRequest) {
     mRegisterRequest->Cancel(aReason);
     mRegisterRequest = nullptr;
   }
 
   return NS_OK;
 }
 
 nsresult
 MulticastDNSDeviceProvider::StopDiscovery(nsresult aReason)
 {
-  LOG_I("StopDiscovery (0x%08x)", aReason);
+  LOG_I("StopDiscovery (0x%08" PRIx32 ")", static_cast<uint32_t>(aReason));
 
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mDiscoveryTimer);
 
   Unused << mDiscoveryTimer->Cancel();
 
   if (mDiscoveryRequest) {
     mDiscoveryRequest->Cancel(aReason);
@@ -955,17 +958,17 @@ MulticastDNSDeviceProvider::OnServerRead
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnServerStopped(nsresult aResult)
 {
-  LOG_I("OnServerStopped: (0x%08x)", aResult);
+  LOG_I("OnServerStopped: (0x%08" PRIx32 ")", static_cast<uint32_t>(aResult));
 
   UnregisterMDNSService(aResult);
 
   // Try restart server if it is stopped abnormally.
   if (NS_FAILED(aResult) && mDiscoverable) {
     mIsServerRetrying = true;
     mServerRetryTimer->Init(this, mServerRetryMs, nsITimer::TYPE_ONE_SHOT);
   }
--- a/dom/security/SRICheck.cpp
+++ b/dom/security/SRICheck.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SRICheck.h"
 
 #include "mozilla/Base64.h"
 #include "mozilla/LoadTainting.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/dom/SRILogHelper.h"
 #include "mozilla/dom/SRIMetadata.h"
 #include "nsContentUtils.h"
 #include "nsIChannel.h"
 #include "nsIConsoleReportCollector.h"
 #include "nsIProtocolHandler.h"
 #include "nsIScriptError.h"
 #include "nsIIncrementalStreamLoader.h"
@@ -365,17 +366,17 @@ SRICheckDataVerifier::Verify(const SRIMe
 {
   NS_ENSURE_ARG_POINTER(aReporter);
 
   if (MOZ_LOG_TEST(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug)) {
     nsAutoCString requestURL;
     nsCOMPtr<nsIRequest> request;
     request = do_QueryInterface(aChannel);
     request->GetName(requestURL);
-    SRILOG(("SRICheckDataVerifier::Verify, url=%s (length=%lu)",
+    SRILOG(("SRICheckDataVerifier::Verify, url=%s (length=%" PRIuSIZE ")",
             requestURL.get(), mBytesHashed));
   }
 
   nsresult rv = Finish();
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
   NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
--- a/dom/security/SRIMetadata.cpp
+++ b/dom/security/SRIMetadata.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SRIMetadata.h"
 
 #include "hasht.h"
 #include "mozilla/dom/URLSearchParams.h"
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "nsICryptoHash.h"
 
 static mozilla::LogModule*
 GetSriMetadataLog()
 {
   static mozilla::LazyLogModule gSriMetadataPRLog("SRIMetadata");
   return gSriMetadataPRLog;
 }
@@ -109,17 +110,17 @@ SRIMetadata::operator+=(const SRIMetadat
 {
   MOZ_ASSERT(!aOther.IsEmpty() && !IsEmpty());
   MOZ_ASSERT(aOther.IsValid() && IsValid());
   MOZ_ASSERT(mAlgorithmType == aOther.mAlgorithmType);
 
   // We only pull in the first element of the other metadata
   MOZ_ASSERT(aOther.mHashes.Length() == 1);
   if (mHashes.Length() < SRIMetadata::MAX_ALTERNATE_HASHES) {
-    SRIMETADATALOG(("SRIMetadata::operator+=, appending another '%s' hash (new length=%d)",
+    SRIMETADATALOG(("SRIMetadata::operator+=, appending another '%s' hash (new length=%" PRIuSIZE ")",
                     mAlgorithm.get(), mHashes.Length()));
     mHashes.AppendElement(aOther.mHashes[0]);
   }
 
   MOZ_ASSERT(mHashes.Length() > 1);
   MOZ_ASSERT(mHashes.Length() <= SRIMetadata::MAX_ALTERNATE_HASHES);
   return *this;
 }
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -1008,17 +1008,17 @@ nsCSPContext::SendReports(nsISupports* a
 
     // AsyncOpen should not fail, but could if there's no load group (like if
     // SetRequestContext is not given a channel).  This should fail quietly and
     // not return an error since it's really ok if reports don't go out, but
     // it's good to log the error locally.
 
     if (NS_FAILED(rv)) {
       const char16_t* params[] = { reportURIs[r].get() };
-      CSPCONTEXTLOG(("AsyncOpen failed for report URI %s", params[0]));
+      CSPCONTEXTLOG(("AsyncOpen failed for report URI %s", NS_ConvertUTF16toUTF8(params[0]).get()));
       logToConsole(u"triedToSendReport", params, ArrayLength(params),
                    aSourceFile, aScriptSample, aLineNum, 0, nsIScriptError::errorFlag);
     } else {
       CSPCONTEXTLOG(("Sent violation report to URI %s", reportURICstring.get()));
     }
   }
   return NS_OK;
 }
@@ -1367,17 +1367,17 @@ nsCSPContext::GetCSPSandboxFlags(uint32_
       *aOutSandboxFlags |= flags;
     } else {
       // sandbox directive is ignored in report-only mode, warn about it and
       // continue the loop checking for an enforcement policy.
       nsAutoString policy;
       mPolicies[i]->toString(policy);
 
       CSPCONTEXTLOG(("nsCSPContext::GetCSPSandboxFlags, report only policy, ignoring sandbox in: %s",
-                    policy.get()));
+                     NS_ConvertUTF16toUTF8(policy).get()));
 
       const char16_t* params[] = { policy.get() };
       logToConsole(u"ignoringReportOnlyDirective", params, ArrayLength(params),
                    EmptyString(), EmptyString(), 0, 0, nsIScriptError::warningFlag);
     }
   }
 
   return NS_OK;
--- a/dom/security/nsCSPParser.cpp
+++ b/dom/security/nsCSPParser.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nsCSPParser.h"
 #include "nsCSPUtils.h"
 #include "nsIConsoleService.h"
 #include "nsIContentPolicy.h"
 #include "nsIScriptError.h"
 #include "nsIStringBundle.h"
@@ -871,17 +872,17 @@ void
 nsCSPParser::referrerDirectiveValue(nsCSPDirective* aDir)
 {
   // directive-value   = "none" / "none-when-downgrade" / "origin" / "origin-when-cross-origin" / "unsafe-url"
   // directive name is token 0, we need to examine the remaining tokens (and
   // there should only be one token in the value).
   CSPPARSERLOG(("nsCSPParser::referrerDirectiveValue"));
 
   if (mCurDir.Length() != 2) {
-    CSPPARSERLOG(("Incorrect number of tokens in referrer directive, got %d expected 1",
+    CSPPARSERLOG(("Incorrect number of tokens in referrer directive, got %" PRIuSIZE " expected 1",
                  mCurDir.Length() - 1));
     delete aDir;
     return;
   }
 
   if (!mozilla::net::IsValidReferrerPolicy(mCurDir[1])) {
     CSPPARSERLOG(("invalid value for referrer directive: %s",
                   NS_ConvertUTF16toUTF8(mCurDir[1]).get()));
--- a/dom/security/nsCSPUtils.cpp
+++ b/dom/security/nsCSPUtils.cpp
@@ -788,17 +788,16 @@ nsCSPKeywordSrc::permits(nsIURI* aUri, c
 }
 
 bool
 nsCSPKeywordSrc::allows(enum CSPKeyword aKeyword, const nsAString& aHashOrNonce,
                         bool aParserCreated) const
 {
   CSPUTILSLOG(("nsCSPKeywordSrc::allows, aKeyWord: %s, aHashOrNonce: %s, mInvalidated: %s",
               CSP_EnumToKeyword(aKeyword),
-              CSP_EnumToKeyword(mKeyword),
               NS_ConvertUTF16toUTF8(aHashOrNonce).get(),
               mInvalidated ? "yes" : "false"));
 
   if (mInvalidated) {
     // only 'self' and 'unsafe-inline' are keywords that can be ignored. Please note that
     // the parser already translates 'self' into a uri (see assertion in constructor).
     MOZ_ASSERT(mKeyword == CSP_UNSAFE_INLINE,
                "should only invalidate unsafe-inline");
--- a/dom/u2f/U2F.cpp
+++ b/dom/u2f/U2F.cpp
@@ -7,16 +7,17 @@
 #include "hasht.h"
 #include "mozilla/dom/CallbackFunction.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/CryptoBuffer.h"
 #include "mozilla/dom/NSSU2FTokenRemote.h"
 #include "mozilla/dom/U2F.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ReentrantMonitor.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "nsContentUtils.h"
 #include "nsINSSU2FToken.h"
 #include "nsNetCID.h"
 #include "nsNSSComponent.h"
 #include "nsURLParsers.h"
 #include "nsXPCOMCIDInternal.h"
 #include "pk11pub.h"
 
@@ -634,17 +635,17 @@ U2FRegisterRunnable::Run()
 
     // Treat each call to Promise::All as a work unit, as it completes together
     status->WaitGroupAdd();
 
     U2FPrepPromise::All(mAbstractMainThread, prepPromiseList)
     ->Then(mAbstractMainThread, __func__,
       [&status] (const nsTArray<Authenticator>& aTokens) {
         MOZ_LOG(gU2FLog, LogLevel::Debug,
-                ("ALL: None of the RegisteredKeys were recognized. n=%d",
+                ("ALL: None of the RegisteredKeys were recognized. n=%" PRIuSIZE,
                  aTokens.Length()));
 
         status->WaitGroupDone();
       },
       [&status] (ErrorCode aErrorCode) {
         status->Stop(aErrorCode);
         status->WaitGroupDone();
     });
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -67,16 +67,17 @@
 #include "mozilla/dom/SimpleGlobalObject.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/StructuredCloneHolder.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/WorkerBinding.h"
 #include "mozilla/dom/WorkerDebuggerGlobalScopeBinding.h"
 #include "mozilla/dom/WorkerGlobalScopeBinding.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/ThrottledEventQueue.h"
 #include "mozilla/TimelineConsumers.h"
 #include "mozilla/WorkerTimelineMarker.h"
 #include "nsAlgorithm.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollector.h"
 #include "nsError.h"
 #include "nsDOMJSUtils.h"
@@ -6535,17 +6536,17 @@ WorkerPrivate::RescheduleTimeoutTimer(JS
   // our code in RunExpiredTimeouts to "fudge" the timeout value will unleash an
   // early timeout when we execute the event we're about to queue.
   mTimer->Cancel();
 
   double delta =
     (mTimeouts[0]->mTargetTime - TimeStamp::Now()).ToMilliseconds();
   uint32_t delay = delta > 0 ? std::min(delta, double(UINT32_MAX)) : 0;
 
-  LOG(TimeoutsLog(), ("Worker %p scheduled timer for %d ms, %d pending timeouts\n",
+  LOG(TimeoutsLog(), ("Worker %p scheduled timer for %d ms, %" PRIuSIZE " pending timeouts\n",
                       this, delay, mTimeouts.Length()));
 
   nsresult rv = mTimer->InitWithCallback(mTimerRunnable, delay, nsITimer::TYPE_ONE_SHOT);
   if (NS_FAILED(rv)) {
     JS_ReportErrorASCII(aCx, "Failed to start timer!");
     return false;
   }
 
--- a/extensions/auth/nsAuthGSSAPI.cpp
+++ b/extensions/auth/nsAuthGSSAPI.cpp
@@ -10,16 +10,17 @@
 // (formerly draft-brezak-spnego-http-04.txt)
 //
 // Also described here:
 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsecure/html/http-sso-1.asp
 //
 //
 
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
 
 #include "prlink.h"
 #include "nsCOMPtr.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIServiceManager.h"
 #include "nsNativeCharsetUtils.h"
 #include "mozilla/Telemetry.h"
@@ -514,17 +515,18 @@ nsAuthGSSAPI::GetNextToken(const void *i
     if (major_status == GSS_S_COMPLETE)
         rv = NS_SUCCESS_AUTH_FINISHED;
     else
         rv = NS_OK;
 
 end:
     gss_release_name_ptr(&minor_status, &server);
 
-    LOG(("  leaving nsAuthGSSAPI::GetNextToken [rv=%x]", rv));
+    LOG(("  leaving nsAuthGSSAPI::GetNextToken [rv=%" PRIx32 "]",
+         static_cast<uint32_t>(rv)));
     return rv;
 }
 
 NS_IMETHODIMP
 nsAuthGSSAPI::Unwrap(const void *inToken,
                      uint32_t    inTokenLen,
                      void      **outToken,
                      uint32_t   *outTokenLen)
--- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp
+++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp
@@ -17,16 +17,17 @@
 #include "nsIStringBundle.h"
 #include "nsContentUtils.h"
 #include "nsCRT.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nspr.h"
 #include <algorithm>
 
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 
 using mozilla::LogLevel;
 
 mozilla::LazyLogModule MCD("MCD");
 
 extern nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
                                           const char *filename, 
@@ -121,17 +122,18 @@ nsAutoConfig::OnDataAvailable(nsIRequest
 NS_IMETHODIMP
 nsAutoConfig::OnStopRequest(nsIRequest *request, nsISupports *context,
                             nsresult aStatus)
 {
     nsresult rv;
 
     // If the request is failed, go read the failover.jsc file
     if (NS_FAILED(aStatus)) {
-        MOZ_LOG(MCD, LogLevel::Debug, ("mcd request failed with status %x\n", aStatus));
+        MOZ_LOG(MCD, LogLevel::Debug, ("mcd request failed with status %" PRIx32 "\n",
+                                       static_cast<uint32_t>(aStatus)));
         return readOfflineFile();
     }
 
     // Checking for the http response, if failure go read the failover file.
     nsCOMPtr<nsIHttpChannel> pHTTPCon(do_QueryInterface(request));
     if (pHTTPCon) {
         uint32_t httpStatus;
         pHTTPCon->GetResponseStatus(&httpStatus);
--- a/extensions/pref/autoconfig/src/nsReadConfig.cpp
+++ b/extensions/pref/autoconfig/src/nsReadConfig.cpp
@@ -171,17 +171,18 @@ nsresult nsReadConfig::readConfigFile()
     NS_ENSURE_SUCCESS(rv, rv);
 
     int32_t obscureValue = 0;
     (void) defaultPrefBranch->GetIntPref("general.config.obscure_value", &obscureValue);
     MOZ_LOG(MCD, LogLevel::Debug, ("evaluating .cfg file %s with obscureValue %d\n", lockFileName.get(), obscureValue));
     rv = openAndEvaluateJSFile(lockFileName.get(), obscureValue, true, true);
     if (NS_FAILED(rv))
     {
-      MOZ_LOG(MCD, LogLevel::Debug, ("error evaluating .cfg file %s %x\n", lockFileName.get(), rv));
+      MOZ_LOG(MCD, LogLevel::Debug, ("error evaluating .cfg file %s %" PRIx32 "\n",
+                                     lockFileName.get(), static_cast<uint32_t>(rv)));
       return rv;
     }
     
     rv = prefBranch->GetCharPref("general.config.filename", 
                                   getter_Copies(lockFileName));
     if (NS_FAILED(rv))
         // There is NO REASON we should ever get here. This is POST reading 
         // of the config file.
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -22,16 +22,17 @@
 #include "mozilla/layers/ImageBridgeParent.h" // for ImageBridgeParent
 #include "mozilla/layers/ImageLayerComposite.h"
 #include "mozilla/layers/LayerManagerComposite.h"
 #include "mozilla/layers/LayersMessages.h"  // for EditReply, etc
 #include "mozilla/layers/LayersTypes.h"  // for MOZ_LAYERS_LOG
 #include "mozilla/layers/TextureHostOGL.h"  // for TextureHostOGL
 #include "mozilla/layers/PaintedLayerComposite.h"
 #include "mozilla/mozalloc.h"           // for operator delete, etc
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Unused.h"
 #include "nsCoord.h"                    // for NSAppUnitsToFloatPixels
 #include "nsDebug.h"                    // for NS_RUNTIMEABORT
 #include "nsDeviceContext.h"            // for AppUnitsPerCSSPixel
 #include "nsISupportsImpl.h"            // for Layer::Release, etc
 #include "nsLayoutUtils.h"              // for nsLayoutUtils
 #include "nsMathUtils.h"                // for NS_round
 #include "nsPoint.h"                    // for nsPoint
@@ -137,17 +138,17 @@ LayerTransactionParent::RecvUpdate(const
   GeckoProfilerTracingRAII tracer("Paint", "LayerTransaction");
   PROFILER_LABEL("LayerTransactionParent", "RecvUpdate",
     js::ProfileEntry::Category::GRAPHICS);
 
 #ifdef COMPOSITOR_PERFORMANCE_WARNING
   TimeStamp updateStart = TimeStamp::Now();
 #endif
 
-  MOZ_LAYERS_LOG(("[ParentSide] received txn with %d edits", aInfo.cset().Length()));
+  MOZ_LAYERS_LOG(("[ParentSide] received txn with %" PRIuSIZE " edits", aInfo.cset().Length()));
 
   UpdateFwdTransactionId(aInfo.fwdTransactionId());
 
   if (mDestroyed || !layer_manager() || layer_manager()->IsDestroyed()) {
     for (const auto& op : aInfo.toDestroy()) {
       DestroyActor(op);
     }
     return IPC_OK();
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #include "gfxFcPlatformFontList.h"
 #include "gfxFont.h"
 #include "gfxFontConstants.h"
 #include "gfxFontFamilyList.h"
 #include "gfxFT2Utils.h"
 #include "gfxPlatform.h"
 #include "mozilla/ArrayUtils.h"
@@ -376,17 +377,17 @@ gfxFontconfigFontEntry::ReadCMAP(FontInf
     if (mHasCmapTable) {
         gfxPlatformFontList *pfl = gfxPlatformFontList::PlatformFontList();
         mCharacterMap = pfl->FindCharMap(charmap);
     } else {
         // if error occurred, initialize to null cmap
         mCharacterMap = new gfxCharacterMap();
     }
 
-    LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d hash: %8.8x%s\n",
+    LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %" PRIuSIZE " hash: %8.8x%s\n",
                   NS_ConvertUTF16toUTF8(mName).get(),
                   charmap->SizeOfIncludingThis(moz_malloc_size_of),
                   charmap->mHash, mCharacterMap == charmap ? " new" : ""));
     if (LOG_CMAPDATA_ENABLED()) {
         char prefix[256];
         SprintfLiteral(prefix, "(cmapdata) name: %.220s",
                        NS_ConvertUTF16toUTF8(mName).get());
         charmap->Dump(prefix, eGfxLog_cmapdata);
--- a/gfx/thebes/gfxMacPlatformFontList.mm
+++ b/gfx/thebes/gfxMacPlatformFontList.mm
@@ -60,16 +60,17 @@
 #include "nsCharTraits.h"
 #include "nsCocoaFeatures.h"
 #include "nsCocoaUtils.h"
 #include "gfxFontConstants.h"
 
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/gfx/2D.h"
 
 #include <unistd.h>
 #include <time.h>
 #include <dlfcn.h>
 
@@ -221,17 +222,17 @@ MacOSFontEntry::ReadCMAP(FontInfoData *a
     if (mHasCmapTable) {
         gfxPlatformFontList *pfl = gfxPlatformFontList::PlatformFontList();
         mCharacterMap = pfl->FindCharMap(charmap);
     } else {
         // if error occurred, initialize to null cmap
         mCharacterMap = new gfxCharacterMap();
     }
 
-    LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d hash: %8.8x%s\n",
+    LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %" PRIuSIZE " hash: %8.8x%s\n",
                   NS_ConvertUTF16toUTF8(mName).get(),
                   charmap->SizeOfIncludingThis(moz_malloc_size_of),
                   charmap->mHash, mCharacterMap == charmap ? " new" : ""));
     if (LOG_CMAPDATA_ENABLED()) {
         char prefix[256];
         SprintfLiteral(prefix, "(cmapdata) name: %.220s",
                        NS_ConvertUTF16toUTF8(mName).get());
         charmap->Dump(prefix, eGfxLog_cmapdata);
@@ -885,17 +886,17 @@ gfxMacPlatformFontList::InitSingleFaceLi
             // differ from the one we found in the main list.
             MacOSFontEntry* fontEntry =
                 new MacOSFontEntry(fe->Name(), fe->mWeight, true,
                                    static_cast<const MacOSFontEntry*>(fe)->
                                        mSizeHint);
             familyEntry->AddFontEntry(fontEntry);
             familyEntry->SetHasStyles(true);
             mFontFamilies.Put(key, familyEntry);
-            LOG_FONTLIST(("(fontlist-singleface) added new family\n",
+            LOG_FONTLIST(("(fontlist-singleface) added new family: %s, key: %s\n",
                           NS_ConvertUTF16toUTF8(familyName).get(),
                           NS_ConvertUTF16toUTF8(key).get()));
         }
     }
 }
 
 // System fonts under OSX may contain weird "meta" names but if we create
 // a new font using just the Postscript name, the NSFont api returns an object
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -564,17 +564,17 @@ gfxPlatformFontList::SystemFindFontForCh
     if (MOZ_UNLIKELY(MOZ_LOG_TEST(log, LogLevel::Warning))) {
         uint32_t unicodeRange = FindCharUnicodeRange(aCh);
         Script script = mozilla::unicode::GetScriptCode(aCh);
         MOZ_LOG(log, LogLevel::Warning,\
                ("(textrun-systemfallback-%s) char: u+%6.6x "
                  "unicode-range: %d script: %d match: [%s]"
                 " time: %dus cmaps: %d\n",
                 (common ? "common" : "global"), aCh,
-                 unicodeRange, script,
+                unicodeRange, static_cast<int>(script),
                 (fontEntry ? NS_ConvertUTF16toUTF8(fontEntry->Name()).get() :
                     "<none>"),
                 int32_t(elapsed.ToMicroseconds()),
                 cmapCount));
     }
 
     // no match? add to set of non-matching codepoints
     if (!fontEntry) {
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gfxTextRun.h"
 #include "gfxGlyphExtents.h"
 #include "gfxPlatformFontList.h"
 #include "gfxUserFontSet.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Sprintf.h"
 #include "nsGkAtoms.h"
 #include "nsILanguageAtomService.h"
 #include "nsServiceManagerUtils.h"
 
 #include "gfxContext.h"
 #include "gfxFontConstants.h"
 #include "gfxFontMissingGlyphs.h"
@@ -2163,25 +2164,25 @@ gfxFontGroup::InitTextRun(DrawTarget* aD
             if (MOZ_UNLIKELY(MOZ_LOG_TEST(log, LogLevel::Warning))) {
                 nsAutoCString lang;
                 mStyle.language->ToUTF8String(lang);
                 nsAutoString families;
                 mFamilyList.ToString(families);
                 nsAutoCString str((const char*)aString, aLength);
                 MOZ_LOG(log, LogLevel::Warning,\
                        ("(%s) fontgroup: [%s] default: %s lang: %s script: %d "
-                        "len %d weight: %d width: %d style: %s size: %6.2f %d-byte "
+                        "len %d weight: %d width: %d style: %s size: %6.2f %" PRIuSIZE "-byte "
                         "TEXTRUN [%s] ENDTEXTRUN\n",
                         (mStyle.systemFont ? "textrunui" : "textrun"),
                         NS_ConvertUTF16toUTF8(families).get(),
                         (mFamilyList.GetDefaultFontType() == eFamily_serif ?
                          "serif" :
                          (mFamilyList.GetDefaultFontType() == eFamily_sans_serif ?
                           "sans-serif" : "none")),
-                        lang.get(), Script::LATIN, aLength,
+                        lang.get(), static_cast<int>(Script::LATIN), aLength,
                         uint32_t(mStyle.weight), uint32_t(mStyle.stretch),
                         (mStyle.style & NS_FONT_STYLE_ITALIC ? "italic" :
                         (mStyle.style & NS_FONT_STYLE_OBLIQUE ? "oblique" :
                                                                 "normal")),
                         mStyle.size,
                         sizeof(T),
                         str.get()));
             }
@@ -2212,24 +2213,24 @@ gfxFontGroup::InitTextRun(DrawTarget* aD
                     nsAutoCString lang;
                     mStyle.language->ToUTF8String(lang);
                     nsAutoString families;
                     mFamilyList.ToString(families);
                     uint32_t runLen = runLimit - runStart;
                     MOZ_LOG(log, LogLevel::Warning,\
                            ("(%s) fontgroup: [%s] default: %s lang: %s script: %d "
                             "len %d weight: %d width: %d style: %s size: %6.2f "
-                            "%d-byte TEXTRUN [%s] ENDTEXTRUN\n",
+                            "%" PRIuSIZE "-byte TEXTRUN [%s] ENDTEXTRUN\n",
                             (mStyle.systemFont ? "textrunui" : "textrun"),
                             NS_ConvertUTF16toUTF8(families).get(),
                             (mFamilyList.GetDefaultFontType() == eFamily_serif ?
                              "serif" :
                              (mFamilyList.GetDefaultFontType() == eFamily_sans_serif ?
                               "sans-serif" : "none")),
-                            lang.get(), runScript, runLen,
+                            lang.get(), static_cast<int>(runScript), runLen,
                             uint32_t(mStyle.weight), uint32_t(mStyle.stretch),
                             (mStyle.style & NS_FONT_STYLE_ITALIC ? "italic" :
                             (mStyle.style & NS_FONT_STYLE_OBLIQUE ? "oblique" :
                                                                     "normal")),
                             mStyle.size,
                             sizeof(T),
                             NS_ConvertUTF16toUTF8(textPtr + runStart, runLen).get()));
                 }
@@ -2990,17 +2991,17 @@ void gfxFontGroup::ComputeRanges(nsTArra
                ("(%s-fontmatching) fontgroup: [%s] default: %s lang: %s script: %d"
                 "%s\n",
                 (mStyle.systemFont ? "textrunui" : "textrun"),
                 NS_ConvertUTF16toUTF8(families).get(),
                 (mFamilyList.GetDefaultFontType() == eFamily_serif ?
                  "serif" :
                  (mFamilyList.GetDefaultFontType() == eFamily_sans_serif ?
                   "sans-serif" : "none")),
-                lang.get(), aRunScript,
+                lang.get(), static_cast<int>(aRunScript),
                 fontMatches.get()));
     }
 #endif
 }
 
 gfxUserFontSet*
 gfxFontGroup::GetUserFontSet()
 {
--- a/hal/fallback/FallbackThreadPriority.cpp
+++ b/hal/fallback/FallbackThreadPriority.cpp
@@ -8,22 +8,22 @@
 using namespace mozilla::hal;
 
 namespace mozilla {
 namespace hal_impl {
 
 void
 SetCurrentThreadPriority(ThreadPriority aPriority)
 {
-  HAL_LOG("FallbackThreadPriority - SetCurrentThreadPriority(%d)\n",
+  HAL_LOG("FallbackThreadPriority - SetCurrentThreadPriority(%s)\n",
           ThreadPriorityToString(aPriority));
 }
 
 void
 SetThreadPriority(PlatformThreadId aThreadId,
                   ThreadPriority aPriority)
 {
-  HAL_LOG("FallbackThreadPriority - SetThreadPriority(%d, %d)\n",
+  HAL_LOG("FallbackThreadPriority - SetThreadPriority(%d, %s)\n",
           aThreadId, ThreadPriorityToString(aPriority));
 }
 
 } // namespace hal_impl
 } // namespace mozilla
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -2211,18 +2211,18 @@ imgLoader::LoadImage(nsIURI* aURI,
 
     mozilla::net::PredictorLearn(aURI, aInitialDocumentURI,
         nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, aLoadGroup);
 
     nsresult openRes = newChannel->AsyncOpen2(listener);
 
     if (NS_FAILED(openRes)) {
       MOZ_LOG(gImgLog, LogLevel::Debug,
-             ("[this=%p] imgLoader::LoadImage -- AsyncOpen2() failed: 0x%x\n",
-              this, openRes));
+             ("[this=%p] imgLoader::LoadImage -- AsyncOpen2() failed: 0x%" PRIx32 "\n",
+              this, static_cast<uint32_t>(openRes)));
       request->CancelAndAbort(openRes);
       return openRes;
     }
 
     // Try to add the new request into the cache.
     PutIntoCache(key, entry);
   } else {
     LOG_MSG_WITH_PARAM(gImgLog,
@@ -2678,19 +2678,19 @@ ProxyListener::CheckListenerChain()
   NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread!");
   nsresult rv = NS_OK;
   nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
     do_QueryInterface(mDestListener, &rv);
   if (retargetableListener) {
     rv = retargetableListener->CheckListenerChain();
   }
   MOZ_LOG(gImgLog, LogLevel::Debug,
-         ("ProxyListener::CheckListenerChain %s [this=%p listener=%p rv=%x]",
+         ("ProxyListener::CheckListenerChain %s [this=%p listener=%p rv=%" PRIx32 "]",
           (NS_SUCCEEDED(rv) ? "success" : "failure"),
-          this, (nsIStreamListener*)mDestListener, rv));
+          this, (nsIStreamListener*)mDestListener, static_cast<uint32_t>(rv)));
   return rv;
 }
 
 /**
  * http validate class.  check a channel for a 304
  */
 
 NS_IMPL_ISUPPORTS(imgCacheValidator, nsIStreamListener, nsIRequestObserver,
@@ -2900,18 +2900,18 @@ imgCacheValidator::CheckListenerChain()
   NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread!");
   nsresult rv = NS_OK;
   nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
     do_QueryInterface(mDestListener, &rv);
   if (retargetableListener) {
     rv = retargetableListener->CheckListenerChain();
   }
   MOZ_LOG(gImgLog, LogLevel::Debug,
-         ("[this=%p] imgCacheValidator::CheckListenerChain -- rv %d=%s",
-          this, NS_SUCCEEDED(rv) ? "succeeded" : "failed", rv));
+         ("[this=%p] imgCacheValidator::CheckListenerChain -- rv %" PRId32 "=%s",
+          this, static_cast<uint32_t>(rv), NS_SUCCEEDED(rv) ? "succeeded" : "failed"));
   return rv;
 }
 
 /** nsIInterfaceRequestor methods **/
 
 NS_IMETHODIMP
 imgCacheValidator::GetInterface(const nsIID& aIID, void** aResult)
 {
--- a/image/imgRequest.cpp
+++ b/image/imgRequest.cpp
@@ -32,16 +32,18 @@
 #include "nsIScriptSecurityManager.h"
 #include "nsContentUtils.h"
 
 #include "plstr.h" // PL_strcasestr(...)
 #include "nsNetUtil.h"
 #include "nsIProtocolHandler.h"
 #include "imgIRequest.h"
 
+#include "mozilla/IntegerPrintfMacros.h"
+
 using namespace mozilla;
 using namespace mozilla::image;
 
 #define LOG_TEST(level) (MOZ_LOG_TEST(gImgLog, (level)))
 
 NS_IMPL_ISUPPORTS(imgRequest,
                   nsIStreamListener, nsIRequestObserver,
                   nsIThreadRetargetableStreamListener,
@@ -777,18 +779,18 @@ imgRequest::OnStartRequest(nsIRequest* a
     if (NS_SUCCEEDED(rv) && !mimeType.EqualsLiteral(IMAGE_SVG_XML)) {
       // Retarget OnDataAvailable to the DecodePool's IO thread.
       nsCOMPtr<nsIEventTarget> target =
         DecodePool::Singleton()->GetIOEventTarget();
       rv = retargetable->RetargetDeliveryTo(target);
     }
     MOZ_LOG(gImgLog, LogLevel::Warning,
            ("[this=%p] imgRequest::OnStartRequest -- "
-            "RetargetDeliveryTo rv %d=%s\n",
-            this, rv, NS_SUCCEEDED(rv) ? "succeeded" : "failed"));
+            "RetargetDeliveryTo rv %" PRIu32 "=%s\n",
+            this, static_cast<uint32_t>(rv), NS_SUCCEEDED(rv) ? "succeeded" : "failed"));
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 imgRequest::OnStopRequest(nsIRequest* aRequest,
                           nsISupports* ctxt, nsresult status)
--- a/layout/base/AccessibleCaretManager.cpp
+++ b/layout/base/AccessibleCaretManager.cpp
@@ -9,16 +9,17 @@
 #include "AccessibleCaret.h"
 #include "AccessibleCaretEventHub.h"
 #include "AccessibleCaretLogger.h"
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/TreeWalker.h"
 #include "mozilla/IMEStateManager.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "nsCaret.h"
 #include "nsContainerFrame.h"
 #include "nsContentUtils.h"
 #include "nsFocusManager.h"
 #include "nsFrame.h"
 #include "nsFrameSelection.h"
 #include "nsGenericHTMLElement.h"
@@ -1468,15 +1469,16 @@ AccessibleCaretManager::DispatchCaretSta
   sel->Stringify(init.mSelectedTextContent);
 
   RefPtr<CaretStateChangedEvent> event =
     CaretStateChangedEvent::Constructor(doc, NS_LITERAL_STRING("mozcaretstatechanged"), init);
 
   event->SetTrusted(true);
   event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
 
-  AC_LOG("%s: reason %d, collapsed %d, caretVisible %d", __FUNCTION__,
-         init.mReason, init.mCollapsed, init.mCaretVisible);
+  AC_LOG("%s: reason %" PRIu32 ", collapsed %d, caretVisible %" PRIu32, __FUNCTION__,
+         static_cast<uint32_t>(init.mReason), init.mCollapsed,
+         static_cast<uint32_t>(init.mCaretVisible));
 
   (new AsyncEventDispatcher(doc, event))->RunDOMEventWhenSafe();
 }
 
 } // namespace mozilla
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -320,17 +320,17 @@ protected:
     TickRefreshDrivers(jsnow, now, mContentRefreshDrivers);
     TickRefreshDrivers(jsnow, now, mRootRefreshDrivers);
 
     LOG("[%p] done.", this);
   }
 
   static void TickDriver(nsRefreshDriver* driver, int64_t jsnow, TimeStamp now)
   {
-    LOG(">> TickDriver: %p (jsnow: %lld)", driver, jsnow);
+    LOG(">> TickDriver: %p (jsnow: %" PRId64 ")", driver, jsnow);
     driver->Tick(jsnow, now);
   }
 
   int64_t mLastFireEpoch;
   bool mLastFireSkipped;
   TimeStamp mLastFireTime;
   TimeStamp mTargetTime;
 
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -1492,17 +1492,18 @@ nsresult nsPrintEngine::DocumentReadyFor
   return rv;
 }
 
 /** ---------------------------------------------------
  *  Cleans up when an error occurred
  */
 nsresult nsPrintEngine::CleanupOnFailure(nsresult aResult, bool aIsPrinting)
 {
-  PR_PL(("****  Failed %s - rv 0x%X", aIsPrinting?"Printing":"Print Preview", aResult));
+  PR_PL(("****  Failed %s - rv 0x%" PRIX32, aIsPrinting?"Printing":"Print Preview",
+         static_cast<uint32_t>(aResult)));
 
   /* cleanup... */
   if (mPagePrintTimer) {
     mPagePrintTimer->Stop();
     DisconnectPagePrintTimer();
   }
   
   if (aIsPrinting) {
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -14,16 +14,17 @@
  * 04/20/2000       IBM Corp.      OS/2 VisualAge build.
  */
 
 /* loading of CSS style sheets using the network APIs */
 
 #include "mozilla/css/Loader.h"
 
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/MemoryReporting.h"
 
 #include "mozilla/StyleSheetInlines.h"
 #include "nsIRunnable.h"
 #include "nsIUnicharStreamLoader.h"
 #include "nsSyncLoadService.h"
 #include "nsCOMPtr.h"
@@ -798,17 +799,17 @@ SheetLoadData::OnStreamComplete(nsIUnich
   if (!mLoader->mDocument && !mIsNonDocumentSheet) {
     // Sorry, we don't care about this load anymore
     LOG_WARN(("  No document and not non-document sheet; dropping load"));
     mLoader->SheetComplete(this, NS_BINDING_ABORTED);
     return NS_OK;
   }
 
   if (NS_FAILED(aStatus)) {
-    LOG_WARN(("  Load failed: status 0x%x", aStatus));
+    LOG_WARN(("  Load failed: status 0x%" PRIx32, static_cast<uint32_t>(aStatus)));
     // Handle sheet not loading error because source was a tracking URL.
     // We make a note of this sheet node by including it in a dedicated
     // array of blocked tracking nodes under its parent document.
     //
     // Multiple sheet load instances might be tied to this request,
     // we annotate each one linked to a valid owning element (node).
     if (aStatus == NS_ERROR_TRACKING_URI) {
       nsIDocument* doc = mLoader->GetDocument();
@@ -1869,17 +1870,17 @@ void
 Loader::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
                         LoadDataArray& aDatasToNotify)
 {
   LOG(("css::Loader::DoSheetComplete"));
   NS_PRECONDITION(aLoadData, "Must have a load data!");
   NS_PRECONDITION(aLoadData->mSheet, "Must have a sheet");
   NS_ASSERTION(mSheets, "mLoadingDatas should be initialized by now.");
 
-  LOG(("Load completed, status: 0x%x", aStatus));
+  LOG(("Load completed, status: 0x%" PRIx32, static_cast<uint32_t>(aStatus)));
 
   // Twiddle the hashtables
   if (aLoadData->mURI) {
     LOG_URI("  Finished loading: '%s'", aLoadData->mURI);
     // Remove the data from the list of loading datas
     if (aLoadData->mIsLoading) {
       URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData->mURI,
                                          aLoadData->mLoaderPrincipal,
--- a/layout/style/nsFontFaceLoader.cpp
+++ b/layout/style/nsFontFaceLoader.cpp
@@ -1,16 +1,19 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 // vim:cindent:ts=2:et:sw=2:
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* code for loading in @font-face defined font data */
 
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/Logging.h"
+
 #include "nsFontFaceLoader.h"
 
 #include "mozilla/Logging.h"
 
 #include "nsError.h"
 #include "nsContentUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
@@ -217,18 +220,18 @@ nsFontFaceLoader::OnStreamComplete(nsISt
     }
   }
 
   if (LOG_ENABLED()) {
     if (NS_SUCCEEDED(aStatus)) {
       LOG(("userfonts (%p) download completed - font uri: (%s) time: %d ms\n",
            this, mFontURI->GetSpecOrDefault().get(), downloadTimeMS));
     } else {
-      LOG(("userfonts (%p) download failed - font uri: (%s) error: %8.8x\n",
-           this, mFontURI->GetSpecOrDefault().get(), aStatus));
+      LOG(("userfonts (%p) download failed - font uri: (%s) error: %8.8" PRIx32 "\n",
+           this, mFontURI->GetSpecOrDefault().get(), static_cast<uint32_t>(aStatus)));
     }
   }
 
   if (NS_SUCCEEDED(aStatus)) {
     // for HTTP requests, check whether the request _actually_ succeeded;
     // the "request status" in aStatus does not necessarily indicate this,
     // because HTTP responses such as 404 (Not Found) will still result in
     // a success code and potentially an HTML error page from the server
--- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
@@ -2,17 +2,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebrtcGmpVideoCodec.h"
 
 #include <iostream>
 #include <vector>
 
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Move.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/SyncRunnable.h"
 #include "VideoConduit.h"
 #include "AudioConduit.h"
 #include "runnable_utils.h"
 
 #include "mozIGeckoMediaPluginService.h"
 #include "nsServiceManagerUtils.h"
 #include "GMPVideoDecoderProxy.h"
@@ -525,17 +527,17 @@ WebrtcGmpVideoEncoder::Encoded(GMPVideoE
                                const nsTArray<uint8_t>& aCodecSpecificInfo)
 {
   MutexAutoLock lock(mCallbackMutex);
   if (mCallback) {
     webrtc::FrameType ft;
     GmpFrameTypeToWebrtcFrameType(aEncodedFrame->FrameType(), &ft);
     uint32_t timestamp = (aEncodedFrame->TimeStamp() * 90ll + 999)/1000;
 
-    LOGD(("GMP Encoded: %llu, type %d, len %d",
+    LOGD(("GMP Encoded: %" PRIu64 ", type %d, len %d",
          aEncodedFrame->TimeStamp(),
          aEncodedFrame->BufferType(),
          aEncodedFrame->Size()));
 
     // Right now makes one Encoded() callback per unit
     // XXX convert to FragmentationHeader format (array of offsets and sizes plus a buffer) in
     // combination with H264 packetization changes in webrtc/trunk code
     uint8_t *buffer = aEncodedFrame->Buffer();
@@ -852,17 +854,17 @@ WebrtcGmpVideoDecoder::Decode_g(const we
   // Bug XXXXXX: Set codecSpecific info
   GMPCodecSpecificInfo info;
   memset(&info, 0, sizeof(info));
   info.mCodecType = kGMPVideoCodecH264;
   info.mCodecSpecific.mH264.mSimulcastIdx = 0;
   nsTArray<uint8_t> codecSpecificInfo;
   codecSpecificInfo.AppendElements((uint8_t*)&info, sizeof(GMPCodecSpecificInfo));
 
-  LOGD(("GMP Decode: %llu, len %d", frame->TimeStamp(), aInputImage._length));
+  LOGD(("GMP Decode: %" PRIu64 ", len %" PRIuSIZE, frame->TimeStamp(), aInputImage._length));
   nsresult rv = mGMP->Decode(Move(frame),
                              aMissingFrames,
                              codecSpecificInfo,
                              aRenderTimeMs);
   if (NS_FAILED(rv)) {
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
   if(mDecoderStatus != GMPNoErr){
@@ -935,15 +937,15 @@ WebrtcGmpVideoDecoder::Decoded(GMPVideoi
                                 aDecodedFrame->Stride(kGMPUPlane),
                                 aDecodedFrame->Stride(kGMPVPlane));
     if (ret != 0) {
       return;
     }
     image.set_timestamp((aDecodedFrame->Timestamp() * 90ll + 999)/1000); // round up
     image.set_render_time_ms(0);
 
-    LOGD(("GMP Decoded: %llu", aDecodedFrame->Timestamp()));
+    LOGD(("GMP Decoded: %" PRIu64, aDecodedFrame->Timestamp()));
     mCallback->Decoded(image);
   }
   aDecodedFrame->Destroy();
 }
 
 }
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -16,16 +16,17 @@
 #include "nsContentUtils.h"
 #include "nsProxyRelease.h"
 #include "nsContentSecurityManager.h"
 
 #include "nsIScriptSecurityManager.h"
 #include "nsIPrincipal.h"
 #include "nsIFileURL.h"
 
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "nsITabChild.h"
 #include "private/pprio.h"
 #include "nsInputStreamPump.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
@@ -320,17 +321,17 @@ nsJARChannel::CreateJarInput(nsIZipReade
 
     input.forget(resultInput);
     return NS_OK;
 }
 
 nsresult
 nsJARChannel::LookupFile(bool aAllowAsync)
 {
-    LOG(("nsJARChannel::LookupFile [this=%x %s]\n", this, mSpec.get()));
+    LOG(("nsJARChannel::LookupFile [this=%p %s]\n", this, mSpec.get()));
 
     if (mJarFile)
         return NS_OK;
 
     nsresult rv;
 
     rv = mJarURI->GetJARFile(getter_AddRefs(mJarBaseURI));
     if (NS_FAILED(rv))
@@ -702,17 +703,17 @@ nsJARChannel::SetContentLength(int64_t a
     // XXX does this really make any sense at all?
     mContentLength = aContentLength;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsJARChannel::Open(nsIInputStream **stream)
 {
-    LOG(("nsJARChannel::Open [this=%x]\n", this));
+    LOG(("nsJARChannel::Open [this=%p]\n", this));
 
     NS_ENSURE_TRUE(!mOpened, NS_ERROR_IN_PROGRESS);
     NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
 
     mJarFile = nullptr;
     mIsUnsafe = true;
 
     nsresult rv = LookupFile(false);
@@ -751,17 +752,17 @@ nsJARChannel::AsyncOpen(nsIStreamListene
 {
     MOZ_ASSERT(!mLoadInfo ||
                mLoadInfo->GetSecurityMode() == 0 ||
                mLoadInfo->GetInitialSecurityCheckDone() ||
                (mLoadInfo->GetSecurityMode() == nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL &&
                 nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal())),
                "security flags in loadInfo but asyncOpen2() not called");
 
-    LOG(("nsJARChannel::AsyncOpen [this=%x]\n", this));
+    LOG(("nsJARChannel::AsyncOpen [this=%p]\n", this));
 
     NS_ENSURE_ARG_POINTER(listener);
     NS_ENSURE_TRUE(!mOpened, NS_ERROR_IN_PROGRESS);
     NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
 
     mJarFile = nullptr;
     mIsUnsafe = true;
 
@@ -1011,30 +1012,30 @@ nsJARChannel::OnDownloadComplete(MemoryD
 
 //-----------------------------------------------------------------------------
 // nsIStreamListener
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsJARChannel::OnStartRequest(nsIRequest *req, nsISupports *ctx)
 {
-    LOG(("nsJARChannel::OnStartRequest [this=%x %s]\n", this, mSpec.get()));
+    LOG(("nsJARChannel::OnStartRequest [this=%p %s]\n", this, mSpec.get()));
 
     mRequest = req;
     nsresult rv = mListener->OnStartRequest(this, mListenerContext);
     mRequest = nullptr;
 
     return rv;
 }
 
 NS_IMETHODIMP
 nsJARChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult status)
 {
-    LOG(("nsJARChannel::OnStopRequest [this=%x %s status=%x]\n",
-        this, mSpec.get(), status));
+    LOG(("nsJARChannel::OnStopRequest [this=%p %s status=%" PRIx32 "]\n",
+         this, mSpec.get(), static_cast<uint32_t>(status)));
 
     if (NS_SUCCEEDED(mStatus))
         mStatus = status;
 
     if (mListener) {
         mListener->OnStopRequest(this, mListenerContext, status);
         mListener = nullptr;
         mListenerContext = nullptr;
@@ -1059,17 +1060,17 @@ nsJARChannel::OnStopRequest(nsIRequest *
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsJARChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx,
                                nsIInputStream *stream,
                                uint64_t offset, uint32_t count)
 {
-    LOG(("nsJARChannel::OnDataAvailable [this=%x %s]\n", this, mSpec.get()));
+    LOG(("nsJARChannel::OnDataAvailable [this=%p %s]\n", this, mSpec.get()));
 
     nsresult rv;
 
     rv = mListener->OnDataAvailable(this, mListenerContext, stream, offset, count);
 
     // simply report progress here instead of hooking ourselves up as a
     // nsITransportEventSink implementation.
     // XXX do the 64-bit stuff for real
--- a/netwerk/base/EventTokenBucket.cpp
+++ b/netwerk/base/EventTokenBucket.cpp
@@ -10,16 +10,17 @@
 #include "nsIIOService.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsServiceManagerUtils.h"
 #include "nsSocketTransportService2.h"
 #ifdef DEBUG
 #include "MainThreadUtils.h"
 #endif
+#include "mozilla/SizePrintfMacros.h"
 
 #ifdef XP_WIN
 #include <windows.h>
 #include <mmsystem.h>
 #endif
 
 namespace mozilla {
 namespace net {
@@ -103,17 +104,17 @@ EventTokenBucket::EventTokenBucket(uint3
     mTimer = do_CreateInstance("@mozilla.org/timer;1");
   if (mTimer)
     mTimer->SetTarget(sts);
   SetRate(eventsPerSecond, burstSize);
 }
 
 EventTokenBucket::~EventTokenBucket()
 {
-  SOCKET_LOG(("EventTokenBucket::dtor %p events=%d\n",
+  SOCKET_LOG(("EventTokenBucket::dtor %p events=%" PRIuSIZE "\n",
               this, mEvents.GetSize()));
 
   CleanupTimers();
 
   // Complete any queued events to prevent hangs
   while (mEvents.GetSize()) {
     RefPtr<TokenBucketCancelable> cancelable =
       dont_AddRef(static_cast<TokenBucketCancelable *>(mEvents.PopFront()));
@@ -282,17 +283,17 @@ EventTokenBucket::DispatchEvents()
   if (mPaused || mStopped)
     return;
 
   while (mEvents.GetSize() && mUnitCost <= mCredit) {
     RefPtr<TokenBucketCancelable> cancelable = 
       dont_AddRef(static_cast<TokenBucketCancelable *>(mEvents.PopFront()));
     if (cancelable->mEvent) {
       SOCKET_LOG(("EventTokenBucket::DispachEvents [%p] "
-                  "Dispatching queue token bucket event cost=%lu credit=%lu\n",
+                  "Dispatching queue token bucket event cost=%" PRIu64 " credit=%" PRIu64 "\n",
                   this, mUnitCost, mCredit));
       mCredit -= mUnitCost;
       cancelable->Fire();
     }
   }
   
 #ifdef XP_WIN
   if (!mEvents.GetSize())
@@ -321,17 +322,17 @@ EventTokenBucket::UpdateTimer()
     msecWait = 4;
   else if (msecWait > 60000) // maximum wait
     msecWait = 60000;
 
 #ifdef XP_WIN
   FineGrainTimers();
 #endif
 
-  SOCKET_LOG(("EventTokenBucket::UpdateTimer %p for %dms\n",
+  SOCKET_LOG(("EventTokenBucket::UpdateTimer %p for %" PRIu64 "ms\n",
               this, msecWait));
   nsresult rv = mTimer->InitWithCallback(this, static_cast<uint32_t>(msecWait),
                                          nsITimer::TYPE_ONE_SHOT);
   mTimerArmed = NS_SUCCEEDED(rv);
 }
 
 NS_IMETHODIMP
 EventTokenBucket::Notify(nsITimer *timer)
@@ -364,17 +365,17 @@ EventTokenBucket::UpdateCredits()
 
   TimeStamp now = TimeStamp::Now();
   TimeDuration elapsed = now - mLastUpdate;
   mLastUpdate = now;
 
   mCredit += static_cast<uint64_t>(elapsed.ToMicroseconds());
   if (mCredit > mMaxCredit)
     mCredit = mMaxCredit;
-  SOCKET_LOG(("EventTokenBucket::UpdateCredits %p to %lu (%lu each.. %3.2f)\n",
+  SOCKET_LOG(("EventTokenBucket::UpdateCredits %p to %" PRIu64 " (%" PRIu64 " each.. %3.2f)\n",
               this, mCredit, mUnitCost, (double)mCredit / mUnitCost));
 }
 
 #ifdef XP_WIN
 void
 EventTokenBucket::FineGrainTimers()
 {
   SOCKET_LOG(("EventTokenBucket::FineGrainTimers %p mFineGrainTimerInUse=%d\n",
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -280,23 +280,23 @@ Predictor::Action::OnCacheEntryAvailable
 
   nsAutoCString targetURI, sourceURI;
   mTargetURI->GetAsciiSpec(targetURI);
   if (mSourceURI) {
     mSourceURI->GetAsciiSpec(sourceURI);
   }
   PREDICTOR_LOG(("OnCacheEntryAvailable %p called. entry=%p mFullUri=%d mPredict=%d "
                  "mPredictReason=%d mLearnReason=%d mTargetURI=%s "
-                 "mSourceURI=%s mStackCount=%d isNew=%d result=0x%08x",
+                 "mSourceURI=%s mStackCount=%d isNew=%d result=0x%08" PRIx32,
                  this, entry, mFullUri, mPredict, mPredictReason, mLearnReason,
                  targetURI.get(), sourceURI.get(), mStackCount,
-                 isNew, result));
+                 isNew, static_cast<uint32_t>(result)));
   if (NS_FAILED(result)) {
-    PREDICTOR_LOG(("OnCacheEntryAvailable %p FAILED to get cache entry (0x%08X). "
-                   "Aborting.", this, result));
+    PREDICTOR_LOG(("OnCacheEntryAvailable %p FAILED to get cache entry (0x%08" PRIX32
+                   "). Aborting.", this, static_cast<uint32_t>(result)));
     return NS_OK;
   }
   Telemetry::AccumulateTimeDelta(Telemetry::PREDICTOR_WAIT_TIME,
                                  mStartTime);
   if (mPredict) {
     bool predicted = mPredictor->PredictInternal(mPredictReason, entry, isNew,
                                                  mFullUri, mTargetURI,
                                                  mVerifier, mStackCount);
@@ -1342,27 +1342,28 @@ Predictor::Prefetch(nsIURI *uri, nsIURI 
                               nsContentUtils::GetSystemPrincipal(),
                               nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                               nsIContentPolicy::TYPE_OTHER,
                               nullptr, /* aLoadGroup */
                               nullptr, /* aCallbacks */
                               nsIRequest::LOAD_BACKGROUND);
 
   if (NS_FAILED(rv)) {
-    PREDICTOR_LOG(("    NS_NewChannel failed rv=0x%X", rv));
+    PREDICTOR_LOG(("    NS_NewChannel failed rv=0x%" PRIX32, static_cast<uint32_t>(rv)));
     return rv;
   }
 
   nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
   if (loadInfo) {
     rv = loadInfo->SetOriginAttributes(originAttributes);
   }
 
   if (NS_FAILED(rv)) {
-    PREDICTOR_LOG(("    Set originAttributes into loadInfo failed rv=0x%X", rv));
+    PREDICTOR_LOG(("    Set originAttributes into loadInfo failed rv=0x%" PRIX32,
+                   static_cast<uint32_t>(rv)));
     return rv;
   }
 
   nsCOMPtr<nsIHttpChannel> httpChannel;
   httpChannel = do_QueryInterface(channel);
   if (!httpChannel) {
     PREDICTOR_LOG(("    Could not get HTTP Channel from new channel!"));
     return NS_ERROR_UNEXPECTED;
@@ -1372,17 +1373,17 @@ Predictor::Prefetch(nsIURI *uri, nsIURI 
   // XXX - set a header here to indicate this is a prefetch?
 
   nsCOMPtr<nsIStreamListener> listener = new PrefetchListener(verifier, uri,
                                                               this);
   PREDICTOR_LOG(("    calling AsyncOpen2 listener=%p channel=%p", listener.get(),
                  channel.get()));
   rv = channel->AsyncOpen2(listener);
   if (NS_FAILED(rv)) {
-    PREDICTOR_LOG(("    AsyncOpen2 failed rv=0x%X", rv));
+    PREDICTOR_LOG(("    AsyncOpen2 failed rv=0x%" PRIX32, static_cast<uint32_t>(rv)));
   }
 
   return rv;
 }
 
 // Runs predictions that have been set up.
 bool
 Predictor::RunPredictions(nsIURI *referrer,
@@ -1871,17 +1872,17 @@ Predictor::LearnForSubresource(nsICacheE
   // Update the rolling load count to mark this sub-resource as seen on the
   // most-recent pageload so it can be eligible for prefetch (assuming all
   // the other stars align).
   flags |= (1 << kRollingLoadOffset);
 
   nsCString newValue;
   MakeMetadataEntry(hitCount, lastLoad, flags, newValue);
   rv = entry->SetMetaDataElement(key.BeginReading(), newValue.BeginReading());
-  PREDICTOR_LOG(("    SetMetaDataElement -> 0x%08X", rv));
+  PREDICTOR_LOG(("    SetMetaDataElement -> 0x%08" PRIX32, static_cast<uint32_t>(rv)));
   if (NS_FAILED(rv) && isNewResource) {
     // Roll back the increment to the resource count we made above.
     PREDICTOR_LOG(("    rolling back resource count update"));
     --resourceCount;
     if (resourceCount == 0) {
       entry->SetMetaDataElement(RESOURCE_META_DATA, nullptr);
     } else {
       nsAutoCString count;
@@ -1974,17 +1975,17 @@ Predictor::ParseMetaDataEntry(const char
   value = comma + 1;
   flags = static_cast<uint32_t>(atoi(value));
   PREDICTOR_LOG(("    flags -> %u", flags));
 
   if (key) {
     const char *uriStart = key + (sizeof(META_DATA_PREFIX) - 1);
     nsresult rv = NS_NewURI(uri, uriStart, nullptr, mIOService);
     if (NS_FAILED(rv)) {
-      PREDICTOR_LOG(("    NS_NewURI returned 0x%X", rv));
+      PREDICTOR_LOG(("    NS_NewURI returned 0x%" PRIX32, static_cast<uint32_t>(rv)));
       return false;
     }
     PREDICTOR_LOG(("    uri -> %s", uriStart));
   }
 
   return true;
 }
 
@@ -2455,17 +2456,18 @@ Predictor::PrefetchListener::OnStartRequ
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Predictor::PrefetchListener::OnStopRequest(nsIRequest *aRequest,
                                            nsISupports *aContext,
                                            nsresult aStatusCode)
 {
-  PREDICTOR_LOG(("OnStopRequest this=%p aStatusCode=0x%X", this, aStatusCode));
+  PREDICTOR_LOG(("OnStopRequest this=%p aStatusCode=0x%" PRIX32,
+                 this, static_cast<uint32_t>(aStatusCode)));
   NS_ENSURE_ARG(aRequest);
   if (NS_FAILED(aStatusCode)) {
     return aStatusCode;
   }
   Telemetry::AccumulateTimeDelta(Telemetry::PREDICTOR_PREFETCH_TIME, mStartTime);
 
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest);
   if (!httpChannel) {
@@ -2478,21 +2480,22 @@ Predictor::PrefetchListener::OnStopReque
     return NS_ERROR_UNEXPECTED;
   }
 
   nsresult rv = NS_OK;
   uint32_t httpStatus;
   rv = httpChannel->GetResponseStatus(&httpStatus);
   if (NS_SUCCEEDED(rv) && httpStatus == 200) {
     rv = cachingChannel->ForceCacheEntryValidFor(mPredictor->mPrefetchForceValidFor);
-    PREDICTOR_LOG(("    forcing entry valid for %d seconds rv=%X",
-                   mPredictor->mPrefetchForceValidFor, rv));
+    PREDICTOR_LOG(("    forcing entry valid for %d seconds rv=%" PRIX32,
+                   mPredictor->mPrefetchForceValidFor, static_cast<uint32_t>(rv)));
   } else {
     rv = cachingChannel->ForceCacheEntryValidFor(0);
-    PREDICTOR_LOG(("    removing any forced validity rv=%X", rv));
+    PREDICTOR_LOG(("    removing any forced validity rv=%" PRIX32,
+                   static_cast<uint32_t>(rv)));
   }
 
   nsAutoCString reqName;
   rv = aRequest->GetName(reqName);
   if (NS_FAILED(rv)) {
     reqName.AssignLiteral("<unknown>");
   }
 
@@ -2621,23 +2624,24 @@ Predictor::CacheabilityAction::OnCacheEn
 {
   MOZ_ASSERT(NS_IsMainThread());
   // This is being opened read-only, so isNew should always be false
   MOZ_ASSERT(!isNew);
 
   PREDICTOR_LOG(("CacheabilityAction::OnCacheEntryAvailable this=%p", this));
   if (NS_FAILED(result)) {
     // Nothing to do
-    PREDICTOR_LOG(("    nothing to do result=%X isNew=%d", result, isNew));
+    PREDICTOR_LOG(("    nothing to do result=%" PRIX32 " isNew=%d",
+                   static_cast<uint32_t>(result), isNew));
     return NS_OK;
   }
 
   nsresult rv = entry->VisitMetaData(this);
   if (NS_FAILED(rv)) {
-    PREDICTOR_LOG(("    VisitMetaData returned %x", rv));
+    PREDICTOR_LOG(("    VisitMetaData returned %" PRIx32, static_cast<uint32_t>(rv)));
     return NS_OK;
   }
 
   nsTArray<nsCString> keysToCheck, valuesToCheck;
   keysToCheck.SwapElements(mKeysToCheck);
   valuesToCheck.SwapElements(mValuesToCheck);
 
   MOZ_ASSERT(keysToCheck.Length() == valuesToCheck.Length());
--- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
+++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
@@ -31,18 +31,18 @@ public:
                                        nsresult result)
         : Runnable("nsAsyncVerifyRedirectCallbackEvent")
         , mCallback(cb)
         , mResult(result) {}
 
     NS_IMETHOD Run() override
     {
         LOG(("nsAsyncVerifyRedirectCallbackEvent::Run() "
-             "callback to %p with result %x",
-             mCallback.get(), mResult));
+             "callback to %p with result %" PRIx32,
+             mCallback.get(), static_cast<uint32_t>(mResult)));
        (void) mCallback->OnRedirectVerifyCallback(mResult);
        return NS_OK;
     }
 private:
     nsCOMPtr<nsIAsyncVerifyRedirectCallback> mCallback;
     nsresult mResult;
 };
 
@@ -99,18 +99,19 @@ nsAsyncRedirectVerifyHelper::Init(nsICha
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback(nsresult result)
 {
     LOG(("nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback() "
-         "result=%x expectedCBs=%u mResult=%x",
-         result, mExpectedCallbacks, mResult));
+         "result=%" PRIx32 " expectedCBs=%u mResult=%" PRIx32,
+         static_cast<uint32_t>(result), mExpectedCallbacks,
+         static_cast<uint32_t>(mResult)));
 
     MOZ_DIAGNOSTIC_ASSERT(mExpectedCallbacks > 0,
                           "OnRedirectVerifyCallback called more times than expected");
     if (mExpectedCallbacks <= 0) {
       return NS_ERROR_UNEXPECTED;
     }
 
     --mExpectedCallbacks;
@@ -140,50 +141,51 @@ nsAsyncRedirectVerifyHelper::OnRedirectV
 
 nsresult
 nsAsyncRedirectVerifyHelper::DelegateOnChannelRedirect(nsIChannelEventSink *sink,
                                                        nsIChannel *oldChannel,
                                                        nsIChannel *newChannel,
                                                        uint32_t flags)
 {
     LOG(("nsAsyncRedirectVerifyHelper::DelegateOnChannelRedirect() "
-         "sink=%p expectedCBs=%u mResult=%x",
-         sink, mExpectedCallbacks, mResult));
+         "sink=%p expectedCBs=%u mResult=%" PRIx32,
+         sink, mExpectedCallbacks, static_cast<uint32_t>(mResult)));
 
     ++mExpectedCallbacks;
 
     if (IsOldChannelCanceled()) {
         LOG(("  old channel has been canceled, cancel the redirect by "
              "emulating OnRedirectVerifyCallback..."));
         (void) OnRedirectVerifyCallback(NS_BINDING_ABORTED);
         return NS_BINDING_ABORTED;
     }
 
     nsresult rv =
         sink->AsyncOnChannelRedirect(oldChannel, newChannel, flags, this);
 
-    LOG(("  result=%x expectedCBs=%u", rv, mExpectedCallbacks));
+    LOG(("  result=%" PRIx32 " expectedCBs=%u", static_cast<uint32_t>(rv), mExpectedCallbacks));
 
     // If the sink returns failure from this call the redirect is vetoed. We
     // emulate a callback from the sink in this case in order to perform all
     // the necessary logic.
     if (NS_FAILED(rv)) {
         LOG(("  emulating OnRedirectVerifyCallback..."));
         (void) OnRedirectVerifyCallback(rv);
     }
 
     return rv;  // Return the actual status since our caller may need it
 }
 
 void
 nsAsyncRedirectVerifyHelper::ExplicitCallback(nsresult result)
 {
     LOG(("nsAsyncRedirectVerifyHelper::ExplicitCallback() "
-         "result=%x expectedCBs=%u mCallbackInitiated=%u mResult=%x",
-         result, mExpectedCallbacks, mCallbackInitiated, mResult));
+         "result=%" PRIx32 " expectedCBs=%u mCallbackInitiated=%u mResult=%"  PRIx32,
+         static_cast<uint32_t>(result), mExpectedCallbacks, mCallbackInitiated,
+         static_cast<uint32_t>(mResult)));
 
     nsCOMPtr<nsIAsyncVerifyRedirectCallback>
         callback(do_QueryInterface(mOldChan));
 
     if (!callback || !mCallbackThread) {
         LOG(("nsAsyncRedirectVerifyHelper::ExplicitCallback() "
              "callback=%p mCallbackThread=%p", callback.get(), mCallbackThread.get()));
         return;
@@ -210,17 +212,18 @@ nsAsyncRedirectVerifyHelper::ExplicitCal
     }
    
 }
 
 void
 nsAsyncRedirectVerifyHelper::InitCallback()
 {
     LOG(("nsAsyncRedirectVerifyHelper::InitCallback() "
-         "expectedCBs=%d mResult=%x", mExpectedCallbacks, mResult));
+         "expectedCBs=%d mResult=%" PRIx32, mExpectedCallbacks,
+         static_cast<uint32_t>(mResult)));
 
     mCallbackInitiated = true;
 
     // Invoke the callback if we are done
     if (mExpectedCallbacks == 0)
         ExplicitCallback(mResult);
 }
 
--- a/netwerk/base/nsAsyncStreamCopier.cpp
+++ b/netwerk/base/nsAsyncStreamCopier.cpp
@@ -66,22 +66,22 @@ private:
 nsAsyncStreamCopier::nsAsyncStreamCopier()
     : mLock("nsAsyncStreamCopier.mLock")
     , mMode(NS_ASYNCCOPY_VIA_READSEGMENTS)
     , mChunkSize(nsIOService::gDefaultSegmentSize)
     , mStatus(NS_OK)
     , mIsPending(false)
     , mShouldSniffBuffering(false)
 {
-    LOG(("Creating nsAsyncStreamCopier @%x\n", this));
+    LOG(("Creating nsAsyncStreamCopier @%p\n", this));
 }
 
 nsAsyncStreamCopier::~nsAsyncStreamCopier()
 {
-    LOG(("Destroying nsAsyncStreamCopier @%x\n", this));
+    LOG(("Destroying nsAsyncStreamCopier @%p\n", this));
 }
 
 bool
 nsAsyncStreamCopier::IsComplete(nsresult *status)
 {
     MutexAutoLock lock(mLock);
     if (status)
         *status = mStatus;
@@ -92,17 +92,18 @@ nsIRequest*
 nsAsyncStreamCopier::AsRequest()
 {
     return static_cast<nsIRequest*>(static_cast<nsIAsyncStreamCopier*>(this));
 }
 
 void
 nsAsyncStreamCopier::Complete(nsresult status)
 {
-    LOG(("nsAsyncStreamCopier::Complete [this=%p status=%x]\n", this, status));
+    LOG(("nsAsyncStreamCopier::Complete [this=%p status=%" PRIx32 "]\n", this,
+         static_cast<uint32_t>(status)));
 
     nsCOMPtr<nsIRequestObserver> observer;
     nsCOMPtr<nsISupports> ctx;
     {
         MutexAutoLock lock(mLock);
         mCopierCtx = nullptr;
 
         if (mIsPending) {
@@ -111,17 +112,18 @@ nsAsyncStreamCopier::Complete(nsresult s
 
             // setup OnStopRequest callback and release references...
             observer = mObserver;
             mObserver = nullptr;
         }
     }
 
     if (observer) {
-        LOG(("  calling OnStopRequest [status=%x]\n", status));
+        LOG(("  calling OnStopRequest [status=%" PRIx32 "]\n",
+             static_cast<uint32_t>(status)));
         observer->OnStopRequest(AsRequest(), ctx, status);
     }
 }
 
 void
 nsAsyncStreamCopier::OnAsyncCopyComplete(void *closure, nsresult status)
 {
     nsAsyncStreamCopier *self = (nsAsyncStreamCopier *) closure;
@@ -341,17 +343,17 @@ nsAsyncStreamCopier::ApplyBufferingPolic
 }
 
 //-----------------------------------------------------------------------------
 // Both nsIAsyncStreamCopier and nsIAsyncStreamCopier2
 
 NS_IMETHODIMP
 nsAsyncStreamCopier::AsyncCopy(nsIRequestObserver *observer, nsISupports *ctx)
 {
-    LOG(("nsAsyncStreamCopier::AsyncCopy [this=%p observer=%x]\n", this, observer));
+    LOG(("nsAsyncStreamCopier::AsyncCopy [this=%p observer=%p]\n", this, observer));
 
     NS_ASSERTION(mSource && mSink, "not initialized");
     nsresult rv;
 
     if (observer) {
         // build proxy for observer events
         rv = NS_NewRequestObserverProxy(getter_AddRefs(mObserver), observer, ctx);
         if (NS_FAILED(rv)) return rv;
--- a/netwerk/base/nsInputStreamPump.cpp
+++ b/netwerk/base/nsInputStreamPump.cpp
@@ -191,18 +191,18 @@ nsInputStreamPump::GetStatus(nsresult *s
 
 NS_IMETHODIMP
 nsInputStreamPump::Cancel(nsresult status)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
     ReentrantMonitorAutoEnter mon(mMonitor);
 
-    LOG(("nsInputStreamPump::Cancel [this=%p status=%x]\n",
-        this, status));
+    LOG(("nsInputStreamPump::Cancel [this=%p status=%" PRIx32 "]\n",
+        this, static_cast<uint32_t>(status)));
 
     if (NS_FAILED(mStatus)) {
         LOG(("  already canceled\n"));
         return NS_OK;
     }
 
     NS_ASSERTION(NS_FAILED(status), "cancel with non-failure status code");
     mStatus = status;
@@ -546,17 +546,18 @@ nsInputStreamPump::OnStateTransfer()
     // if canceled, go directly to STATE_STOP...
     if (NS_FAILED(mStatus))
         return STATE_STOP;
 
     nsresult rv;
 
     uint64_t avail;
     rv = mAsyncStream->Available(&avail);
-    LOG(("  Available returned [stream=%x rv=%x avail=%llu]\n", mAsyncStream.get(), rv, avail));
+    LOG(("  Available returned [stream=%p rv=%" PRIx32 " avail=%" PRIu64 "]\n", mAsyncStream.get(),
+         static_cast<uint32_t>(rv), avail));
 
     if (rv == NS_BASE_STREAM_CLOSED) {
         rv = NS_OK;
         avail = 0;
     }
     else if (NS_SUCCEEDED(rv) && avail) {
         // figure out how much data to report (XXX detect overflow??)
         if (avail > mStreamLength - mStreamOffset)
@@ -584,17 +585,17 @@ nsInputStreamPump::OnStateTransfer()
                 NS_NOTREACHED("Tell failed on readable stream");
                 offsetBefore = 0;
             }
 
             uint32_t odaAvail =
                 avail > UINT32_MAX ?
                 UINT32_MAX : uint32_t(avail);
 
-            LOG(("  calling OnDataAvailable [offset=%llu count=%llu(%u)]\n",
+            LOG(("  calling OnDataAvailable [offset=%" PRIu64 " count=%" PRIu64 "(%u)]\n",
                 mStreamOffset, avail, odaAvail));
 
             {
                 // Note: Must exit monitor for call to OnStartRequest to avoid
                 // deadlocks when calls to RetargetDeliveryTo for multiple
                 // nsInputStreamPumps are needed (e.g. nsHttpChannel).
                 mMonitor.Exit();
                 rv = mListener->OnDataAvailable(this, mListenerContext,
@@ -681,17 +682,17 @@ nsInputStreamPump::OnStateStop()
             NewRunnableMethod(this, &nsInputStreamPump::CallOnStateStop));
         NS_ENSURE_SUCCESS(rv, STATE_IDLE);
         return STATE_IDLE;
     }
 
     PROFILER_LABEL("nsInputStreamPump", "OnStateStop",
         js::ProfileEntry::Category::NETWORK);
 
-    LOG(("  OnStateStop [this=%p status=%x]\n", this, mStatus));
+    LOG(("  OnStateStop [this=%p status=%" PRIx32 "]\n", this, static_cast<uint32_t>(mStatus)));
 
     // if an error occurred, we must be sure to pass the error onto the async
     // stream.  in some cases, this is redundant, but since close is idempotent,
     // this is OK.  otherwise, be sure to honor the "close-when-done" option.
 
     if (!mAsyncStream || !mListener) {
         MOZ_ASSERT(mAsyncStream, "null mAsyncStream: OnStateStop called twice?");
         MOZ_ASSERT(mListener, "null mListener: OnStateStop called twice?");
@@ -753,14 +754,14 @@ nsInputStreamPump::RetargetDeliveryTo(ns
         do_QueryInterface(mListener, &rv);
     if (NS_SUCCEEDED(rv) && retargetableListener) {
         rv = retargetableListener->CheckListenerChain();
         if (NS_SUCCEEDED(rv)) {
             mTargetThread = aNewTarget;
             mRetargeting = true;
         }
     }
-    LOG(("nsInputStreamPump::RetargetDeliveryTo [this=%x aNewTarget=%p] "
-         "%s listener [%p] rv[%x]",
+    LOG(("nsInputStreamPump::RetargetDeliveryTo [this=%p aNewTarget=%p] "
+         "%s listener [%p] rv[%" PRIx32 "]",
          this, aNewTarget, (mTargetThread == aNewTarget ? "success" : "failure"),
-         (nsIStreamListener*)mListener, rv));
+         (nsIStreamListener*)mListener, static_cast<uint32_t>(rv)));
     return rv;
 }
--- a/netwerk/base/nsLoadGroup.cpp
+++ b/netwerk/base/nsLoadGroup.cpp
@@ -110,17 +110,17 @@ nsLoadGroup::nsLoadGroup(nsISupports* ou
     , mPriority(PRIORITY_NORMAL)
     , mIsCanceling(false)
     , mDefaultLoadIsTimed(false)
     , mTimedRequests(0)
     , mCachedRequests(0)
     , mTimedNonCachedRequestsUntilOnEndPageLoad(0)
 {
     NS_INIT_AGGREGATED(outer);
-    LOG(("LOADGROUP [%x]: Created.\n", this));
+    LOG(("LOADGROUP [%p]: Created.\n", this));
 }
 
 nsLoadGroup::~nsLoadGroup()
 {
     DebugOnly<nsresult> rv = Cancel(NS_BINDING_ABORTED);
     NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed");
 
     mDefaultLoadRequest = nullptr;
@@ -137,17 +137,17 @@ nsLoadGroup::~nsLoadGroup()
             rcid_nscs.AssignASCII(rcid_str);
 
             gNeckoChild->SendRemoveRequestContext(rcid_nscs);
         } else {
             mRequestContextService->RemoveRequestContext(rcid);
         }
     }
 
-    LOG(("LOADGROUP [%x]: Destroyed.\n", this));
+    LOG(("LOADGROUP [%p]: Destroyed.\n", this));
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupports methods:
 
 NS_IMPL_AGGREGATED(nsLoadGroup)
 NS_INTERFACE_MAP_BEGIN_AGGREGATED(nsLoadGroup)
@@ -252,17 +252,17 @@ nsLoadGroup::Cancel(nsresult status)
             // |request| was removed already
             NS_RELEASE(request);
             continue;
         }
 
         if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
             nsAutoCString nameStr;
             request->GetName(nameStr);
-            LOG(("LOADGROUP [%x]: Canceling request %x %s.\n",
+            LOG(("LOADGROUP [%p]: Canceling request %p %s.\n",
                  this, request, nameStr.get()));
         }
 
         //
         // Remove the request from the load group...  This may cause
         // the OnStopRequest notification to fire...
         //
         // XXX: What should the context be?
@@ -313,17 +313,17 @@ nsLoadGroup::Suspend()
 
         NS_ASSERTION(request, "NULL request found in list.");
         if (!request)
             continue;
 
         if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
             nsAutoCString nameStr;
             request->GetName(nameStr);
-            LOG(("LOADGROUP [%x]: Suspending request %x %s.\n",
+            LOG(("LOADGROUP [%p]: Suspending request %p %s.\n",
                 this, request, nameStr.get()));
         }
 
         // Suspend the request...
         rv = request->Suspend();
 
         // Remember the first failure and return it...
         if (NS_FAILED(rv) && NS_SUCCEEDED(firstError))
@@ -358,17 +358,17 @@ nsLoadGroup::Resume()
 
         NS_ASSERTION(request, "NULL request found in list.");
         if (!request)
             continue;
 
         if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
             nsAutoCString nameStr;
             request->GetName(nameStr);
-            LOG(("LOADGROUP [%x]: Resuming request %x %s.\n",
+            LOG(("LOADGROUP [%p]: Resuming request %p %s.\n",
                 this, request, nameStr.get()));
         }
 
         // Resume the request...
         rv = request->Resume();
 
         // Remember the first failure and return it...
         if (NS_FAILED(rv) && NS_SUCCEEDED(firstError))
@@ -447,28 +447,28 @@ nsLoadGroup::SetDefaultLoadRequest(nsIRe
 NS_IMETHODIMP
 nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt)
 {
     nsresult rv;
 
     if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
         nsAutoCString nameStr;
         request->GetName(nameStr);
-        LOG(("LOADGROUP [%x]: Adding request %x %s (count=%d).\n",
+        LOG(("LOADGROUP [%p]: Adding request %p %s (count=%d).\n",
              this, request, nameStr.get(), mRequests.EntryCount()));
     }
 
     NS_ASSERTION(!mRequests.Search(request),
                  "Entry added to loadgroup twice, don't do that");
 
     //
     // Do not add the channel, if the loadgroup is being canceled...
     //
     if (mIsCanceling) {
-        LOG(("LOADGROUP [%x]: AddChannel() ABORTED because LoadGroup is"
+        LOG(("LOADGROUP [%p]: AddChannel() ABORTED because LoadGroup is"
              " being canceled!!\n", this));
 
         return NS_BINDING_ABORTED;
     }
 
     nsLoadFlags flags;
     // if the request is the default load request or if the default load
     // request is null, then the load group should inherit its load flags from
@@ -504,22 +504,22 @@ nsLoadGroup::AddRequest(nsIRequest *requ
         //
         // Fire the OnStartRequest notification out to the observer...
         //
         // If the notification fails then DO NOT add the request to
         // the load group.
         //
         nsCOMPtr<nsIRequestObserver> observer = do_QueryReferent(mObserver);
         if (observer) {
-            LOG(("LOADGROUP [%x]: Firing OnStartRequest for request %x."
+            LOG(("LOADGROUP [%p]: Firing OnStartRequest for request %p."
                  "(foreground count=%d).\n", this, request, mForegroundCount));
 
             rv = observer->OnStartRequest(request, ctxt);
             if (NS_FAILED(rv)) {
-                LOG(("LOADGROUP [%x]: OnStartRequest for request %x FAILED.\n",
+                LOG(("LOADGROUP [%p]: OnStartRequest for request %p FAILED.\n",
                     this, request));
                 //
                 // The URI load has been canceled by the observer.  Clean up
                 // the damage...
                 //
 
                 mRequests.Remove(request);
 
@@ -544,34 +544,35 @@ nsLoadGroup::RemoveRequest(nsIRequest *r
                            nsresult aStatus)
 {
     NS_ENSURE_ARG_POINTER(request);
     nsresult rv;
 
     if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
         nsAutoCString nameStr;
         request->GetName(nameStr);
-        LOG(("LOADGROUP [%x]: Removing request %x %s status %x (count=%d).\n",
-            this, request, nameStr.get(), aStatus, mRequests.EntryCount() - 1));
+        LOG(("LOADGROUP [%p]: Removing request %p %s status %" PRIx32 " (count=%d).\n",
+             this, request, nameStr.get(), static_cast<uint32_t>(aStatus),
+             mRequests.EntryCount() - 1));
     }
 
     // Make sure we have a owning reference to the request we're about
     // to remove.
 
     nsCOMPtr<nsIRequest> kungFuDeathGrip(request);
 
     //
     // Remove the request from the group.  If this fails, it means that
     // the request was *not* in the group so do not update the foreground
     // count or it will get messed up...
     //
     auto entry = static_cast<RequestMapEntry*>(mRequests.Search(request));
 
     if (!entry) {
-        LOG(("LOADGROUP [%x]: Unable to remove request %x. Not in group!\n",
+        LOG(("LOADGROUP [%p]: Unable to remove request %p. Not in group!\n",
             this, request));
 
         return NS_ERROR_FAILURE;
     }
 
     mRequests.RemoveEntry(entry);
 
     // Collect telemetry stats only when default request is a timed channel.
@@ -622,23 +623,23 @@ nsLoadGroup::RemoveRequest(nsIRequest *r
 
     if (!(flags & nsIRequest::LOAD_BACKGROUND)) {
         NS_ASSERTION(mForegroundCount > 0, "ForegroundCount messed up");
         mForegroundCount -= 1;
 
         // Fire the OnStopRequest out to the observer...
         nsCOMPtr<nsIRequestObserver> observer = do_QueryReferent(mObserver);
         if (observer) {
-            LOG(("LOADGROUP [%x]: Firing OnStopRequest for request %x."
+            LOG(("LOADGROUP [%p]: Firing OnStopRequest for request %p."
                  "(foreground count=%d).\n", this, request, mForegroundCount));
 
             rv = observer->OnStopRequest(request, ctxt, aStatus);
 
             if (NS_FAILED(rv)) {
-                LOG(("LOADGROUP [%x]: OnStopRequest for request %x FAILED.\n",
+                LOG(("LOADGROUP [%p]: OnStopRequest for request %p FAILED.\n",
                     this, request));
             }
         }
 
         // If that was the last request -> remove ourselves from loadgroup
         if (mForegroundCount == 0 && mLoadGroup) {
             mLoadGroup->RemoveRequest(this, nullptr, aStatus);
         }
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -268,17 +268,18 @@ private:
 
             if (NS_FAILED(rv))
                 mCallback->OnProxyAvailable(this, mChannel, nullptr, rv);
 
             // do not call onproxyavailable() in SUCCESS case - the newRequest will
             // take care of that
         }
         else {
-            LOG(("pac thread callback did not provide information %X\n", mStatus));
+            LOG(("pac thread callback did not provide information %" PRIX32 "\n",
+                 static_cast<uint32_t>(mStatus)));
             if (NS_SUCCEEDED(mStatus))
                 mPPS->MaybeDisableDNSPrefetch(mProxyInfo);
             mCallback->OnProxyAvailable(this, mChannel, mProxyInfo, mStatus);
         }
 
         // We are on the main thread now and don't need these any more so
         // release them to avoid having to proxy them back to the main thread
         // in the dtor
@@ -569,17 +570,17 @@ nsProtocolProxyService::PrefsChanged(nsI
                 type = PROXYCONFIG_DIRECT;
                 // Reset the type so that the dialog looks correct, and we
                 // don't have to handle this case everywhere else
                 // I'm paranoid about a loop of some sort - only do this
                 // if we're enumerating all prefs, and ignore any error
                 if (!pref)
                     prefBranch->SetIntPref(PROXY_PREF("type"), type);
             } else if (type >= PROXYCONFIG_COUNT) {
-                LOG(("unknown proxy type: %lu; assuming direct\n", type));
+                LOG(("unknown proxy type: %" PRId32 "; assuming direct\n", type));
                 type = PROXYCONFIG_DIRECT;
             }
             mProxyConfig = type;
             reloadPAC = true;
         }
 
         if (mProxyConfig == PROXYCONFIG_SYSTEM) {
             mSystemProxySettings = do_GetService(NS_SYSTEMPROXYSETTINGS_CONTRACTID);
--- a/netwerk/base/nsRequestObserverProxy.cpp
+++ b/netwerk/base/nsRequestObserverProxy.cpp
@@ -5,16 +5,17 @@
 
 #include "mozilla/DebugOnly.h"
 
 #include "nscore.h"
 #include "nsRequestObserverProxy.h"
 #include "nsIRequest.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Logging.h"
+#include "mozilla/IntegerPrintfMacros.h"
 
 namespace mozilla {
 namespace net {
 
 static LazyLogModule gRequestObserverProxyLog("nsRequestObserverProxy");
 
 #undef LOG
 #define LOG(args) MOZ_LOG(gRequestObserverProxyLog, LogLevel::Debug, args)
@@ -44,27 +45,28 @@ public:
     {
         NS_PRECONDITION(mProxy, "null pointer");
     }
 
     virtual ~nsOnStartRequestEvent() {}
 
     NS_IMETHOD Run() override
     {
-        LOG(("nsOnStartRequestEvent::HandleEvent [req=%x]\n", mRequest.get()));
+        LOG(("nsOnStartRequestEvent::HandleEvent [req=%p]\n", mRequest.get()));
 
         if (!mProxy->mObserver) {
             NS_NOTREACHED("already handled onStopRequest event (observer is null)");
             return NS_OK;
         }
 
         LOG(("handle startevent=%p\n", this));
         nsresult rv = mProxy->mObserver->OnStartRequest(mRequest, mProxy->mContext);
         if (NS_FAILED(rv)) {
-            LOG(("OnStartRequest failed [rv=%x] canceling request!\n", rv));
+            LOG(("OnStartRequest failed [rv=%" PRIx32 "] canceling request!\n",
+                 static_cast<uint32_t>(rv)));
             rv = mRequest->Cancel(rv);
             NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed for request!");
         }
 
         return NS_OK;
     }
 };
 
@@ -83,17 +85,17 @@ public:
     {
         NS_PRECONDITION(mProxy, "null pointer");
     }
 
     virtual ~nsOnStopRequestEvent() {}
 
     NS_IMETHOD Run() override
     {
-        LOG(("nsOnStopRequestEvent::HandleEvent [req=%x]\n", mRequest.get()));
+        LOG(("nsOnStopRequestEvent::HandleEvent [req=%p]\n", mRequest.get()));
 
         nsMainThreadPtrHandle<nsIRequestObserver> observer = mProxy->mObserver;
         if (!observer) {
             NS_NOTREACHED("already handled onStopRequest event (observer is null)");
             return NS_OK;
         }
         // Do not allow any more events to be handled after OnStopRequest
         mProxy->mObserver = 0;
@@ -121,17 +123,17 @@ NS_IMPL_ISUPPORTS(nsRequestObserverProxy
 // nsRequestObserverProxy::nsIRequestObserver implementation...
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP 
 nsRequestObserverProxy::OnStartRequest(nsIRequest *request,
                                        nsISupports *context)
 {
     MOZ_ASSERT(!context || context == mContext);
-    LOG(("nsRequestObserverProxy::OnStartRequest [this=%p req=%x]\n", this, request));
+    LOG(("nsRequestObserverProxy::OnStartRequest [this=%p req=%p]\n", this, request));
 
     nsOnStartRequestEvent *ev = 
         new nsOnStartRequestEvent(this, request);
     if (!ev)
         return NS_ERROR_OUT_OF_MEMORY;
 
     LOG(("post startevent=%p\n", ev));
     nsresult rv = FireEvent(ev);
@@ -141,18 +143,18 @@ nsRequestObserverProxy::OnStartRequest(n
 }
 
 NS_IMETHODIMP 
 nsRequestObserverProxy::OnStopRequest(nsIRequest *request,
                                       nsISupports *context,
                                       nsresult status)
 {
     MOZ_ASSERT(!context || context == mContext);
-    LOG(("nsRequestObserverProxy: OnStopRequest [this=%p req=%x status=%x]\n",
-        this, request, status));
+    LOG(("nsRequestObserverProxy: OnStopRequest [this=%p req=%p status=%" PRIx32 "]\n",
+         this, request, static_cast<uint32_t>(status)));
 
     // The status argument is ignored because, by the time the OnStopRequestEvent
     // is actually processed, the status of the request may have changed :-( 
     // To make sure that an accurate status code is always used, GetStatus() is
     // called when the OnStopRequestEvent is actually processed (see above).
 
     nsOnStopRequestEvent *ev = 
         new nsOnStopRequestEvent(this, request);
--- a/netwerk/base/nsSocketTransport2.cpp
+++ b/netwerk/base/nsSocketTransport2.cpp
@@ -233,17 +233,18 @@ ErrorAccordingToNSPR(PRErrorCode errorCo
     //   'connect' to a socket that is already connected. The socket
     //   components manage each file descriptor's state, and in some cases
     //   handle this error result internally. We shouldn't be returning
     //   this to our callers.
     //
     // PR_IO_ERROR
     //   This is so vague that NS_ERROR_FAILURE is just as good.
     }
-    SOCKET_LOG(("ErrorAccordingToNSPR [in=%d out=%x]\n", errorCode, rv));
+    SOCKET_LOG(("ErrorAccordingToNSPR [in=%d out=%" PRIx32 "]\n", errorCode,
+                static_cast<uint32_t>(rv)));
     return rv;
 }
 
 //-----------------------------------------------------------------------------
 // socket input stream impl 
 //-----------------------------------------------------------------------------
 
 nsSocketInputStream::nsSocketInputStream(nsSocketTransport *trans)
@@ -261,18 +262,18 @@ nsSocketInputStream::~nsSocketInputStrea
 
 // called on the socket transport thread...
 //
 //   condition : failure code if socket has been closed
 //
 void
 nsSocketInputStream::OnSocketReady(nsresult condition)
 {
-    SOCKET_LOG(("nsSocketInputStream::OnSocketReady [this=%p cond=%x]\n",
-        this, condition));
+    SOCKET_LOG(("nsSocketInputStream::OnSocketReady [this=%p cond=%" PRIx32 "]\n",
+                this, static_cast<uint32_t>(condition)));
 
     NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
     nsCOMPtr<nsIInputStreamCallback> callback;
     {
         MutexAutoLock lock(mTransport->mLock);
 
         // update condition, but be careful not to erase an already
@@ -444,17 +445,18 @@ nsSocketInputStream::IsNonBlocking(bool 
 {
     *nonblocking = true;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSocketInputStream::CloseWithStatus(nsresult reason)
 {
-    SOCKET_LOG(("nsSocketInputStream::CloseWithStatus [this=%p reason=%x]\n", this, reason));
+    SOCKET_LOG(("nsSocketInputStream::CloseWithStatus [this=%p reason=%" PRIx32 "]\n", this,
+               static_cast<uint32_t>(reason)));
 
     // may be called from any thread
  
     nsresult rv;
     {
         MutexAutoLock lock(mTransport->mLock);
 
         if (NS_SUCCEEDED(mCondition))
@@ -524,18 +526,18 @@ nsSocketOutputStream::~nsSocketOutputStr
 
 // called on the socket transport thread...
 //
 //   condition : failure code if socket has been closed
 //
 void
 nsSocketOutputStream::OnSocketReady(nsresult condition)
 {
-    SOCKET_LOG(("nsSocketOutputStream::OnSocketReady [this=%p cond=%x]\n",
-        this, condition));
+    SOCKET_LOG(("nsSocketOutputStream::OnSocketReady [this=%p cond=%" PRIx32 "]\n",
+                this, static_cast<uint32_t>(condition)));
 
     NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
     nsCOMPtr<nsIOutputStreamCallback> callback;
     {
         MutexAutoLock lock(mTransport->mLock);
 
         // update condition, but be careful not to erase an already
@@ -679,17 +681,18 @@ nsSocketOutputStream::IsNonBlocking(bool
 {
     *nonblocking = true;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSocketOutputStream::CloseWithStatus(nsresult reason)
 {
-    SOCKET_LOG(("nsSocketOutputStream::CloseWithStatus [this=%p reason=%x]\n", this, reason));
+    SOCKET_LOG(("nsSocketOutputStream::CloseWithStatus [this=%p reason=%" PRIx32 "]\n", this,
+                static_cast<uint32_t>(reason)));
 
     // may be called from any thread
  
     nsresult rv;
     {
         MutexAutoLock lock(mTransport->mLock);
 
         if (NS_SUCCEEDED(mCondition))
@@ -986,30 +989,31 @@ nsSocketTransport::InitWithConnectedSock
 {
     mSecInfo = aSecInfo;
     return InitWithConnectedSocket(aFD, aAddr);
 }
 
 nsresult
 nsSocketTransport::PostEvent(uint32_t type, nsresult status, nsISupports *param)
 {
-    SOCKET_LOG(("nsSocketTransport::PostEvent [this=%p type=%u status=%x param=%p]\n",
-        this, type, status, param));
+    SOCKET_LOG(("nsSocketTransport::PostEvent [this=%p type=%u status=%" PRIx32 " param=%p]\n",
+                this, type, static_cast<uint32_t>(status), param));
 
     nsCOMPtr<nsIRunnable> event = new nsSocketEvent(this, type, status, param);
     if (!event)
         return NS_ERROR_OUT_OF_MEMORY;
 
     return mSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL);
 }
 
 void
 nsSocketTransport::SendStatus(nsresult status)
 {
-    SOCKET_LOG(("nsSocketTransport::SendStatus [this=%p status=%x]\n", this, status));
+    SOCKET_LOG(("nsSocketTransport::SendStatus [this=%p status=%" PRIx32 "]\n", this,
+                static_cast<uint32_t>(status)));
 
     nsCOMPtr<nsITransportEventSink> sink;
     uint64_t progress;
     {
         MutexAutoLock lock(mLock);
         sink = mEventSink;
         switch (status) {
         case NS_NET_STATUS_SENDING_TO:
@@ -1203,17 +1207,17 @@ nsSocketTransport::BuildSocket(PRFileDes
             bool isSSL = (strcmp(mTypes[i], "ssl") == 0);
             if (isSSL || (strcmp(mTypes[i], "starttls") == 0)) {
                 // remember security info and give notification callbacks to PSM...
                 nsCOMPtr<nsIInterfaceRequestor> callbacks;
                 {
                     MutexAutoLock lock(mLock);
                     mSecInfo = secinfo;
                     callbacks = mCallbacks;
-                    SOCKET_LOG(("  [secinfo=%x callbacks=%x]\n", mSecInfo.get(), mCallbacks.get()));
+                    SOCKET_LOG(("  [secinfo=%p callbacks=%p]\n", mSecInfo.get(), mCallbacks.get()));
                 }
                 // don't call into PSM while holding mLock!!
                 nsCOMPtr<nsISSLSocketControl> secCtrl(do_QueryInterface(secinfo));
                 if (secCtrl)
                     secCtrl->SetNotificationCallbacks(callbacks);
                 // remember if socket type is SSL so we can ProxyStartSSL if need be.
                 usingSSL = isSSL;
             }
@@ -1222,17 +1226,18 @@ nsSocketTransport::BuildSocket(PRFileDes
                 // since socks is transparent, any layers above
                 // it do not have to worry about proxy stuff
                 proxyInfo = nullptr;
                 proxyTransparent = true;
             }
         }
 
         if (NS_FAILED(rv)) {
-            SOCKET_LOG(("  error pushing io layer [%u:%s rv=%x]\n", i, mTypes[i], rv));
+            SOCKET_LOG(("  error pushing io layer [%u:%s rv=%" PRIx32 "]\n", i, mTypes[i],
+                        static_cast<uint32_t>(rv)));
             if (fd) {
                 CloseSocket(fd,
                     mSocketTransportService->IsTelemetryEnabledAndNotSleepPhase());
             }
         }
     }
 
     return rv;
@@ -1336,17 +1341,17 @@ nsSocketTransport::InitiateSocket()
     // create new socket fd, push io layers, etc.
     //
     PRFileDesc *fd;
     bool proxyTransparent;
     bool usingSSL;
 
     rv = BuildSocket(fd, proxyTransparent, usingSSL);
     if (NS_FAILED(rv)) {
-        SOCKET_LOG(("  BuildSocket failed [rv=%x]\n", rv));
+        SOCKET_LOG(("  BuildSocket failed [rv=%" PRIx32 "]\n", static_cast<uint32_t>(rv)));
         return rv;
     }
 
     // Attach network activity monitor
     NetworkActivityMonitor::AttachIOLayer(fd);
 
     PRStatus status;
 
@@ -1578,18 +1583,18 @@ nsSocketTransport::InitiateSocket()
     return rv;
 }
 
 bool
 nsSocketTransport::RecoverFromError()
 {
     NS_ASSERTION(NS_FAILED(mCondition), "there should be something wrong");
 
-    SOCKET_LOG(("nsSocketTransport::RecoverFromError [this=%p state=%x cond=%x]\n",
-        this, mState, mCondition));
+    SOCKET_LOG(("nsSocketTransport::RecoverFromError [this=%p state=%x cond=%" PRIx32 "]\n",
+                this, mState, static_cast<uint32_t>(mCondition)));
 
 #if defined(XP_UNIX)
     // Unix domain connections don't have multiple addresses to try,
     // so the recovery techniques here don't apply.
     if (mNetAddrIsSet && mNetAddr.raw.family == AF_LOCAL)
         return false;
 #endif
 
@@ -1678,18 +1683,18 @@ nsSocketTransport::RecoverFromError()
 
     return tryAgain;
 }
 
 // called on the socket thread only
 void
 nsSocketTransport::OnMsgInputClosed(nsresult reason)
 {
-    SOCKET_LOG(("nsSocketTransport::OnMsgInputClosed [this=%p reason=%x]\n",
-        this, reason));
+    SOCKET_LOG(("nsSocketTransport::OnMsgInputClosed [this=%p reason=%" PRIx32 "]\n",
+        this, static_cast<uint32_t>(reason)));
 
     NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
     mInputClosed = true;
     // check if event should affect entire transport
     if (NS_FAILED(reason) && (reason != NS_BASE_STREAM_CLOSED))
         mCondition = reason;                // XXX except if NS_FAILED(mCondition), right??
     else if (mOutputClosed)
@@ -1700,18 +1705,18 @@ nsSocketTransport::OnMsgInputClosed(nsre
         mInput.OnSocketReady(reason);
     }
 }
 
 // called on the socket thread only
 void
 nsSocketTransport::OnMsgOutputClosed(nsresult reason)
 {
-    SOCKET_LOG(("nsSocketTransport::OnMsgOutputClosed [this=%p reason=%x]\n",
-        this, reason));
+    SOCKET_LOG(("nsSocketTransport::OnMsgOutputClosed [this=%p reason=%" PRIx32 "]\n",
+        this, static_cast<uint32_t>(reason)));
 
     NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
     mOutputClosed = true;
     // check if event should affect entire transport
     if (NS_FAILED(reason) && (reason != NS_BASE_STREAM_CLOSED))
         mCondition = reason;                // XXX except if NS_FAILED(mCondition), right??
     else if (mInputClosed)
@@ -1746,17 +1751,18 @@ nsSocketTransport::OnSocketConnected()
         SetSocketName(mFD);
         mFDconnected = true;
     }
 
     // Ensure keepalive is configured correctly if previously enabled.
     if (mKeepaliveEnabled) {
         nsresult rv = SetKeepaliveEnabledInternal(true);
         if (NS_WARN_IF(NS_FAILED(rv))) {
-            SOCKET_LOG(("  SetKeepaliveEnabledInternal failed rv[0x%x]", rv));
+            SOCKET_LOG(("  SetKeepaliveEnabledInternal failed rv[0x%" PRIx32 "]",
+                        static_cast<uint32_t>(rv)));
         }
     }
 
     SendStatus(NS_NET_STATUS_CONNECTED_TO);
 }
 
 void
 nsSocketTransport::SetSocketName(PRFileDesc *fd)
@@ -1819,17 +1825,17 @@ STS_PRCloseOnSocketTransport(PRFileDesc 
 }
 
 void
 nsSocketTransport::ReleaseFD_Locked(PRFileDesc *fd)
 {
     mLock.AssertCurrentThreadOwns();
 
     NS_ASSERTION(mFD == fd, "wrong fd");
-    SOCKET_LOG(("JIMB: ReleaseFD_Locked: mFDref = %d\n", mFDref));
+    SOCKET_LOG(("JIMB: ReleaseFD_Locked: mFDref = %" PRIuPTR "\n", mFDref));
 
     if (--mFDref == 0) {
         if (gIOService->IsNetTearingDown() &&
             ((PR_IntervalNow() - gIOService->NetTearingDownStarted()) >
              gSocketTransportService->MaxTimeForPrClosePref())) {
           // If shutdown last to long, let the socket leak and do not close it.
           SOCKET_LOG(("Intentional leak"));
         } else if (PR_GetCurrentThread() == gSocketThread) {
@@ -1845,22 +1851,23 @@ nsSocketTransport::ReleaseFD_Locked(PRFi
 }
 
 //-----------------------------------------------------------------------------
 // socket event handler impl
 
 void
 nsSocketTransport::OnSocketEvent(uint32_t type, nsresult status, nsISupports *param)
 {
-    SOCKET_LOG(("nsSocketTransport::OnSocketEvent [this=%p type=%u status=%x param=%p]\n",
-        this, type, status, param));
+    SOCKET_LOG(("nsSocketTransport::OnSocketEvent [this=%p type=%u status=%" PRIx32 " param=%p]\n",
+                this, type, static_cast<uint32_t>(status), param));
 
     if (NS_FAILED(mCondition)) {
         // block event since we're apparently already dead.
-        SOCKET_LOG(("  blocking event [condition=%x]\n", mCondition));
+        SOCKET_LOG(("  blocking event [condition=%" PRIx32 "]\n",
+                    static_cast<uint32_t>(mCondition)));
         //
         // notify input/output streams in case either has a pending notify.
         //
         mInput.OnSocketReady(mCondition);
         mOutput.OnSocketReady(mCondition);
         return;
     }
 
@@ -1943,17 +1950,18 @@ nsSocketTransport::OnSocketEvent(uint32_
         mPollTimeout = mTimeouts[(mState == STATE_TRANSFERRING)
           ? TIMEOUT_READ_WRITE : TIMEOUT_CONNECT];
         break;
     default:
         SOCKET_LOG(("  unhandled event!\n"));
     }
     
     if (NS_FAILED(mCondition)) {
-        SOCKET_LOG(("  after event [this=%p cond=%x]\n", this, mCondition));
+        SOCKET_LOG(("  after event [this=%p cond=%"  PRIx32 "]\n", this,
+                    static_cast<uint32_t>(mCondition)));
         if (!mAttached) // need to process this error ourselves...
             OnSocketDetached(nullptr);
     }
     else if (mPollFlags == PR_POLL_EXCEPT)
         mPollFlags = 0; // make idle
 }
 
 //-----------------------------------------------------------------------------
@@ -2056,17 +2064,18 @@ nsSocketTransport::OnSocketReady(PRFileD
             }
             else {
                 //
                 // else, the connection failed...
                 //
                 mCondition = ErrorAccordingToNSPR(code);
                 if ((mCondition == NS_ERROR_CONNECTION_REFUSED) && !mProxyHost.IsEmpty())
                     mCondition = NS_ERROR_PROXY_CONNECTION_REFUSED;
-                SOCKET_LOG(("  connection failed! [reason=%x]\n", mCondition));
+                SOCKET_LOG(("  connection failed! [reason=%" PRIx32 "]\n",
+                            static_cast<uint32_t>(mCondition)));
             }
         }
     }
     else if ((mState == STATE_CONNECTING) && gIOService->IsNetTearingDown()) {
         // We do not need to do PR_ConnectContinue when we are already
         // shutting down.
         SOCKET_LOG(("We are in shutdown so skip PR_ConnectContinue and set "
                     "and error.\n"));
@@ -2080,18 +2089,18 @@ nsSocketTransport::OnSocketReady(PRFileD
     if (mPollFlags == PR_POLL_EXCEPT)
         mPollFlags = 0; // make idle
 }
 
 // called on the socket thread only
 void
 nsSocketTransport::OnSocketDetached(PRFileDesc *fd)
 {
-    SOCKET_LOG(("nsSocketTransport::OnSocketDetached [this=%p cond=%x]\n",
-        this, mCondition));
+    SOCKET_LOG(("nsSocketTransport::OnSocketDetached [this=%p cond=%" PRIx32 "]\n",
+                this, static_cast<uint32_t>(mCondition)));
 
     NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
     // if we didn't initiate this detach, then be sure to pass an error
     // condition up to our consumers.  (e.g., STS is shutting down.)
     if (NS_SUCCEEDED(mCondition)) {
         if (gIOService->IsOffline()) {
           mCondition = NS_ERROR_OFFLINE;
@@ -2749,18 +2758,18 @@ nsSocketTransport::OnKeepaliveEnabledPre
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
     // The global pref toggles keepalive as a system feature; it only affects
     // an individual socket if keepalive has been specifically enabled for it.
     // So, ensure keepalive is configured correctly if previously enabled.
     if (mKeepaliveEnabled) {
         nsresult rv = SetKeepaliveEnabledInternal(aEnabled);
         if (NS_WARN_IF(NS_FAILED(rv))) {
-            SOCKET_LOG(("  SetKeepaliveEnabledInternal [%s] failed rv[0x%x]",
-                        aEnabled ? "enable" : "disable", rv));
+            SOCKET_LOG(("  SetKeepaliveEnabledInternal [%s] failed rv[0x%" PRIx32 "]",
+                        aEnabled ? "enable" : "disable", static_cast<uint32_t>(rv)));
         }
     }
 }
 
 nsresult
 nsSocketTransport::SetKeepaliveEnabledInternal(bool aEnable)
 {
     MOZ_ASSERT(mKeepaliveIdleTimeS > 0 &&
@@ -2778,22 +2787,22 @@ nsSocketTransport::SetKeepaliveEnabledIn
     // Only enable if keepalives are globally enabled, but ensure other
     // options are set correctly on the fd.
     bool enable = aEnable && mSocketTransportService->IsKeepaliveEnabled();
     nsresult rv = fd.SetKeepaliveVals(enable,
                                       mKeepaliveIdleTimeS,
                                       mKeepaliveRetryIntervalS,
                                       mKeepaliveProbeCount);
     if (NS_WARN_IF(NS_FAILED(rv))) {
-        SOCKET_LOG(("  SetKeepaliveVals failed rv[0x%x]", rv));
+        SOCKET_LOG(("  SetKeepaliveVals failed rv[0x%" PRIx32 "]", static_cast<uint32_t>(rv)));
         return rv;
     }
     rv = fd.SetKeepaliveEnabled(enable);
     if (NS_WARN_IF(NS_FAILED(rv))) {
-        SOCKET_LOG(("  SetKeepaliveEnabled failed rv[0x%x]", rv));
+        SOCKET_LOG(("  SetKeepaliveEnabled failed rv[0x%" PRIx32 "]", static_cast<uint32_t>(rv)));
         return rv;
     }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSocketTransport::GetKeepaliveEnabled(bool *aResult)
 {
@@ -2844,18 +2853,18 @@ nsSocketTransport::SetKeepaliveEnabled(b
         return NS_OK;
     }
 
     nsresult rv = NS_OK;
     if (aEnable) {
         rv = EnsureKeepaliveValsAreInitialized();
         if (NS_WARN_IF(NS_FAILED(rv))) {
             SOCKET_LOG(("  SetKeepaliveEnabled [%p] "
-                        "error [0x%x] initializing keepalive vals",
-                        this, rv));
+                        "error [0x%" PRIx32 "] initializing keepalive vals",
+                        this, static_cast<uint32_t>(rv)));
             return rv;
         }
     }
     SOCKET_LOG(("nsSocketTransport::SetKeepaliveEnabled [%p] "
                 "%s, idle time[%ds] retry interval[%ds] packet count[%d]: "
                 "globally %s.",
                 this, aEnable ? "enabled" : "disabled",
                 mKeepaliveIdleTimeS, mKeepaliveRetryIntervalS,
@@ -2865,17 +2874,18 @@ nsSocketTransport::SetKeepaliveEnabled(b
 
     // Set mKeepaliveEnabled here so that state is maintained; it is possible
     // that we're in between fds, e.g. the 1st IP address failed, so we're about
     // to retry on a 2nd from the DNS record.
     mKeepaliveEnabled = aEnable;
 
     rv = SetKeepaliveEnabledInternal(aEnable);
     if (NS_WARN_IF(NS_FAILED(rv))) {
-        SOCKET_LOG(("  SetKeepaliveEnabledInternal failed rv[0x%x]", rv));
+        SOCKET_LOG(("  SetKeepaliveEnabledInternal failed rv[0x%" PRIx32 "]",
+                    static_cast<uint32_t>(rv)));
         return rv;
     }
 
     return NS_OK;
 #else /* !(defined(XP_WIN) || defined(XP_UNIX) || defined(XP_MACOSX)) */
     SOCKET_LOG(("nsSocketTransport::SetKeepaliveEnabled unsupported platform"));
     return NS_ERROR_NOT_IMPLEMENTED;
 #endif
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -1,16 +1,17 @@
 // vim:set sw=4 sts=4 et cin:
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsSocketTransportService2.h"
 #include "nsSocketTransport2.h"
 #include "NetworkActivityMonitor.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "nsIOService.h"
 #include "nsASocketHandler.h"
 #include "nsError.h"
 #include "prnetdb.h"
 #include "prerror.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
@@ -438,17 +439,17 @@ nsSocketTransportService::PollTimeout()
         if (r < minR)
             minR = r;
     }
     // nsASocketHandler defines UINT16_MAX as do not timeout
     if (minR == UINT16_MAX) {
         SOCKET_LOG(("poll timeout: none\n"));
         return NS_SOCKET_POLL_TIMEOUT;
     }
-    SOCKET_LOG(("poll timeout: %lu\n", minR));
+    SOCKET_LOG(("poll timeout: %" PRIu32 "\n", minR));
     return PR_SecondsToInterval(minR);
 }
 
 int32_t
 nsSocketTransportService::Poll(uint32_t *interval,
                                TimeDuration *pollDuration)
 {
     PRPollDesc *pollList;
@@ -1053,19 +1054,19 @@ nsSocketTransportService::DoPollIteratio
     // walk active list backwards to see if any sockets should actually be
     // idle, then walk the idle list backwards to see if any idle sockets
     // should become active.  take care to check only idle sockets that
     // were idle to begin with ;-)
     //
     count = mIdleCount;
     for (i=mActiveCount-1; i>=0; --i) {
         //---
-        SOCKET_LOG(("  active [%u] { handler=%p condition=%x pollflags=%hu }\n", i,
+        SOCKET_LOG(("  active [%u] { handler=%p condition=%" PRIx32 " pollflags=%hu }\n", i,
             mActiveList[i].mHandler,
-            mActiveList[i].mHandler->mCondition,
+            static_cast<uint32_t>(mActiveList[i].mHandler->mCondition),
             mActiveList[i].mHandler->mPollFlags));
         //---
         if (NS_FAILED(mActiveList[i].mHandler->mCondition))
             DetachSocket(mActiveList, &mActiveList[i]);
         else {
             uint16_t in_flags = mActiveList[i].mHandler->mPollFlags;
             if (in_flags == 0)
                 MoveToIdleList(&mActiveList[i]);
@@ -1073,19 +1074,19 @@ nsSocketTransportService::DoPollIteratio
                 // update poll flags
                 mPollList[i+1].in_flags = in_flags;
                 mPollList[i+1].out_flags = 0;
             }
         }
     }
     for (i=count-1; i>=0; --i) {
         //---
-        SOCKET_LOG(("  idle [%u] { handler=%p condition=%x pollflags=%hu }\n", i,
+        SOCKET_LOG(("  idle [%u] { handler=%p condition=%" PRIx32 " pollflags=%hu }\n", i,
             mIdleList[i].mHandler,
-            mIdleList[i].mHandler->mCondition,
+            static_cast<uint32_t>(mIdleList[i].mHandler->mCondition),
             mIdleList[i].mHandler->mPollFlags));
         //---
         if (NS_FAILED(mIdleList[i].mHandler->mCondition))
             DetachSocket(mIdleList, &mIdleList[i]);
         else if (mIdleList[i].mHandler->mPollFlags != 0)
             MoveToPollList(&mIdleList[i]);
     }
 
--- a/netwerk/base/nsUDPSocket.cpp
+++ b/netwerk/base/nsUDPSocket.cpp
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Attributes.h"
 #include "mozilla/EndianUtils.h"
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/HoldDropJSObjects.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Telemetry.h"
 
 #include "nsSocketTransport2.h"
 #include "nsUDPSocket.h"
 #include "nsProxyRelease.h"
 #include "nsAutoPtr.h"
 #include "nsError.h"
 #include "nsNetCID.h"
@@ -1027,17 +1028,17 @@ SocketListenerProxyBackground::OnPacketR
   mMessage->GetFromAddr(getter_AddRefs(nsAddr));
   nsAddr->GetNetAddr(&netAddr);
 
   nsCOMPtr<nsIOutputStream> outputStream;
   mMessage->GetOutputStream(getter_AddRefs(outputStream));
 
   FallibleTArray<uint8_t>& data = mMessage->GetDataAsTArray();
 
-  UDPSOCKET_LOG(("%s [this=%p], len %u", __FUNCTION__, this, data.Length()));
+  UDPSOCKET_LOG(("%s [this=%p], len %" PRIuSIZE, __FUNCTION__, this, data.Length()));
   nsCOMPtr<nsIUDPMessage> message = new UDPMessageProxy(&netAddr,
                                                         outputStream,
                                                         data);
   mListener->OnPacketReceived(mSocket, message);
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/netwerk/cache/nsCache.cpp
+++ b/netwerk/cache/nsCache.cpp
@@ -3,33 +3,35 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsCache.h"
 #include "nsReadableUtils.h"
 #include "nsDependentSubstring.h"
 #include "nsString.h"
+#include "mozilla/IntegerPrintfMacros.h"
 
 
 /**
  * Cache Service Utility Functions
  */
 
 mozilla::LazyLogModule gCacheLog("cache");
 
 void
 CacheLogPrintPath(mozilla::LogLevel level, const char * format, nsIFile * item)
 {
     nsAutoCString path;
     nsresult rv = item->GetNativePath(path);
     if (NS_SUCCEEDED(rv)) {
         MOZ_LOG(gCacheLog, level, (format, path.get()));
     } else {
-        MOZ_LOG(gCacheLog, level, ("GetNativePath failed: %x", rv));
+        MOZ_LOG(gCacheLog, level, ("GetNativePath failed: %" PRIx32,
+                                   static_cast<uint32_t>(rv)));
     }
 }
 
 
 uint32_t
 SecondsFromPRTime(PRTime prTime)
 {
   int64_t  microSecondsPerSecond = PR_USEC_PER_SEC;
--- a/netwerk/cache/nsCacheEntryDescriptor.cpp
+++ b/netwerk/cache/nsCacheEntryDescriptor.cpp
@@ -9,16 +9,17 @@
 #include "nsCacheService.h"
 #include "nsCacheEntryDescriptor.h"
 #include "nsCacheEntry.h"
 #include "nsReadableUtils.h"
 #include "nsIOutputStream.h"
 #include "nsCRT.h"
 #include "nsThreadUtils.h"
 #include <algorithm>
+#include "mozilla/IntegerPrintfMacros.h"
 
 #define kMinDecompressReadBufLen 1024
 #define kMinCompressWriteBufLen  1024
 
 
 /******************************************************************************
  * nsAsyncDoomEvent
  *****************************************************************************/
@@ -813,18 +814,18 @@ nsInputStreamWrapper::Read(char *buf, ui
 nsresult nsCacheEntryDescriptor::
 nsInputStreamWrapper::Read_Locked(char *buf, uint32_t count, uint32_t *countRead)
 {
     nsresult rv = EnsureInit();
     if (NS_SUCCEEDED(rv))
         rv = mInput->Read(buf, count, countRead);
 
     CACHE_LOG_DEBUG(("nsInputStreamWrapper::Read "
-                      "[entry=%p, wrapper=%p, mInput=%p, rv=%d]",
-                      mDescriptor, this, mInput.get(), rv));
+                      "[entry=%p, wrapper=%p, mInput=%p, rv=%" PRId32 "]",
+                     mDescriptor, this, mInput.get(), static_cast<uint32_t>(rv)));
 
     return rv;
 }
 
 nsresult nsCacheEntryDescriptor::
 nsInputStreamWrapper::ReadSegments(nsWriteSegmentFun writer, void *closure,
                                    uint32_t count, uint32_t *countRead)
 {
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -928,17 +928,17 @@ nsCacheProfilePrefObserver::MemoryCacheC
 {
     int32_t capacity = mMemoryCacheCapacity;
     if (capacity >= 0) {
         CACHE_LOG_DEBUG(("Memory cache capacity forced to %d\n", capacity));
         return capacity;
     }
 
     static uint64_t bytes = PR_GetPhysicalMemorySize();
-    CACHE_LOG_DEBUG(("Physical Memory size is %llu\n", bytes));
+    CACHE_LOG_DEBUG(("Physical Memory size is %" PRIu64 "\n", bytes));
 
     // If getting the physical memory failed, arbitrarily assume
     // 32 MB of RAM. We use a low default to have a reasonable
     // size on all the devices we support.
     if (bytes == 0)
         bytes = 32 * 1024 * 1024;
 
     // Conversion from unsigned int64_t to double doesn't work on all platforms.
@@ -1771,17 +1771,18 @@ nsCacheService::CreateCustomOfflineDevic
     NS_ADDREF(*aDevice);
 
     // set the preferences
     (*aDevice)->SetCacheParentDirectory(aProfileDir);
     (*aDevice)->SetCapacity(aQuota);
 
     nsresult rv = (*aDevice)->InitWithSqlite(mStorageService);
     if (NS_FAILED(rv)) {
-        CACHE_LOG_DEBUG(("OfflineDevice->InitWithSqlite() failed (0x%.8x)\n", rv));
+        CACHE_LOG_DEBUG(("OfflineDevice->InitWithSqlite() failed (0x%.8" PRIx32 ")\n",
+                         static_cast<uint32_t>(rv)));
         CACHE_LOG_DEBUG(("    - disabling offline cache for this session.\n"));
 
         NS_RELEASE(*aDevice);
     }
     return rv;
 }
 
 nsresult
@@ -2184,17 +2185,17 @@ nsCacheService::SearchCacheDevices(nsCSt
     CACHE_LOG_DEBUG(("mMemoryDevice: 0x%p\n", mMemoryDevice));
 
     *collision = false;
     if ((policy == nsICache::STORE_ANYWHERE) || (policy == nsICache::STORE_IN_MEMORY)) {
         // If there is no memory device, then there is nothing to search...
         if (mMemoryDevice) {
             entry = mMemoryDevice->FindEntry(key, collision);
             CACHE_LOG_DEBUG(("Searching mMemoryDevice for key %s found: 0x%p, "
-                             "collision: %d\n", key->get(), entry, collision));
+                             "collision: %d\n", key->get(), entry, *collision));
         }
     }
 
     if (!entry && 
         ((policy == nsICache::STORE_ANYWHERE) || (policy == nsICache::STORE_ON_DISK))) {
 
         if (mEnableDiskDevice) {
             if (!mDiskDevice) {
--- a/netwerk/cache/nsDiskCacheBlockFile.cpp
+++ b/netwerk/cache/nsDiskCacheBlockFile.cpp
@@ -3,16 +3,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsCache.h"
 #include "nsDiskCache.h"
 #include "nsDiskCacheBlockFile.h"
 #include "mozilla/FileUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/MemoryReporting.h"
 #include <algorithm>
 
 using namespace mozilla;
 
 /******************************************************************************
  * nsDiskCacheBlockFile - 
  *****************************************************************************/
@@ -38,18 +39,18 @@ nsDiskCacheBlockFile::Open(nsIFile * blo
     mBitMapWords = bitMapSize / 32;
     uint32_t bitMapBytes = mBitMapWords * 4;
     
     // open the file - restricted to user, the data could be confidential
     nsresult rv = blockFile->OpenNSPRFileDesc(PR_RDWR | PR_CREATE_FILE, 00600, &mFD);
     if (NS_FAILED(rv)) {
         *corruptInfo = nsDiskCache::kCouldNotCreateBlockFile;
         CACHE_LOG_DEBUG(("CACHE: nsDiskCacheBlockFile::Open "
-                         "[this=%p] unable to open or create file: %d",
-                         this, rv));
+                         "[this=%p] unable to open or create file: %" PRId32,
+                         this, static_cast<uint32_t>(rv)));
         return rv;  // unable to open or create file
     }
     
     // allocate bit map buffer
     mBitMap = new uint32_t[mBitMapWords];
     
     // check if we just creating the file
     mFileSize = PR_Available(mFD);
@@ -97,17 +98,17 @@ nsDiskCacheBlockFile::Open(nsIFile * blo
         }
     }
     CACHE_LOG_DEBUG(("CACHE: nsDiskCacheBlockFile::Open [this=%p] succeeded",
                       this));
     return NS_OK;
 
 error_exit:
     CACHE_LOG_DEBUG(("CACHE: nsDiskCacheBlockFile::Open [this=%p] failed with "
-                     "error %d", this, rv));
+                     "error %" PRId32, this, static_cast<uint32_t>(rv)));
     Close(false);
     return rv;
 }
 
 
 /******************************************************************************
  *  Close
  *****************************************************************************/
--- a/netwerk/cache/nsDiskCacheDevice.cpp
+++ b/netwerk/cache/nsDiskCacheDevice.cpp
@@ -470,17 +470,18 @@ nsDiskCacheDevice::FindEntry(nsCString *
     if (binding && !binding->mCacheEntry->Key()->Equals(*key)) {
         *collision = true;
         return nullptr;
     } else if (binding && binding->mDeactivateEvent) {
         binding->mDeactivateEvent->CancelEvent();
         binding->mDeactivateEvent = nullptr;
         CACHE_LOG_DEBUG(("CACHE: reusing deactivated entry %p " \
                          "req-key=%s  entry-key=%s\n",
-                         binding->mCacheEntry, key, binding->mCacheEntry->Key()));
+                         binding->mCacheEntry, key->get(),
+                         binding->mCacheEntry->Key()->get()));
 
         return binding->mCacheEntry; // just return this one, observing that
                                      // FindActiveBinding() does not return
                                      // bindings to doomed entries
     }
     binding = nullptr;
 
     // lookup hash number in cache map
@@ -979,17 +980,18 @@ nsDiskCacheDevice::OpenDiskCache()
         }
     }
 
     // if we don't have a cache directory, create one and open it
     if (!exists) {
         nsCacheService::MarkStartingFresh();
         rv = mCacheDirectory->Create(nsIFile::DIRECTORY_TYPE, 0777);
         CACHE_LOG_PATH(LogLevel::Info, "\ncreate cache directory: %s\n", mCacheDirectory);
-        CACHE_LOG_INFO(("mCacheDirectory->Create() = %x\n", rv));
+        CACHE_LOG_INFO(("mCacheDirectory->Create() = %" PRIx32 "\n",
+                        static_cast<uint32_t>(rv)));
         if (NS_FAILED(rv))
             return rv;
     
         // reopen the cache map     
         nsDiskCache::CorruptCacheInfo corruptInfo;
         rv = mCacheMap.Open(mCacheDirectory, &corruptInfo);
         if (NS_FAILED(rv))
             return rv;
--- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp
@@ -213,18 +213,18 @@ nsOfflineCacheEvictionFunction::OnFuncti
     return NS_OK;
   }
 
   nsCOMPtr<nsIFile> file;
   rv = GetCacheDataFile(mDevice->CacheDirectory(), key,
                         generation, file);
   if (NS_FAILED(rv))
   {
-    LOG(("GetCacheDataFile [key=%s generation=%d] failed [rv=%x]!\n",
-         key, generation, rv));
+    LOG(("GetCacheDataFile [key=%s generation=%d] failed [rv=%" PRIx32 "]!\n",
+         key, generation, static_cast<uint32_t>(rv)));
     return rv;
   }
 
   mItems.AppendObject(file);
 
   return NS_OK;
 }
 
@@ -1501,17 +1501,17 @@ nsOfflineCacheDevice::FindEntry(nsCStrin
                            (const uint8_t **) &rec.metaData);
   rec.generation     = statement->AsInt32(1);
   rec.dataSize       = statement->AsInt32(2);
   rec.fetchCount     = statement->AsInt32(3);
   rec.lastFetched    = statement->AsInt64(4);
   rec.lastModified   = statement->AsInt64(5);
   rec.expirationTime = statement->AsInt64(6);
 
-  LOG(("entry: [%u %d %d %d %lld %lld %lld]\n",
+  LOG(("entry: [%u %d %d %d %" PRId64 " %" PRId64 " %" PRId64 "]\n",
         rec.metaDataLen,
         rec.generation,
         rec.dataSize,
         rec.fetchCount,
         rec.lastFetched,
         rec.lastModified,
         rec.expirationTime));
 
--- a/netwerk/cache/nsDiskCacheStreams.cpp
+++ b/netwerk/cache/nsDiskCacheStreams.cpp
@@ -111,30 +111,30 @@ nsDiskCacheInputStream::Available(uint64
 NS_IMETHODIMP
 nsDiskCacheInputStream::Read(char * buffer, uint32_t count, uint32_t * bytesRead)
 {
     *bytesRead = 0;
 
     if (mClosed) {
         CACHE_LOG_DEBUG(("CACHE: nsDiskCacheInputStream::Read "
                          "[stream=%p] stream was closed",
-                         this, buffer, count));
+                         this));
         return NS_OK;
     }
     
     if (mPos == mStreamEnd) {
         CACHE_LOG_DEBUG(("CACHE: nsDiskCacheInputStream::Read "
                          "[stream=%p] stream at end of file",
-                         this, buffer, count));
+                         this));
         return NS_OK;
     }
     if (mPos > mStreamEnd) {
         CACHE_LOG_DEBUG(("CACHE: nsDiskCacheInputStream::Read "
                          "[stream=%p] stream past end of file (!)",
-                         this, buffer, count));
+                         this));
         return NS_ERROR_UNEXPECTED;
     }
     
     if (count > mStreamEnd - mPos)
         count = mStreamEnd - mPos;
 
     if (mFD) {
         // just read from file
--- a/netwerk/cache/nsMemoryCacheDevice.cpp
+++ b/netwerk/cache/nsMemoryCacheDevice.cpp
@@ -7,16 +7,17 @@
 #include "nsCache.h"
 #include "nsMemoryCacheDevice.h"
 #include "nsCacheService.h"
 #include "nsICacheService.h"
 #include "nsICacheVisitor.h"
 #include "nsIStorageStream.h"
 #include "nsCRT.h"
 #include "nsReadableUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Telemetry.h"
 #include <algorithm>
 
 // The memory cache implements the "LRU-SP" caching algorithm
 // described in "LRU-SP: A Size-Adjusted and Popularity-Aware LRU Replacement
 // Algorithm for Web Caching" by Kai Cheng and Yahiko Kambayashi.
 
@@ -262,17 +263,17 @@ nsMemoryCacheDevice::GetFileForEntry( ns
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 bool
 nsMemoryCacheDevice::EntryIsTooBig(int64_t entrySize)
 {
     CACHE_LOG_DEBUG(("nsMemoryCacheDevice::EntryIsTooBig "
-                     "[size=%d max=%d soft=%d]\n",
+                     "[size=%" PRId64 " max=%d soft=%d]\n",
                      entrySize, mMaxEntrySize, mSoftLimit));
     if (mMaxEntrySize == -1)
         return entrySize > mSoftLimit;
     else
         return (entrySize > mSoftLimit || entrySize > mMaxEntrySize);
 }
 
 size_t
@@ -477,17 +478,18 @@ nsMemoryCacheDevice::DoEvictEntries(bool
             elem = PR_NEXT_LINK(elem);
 
             if (!matchFn(entry, args))
                 continue;
             
             if (entry->IsInUse()) {
                 nsresult rv = nsCacheService::DoomEntry(entry);
                 if (NS_FAILED(rv)) {
-                    CACHE_LOG_WARNING(("memCache->DoEvictEntries() aborted: rv =%x", rv));
+                    CACHE_LOG_WARNING(("memCache->DoEvictEntries() aborted: rv =%" PRIx32,
+                                       static_cast<uint32_t>(rv)));
                     return rv;
                 }
             } else {
                 EvictEntry(entry, DELETE_ENTRY);
             }
         }
     }
 
--- a/netwerk/cache2/CacheEntry.cpp
+++ b/netwerk/cache2/CacheEntry.cpp
@@ -21,16 +21,17 @@
 
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "nsProxyRelease.h"
 #include "nsSerializationHelper.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Telemetry.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include <math.h>
 #include <algorithm>
 
 namespace mozilla {
 namespace net {
 
 static uint32_t const ENTRY_WANTED =
   nsICacheEntryOpenCallback::ENTRY_WANTED;
@@ -444,18 +445,18 @@ bool CacheEntry::Load(bool aTruncate, bo
     mState = EMPTY;
   }
 
   return mState == LOADING;
 }
 
 NS_IMETHODIMP CacheEntry::OnFileReady(nsresult aResult, bool aIsNew)
 {
-  LOG(("CacheEntry::OnFileReady [this=%p, rv=0x%08x, new=%d]",
-      this, aResult, aIsNew));
+  LOG(("CacheEntry::OnFileReady [this=%p, rv=0x%08" PRIx32 ", new=%d]",
+       this, static_cast<uint32_t>(aResult), aIsNew));
 
   MOZ_ASSERT(!mLoadStart.IsNull());
 
   if (NS_SUCCEEDED(aResult)) {
     if (aIsNew) {
       CacheFileUtils::DetailedCacheHitTelemetry::AddRecord(
         CacheFileUtils::DetailedCacheHitTelemetry::MISS, mLoadStart);
     } else {
@@ -537,20 +538,22 @@ already_AddRefed<CacheEntryHandle> Cache
       mUseDisk && !aMemoryOnly,
       mSkipSizeCheck,
       mPinned,
       true, // truncate existing (this one)
       getter_AddRefs(handle));
 
     if (NS_SUCCEEDED(rv)) {
       newEntry = handle->Entry();
-      LOG(("  exchanged entry %p by entry %p, rv=0x%08x", this, newEntry.get(), rv));
+      LOG(("  exchanged entry %p by entry %p, rv=0x%08" PRIx32,
+           this, newEntry.get(), static_cast<uint32_t>(rv)));
       newEntry->AsyncOpen(aCallback, nsICacheStorage::OPEN_TRUNCATE);
     } else {
-      LOG(("  exchanged of entry %p failed, rv=0x%08x", this, rv));
+      LOG(("  exchanged of entry %p failed, rv=0x%08" PRIx32,
+           this, static_cast<uint32_t>(rv)));
       AsyncDoom(nullptr);
     }
   }
 
   mPreventCallbacks = false;
 
   if (!newEntry)
     return nullptr;
@@ -740,17 +743,18 @@ bool CacheEntry::InvokeCallback(Callback
         // Metadata present, validate the entry
         uint32_t checkResult;
         {
           // mayhemer: TODO check and solve any potential races of concurent OnCacheEntryCheck
           mozilla::MutexAutoUnlock unlock(mLock);
 
           nsresult rv = aCallback.mCallback->OnCacheEntryCheck(
             this, nullptr, &checkResult);
-          LOG(("  OnCacheEntryCheck: rv=0x%08x, result=%d", rv, checkResult));
+          LOG(("  OnCacheEntryCheck: rv=0x%08" PRIx32 ", result=%" PRId32,
+               static_cast<uint32_t>(rv), static_cast<uint32_t>(checkResult)));
 
           if (NS_FAILED(rv))
             checkResult = ENTRY_NOT_WANTED;
         }
 
         aCallback.mRevalidating = checkResult == ENTRY_NEEDS_REVALIDATION;
 
         switch (checkResult) {
@@ -831,17 +835,17 @@ void CacheEntry::InvokeAvailableCallback
   }
 
   if (!onAvailThread) {
     // Dispatch to the right thread
     RefPtr<AvailableCallbackRunnable> event =
       new AvailableCallbackRunnable(this, aCallback);
 
     rv = aCallback.mTargetThread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
-    LOG(("  redispatched, (rv = 0x%08x)", rv));
+    LOG(("  redispatched, (rv = 0x%08" PRIx32 ")", static_cast<uint32_t>(rv)));
     return;
   }
 
   if (mIsDoomed || aCallback.mNotWanted) {
     LOG(("  doomed or not wanted, notifying OCEA with NS_ERROR_CACHE_KEY_NOT_FOUND"));
     aCallback.mCallback->OnCacheEntryAvailable(
       nullptr, false, nullptr, NS_ERROR_CACHE_KEY_NOT_FOUND);
     return;
@@ -881,17 +885,17 @@ void CacheEntry::InvokeAvailableCallback
 
   OnFetched(aCallback);
 
   RefPtr<CacheEntryHandle> handle = NewWriteHandle();
   rv = aCallback.mCallback->OnCacheEntryAvailable(
     handle, state == WRITING, nullptr, NS_OK);
 
   if (NS_FAILED(rv)) {
-    LOG(("  writing/revalidating failed (0x%08x)", rv));
+    LOG(("  writing/revalidating failed (0x%08" PRIx32 ")", static_cast<uint32_t>(rv)));
 
     // Consumer given a new entry failed to take care of the entry.
     OnHandleClosed(handle);
     return;
   }
 
   LOG(("  writing/revalidating"));
 }
@@ -1499,17 +1503,17 @@ NS_IMETHODIMP CacheEntry::GetDataSize(in
   NS_ENSURE_SUCCESS(mFileStatus, mFileStatus);
 
   // mayhemer: TODO Problem with compression?
   if (!mFile->DataSize(aDataSize)) {
     LOG(("  write in progress (stream active)"));
     return NS_ERROR_IN_PROGRESS;
   }
 
-  LOG(("  size=%lld", *aDataSize));
+  LOG(("  size=%" PRId64, *aDataSize));
   return NS_OK;
 }
 
 
 NS_IMETHODIMP CacheEntry::GetAltDataSize(int64_t *aDataSize)
 {
   LOG(("CacheEntry::GetAltDataSize [this=%p]", this));
   if (NS_FAILED(mFileStatus)) {
--- a/netwerk/cache2/CacheFile.cpp
+++ b/netwerk/cache2/CacheFile.cpp
@@ -322,18 +322,18 @@ nsresult
 CacheFile::OnChunkRead(nsresult aResult, CacheFileChunk *aChunk)
 {
   CacheFileAutoLock lock(this);
 
   nsresult rv;
 
   uint32_t index = aChunk->Index();
 
-  LOG(("CacheFile::OnChunkRead() [this=%p, rv=0x%08x, chunk=%p, idx=%u]",
-       this, aResult, aChunk, index));
+  LOG(("CacheFile::OnChunkRead() [this=%p, rv=0x%08" PRIx32 ", chunk=%p, idx=%u]",
+       this, static_cast<uint32_t>(aResult), aChunk, index));
 
   if (NS_FAILED(aResult)) {
     SetError(aResult);
   }
 
   if (HaveChunkListeners(index)) {
     rv = NotifyChunkListeners(index, aResult, aChunk);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -351,18 +351,18 @@ CacheFile::OnChunkWritten(nsresult aResu
   // addref and release (outside the lock) the chunk which ensures that
   // CacheFile::DeactivateChunk() will be called again.
   RefPtr<CacheFileChunk> deactivateChunkAgain;
 
   CacheFileAutoLock lock(this);
 
   nsresult rv;
 
-  LOG(("CacheFile::OnChunkWritten() [this=%p, rv=0x%08x, chunk=%p, idx=%u]",
-       this, aResult, aChunk, aChunk->Index()));
+  LOG(("CacheFile::OnChunkWritten() [this=%p, rv=0x%08" PRIx32 ", chunk=%p, idx=%u]",
+       this, static_cast<uint32_t>(aResult), aChunk, aChunk->Index()));
 
   MOZ_ASSERT(!mMemoryOnly);
   MOZ_ASSERT(!mOpeningFile);
   MOZ_ASSERT(mHandle);
 
   if (NS_FAILED(aResult)) {
     SetError(aResult);
   }
@@ -379,17 +379,17 @@ CacheFile::OnChunkWritten(nsresult aResu
     if (NS_SUCCEEDED(rv)) {
       MOZ_ASSERT(aChunk->mRefCnt != 2);
       return NS_OK;
     }
   }
 
   if (aChunk->mRefCnt != 2) {
     LOG(("CacheFile::OnChunkWritten() - Chunk is still used [this=%p, chunk=%p,"
-         " refcnt=%d]", this, aChunk, aChunk->mRefCnt.get()));
+         " refcnt=%" PRIuPTR "]", this, aChunk, aChunk->mRefCnt.get()));
 
     return NS_OK;
   }
 
   if (aChunk->IsDirty()) {
     LOG(("CacheFile::OnChunkWritten() - Unused chunk is dirty. We must go "
          "through deactivation again. [this=%p, chunk=%p]", this, aChunk));
 
@@ -473,18 +473,18 @@ CacheFile::OnFileOpened(CacheFileHandle 
 
     MOZ_ASSERT(mOpeningFile);
     MOZ_ASSERT((NS_SUCCEEDED(aResult) && aHandle) ||
                (NS_FAILED(aResult) && !aHandle));
     MOZ_ASSERT((mListener && !mMetadata) || // !createNew
                (!mListener && mMetadata));  // createNew
     MOZ_ASSERT(!mMemoryOnly || mMetadata); // memory-only was set on new entry
 
-    LOG(("CacheFile::OnFileOpened() [this=%p, rv=0x%08x, handle=%p]",
-         this, aResult, aHandle));
+    LOG(("CacheFile::OnFileOpened() [this=%p, rv=0x%08" PRIx32 ", handle=%p]",
+         this, static_cast<uint32_t>(aResult), aHandle));
 
     mOpeningFile = false;
 
     autoDoom.mListener.swap(mDoomAfterOpenListener);
 
     if (mMemoryOnly) {
       // We can be here only in case the entry was initilized as createNew and
       // SetMemoryOnly() was called.
@@ -603,17 +603,18 @@ CacheFile::OnDataRead(CacheFileHandle *a
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 CacheFile::OnMetadataRead(nsresult aResult)
 {
   MOZ_ASSERT(mListener);
 
-  LOG(("CacheFile::OnMetadataRead() [this=%p, rv=0x%08x]", this, aResult));
+  LOG(("CacheFile::OnMetadataRead() [this=%p, rv=0x%08" PRIx32 "]",
+       this, static_cast<uint32_t>(aResult)));
 
   bool isNew = false;
   if (NS_SUCCEEDED(aResult)) {
     mPinned = mMetadata->Pinned();
     mReady = true;
     mDataSize = mMetadata->Offset();
     if (mDataSize == 0 && mMetadata->ElementsSize() == 0) {
       isNew = true;
@@ -644,17 +645,18 @@ CacheFile::OnMetadataRead(nsresult aResu
   return NS_OK;
 }
 
 nsresult
 CacheFile::OnMetadataWritten(nsresult aResult)
 {
   CacheFileAutoLock lock(this);
 
-  LOG(("CacheFile::OnMetadataWritten() [this=%p, rv=0x%08x]", this, aResult));
+  LOG(("CacheFile::OnMetadataWritten() [this=%p, rv=0x%08" PRIx32 "]",
+       this, static_cast<uint32_t>(aResult)));
 
   MOZ_ASSERT(mWritingMetadata);
   mWritingMetadata = false;
 
   MOZ_ASSERT(!mMemoryOnly);
   MOZ_ASSERT(!mOpeningFile);
 
   if (NS_WARN_IF(NS_FAILED(aResult))) {
@@ -682,18 +684,18 @@ CacheFile::OnFileDoomed(CacheFileHandle 
 {
   nsCOMPtr<CacheFileListener> listener;
 
   {
     CacheFileAutoLock lock(this);
 
     MOZ_ASSERT(mListener);
 
-    LOG(("CacheFile::OnFileDoomed() [this=%p, rv=0x%08x, handle=%p]",
-         this, aResult, aHandle));
+    LOG(("CacheFile::OnFileDoomed() [this=%p, rv=0x%08" PRIx32 ", handle=%p]",
+         this, static_cast<uint32_t>(aResult), aHandle));
 
     mListener.swap(listener);
   }
 
   listener->OnFileDoomed(aResult);
   return NS_OK;
 }
 
@@ -732,17 +734,17 @@ CacheFile::OpenInputStream(nsICacheEntry
     LOG(("CacheFile::OpenInputStream() - CacheFile is not ready [this=%p]",
          this));
 
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   if (NS_FAILED(mStatus)) {
     LOG(("CacheFile::OpenInputStream() - CacheFile is in a failure state "
-         "[this=%p, status=0x%08x]", this, mStatus));
+         "[this=%p, status=0x%08" PRIx32 "]", this, static_cast<uint32_t>(mStatus)));
 
     // Don't allow opening the input stream when this CacheFile is in
     // a failed state.  This is the only way to protect consumers correctly
     // from reading a broken entry.  When the file is in the failed state,
     // it's also doomed, so reopening the entry won't make any difference -
     // data will still be inaccessible anymore.  Note that for just doomed 
     // files, we must allow reading the data.
     return mStatus;
@@ -786,17 +788,17 @@ CacheFile::OpenAlternativeInputStream(ns
   if (mAltDataOffset == -1) {
     LOG(("CacheFile::OpenAlternativeInputStream() - Alternative data is not "
          "available [this=%p]", this));
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   if (NS_FAILED(mStatus)) {
     LOG(("CacheFile::OpenAlternativeInputStream() - CacheFile is in a failure "
-         "state [this=%p, status=0x%08x]", this, mStatus));
+         "state [this=%p, status=0x%08" PRIx32 "]", this, static_cast<uint32_t>(mStatus)));
 
     // Don't allow opening the input stream when this CacheFile is in
     // a failed state.  This is the only way to protect consumers correctly
     // from reading a broken entry.  When the file is in the failed state,
     // it's also doomed, so reopening the entry won't make any difference -
     // data will still be inaccessible anymore.  Note that for just doomed 
     // files, we must allow reading the data.
     return mStatus;
@@ -1363,17 +1365,17 @@ CacheFile::GetChunkLocked(uint32_t aInde
 
   if (off < mDataSize) {
     // We cannot be here if this is memory only entry since the chunk must exist
     MOZ_ASSERT(!mMemoryOnly);
     if (mMemoryOnly) {
       // If this ever really happen it is better to fail rather than crashing on
       // a null handle.
       LOG(("CacheFile::GetChunkLocked() - Unexpected state! Offset < mDataSize "
-           "for memory-only entry. [this=%p, off=%lld, mDataSize=%lld]",
+           "for memory-only entry. [this=%p, off=%" PRId64 ", mDataSize=%" PRId64 "]",
            this, off, mDataSize));
 
       return NS_ERROR_UNEXPECTED;
     }
 
     chunk = new CacheFileChunk(this, aIndex, aCaller == WRITER);
     mChunks.Put(aIndex, chunk);
     chunk->mActiveChunk = true;
@@ -1607,17 +1609,17 @@ CacheFile::DeactivateChunk(CacheFileChun
 
     MOZ_ASSERT(mReady);
     MOZ_ASSERT((mHandle && !mMemoryOnly && !mOpeningFile) ||
                (!mHandle && mMemoryOnly && !mOpeningFile) ||
                (!mHandle && !mMemoryOnly && mOpeningFile));
 
     if (aChunk->mRefCnt != 2) {
       LOG(("CacheFile::DeactivateChunk() - Chunk is still used [this=%p, "
-           "chunk=%p, refcnt=%d]", this, aChunk, aChunk->mRefCnt.get()));
+           "chunk=%p, refcnt=%" PRIuPTR "]", this, aChunk, aChunk->mRefCnt.get()));
 
       // somebody got the reference before the lock was acquired
       return NS_OK;
     }
 
     if (aChunk->mDiscardedChunk) {
       aChunk->mActiveChunk = false;
       ReleaseOutsideLock(RefPtr<CacheFileChunkListener>(aChunk->mFile.forget()).forget());
@@ -1643,33 +1645,34 @@ CacheFile::DeactivateChunk(CacheFileChun
 
     if (NS_FAILED(chunk->GetStatus())) {
       SetError(chunk->GetStatus());
     }
 
     if (NS_FAILED(mStatus)) {
       // Don't write any chunk to disk since this entry will be doomed
       LOG(("CacheFile::DeactivateChunk() - Releasing chunk because of status "
-           "[this=%p, chunk=%p, mStatus=0x%08x]", this, chunk.get(), mStatus));
+           "[this=%p, chunk=%p, mStatus=0x%08" PRIx32 "]",
+           this, chunk.get(), static_cast<uint32_t>(mStatus)));
 
       RemoveChunkInternal(chunk, false);
       return mStatus;
     }
 
     if (chunk->IsDirty() && !mMemoryOnly && !mOpeningFile) {
       LOG(("CacheFile::DeactivateChunk() - Writing dirty chunk to the disk "
            "[this=%p]", this));
 
       mDataIsDirty = true;
 
       rv = chunk->Write(mHandle, this);
       if (NS_FAILED(rv)) {
         LOG(("CacheFile::DeactivateChunk() - CacheFileChunk::Write() failed "
-             "synchronously. Removing it. [this=%p, chunk=%p, rv=0x%08x]",
-             this, chunk.get(), rv));
+             "synchronously. Removing it. [this=%p, chunk=%p, rv=0x%08" PRIx32 "]",
+             this, chunk.get(), static_cast<uint32_t>(rv)));
 
         RemoveChunkInternal(chunk, false);
 
         SetError(rv);
         return rv;
       }
 
       // Chunk will be removed in OnChunkWritten if it is still unused
@@ -1887,18 +1890,18 @@ StatusToTelemetryEnum(nsresult aStatus)
   NS_NOTREACHED("We should never get here");
 }
 
 nsresult
 CacheFile::RemoveInput(CacheFileInputStream *aInput, nsresult aStatus)
 {
   CacheFileAutoLock lock(this);
 
-  LOG(("CacheFile::RemoveInput() [this=%p, input=%p, status=0x%08x]", this,
-       aInput, aStatus));
+  LOG(("CacheFile::RemoveInput() [this=%p, input=%p, status=0x%08" PRIx32 "]", this,
+       aInput, static_cast<uint32_t>(aStatus)));
 
   DebugOnly<bool> found;
   found = mInputs.RemoveElement(aInput);
   MOZ_ASSERT(found);
 
   ReleaseOutsideLock(already_AddRefed<nsIInputStream>(static_cast<nsIInputStream*>(aInput)));
 
   if (!mMemoryOnly)
@@ -1914,18 +1917,18 @@ CacheFile::RemoveInput(CacheFileInputStr
   return NS_OK;
 }
 
 nsresult
 CacheFile::RemoveOutput(CacheFileOutputStream *aOutput, nsresult aStatus)
 {
   AssertOwnsLock();
 
-  LOG(("CacheFile::RemoveOutput() [this=%p, output=%p, status=0x%08x]", this,
-       aOutput, aStatus));
+  LOG(("CacheFile::RemoveOutput() [this=%p, output=%p, status=0x%08" PRIx32 "]", this,
+       aOutput, static_cast<uint32_t>(aStatus)));
 
   if (mOutput != aOutput) {
     LOG(("CacheFile::RemoveOutput() - This output was already removed, ignoring"
          " call [this=%p]", this));
     return NS_OK;
   }
 
   mOutput = nullptr;
@@ -1955,18 +1958,18 @@ CacheFile::RemoveOutput(CacheFileOutputS
 nsresult
 CacheFile::NotifyChunkListener(CacheFileChunkListener *aCallback,
                                nsIEventTarget *aTarget,
                                nsresult aResult,
                                uint32_t aChunkIdx,
                                CacheFileChunk *aChunk)
 {
   LOG(("CacheFile::NotifyChunkListener() [this=%p, listener=%p, target=%p, "
-       "rv=0x%08x, idx=%u, chunk=%p]", this, aCallback, aTarget, aResult,
-       aChunkIdx, aChunk));
+       "rv=0x%08" PRIx32 ", idx=%u, chunk=%p]", this, aCallback, aTarget,
+       static_cast<uint32_t>(aResult), aChunkIdx, aChunk));
 
   nsresult rv;
   RefPtr<NotifyChunkListenerEvent> ev;
   ev = new NotifyChunkListenerEvent(aCallback, aResult, aChunkIdx, aChunk);
   if (aTarget)
     rv = aTarget->Dispatch(ev, NS_DISPATCH_NORMAL);
   else
     rv = NS_DispatchToCurrentThread(ev);
@@ -2004,18 +2007,18 @@ CacheFile::QueueChunkListener(uint32_t a
   listeners->mItems.AppendElement(item);
   return NS_OK;
 }
 
 nsresult
 CacheFile::NotifyChunkListeners(uint32_t aIndex, nsresult aResult,
                                 CacheFileChunk *aChunk)
 {
-  LOG(("CacheFile::NotifyChunkListeners() [this=%p, idx=%u, rv=0x%08x, "
-       "chunk=%p]", this, aIndex, aResult, aChunk));
+  LOG(("CacheFile::NotifyChunkListeners() [this=%p, idx=%u, rv=0x%08" PRIx32 ", "
+       "chunk=%p]", this, aIndex, static_cast<uint32_t>(aResult), aChunk));
 
   AssertOwnsLock();
 
   nsresult rv, rv2;
 
   ChunkListeners *listeners;
   mChunkListeners.Get(aIndex, &listeners);
   MOZ_ASSERT(listeners);
--- a/netwerk/cache2/CacheFileChunk.cpp
+++ b/netwerk/cache2/CacheFileChunk.cpp
@@ -3,16 +3,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CacheLog.h"
 #include "CacheFileChunk.h"
 
 #include "CacheFile.h"
 #include "nsThreadUtils.h"
 
+#include "mozilla/IntegerPrintfMacros.h"
+
 namespace mozilla {
 namespace net {
 
 #define kMinBufSize        512
 
 CacheFileChunkBuffer::CacheFileChunkBuffer(CacheFileChunk *aChunk)
   : mChunk(aChunk)
   , mBuf(nullptr)
@@ -634,18 +636,18 @@ CacheFileChunk::OnFileOpened(CacheFileHa
   MOZ_CRASH("CacheFileChunk::OnFileOpened should not be called!");
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 CacheFileChunk::OnDataWritten(CacheFileHandle *aHandle, const char *aBuf,
                               nsresult aResult)
 {
-  LOG(("CacheFileChunk::OnDataWritten() [this=%p, handle=%p, result=0x%08x]",
-       this, aHandle, aResult));
+  LOG(("CacheFileChunk::OnDataWritten() [this=%p, handle=%p, result=0x%08" PRIx32 "]",
+       this, aHandle, static_cast<uint32_t>(aResult)));
 
   nsCOMPtr<CacheFileChunkListener> listener;
 
   {
     CacheFileAutoLock lock(mFile);
 
     MOZ_ASSERT(mState == WRITING);
     MOZ_ASSERT(mListener);
@@ -664,18 +666,18 @@ CacheFileChunk::OnDataWritten(CacheFileH
 
   return NS_OK;
 }
 
 nsresult
 CacheFileChunk::OnDataRead(CacheFileHandle *aHandle, char *aBuf,
                            nsresult aResult)
 {
-  LOG(("CacheFileChunk::OnDataRead() [this=%p, handle=%p, result=0x%08x]",
-       this, aHandle, aResult));
+  LOG(("CacheFileChunk::OnDataRead() [this=%p, handle=%p, result=0x%08" PRIx32 "]",
+       this, aHandle, static_cast<uint32_t>(aResult)));
 
   nsCOMPtr<CacheFileChunkListener> listener;
 
   {
     CacheFileAutoLock lock(mFile);
 
     MOZ_ASSERT(mState == READING);
     MOZ_ASSERT(mListener);
@@ -773,17 +775,18 @@ CacheFileChunk::GetStatus()
   AssertOwnsLock();
 
   return mStatus;
 }
 
 void
 CacheFileChunk::SetError(nsresult aStatus)
 {
-  LOG(("CacheFileChunk::SetError() [this=%p, status=0x%08x]", this, aStatus));
+  LOG(("CacheFileChunk::SetError() [this=%p, status=0x%08" PRIx32 "]",
+       this, static_cast<uint32_t>(aStatus)));
 
   MOZ_ASSERT(NS_FAILED(aStatus));
 
   if (NS_FAILED(mStatus)) {
     // Remember only the first error code.
     return;
   }
 
--- a/netwerk/cache2/CacheFileContextEvictor.cpp
+++ b/netwerk/cache2/CacheFileContextEvictor.cpp
@@ -10,16 +10,17 @@
 #include "CacheFileUtils.h"
 #include "nsIFile.h"
 #include "LoadContextInfo.h"
 #include "nsThreadUtils.h"
 #include "nsString.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIDirectoryEnumerator.h"
 #include "mozilla/Base64.h"
+#include "mozilla/IntegerPrintfMacros.h"
 
 
 namespace mozilla {
 namespace net {
 
 #define CONTEXT_EVICTION_PREFIX "ce_"
 const uint32_t kContextEvictionPrefixLength =
   sizeof(CONTEXT_EVICTION_PREFIX) - 1;
@@ -135,17 +136,17 @@ CacheFileContextEvictor::AddContext(nsIL
 
     rv = CacheIndex::GetIterator(aLoadContextInfo, false,
                                  getter_AddRefs(entry->mIterator));
     if (NS_FAILED(rv)) {
       // This could probably happen during shutdown. Remove the entry from
       // the array, but leave the info on the disk. No entry can be opened
       // during shutdown and we'll load the eviction info on next start.
       LOG(("CacheFileContextEvictor::AddContext() - Cannot get an iterator. "
-           "[rv=0x%08x]", rv));
+           "[rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
       mEntries.RemoveElement(entry);
       return rv;
     }
 
     StartEvicting();
   }
 
   return NS_OK;
@@ -232,17 +233,17 @@ CacheFileContextEvictor::WasEvicted(cons
     }
 
     if (lastModifiedTime > entry->mTimeStamp) {
       // File has been modified since context eviction.
       continue;
     }
 
     LOG(("CacheFileContextEvictor::WasEvicted() - evicted [pinning=%d, "
-         "mTimeStamp=%lld, lastModifiedTime=%lld]",
+         "mTimeStamp=%" PRId64 ", lastModifiedTime=%" PRId64 "]",
          entry->mPinned, entry->mTimeStamp, lastModifiedTime));
 
     if (entry->mPinned) {
       *aEvictedAsPinned = true;
     } else {
       *aEvictedAsNonPinned = true;
     }
   }
@@ -270,17 +271,17 @@ CacheFileContextEvictor::PersistEviction
   nsAutoCString path;
   file->GetNativePath(path);
 
   PRFileDesc *fd;
   rv = file->OpenNSPRFileDesc(PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE, 0600,
                               &fd);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG(("CacheFileContextEvictor::PersistEvictionInfoToDisk() - Creating file "
-         "failed! [path=%s, rv=0x%08x]", path.get(), rv));
+         "failed! [path=%s, rv=0x%08" PRIx32 "]", path.get(), static_cast<uint32_t>(rv)));
     return rv;
   }
 
   PR_Close(fd);
 
   LOG(("CacheFileContextEvictor::PersistEvictionInfoToDisk() - Successfully "
        "created file. [path=%s]", path.get()));
 
@@ -305,17 +306,17 @@ CacheFileContextEvictor::RemoveEvictInfo
   }
 
   nsAutoCString path;
   file->GetNativePath(path);
 
   rv = file->Remove(false);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG(("CacheFileContextEvictor::RemoveEvictionInfoFromDisk() - Removing file"
-         " failed! [path=%s, rv=0x%08x]", path.get(), rv));
+         " failed! [path=%s, rv=0x%08" PRIx32 "]", path.get(), static_cast<uint32_t>(rv)));
     return rv;
   }
 
   LOG(("CacheFileContextEvictor::RemoveEvictionInfoFromDisk() - Successfully "
        "removed file. [path=%s]", path.get()));
 
   return NS_OK;
 }
@@ -477,17 +478,17 @@ CacheFileContextEvictor::CreateIterators
 
   nsresult rv;
 
   for (uint32_t i = 0; i < mEntries.Length(); ) {
     rv = CacheIndex::GetIterator(mEntries[i]->mInfo, false,
                                  getter_AddRefs(mEntries[i]->mIterator));
     if (NS_FAILED(rv)) {
       LOG(("CacheFileContextEvictor::CreateIterators() - Cannot get an iterator"
-           ". [rv=0x%08x]", rv));
+           ". [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
       mEntries.RemoveElementAt(i);
       continue;
     }
 
     ++i;
   }
 }
 
@@ -524,17 +525,17 @@ CacheFileContextEvictor::StartEvicting()
   nsCOMPtr<nsIRunnable> ev;
   ev = NewRunnableMethod(this, &CacheFileContextEvictor::EvictEntries);
 
   RefPtr<CacheIOThread> ioThread = CacheFileIOManager::IOThread();
 
   nsresult rv = ioThread->Dispatch(ev, CacheIOThread::EVICT);
   if (NS_FAILED(rv)) {
     LOG(("CacheFileContextEvictor::StartEvicting() - Cannot dispatch event to "
-         "IO thread. [rv=0x%08x]", rv));
+         "IO thread. [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
   }
 
   mEvicting = true;
 }
 
 nsresult
 CacheFileContextEvictor::EvictEntries()
 {
@@ -640,17 +641,17 @@ CacheFileContextEvictor::EvictEntries()
     if (NS_FAILED(rv)) {
       LOG(("CacheFileContextEvictor::EvictEntries() - Cannot get last modified "
            "time, skipping entry."));
       continue;
     }
 
     if (lastModifiedTime > mEntries[0]->mTimeStamp) {
       LOG(("CacheFileContextEvictor::EvictEntries() - Skipping newer entry. "
-           "[mTimeStamp=%lld, lastModifiedTime=%lld]", mEntries[0]->mTimeStamp,
+           "[mTimeStamp=%" PRId64 ", lastModifiedTime=%" PRId64 "]", mEntries[0]->mTimeStamp,
            lastModifiedTime));
       continue;
     }
 
     LOG(("CacheFileContextEvictor::EvictEntries - Removing entry."));
     file->Remove(false);
     CacheIndex::RemoveEntry(&hash);
   }
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -22,16 +22,17 @@
 #include "nsICacheStorageVisitor.h"
 #include "nsISizeOf.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Services.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "private/pprio.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "nsNetUtil.h"
 
 // include files for ftruncate (or equivalent)
 #if defined(XP_UNIX)
 #include <unistd.h>
 #elif defined(XP_WIN)
 #include <windows.h>
@@ -86,17 +87,17 @@ CacheFileHandle::Release()
   nsrefcnt count = mRefCnt - 1;
   if (DispatchRelease()) {
     // Redispatched to the IO thread.
     return count;
   }
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
 
-  LOG(("CacheFileHandle::Release() [this=%p, refcnt=%d]", this, mRefCnt.get()));
+  LOG(("CacheFileHandle::Release() [this=%p, refcnt=%" PRIuPTR "]", this, mRefCnt.get()));
   NS_PRECONDITION(0 != mRefCnt, "dup release");
   count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "CacheFileHandle");
 
   if (0 == count) {
     mRefCnt = 1;
     delete (this);
     return 0;
@@ -173,27 +174,29 @@ CacheFileHandle::Log()
   nsAutoCString leafName;
   if (mFile) {
     mFile->GetNativeLeafName(leafName);
   }
 
   if (mSpecialFile) {
     LOG(("CacheFileHandle::Log() - special file [this=%p, "
          "isDoomed=%d, priority=%d, closed=%d, invalid=%d, "
-         "pinning=%d, fileExists=%d, fileSize=%lld, leafName=%s, key=%s]",
+         "pinning=%" PRIu32 ", fileExists=%d, fileSize=%" PRId64 ", leafName=%s, key=%s]",
          this,
          bool(mIsDoomed), bool(mPriority), bool(mClosed), bool(mInvalid),
-         mPinning, bool(mFileExists), mFileSize, leafName.get(), mKey.get()));
+         static_cast<uint32_t>(mPinning), bool(mFileExists), mFileSize, leafName.get(),
+         mKey.get()));
   } else {
     LOG(("CacheFileHandle::Log() - entry file [this=%p, hash=%08x%08x%08x%08x%08x, "
          "isDoomed=%d, priority=%d, closed=%d, invalid=%d, "
-         "pinning=%d, fileExists=%d, fileSize=%lld, leafName=%s, key=%s]",
+         "pinning=%" PRIu32 ", fileExists=%d, fileSize=%" PRId64 ", leafName=%s, key=%s]",
          this, LOGSHA1(mHash),
          bool(mIsDoomed), bool(mPriority), bool(mClosed), bool(mInvalid),
-         mPinning, bool(mFileExists), mFileSize, leafName.get(), mKey.get()));
+         static_cast<uint32_t>(mPinning), bool(mFileExists), mFileSize, leafName.get(),
+         mKey.get()));
   }
 }
 
 uint32_t
 CacheFileHandle::FileSizeInK() const
 {
   MOZ_ASSERT(mFileSize != -1);
   uint64_t size64 = mFileSize;
@@ -1587,17 +1590,17 @@ CacheFileIOManager::OpenFileInternal(con
       CacheIndex::RemoveEntry(aHash);
 
       LOG(("CacheFileIOManager::OpenFileInternal() - Removing old file from "
            "disk"));
       rv = file->Remove(false);
       if (NS_FAILED(rv)) {
         NS_WARNING("Cannot remove old entry from the disk");
         LOG(("CacheFileIOManager::OpenFileInternal() - Removing old file failed"
-             ". [rv=0x%08x]", rv));
+             ". [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
       }
     }
 
     CacheIndex::AddEntry(aHash);
     handle->mFile.swap(file);
     handle->mFileSize = 0;
   }
 
@@ -1711,17 +1714,17 @@ CacheFileIOManager::OpenSpecialFileInter
 
     if (exists) {
       LOG(("CacheFileIOManager::OpenSpecialFileInternal() - Removing file from "
            "disk"));
       rv = file->Remove(false);
       if (NS_FAILED(rv)) {
         NS_WARNING("Cannot remove old entry from the disk");
         LOG(("CacheFileIOManager::OpenSpecialFileInternal() - Removing file "
-             "failed. [rv=0x%08x]", rv));
+             "failed. [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
       }
     }
 
     handle->mFile.swap(file);
     handle->mFileSize = 0;
   }
 
   if (handle) {
@@ -1799,17 +1802,17 @@ CacheFileIOManager::CloseHandleInternal(
 }
 
 // static
 nsresult
 CacheFileIOManager::Read(CacheFileHandle *aHandle, int64_t aOffset,
                          char *aBuf, int32_t aCount,
                          CacheFileIOListener *aCallback)
 {
-  LOG(("CacheFileIOManager::Read() [handle=%p, offset=%lld, count=%d, "
+  LOG(("CacheFileIOManager::Read() [handle=%p, offset=%" PRId64 ", count=%d, "
        "listener=%p]", aHandle, aOffset, aCount, aCallback));
 
   if (CacheObserver::ShuttingDown()) {
     LOG(("  no reads after shutdown"));
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   nsresult rv;
@@ -1828,17 +1831,17 @@ CacheFileIOManager::Read(CacheFileHandle
 
   return NS_OK;
 }
 
 nsresult
 CacheFileIOManager::ReadInternal(CacheFileHandle *aHandle, int64_t aOffset,
                                  char *aBuf, int32_t aCount)
 {
-  LOG(("CacheFileIOManager::ReadInternal() [handle=%p, offset=%lld, count=%d]",
+  LOG(("CacheFileIOManager::ReadInternal() [handle=%p, offset=%" PRId64 ", count=%d]",
        aHandle, aOffset, aCount));
 
   nsresult rv;
 
   if (CacheObserver::ShuttingDown()) {
     LOG(("  no reads after shutdown"));
     return NS_ERROR_NOT_INITIALIZED;
   }
@@ -1877,17 +1880,17 @@ CacheFileIOManager::ReadInternal(CacheFi
 }
 
 // static
 nsresult
 CacheFileIOManager::Write(CacheFileHandle *aHandle, int64_t aOffset,
                           const char *aBuf, int32_t aCount, bool aValidate,
                           bool aTruncate, CacheFileIOListener *aCallback)
 {
-  LOG(("CacheFileIOManager::Write() [handle=%p, offset=%lld, count=%d, "
+  LOG(("CacheFileIOManager::Write() [handle=%p, offset=%" PRId64 ", count=%d, "
        "validate=%d, truncate=%d, listener=%p]", aHandle, aOffset, aCount,
        aValidate, aTruncate, aCallback));
 
   nsresult rv;
   RefPtr<CacheFileIOManager> ioMan = gInstance;
 
   if (aHandle->IsClosed() || (aCallback && aCallback->IsKilled()) || !ioMan) {
     if (!aCallback) {
@@ -1933,17 +1936,17 @@ TruncFile(PRFileDesc *aFD, int64_t aEOF)
   return NS_OK;
 }
 
 nsresult
 CacheFileIOManager::WriteInternal(CacheFileHandle *aHandle, int64_t aOffset,
                                   const char *aBuf, int32_t aCount,
                                   bool aValidate, bool aTruncate)
 {
-  LOG(("CacheFileIOManager::WriteInternal() [handle=%p, offset=%lld, count=%d, "
+  LOG(("CacheFileIOManager::WriteInternal() [handle=%p, offset=%" PRId64 ", count=%d, "
        "validate=%d, truncate=%d]", aHandle, aOffset, aCount, aValidate,
        aTruncate));
 
   nsresult rv;
 
   if (aHandle->mKilled) {
     LOG(("  handle already killed, nothing written"));
     return NS_OK;
@@ -1982,22 +1985,22 @@ CacheFileIOManager::WriteInternal(CacheF
   }
 
   // Check whether this write would cause critical low disk space.
   if (aHandle->mFileSize < aOffset + aCount) {
     int64_t freeSpace = -1;
     rv = mCacheDirectory->GetDiskSpaceAvailable(&freeSpace);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       LOG(("CacheFileIOManager::WriteInternal() - GetDiskSpaceAvailable() "
-           "failed! [rv=0x%08x]", rv));
+           "failed! [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
     } else {
       uint32_t limit = CacheObserver::DiskFreeSpaceHardLimit();
       if (freeSpace - aOffset - aCount + aHandle->mFileSize < limit) {
         LOG(("CacheFileIOManager::WriteInternal() - Low free space, refusing "
-             "to write! [freeSpace=%lld, limit=%u]", freeSpace, limit));
+             "to write! [freeSpace=%" PRId64 ", limit=%u]", freeSpace, limit));
         return NS_ERROR_FILE_DISK_FULL;
       }
     }
   }
 
   // Write invalidates the entry by default
   aHandle->mInvalid = true;
 
@@ -2237,17 +2240,17 @@ CacheFileIOManager::DoomFileByKeyInterna
   }
 
   LOG(("CacheFileIOManager::DoomFileByKeyInternal() - Removing file from "
        "disk"));
   rv = file->Remove(false);
   if (NS_FAILED(rv)) {
     NS_WARNING("Cannot remove old entry from the disk");
     LOG(("CacheFileIOManager::DoomFileByKeyInternal() - Removing file failed. "
-         "[rv=0x%08x]", rv));
+         "[rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
   }
 
   CacheIndex::RemoveEntry(aHash);
 
   return NS_OK;
 }
 
 // static
@@ -2330,18 +2333,18 @@ CacheFileIOManager::MaybeReleaseNSPRHand
 }
 
 // static
 nsresult
 CacheFileIOManager::TruncateSeekSetEOF(CacheFileHandle *aHandle,
                                        int64_t aTruncatePos, int64_t aEOFPos,
                                        CacheFileIOListener *aCallback)
 {
-  LOG(("CacheFileIOManager::TruncateSeekSetEOF() [handle=%p, truncatePos=%lld, "
-       "EOFPos=%lld, listener=%p]", aHandle, aTruncatePos, aEOFPos, aCallback));
+  LOG(("CacheFileIOManager::TruncateSeekSetEOF() [handle=%p, truncatePos=%" PRId64 ", "
+       "EOFPos=%" PRId64 ", listener=%p]", aHandle, aTruncatePos, aEOFPos, aCallback));
 
   nsresult rv;
   RefPtr<CacheFileIOManager> ioMan = gInstance;
 
   if (aHandle->IsClosed() || (aCallback && aCallback->IsKilled()) || !ioMan) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
@@ -2474,17 +2477,17 @@ CacheFileIOManager::GetEntryInfo(const S
 }
 
 nsresult
 CacheFileIOManager::TruncateSeekSetEOFInternal(CacheFileHandle *aHandle,
                                                int64_t aTruncatePos,
                                                int64_t aEOFPos)
 {
   LOG(("CacheFileIOManager::TruncateSeekSetEOFInternal() [handle=%p, "
-       "truncatePos=%lld, EOFPos=%lld]", aHandle, aTruncatePos, aEOFPos));
+       "truncatePos=%" PRId64 ", EOFPos=%" PRId64 "]", aHandle, aTruncatePos, aEOFPos));
 
   nsresult rv;
 
   if (aHandle->mKilled) {
     LOG(("  handle already killed, file not truncated"));
     return NS_OK;
   }
 
@@ -2514,22 +2517,23 @@ CacheFileIOManager::TruncateSeekSetEOFIn
   }
 
   // Check whether this operation would cause critical low disk space.
   if (aHandle->mFileSize < aEOFPos) {
     int64_t freeSpace = -1;
     rv = mCacheDirectory->GetDiskSpaceAvailable(&freeSpace);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       LOG(("CacheFileIOManager::TruncateSeekSetEOFInternal() - "
-           "GetDiskSpaceAvailable() failed! [rv=0x%08x]", rv));
+           "GetDiskSpaceAvailable() failed! [rv=0x%08" PRIx32 "]",
+           static_cast<uint32_t>(rv)));
     } else {
       uint32_t limit = CacheObserver::DiskFreeSpaceHardLimit();
       if (freeSpace - aEOFPos + aHandle->mFileSize < limit) {
         LOG(("CacheFileIOManager::TruncateSeekSetEOFInternal() - Low free space"
-             ", refusing to write! [freeSpace=%lld, limit=%u]", freeSpace,
+             ", refusing to write! [freeSpace=%" PRId64 ", limit=%u]", freeSpace,
              limit));
         return NS_ERROR_FILE_DISK_FULL;
       }
     }
   }
 
   // This operation always invalidates the entry
   aHandle->mInvalid = true;
@@ -2624,17 +2628,17 @@ CacheFileIOManager::RenameFileInternal(C
 
   if (exists) {
     LOG(("CacheFileIOManager::RenameFileInternal() - Removing old file from "
          "disk"));
     rv = file->Remove(false);
     if (NS_FAILED(rv)) {
       NS_WARNING("Cannot remove file from the disk");
       LOG(("CacheFileIOManager::RenameFileInternal() - Removing old file failed"
-           ". [rv=0x%08x]", rv));
+           ". [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
     }
   }
 
   if (!aHandle->FileExists()) {
     aHandle->mKey = aNewName;
     return NS_OK;
   }
 
@@ -2694,33 +2698,34 @@ CacheFileIOManager::EvictIfOverLimitInte
 
   int64_t freeSpace;
   rv = mCacheDirectory->GetDiskSpaceAvailable(&freeSpace);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     freeSpace = -1;
 
     // Do not change smart size.
     LOG(("CacheFileIOManager::EvictIfOverLimitInternal() - "
-         "GetDiskSpaceAvailable() failed! [rv=0x%08x]", rv));
+         "GetDiskSpaceAvailable() failed! [rv=0x%08" PRIx32 "]",
+         static_cast<uint32_t>(rv)));
   } else {
     UpdateSmartCacheSize(freeSpace);
   }
 
   uint32_t cacheUsage;
   rv = CacheIndex::GetCacheSize(&cacheUsage);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t cacheLimit = CacheObserver::DiskCacheCapacity() >> 10;
   uint32_t freeSpaceLimit = CacheObserver::DiskFreeSpaceSoftLimit();
 
   if (cacheUsage <= cacheLimit &&
       (freeSpace == -1 || freeSpace >= freeSpaceLimit)) {
     LOG(("CacheFileIOManager::EvictIfOverLimitInternal() - Cache size and free "
          "space in limits. [cacheSize=%ukB, cacheSizeLimit=%ukB, "
-         "freeSpace=%lld, freeSpaceLimit=%u]", cacheUsage, cacheLimit,
+         "freeSpace=%" PRId64 ", freeSpaceLimit=%u]", cacheUsage, cacheLimit,
          freeSpace, freeSpaceLimit));
     return NS_OK;
   }
 
   LOG(("CacheFileIOManager::EvictIfOverLimitInternal() - Cache size exceeded "
        "limit. Starting overlimit eviction. [cacheSize=%u, limit=%u]",
        cacheUsage, cacheLimit));
 
@@ -2756,39 +2761,40 @@ CacheFileIOManager::OverLimitEvictionInt
   }
 
   while (true) {
     int64_t freeSpace = -1;
     rv = mCacheDirectory->GetDiskSpaceAvailable(&freeSpace);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       // Do not change smart size.
       LOG(("CacheFileIOManager::EvictIfOverLimitInternal() - "
-           "GetDiskSpaceAvailable() failed! [rv=0x%08x]", rv));
+           "GetDiskSpaceAvailable() failed! [rv=0x%08" PRIx32 "]",
+           static_cast<uint32_t>(rv)));
     } else {
       UpdateSmartCacheSize(freeSpace);
     }
 
     uint32_t cacheUsage;
     rv = CacheIndex::GetCacheSize(&cacheUsage);
     NS_ENSURE_SUCCESS(rv, rv);
 
     uint32_t cacheLimit = CacheObserver::DiskCacheCapacity() >> 10;
     uint32_t freeSpaceLimit = CacheObserver::DiskFreeSpaceSoftLimit();
 
     if (cacheUsage > cacheLimit) {
       LOG(("CacheFileIOManager::OverLimitEvictionInternal() - Cache size over "
            "limit. [cacheSize=%u, limit=%u]", cacheUsage, cacheLimit));
     } else if (freeSpace != 1 && freeSpace < freeSpaceLimit) {
       LOG(("CacheFileIOManager::OverLimitEvictionInternal() - Free space under "
-           "limit. [freeSpace=%lld, freeSpaceLimit=%u]", freeSpace,
+           "limit. [freeSpace=%" PRId64 ", freeSpaceLimit=%u]", freeSpace,
            freeSpaceLimit));
     } else {
       LOG(("CacheFileIOManager::OverLimitEvictionInternal() - Cache size and "
            "free space in limits. [cacheSize=%ukB, cacheSizeLimit=%ukB, "
-           "freeSpace=%lld, freeSpaceLimit=%u]", cacheUsage, cacheLimit,
+           "freeSpace=%" PRId64 ", freeSpaceLimit=%u]", cacheUsage, cacheLimit,
            freeSpace, freeSpaceLimit));
       return NS_OK;
     }
 
     if (CacheIOThread::YieldAndRerun()) {
       LOG(("CacheFileIOManager::OverLimitEvictionInternal() - Breaking loop "
            "for higher level events."));
       mOverLimitEvicting = true;
@@ -2801,30 +2807,32 @@ CacheFileIOManager::OverLimitEvictionInt
     rv = CacheIndex::GetEntryForEviction(false, &hash, &cnt);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = DoomFileByKeyInternal(&hash);
     if (NS_SUCCEEDED(rv)) {
       consecutiveFailures = 0;
     } else if (rv == NS_ERROR_NOT_AVAILABLE) {
       LOG(("CacheFileIOManager::OverLimitEvictionInternal() - "
-           "DoomFileByKeyInternal() failed. [rv=0x%08x]", rv));
+           "DoomFileByKeyInternal() failed. [rv=0x%08" PRIx32 "]",
+           static_cast<uint32_t>(rv)));
       // TODO index is outdated, start update
 
       // Make sure index won't return the same entry again
       CacheIndex::RemoveEntry(&hash);
       consecutiveFailures = 0;
     } else {
       // This shouldn't normally happen, but the eviction must not fail
       // completely if we ever encounter this problem.
       NS_WARNING("CacheFileIOManager::OverLimitEvictionInternal() - Unexpected "
                  "failure of DoomFileByKeyInternal()");
 
       LOG(("CacheFileIOManager::OverLimitEvictionInternal() - "
-           "DoomFileByKeyInternal() failed. [rv=0x%08x]", rv));
+           "DoomFileByKeyInternal() failed. [rv=0x%08" PRIx32 "]",
+           static_cast<uint32_t>(rv)));
 
       // Normally, CacheIndex::UpdateEntry() is called only to update newly
       // created/opened entries which are always fresh and UpdateEntry() expects
       // and checks this flag. The way we use UpdateEntry() here is a kind of
       // hack and we must make sure the flag is set by calling
       // EnsureEntryExists().
       rv = CacheIndex::EnsureEntryExists(&hash);
       NS_ENSURE_SUCCESS(rv, rv);
@@ -3147,18 +3155,18 @@ CacheFileIOManager::TrashDirectory(nsIFi
   // When the directory is empty, it is cheaper to remove it directly instead of
   // using the trash mechanism.
   bool isEmpty;
   rv = IsEmptyDirectory(aFile, &isEmpty);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (isEmpty) {
     rv = aFile->Remove(false);
-    LOG(("CacheFileIOManager::TrashDirectory() - Directory removed [rv=0x%08x]",
-         rv));
+    LOG(("CacheFileIOManager::TrashDirectory() - Directory removed [rv=0x%08" PRIx32 "]",
+         static_cast<uint32_t>(rv)));
     return rv;
   }
 
 #ifdef DEBUG
   nsCOMPtr<nsIFile> dirCheck;
   rv = aFile->GetParent(getter_AddRefs(dirCheck));
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -3463,17 +3471,17 @@ CacheFileIOManager::FindTrashDirToRemove
 
 // static
 nsresult
 CacheFileIOManager::InitIndexEntry(CacheFileHandle *aHandle,
                                    OriginAttrsHash  aOriginAttrsHash,
                                    bool             aAnonymous,
                                    bool             aPinning)
 {
-  LOG(("CacheFileIOManager::InitIndexEntry() [handle=%p, originAttrsHash=%llx, "
+  LOG(("CacheFileIOManager::InitIndexEntry() [handle=%p, originAttrsHash=%" PRIx64 ", "
        "anonymous=%d, pinning=%d]", aHandle, aOriginAttrsHash, aAnonymous,
        aPinning));
 
   nsresult rv;
   RefPtr<CacheFileIOManager> ioMan = gInstance;
 
   if (aHandle->IsClosed() || !ioMan) {
     return NS_ERROR_NOT_INITIALIZED;
@@ -3899,30 +3907,32 @@ CacheFileIOManager::OpenNSPRHandle(Cache
         }
       } else {
         LOG(("CacheFileIOManager::OpenNSPRHandle() - Couldn't evict an existing"
              " entry."));
         rv = NS_ERROR_FILE_NO_DEVICE_SPACE;
       }
     }
     if (NS_FAILED(rv)) {
-      LOG(("CacheFileIOManager::OpenNSPRHandle() Create failed with 0x%08x", rv));
+      LOG(("CacheFileIOManager::OpenNSPRHandle() Create failed with 0x%08" PRIx32,
+           static_cast<uint32_t>(rv)));
     }
     NS_ENSURE_SUCCESS(rv, rv);
 
     aHandle->mFileExists = true;
   } else {
     rv = aHandle->mFile->OpenNSPRFileDesc(PR_RDWR, 0600, &aHandle->mFD);
     if (NS_ERROR_FILE_NOT_FOUND == rv) {
       LOG(("  file doesn't exists"));
       aHandle->mFileExists = false;
       return DoomFileInternal(aHandle);
     }
     if (NS_FAILED(rv)) {
-      LOG(("CacheFileIOManager::OpenNSPRHandle() Open failed with 0x%08x", rv));
+      LOG(("CacheFileIOManager::OpenNSPRHandle() Open failed with 0x%08" PRIx32,
+           static_cast<uint32_t>(rv)));
     }
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   mHandlesByLastUsed.AppendElement(aHandle);
 
   LOG(("CacheFileIOManager::OpenNSPRHandle END, handle=%p", aHandle));
 
@@ -3966,18 +3976,18 @@ CacheFileIOManager::SyncRemoveDir(nsIFil
     nsAutoCString path;
     file->GetNativePath(path);
     LOG(("CacheFileIOManager::SyncRemoveDir() - Removing directory %s",
          path.get()));
   }
 
   rv = file->Remove(true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
-    LOG(("CacheFileIOManager::SyncRemoveDir() - Removing failed! [rv=0x%08x]",
-         rv));
+    LOG(("CacheFileIOManager::SyncRemoveDir() - Removing failed! [rv=0x%08" PRIx32 "]",
+         static_cast<uint32_t>(rv)));
   }
 
   return rv;
 }
 
 void
 CacheFileIOManager::SyncRemoveAllCacheFiles()
 {
@@ -3997,18 +4007,18 @@ CacheFileIOManager::SyncRemoveAllCacheFi
     rv = FindTrashDirToRemove();
     if (rv == NS_ERROR_NOT_AVAILABLE) {
       LOG(("CacheFileIOManager::SyncRemoveAllCacheFiles() - No trash directory "
            "found."));
       break;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       LOG(("CacheFileIOManager::SyncRemoveAllCacheFiles() - "
-           "FindTrashDirToRemove() returned an unexpected error. [rv=0x%08x]",
-           rv));
+           "FindTrashDirToRemove() returned an unexpected error. [rv=0x%08" PRIx32 "]",
+           static_cast<uint32_t>(rv)));
       break;
     }
 
     rv = SyncRemoveDir(mTrashDir, nullptr);
     if (NS_FAILED(rv)) {
       nsAutoCString leafName;
       mTrashDir->GetNativeLeafName(leafName);
       mFailedTrashDirs.AppendElement(leafName);
@@ -4093,17 +4103,17 @@ CacheFileIOManager::UpdateSmartCacheSize
   if (!isUpToDate) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   uint32_t cacheUsage;
   rv = CacheIndex::GetCacheSize(&cacheUsage);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG(("CacheFileIOManager::UpdateSmartCacheSize() - Cannot get cacheUsage! "
-         "[rv=0x%08x]", rv));
+         "[rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
     return rv;
   }
 
   mLastSmartSizeTime = TimeStamp::NowLoRes();
 
   uint32_t smartSize = SmartCacheSize(static_cast<uint32_t>(aFreeSpace / 1024) +
                                       cacheUsage);
 
--- a/netwerk/cache2/CacheFileInputStream.cpp
+++ b/netwerk/cache2/CacheFileInputStream.cpp
@@ -79,24 +79,24 @@ CacheFileInputStream::Close()
 
 NS_IMETHODIMP
 CacheFileInputStream::Available(uint64_t *_retval)
 {
   CacheFileAutoLock lock(mFile);
 
   if (mClosed) {
     LOG(("CacheFileInputStream::Available() - Stream is closed. [this=%p, "
-         "status=0x%08x]", this, mStatus));
+         "status=0x%08" PRIx32 "]", this, static_cast<uint32_t>(mStatus)));
     return NS_FAILED(mStatus) ? mStatus : NS_BASE_STREAM_CLOSED;
   }
 
   EnsureCorrectChunk(false);
   if (NS_FAILED(mStatus)) {
     LOG(("CacheFileInputStream::Available() - EnsureCorrectChunk failed. "
-         "[this=%p, status=0x%08x]", this, mStatus));
+         "[this=%p, status=0x%08" PRIx32 "]", this, static_cast<uint32_t>(mStatus)));
     return mStatus;
   }
 
   nsresult rv = NS_OK;
   *_retval = 0;
 
   if (mChunk) {
     int64_t canRead = mFile->BytesFromChunk(mChunk->Index(), mAlternativeData);
@@ -104,18 +104,18 @@ CacheFileInputStream::Available(uint64_t
 
     if (canRead > 0) {
       *_retval = canRead;
     } else if (canRead == 0 && !mFile->OutputStreamExists(mAlternativeData)) {
       rv = NS_BASE_STREAM_CLOSED;
     }
   }
 
-  LOG(("CacheFileInputStream::Available() [this=%p, retval=%lld, rv=0x%08x]",
-       this, *_retval, rv));
+  LOG(("CacheFileInputStream::Available() [this=%p, retval=%" PRIu64 ", rv=0x%08" PRIx32 "]",
+       this, *_retval, static_cast<uint32_t>(rv)));
 
   return rv;
 }
 
 NS_IMETHODIMP
 CacheFileInputStream::Read(char *aBuf, uint32_t aCount, uint32_t *_retval)
 {
   LOG(("CacheFileInputStream::Read() [this=%p, count=%d]", this, aCount));
@@ -138,17 +138,17 @@ CacheFileInputStream::ReadSegments(nsWri
   if (mInReadSegments) {
     LOG(("CacheFileInputStream::ReadSegments() - Cannot be called while the "
          "stream is in ReadSegments!"));
     return NS_ERROR_UNEXPECTED;
   }
 
   if (mClosed) {
     LOG(("CacheFileInputStream::ReadSegments() - Stream is closed. [this=%p, "
-         "status=0x%08x]", this, mStatus));
+         "status=0x%08" PRIx32 "]", this, static_cast<uint32_t>(mStatus)));
 
     if NS_FAILED(mStatus)
       return mStatus;
 
     return NS_OK;
   }
 
   EnsureCorrectChunk(false);
@@ -224,18 +224,18 @@ CacheFileInputStream::ReadSegments(nsWri
       } else {
         rv = NS_OK;
       }
     }
 
     break;
   }
 
-  LOG(("CacheFileInputStream::ReadSegments() [this=%p, rv=0x%08x, retval=%d]",
-       this, rv, *_retval));
+  LOG(("CacheFileInputStream::ReadSegments() [this=%p, rv=0x%08" PRIx32 ", retval=%d]",
+       this, static_cast<uint32_t>(rv), *_retval));
 
   return rv;
 }
 
 NS_IMETHODIMP
 CacheFileInputStream::IsNonBlocking(bool *_retval)
 {
   *_retval = true;
@@ -243,27 +243,27 @@ CacheFileInputStream::IsNonBlocking(bool
 }
 
 // nsIAsyncInputStream
 NS_IMETHODIMP
 CacheFileInputStream::CloseWithStatus(nsresult aStatus)
 {
   CacheFileAutoLock lock(mFile);
 
-  LOG(("CacheFileInputStream::CloseWithStatus() [this=%p, aStatus=0x%08x]",
-       this, aStatus));
+  LOG(("CacheFileInputStream::CloseWithStatus() [this=%p, aStatus=0x%08" PRIx32 "]",
+       this, static_cast<uint32_t>(aStatus)));
 
   return CloseWithStatusLocked(aStatus);
 }
 
 nsresult
 CacheFileInputStream::CloseWithStatusLocked(nsresult aStatus)
 {
   LOG(("CacheFileInputStream::CloseWithStatusLocked() [this=%p, "
-       "aStatus=0x%08x]", this, aStatus));
+       "aStatus=0x%08" PRIx32 "]", this, static_cast<uint32_t>(aStatus)));
 
   if (mClosed) {
     // We notify listener and null out mCallback immediately after closing
     // the stream. If we're in ReadSegments we postpone notification until we
     // step out from ReadSegments. So if the stream is already closed the
     // following assertion must be true.
     MOZ_ASSERT(!mCallback || mInReadSegments);
 
@@ -342,17 +342,17 @@ CacheFileInputStream::AsyncWait(nsIInput
 }
 
 // nsISeekableStream
 NS_IMETHODIMP
 CacheFileInputStream::Seek(int32_t whence, int64_t offset)
 {
   CacheFileAutoLock lock(mFile);
 
-  LOG(("CacheFileInputStream::Seek() [this=%p, whence=%d, offset=%lld]",
+  LOG(("CacheFileInputStream::Seek() [this=%p, whence=%d, offset=%" PRId64 "]",
        this, whence, offset));
 
   if (mInReadSegments) {
     LOG(("CacheFileInputStream::Seek() - Cannot be called while the stream is "
          "in ReadSegments!"));
     return NS_ERROR_UNEXPECTED;
   }
 
@@ -380,17 +380,17 @@ CacheFileInputStream::Seek(int32_t whenc
       break;
     default:
       NS_ERROR("invalid whence");
       return NS_ERROR_INVALID_ARG;
   }
   mPos = newPos;
   EnsureCorrectChunk(false);
 
-  LOG(("CacheFileInputStream::Seek() [this=%p, pos=%lld]", this, mPos));
+  LOG(("CacheFileInputStream::Seek() [this=%p, pos=%" PRId64 "]", this, mPos));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 CacheFileInputStream::Tell(int64_t *_retval)
 {
   CacheFileAutoLock lock(mFile);
 
@@ -400,17 +400,17 @@ CacheFileInputStream::Tell(int64_t *_ret
   }
 
   *_retval = mPos;
 
   if (mAlternativeData) {
     *_retval -= mFile->mAltDataOffset;
   }
 
-  LOG(("CacheFileInputStream::Tell() [this=%p, retval=%lld]", this, *_retval));
+  LOG(("CacheFileInputStream::Tell() [this=%p, retval=%" PRId64 "]", this, *_retval));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 CacheFileInputStream::SetEOF()
 {
   MOZ_ASSERT(false, "Don't call SetEOF on cache input stream");
   return NS_ERROR_NOT_IMPLEMENTED;
@@ -432,25 +432,25 @@ CacheFileInputStream::OnChunkWritten(nsr
 }
 
 nsresult
 CacheFileInputStream::OnChunkAvailable(nsresult aResult, uint32_t aChunkIdx,
                                        CacheFileChunk *aChunk)
 {
   CacheFileAutoLock lock(mFile);
 
-  LOG(("CacheFileInputStream::OnChunkAvailable() [this=%p, result=0x%08x, "
-       "idx=%d, chunk=%p]", this, aResult, aChunkIdx, aChunk));
+  LOG(("CacheFileInputStream::OnChunkAvailable() [this=%p, result=0x%08" PRIx32 ", "
+       "idx=%d, chunk=%p]", this, static_cast<uint32_t>(aResult), aChunkIdx, aChunk));
 
   MOZ_ASSERT(mListeningForChunk != -1);
 
   if (mListeningForChunk != static_cast<int64_t>(aChunkIdx)) {
     // This is not a chunk that we're waiting for
     LOG(("CacheFileInputStream::OnChunkAvailable() - Notification is for a "
-         "different chunk. [this=%p, listeningForChunk=%lld]",
+         "different chunk. [this=%p, listeningForChunk=%" PRId64 "]",
          this, mListeningForChunk));
 
     return NS_OK;
   }
 
   MOZ_ASSERT(!mChunk);
   MOZ_ASSERT(!mWaitingForUpdate);
   MOZ_ASSERT(!mInReadSegments);
@@ -563,26 +563,27 @@ CacheFileInputStream::EnsureCorrectChunk
   MOZ_ASSERT(!mWaitingForUpdate);
 
   if (aReleaseOnly)
     return;
 
   if (mListeningForChunk == static_cast<int64_t>(chunkIdx)) {
     // We're already waiting for this chunk
     LOG(("CacheFileInputStream::EnsureCorrectChunk() - Already listening for "
-         "chunk %lld [this=%p]", mListeningForChunk, this));
+         "chunk %" PRId64 " [this=%p]", mListeningForChunk, this));
 
     return;
   }
 
   rv = mFile->GetChunkLocked(chunkIdx, CacheFile::READER, this,
                              getter_AddRefs(mChunk));
   if (NS_FAILED(rv)) {
     LOG(("CacheFileInputStream::EnsureCorrectChunk() - GetChunkLocked failed. "
-         "[this=%p, idx=%d, rv=0x%08x]", this, chunkIdx, rv));
+         "[this=%p, idx=%d, rv=0x%08" PRIx32 "]", this, chunkIdx,
+         static_cast<uint32_t>(rv)));
     if (rv != NS_ERROR_NOT_AVAILABLE) {
       // Close the stream with error. The consumer will receive this error later
       // in Read(), Available() etc. We need to handle NS_ERROR_NOT_AVAILABLE
       // differently since it is returned when the requested chunk is not
       // available and there is no writer that could create it, i.e. it means
       // that we've reached the end of the file.
       CloseWithStatusLocked(rv);
 
@@ -603,17 +604,17 @@ CacheFileInputStream::CanRead(CacheFileC
   MOZ_ASSERT(mChunk);
   MOZ_ASSERT(mPos / kChunkSize == mChunk->Index());
 
   int64_t retval = aHandle->Offset() + aHandle->DataSize() - mPos;
   if (retval <= 0 && NS_FAILED(mChunk->GetStatus())) {
     CloseWithStatusLocked(mChunk->GetStatus());
   }
 
-  LOG(("CacheFileInputStream::CanRead() [this=%p, canRead=%lld]",
+  LOG(("CacheFileInputStream::CanRead() [this=%p, canRead=%" PRId64 "]",
        this, retval));
 
   return retval;
 }
 
 void
 CacheFileInputStream::NotifyListener()
 {
@@ -643,19 +644,20 @@ CacheFileInputStream::NotifyListener()
 }
 
 void
 CacheFileInputStream::MaybeNotifyListener()
 {
   mFile->AssertOwnsLock();
 
   LOG(("CacheFileInputStream::MaybeNotifyListener() [this=%p, mCallback=%p, "
-       "mClosed=%d, mStatus=0x%08x, mChunk=%p, mListeningForChunk=%lld, "
-       "mWaitingForUpdate=%d]", this, mCallback.get(), mClosed, mStatus,
-       mChunk.get(), mListeningForChunk, mWaitingForUpdate));
+       "mClosed=%d, mStatus=0x%08" PRIx32 ", mChunk=%p, mListeningForChunk=%" PRId64 ", "
+       "mWaitingForUpdate=%d]", this, mCallback.get(), mClosed,
+       static_cast<uint32_t>(mStatus), mChunk.get(), mListeningForChunk,
+       mWaitingForUpdate));
 
   MOZ_ASSERT(!mInReadSegments);
 
   if (!mCallback)
     return;
 
   if (mClosed || NS_FAILED(mStatus)) {
     NotifyListener();
--- a/netwerk/cache2/CacheFileMetadata.cpp
+++ b/netwerk/cache2/CacheFileMetadata.cpp
@@ -11,16 +11,17 @@
 #include "CacheFileChunk.h"
 #include "CacheFileUtils.h"
 #include "nsILoadContextInfo.h"
 #include "nsICacheEntry.h" // for nsICacheEntryMetaDataVisitor
 #include "../cache/nsCacheUtils.h"
 #include "nsIFile.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/DebugOnly.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "prnetdb.h"
 
 
 namespace mozilla {
 namespace net {
 
 #define kMinMetadataRead 1024  // TODO find optimal value from telemetry
 #define kAlignSize       4096
@@ -181,17 +182,17 @@ CacheFileMetadata::ReadMetadata(CacheFil
     InitEmptyMetadata();
     aListener->OnMetadataRead(NS_OK);
     return NS_OK;
   }
 
   if (size < int64_t(sizeof(CacheFileMetadataHeader) + 2*sizeof(uint32_t))) {
     // there must be at least checksum, header and offset
     LOG(("CacheFileMetadata::ReadMetadata() - File is corrupted, creating "
-         "empty metadata. [this=%p, filesize=%lld]", this, size));
+         "empty metadata. [this=%p, filesize=%" PRId64 "]", this, size));
 
     InitEmptyMetadata();
     aListener->OnMetadataRead(NS_OK);
     return NS_OK;
   }
 
   // Set offset so that we read at least kMinMetadataRead if the file is big
   // enough.
@@ -206,25 +207,25 @@ CacheFileMetadata::ReadMetadata(CacheFil
   offset = (offset / kAlignSize) * kAlignSize;
 
   mBufSize = size - offset;
   mBuf = static_cast<char *>(moz_xmalloc(mBufSize));
 
   DoMemoryReport(MemoryUsage());
 
   LOG(("CacheFileMetadata::ReadMetadata() - Reading metadata from disk, trying "
-       "offset=%lld, filesize=%lld [this=%p]", offset, size, this));
+       "offset=%" PRId64 ", filesize=%" PRId64 " [this=%p]", offset, size, this));
 
   mReadStart = mozilla::TimeStamp::Now();
   mListener = aListener;
   rv = CacheFileIOManager::Read(mHandle, offset, mBuf, mBufSize, this);
   if (NS_FAILED(rv)) {
     LOG(("CacheFileMetadata::ReadMetadata() - CacheFileIOManager::Read() failed"
-         " synchronously, creating empty metadata. [this=%p, rv=0x%08x]",
-         this, rv));
+         " synchronously, creating empty metadata. [this=%p, rv=0x%08" PRIx32 "]",
+         this, static_cast<uint32_t>(rv)));
 
     mListener = nullptr;
     InitEmptyMetadata();
     aListener->OnMetadataRead(NS_OK);
     return NS_OK;
   }
 
   return NS_OK;
@@ -289,17 +290,18 @@ CacheFileMetadata::WriteMetadata(uint32_
     // released by CacheFileIOManager. Just null out mWriteBuf here.
     mWriteBuf = nullptr;
   }
 
   rv = CacheFileIOManager::Write(mHandle, aOffset, writeBuffer, p - writeBuffer,
                                  true, true, aListener ? this : nullptr);
   if (NS_FAILED(rv)) {
     LOG(("CacheFileMetadata::WriteMetadata() - CacheFileIOManager::Write() "
-         "failed synchronously. [this=%p, rv=0x%08x]", this, rv));
+         "failed synchronously. [this=%p, rv=0x%08" PRIx32 "]",
+         this, static_cast<uint32_t>(rv)));
 
     mListener = nullptr;
     if (mWriteBuf) {
       CacheFileUtils::FreeBuffer(mWriteBuf);
       mWriteBuf = nullptr;
     }
     NS_ENSURE_SUCCESS(rv, rv);
   }
@@ -636,18 +638,18 @@ CacheFileMetadata::OnFileOpened(CacheFil
   MOZ_CRASH("CacheFileMetadata::OnFileOpened should not be called!");
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 CacheFileMetadata::OnDataWritten(CacheFileHandle *aHandle, const char *aBuf,
                                  nsresult aResult)
 {
-  LOG(("CacheFileMetadata::OnDataWritten() [this=%p, handle=%p, result=0x%08x]",
-       this, aHandle, aResult));
+  LOG(("CacheFileMetadata::OnDataWritten() [this=%p, handle=%p, result=0x%08" PRIx32 "]",
+       this, aHandle, static_cast<uint32_t>(aResult)));
 
   MOZ_ASSERT(mListener);
   MOZ_ASSERT(mWriteBuf);
 
   CacheFileUtils::FreeBuffer(mWriteBuf);
   mWriteBuf = nullptr;
 
   nsCOMPtr<CacheFileMetadataListener> listener;
@@ -659,27 +661,28 @@ CacheFileMetadata::OnDataWritten(CacheFi
 
   return NS_OK;
 }
 
 nsresult
 CacheFileMetadata::OnDataRead(CacheFileHandle *aHandle, char *aBuf,
                               nsresult aResult)
 {
-  LOG(("CacheFileMetadata::OnDataRead() [this=%p, handle=%p, result=0x%08x]",
-       this, aHandle, aResult));
+  LOG(("CacheFileMetadata::OnDataRead() [this=%p, handle=%p, result=0x%08" PRIx32 "]",
+       this, aHandle, static_cast<uint32_t>(aResult)));
 
   MOZ_ASSERT(mListener);
 
   nsresult rv;
   nsCOMPtr<CacheFileMetadataListener> listener;
 
   if (NS_FAILED(aResult)) {
     LOG(("CacheFileMetadata::OnDataRead() - CacheFileIOManager::Read() failed"
-         ", creating empty metadata. [this=%p, rv=0x%08x]", this, aResult));
+         ", creating empty metadata. [this=%p, rv=0x%08" PRIx32 "]",
+         this, static_cast<uint32_t>(aResult)));
 
     InitEmptyMetadata();
 
     mListener.swap(listener);
     listener->OnMetadataRead(NS_OK);
     return NS_OK;
   }
 
@@ -697,32 +700,32 @@ CacheFileMetadata::OnDataRead(CacheFileH
   uint32_t realOffset = NetworkEndian::readUint32(mBuf + mBufSize -
                                                   sizeof(uint32_t));
 
   int64_t size = mHandle->FileSize();
   MOZ_ASSERT(size != -1);
 
   if (realOffset >= size) {
     LOG(("CacheFileMetadata::OnDataRead() - Invalid realOffset, creating "
-         "empty metadata. [this=%p, realOffset=%u, size=%lld]", this,
+         "empty metadata. [this=%p, realOffset=%u, size=%" PRId64 "]", this,
          realOffset, size));
 
     InitEmptyMetadata();
 
     mListener.swap(listener);
     listener->OnMetadataRead(NS_OK);
     return NS_OK;
   }
 
   uint32_t maxHashCount = size / kChunkSize;
   uint32_t maxMetadataSize = CalcMetadataSize(kMaxElementsSize, maxHashCount);
   if (size - realOffset > maxMetadataSize) {
     LOG(("CacheFileMetadata::OnDataRead() - Invalid realOffset, metadata would "
          "be too big, creating empty metadata. [this=%p, realOffset=%u, "
-         "maxMetadataSize=%u, size=%lld]", this, realOffset, maxMetadataSize,
+         "maxMetadataSize=%u, size=%" PRId64 "]", this, realOffset, maxMetadataSize,
          size));
 
     InitEmptyMetadata();
 
     mListener.swap(listener);
     listener->OnMetadataRead(NS_OK);
     return NS_OK;
   }
@@ -755,17 +758,17 @@ CacheFileMetadata::OnDataRead(CacheFileH
          "have full metadata. [this=%p]", missing, this));
 
     mFirstRead = false;
     mReadStart = mozilla::TimeStamp::Now();
     rv = CacheFileIOManager::Read(mHandle, realOffset, mBuf, missing, this);
     if (NS_FAILED(rv)) {
       LOG(("CacheFileMetadata::OnDataRead() - CacheFileIOManager::Read() "
            "failed synchronously, creating empty metadata. [this=%p, "
-           "rv=0x%08x]", this, rv));
+           "rv=0x%08" PRIx32 "]", this, static_cast<uint32_t>(rv)));
 
       InitEmptyMetadata();
 
       mListener.swap(listener);
       listener->OnMetadataRead(NS_OK);
       return NS_OK;
     }
 
--- a/netwerk/cache2/CacheFileOutputStream.cpp
+++ b/netwerk/cache2/CacheFileOutputStream.cpp
@@ -88,17 +88,17 @@ CacheFileOutputStream::Write(const char 
                              uint32_t *_retval)
 {
   CacheFileAutoLock lock(mFile);
 
   LOG(("CacheFileOutputStream::Write() [this=%p, count=%d]", this, aCount));
 
   if (mClosed) {
     LOG(("CacheFileOutputStream::Write() - Stream is closed. [this=%p, "
-         "status=0x%08x]", this, mStatus));
+         "status=0x%08" PRIx32"]", this, static_cast<uint32_t>(mStatus)));
 
     return NS_FAILED(mStatus) ? mStatus : NS_BASE_STREAM_CLOSED;
   }
 
   if (!mFile->mSkipSizeCheck && CacheObserver::EntryIsTooBig(mPos + aCount, !mFile->mMemoryOnly)) {
     LOG(("CacheFileOutputStream::Write() - Entry is too big, failing and "
          "dooming the entry. [this=%p]", this));
 
@@ -186,27 +186,27 @@ CacheFileOutputStream::IsNonBlocking(boo
 }
 
 // nsIAsyncOutputStream
 NS_IMETHODIMP
 CacheFileOutputStream::CloseWithStatus(nsresult aStatus)
 {
   CacheFileAutoLock lock(mFile);
 
-  LOG(("CacheFileOutputStream::CloseWithStatus() [this=%p, aStatus=0x%08x]",
-       this, aStatus));
+  LOG(("CacheFileOutputStream::CloseWithStatus() [this=%p, aStatus=0x%08" PRIx32 "]",
+       this, static_cast<uint32_t>(aStatus)));
 
   return CloseWithStatusLocked(aStatus);
 }
 
 nsresult
 CacheFileOutputStream::CloseWithStatusLocked(nsresult aStatus)
 {
   LOG(("CacheFileOutputStream::CloseWithStatusLocked() [this=%p, "
-       "aStatus=0x%08x]", this, aStatus));
+       "aStatus=0x%08" PRIx32 "]", this, static_cast<uint32_t>(aStatus)));
 
   if (mClosed) {
     MOZ_ASSERT(!mCallback);
     return NS_OK;
   }
 
   mClosed = true;
   mStatus = NS_FAILED(aStatus) ? aStatus : NS_BASE_STREAM_CLOSED;
@@ -251,17 +251,17 @@ CacheFileOutputStream::AsyncWait(nsIOutp
 }
 
 // nsISeekableStream
 NS_IMETHODIMP
 CacheFileOutputStream::Seek(int32_t whence, int64_t offset)
 {
   CacheFileAutoLock lock(mFile);
 
-  LOG(("CacheFileOutputStream::Seek() [this=%p, whence=%d, offset=%lld]",
+  LOG(("CacheFileOutputStream::Seek() [this=%p, whence=%d, offset=%" PRId64 "]",
        this, whence, offset));
 
   if (mClosed) {
     LOG(("CacheFileOutputStream::Seek() - Stream is closed. [this=%p]", this));
     return NS_BASE_STREAM_CLOSED;
   }
 
   int64_t newPos = offset;
@@ -283,17 +283,17 @@ CacheFileOutputStream::Seek(int32_t when
       break;
     default:
       NS_ERROR("invalid whence");
       return NS_ERROR_INVALID_ARG;
   }
   mPos = newPos;
   EnsureCorrectChunk(true);
 
-  LOG(("CacheFileOutputStream::Seek() [this=%p, pos=%lld]", this, mPos));
+  LOG(("CacheFileOutputStream::Seek() [this=%p, pos=%" PRId64 "]", this, mPos));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 CacheFileOutputStream::Tell(int64_t *_retval)
 {
   CacheFileAutoLock lock(mFile);
 
@@ -303,17 +303,17 @@ CacheFileOutputStream::Tell(int64_t *_re
   }
 
   *_retval = mPos;
 
   if (mAlternativeData) {
     *_retval -= mFile->mAltDataOffset;
   }
 
-  LOG(("CacheFileOutputStream::Tell() [this=%p, retval=%lld]", this, *_retval));
+  LOG(("CacheFileOutputStream::Tell() [this=%p, retval=%" PRId64 "]", this, *_retval));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 CacheFileOutputStream::SetEOF()
 {
   MOZ_ASSERT(false, "CacheFileOutputStream::SetEOF() not implemented");
   // Right now we don't use SetEOF(). If we ever need this method, we need
@@ -401,17 +401,18 @@ CacheFileOutputStream::EnsureCorrectChun
   if (aReleaseOnly)
     return;
 
   nsresult rv;
   rv = mFile->GetChunkLocked(chunkIdx, CacheFile::WRITER, nullptr,
                              getter_AddRefs(mChunk));
   if (NS_FAILED(rv)) {
     LOG(("CacheFileOutputStream::EnsureCorrectChunk() - GetChunkLocked failed. "
-         "[this=%p, idx=%d, rv=0x%08x]", this, chunkIdx, rv));
+         "[this=%p, idx=%d, rv=0x%08" PRIx32 "]", this, chunkIdx,
+         static_cast<uint32_t>(rv)));
     CloseWithStatusLocked(rv);
   }
 }
 
 void
 CacheFileOutputStream::FillHole()
 {
   mFile->AssertOwnsLock();
--- a/netwerk/cache2/CacheFileUtils.cpp
+++ b/netwerk/cache2/CacheFileUtils.cpp
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CacheIndex.h"
 #include "CacheLog.h"
 #include "CacheFileUtils.h"
 #include "LoadContextInfo.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Tokenizer.h"
 #include "mozilla/Telemetry.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsString.h"
 #include <algorithm>
 #include "mozilla/Unused.h"
 
@@ -313,17 +314,17 @@ ValidityPair::Merge(const ValidityPair& 
 
   mOffset = offset;
   mLen = end - offset;
 }
 
 void
 ValidityMap::Log() const
 {
-  LOG(("ValidityMap::Log() - number of pairs: %u", mMap.Length()));
+  LOG(("ValidityMap::Log() - number of pairs: %" PRIuSIZE, mMap.Length()));
   for (uint32_t i=0; i<mMap.Length(); i++) {
     LOG(("    (%u, %u)", mMap[i].Offset() + 0, mMap[i].Len() + 0));
   }
 }
 
 uint32_t
 ValidityMap::Length() const
 {
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -350,17 +350,17 @@ CacheIndex::PreShutdown()
 
   LOG(("CacheIndex::PreShutdown() - Closing iterators."));
   for (uint32_t i = 0; i < index->mIterators.Length(); ) {
     rv = index->mIterators[i]->CloseInternal(NS_ERROR_FAILURE);
     if (NS_FAILED(rv)) {
       // CacheIndexIterator::CloseInternal() removes itself from mIteratos iff
       // it returns success.
       LOG(("CacheIndex::PreShutdown() - Failed to remove iterator %p. "
-           "[rv=0x%08x]", rv));
+           "[rv=0x%08" PRIx32 "]", index->mIterators[i], static_cast<uint32_t>(rv)));
       i++;
     }
   }
 
   index->mShuttingDown = true;
 
   if (index->mState == READY) {
     return NS_OK; // nothing to do
@@ -707,17 +707,17 @@ CacheIndex::EnsureEntryExists(const SHA1
 // static
 nsresult
 CacheIndex::InitEntry(const SHA1Sum::Hash *aHash,
                       OriginAttrsHash      aOriginAttrsHash,
                       bool                 aAnonymous,
                       bool                 aPinned)
 {
   LOG(("CacheIndex::InitEntry() [hash=%08x%08x%08x%08x%08x, "
-       "originAttrsHash=%llx, anonymous=%d, pinned=%d]", LOGSHA1(aHash),
+       "originAttrsHash=%" PRIx64 ", anonymous=%d, pinned=%d]", LOGSHA1(aHash),
        aOriginAttrsHash, aAnonymous, aPinned));
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   StaticMutexAutoLock lock(sLock);
 
   RefPtr<CacheIndex> index = gInstance;
 
@@ -1091,17 +1091,17 @@ CacheIndex::RemoveAll()
     index->mIndex.Clear();
 
     for (uint32_t i = 0; i < index->mIterators.Length(); ) {
       nsresult rv = index->mIterators[i]->CloseInternal(NS_ERROR_NOT_AVAILABLE);
       if (NS_FAILED(rv)) {
         // CacheIndexIterator::CloseInternal() removes itself from mIterators
         // iff it returns success.
         LOG(("CacheIndex::RemoveAll() - Failed to remove iterator %p. "
-             "[rv=0x%08x]", rv));
+             "[rv=0x%08" PRIx32 "]", index->mIterators[i], static_cast<uint32_t>(rv)));
         i++;
       }
     }
   }
 
   if (file) {
     // Ignore the result. The file might not exist and the failure is not fatal.
     file->Remove(false);
@@ -1453,17 +1453,17 @@ CacheIndex::IsUpToDate(bool *_retval)
 
   if (!index->IsIndexUsable()) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   *_retval = (index->mState == READY || index->mState == WRITING) &&
              !index->mIndexNeedsUpdate && !index->mShuttingDown;
 
-  LOG(("CacheIndex::IsUpToDate() - returning %p", *_retval));
+  LOG(("CacheIndex::IsUpToDate() - returning %d", *_retval));
   return NS_OK;
 }
 
 bool
 CacheIndex::IsIndexUsable()
 {
   MOZ_ASSERT(mState != INITIAL);
 
@@ -1491,18 +1491,18 @@ CacheIndex::IsCollision(CacheIndexEntry 
 {
   if (!aEntry->IsInitialized()) {
     return false;
   }
 
   if (aEntry->Anonymous() != aAnonymous ||
       aEntry->OriginAttrsHash() != aOriginAttrsHash) {
     LOG(("CacheIndex::IsCollision() - Collision detected for entry hash=%08x"
-         "%08x%08x%08x%08x, expected values: originAttrsHash=%llx, "
-         "anonymous=%d; actual values: originAttrsHash=%llx, anonymous=%d]",
+         "%08x%08x%08x%08x, expected values: originAttrsHash=%" PRIu64 ", "
+         "anonymous=%d; actual values: originAttrsHash=%" PRIu64 ", anonymous=%d]",
          LOGSHA1(aEntry->Hash()), aOriginAttrsHash, aAnonymous,
          aEntry->OriginAttrsHash(), aEntry->Anonymous()));
     return true;
   }
 
   return false;
 }
 
@@ -1628,17 +1628,18 @@ CacheIndex::WriteIndexToDisk()
   mProcessEntries = mIndexStats.ActiveEntriesCount();
 
   mIndexFileOpener = new FileOpenHelper(this);
   rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(TEMP_INDEX_NAME),
                                     CacheFileIOManager::SPECIAL_FILE |
                                     CacheFileIOManager::CREATE,
                                     mIndexFileOpener);
   if (NS_FAILED(rv)) {
-    LOG(("CacheIndex::WriteIndexToDisk() - Can't open file [rv=0x%08x]", rv));
+    LOG(("CacheIndex::WriteIndexToDisk() - Can't open file [rv=0x%08" PRIx32 "]",
+         static_cast<uint32_t>(rv)));
     FinishWrite(false);
     return;
   }
 
   // Write index header to a buffer, it will be written to disk together with
   // records in WriteRecords() once we open the file successfully.
   AllocBuffer();
   mRWHash = new CacheHash();
@@ -1737,17 +1738,17 @@ CacheIndex::WriteRecords()
   } else {
     MOZ_ASSERT(hasMore);
   }
 
   rv = CacheFileIOManager::Write(mIndexHandle, fileOffset, mRWBuf, mRWBufPos,
                                  mSkipEntries == mProcessEntries, false, this);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::WriteRecords() - CacheFileIOManager::Write() failed "
-         "synchronously [rv=0x%08x]", rv));
+         "synchronously [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
     FinishWrite(false);
   } else {
     mRWPending = true;
   }
 
   mRWBufPos = 0;
 }
 
@@ -2042,40 +2043,41 @@ CacheIndex::ReadIndexFromDisk()
 
   mIndexFileOpener = new FileOpenHelper(this);
   rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(INDEX_NAME),
                                     CacheFileIOManager::SPECIAL_FILE |
                                     CacheFileIOManager::OPEN,
                                     mIndexFileOpener);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::ReadIndexFromDisk() - CacheFileIOManager::OpenFile() "
-         "failed [rv=0x%08x, file=%s]", rv, INDEX_NAME));
+         "failed [rv=0x%08" PRIx32 ", file=%s]", static_cast<uint32_t>(rv), INDEX_NAME));
     FinishRead(false);
     return;
   }
 
   mJournalFileOpener = new FileOpenHelper(this);
   rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(JOURNAL_NAME),
                                     CacheFileIOManager::SPECIAL_FILE |
                                     CacheFileIOManager::OPEN,
                                     mJournalFileOpener);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::ReadIndexFromDisk() - CacheFileIOManager::OpenFile() "
-         "failed [rv=0x%08x, file=%s]", rv, JOURNAL_NAME));
+         "failed [rv=0x%08" PRIx32 ", file=%s]", static_cast<uint32_t>(rv), JOURNAL_NAME));
     FinishRead(false);
   }
 
   mTmpFileOpener = new FileOpenHelper(this);
   rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(TEMP_INDEX_NAME),
                                     CacheFileIOManager::SPECIAL_FILE |
                                     CacheFileIOManager::OPEN,
                                     mTmpFileOpener);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::ReadIndexFromDisk() - CacheFileIOManager::OpenFile() "
-         "failed [rv=0x%08x, file=%s]", rv, TEMP_INDEX_NAME));
+         "failed [rv=0x%08" PRIx32 ", file=%s]", static_cast<uint32_t>(rv),
+         TEMP_INDEX_NAME));
     FinishRead(false);
   }
 }
 
 void
 CacheIndex::StartReadingIndex()
 {
   LOG(("CacheIndex::StartReadingIndex()"));
@@ -2106,17 +2108,17 @@ CacheIndex::StartReadingIndex()
   mRWHash = new CacheHash();
 
   mRWBufPos = std::min(mRWBufSize,
                        static_cast<uint32_t>(mIndexHandle->FileSize()));
 
   rv = CacheFileIOManager::Read(mIndexHandle, 0, mRWBuf, mRWBufPos, this);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::StartReadingIndex() - CacheFileIOManager::Read() failed "
-         "synchronously [rv=0x%08x]", rv));
+         "synchronously [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
     FinishRead(false);
   } else {
     mRWPending = true;
   }
 }
 
 void
 CacheIndex::ParseRecords()
@@ -2233,17 +2235,17 @@ CacheIndex::ParseRecords()
                              static_cast<uint32_t>(mIndexHandle->FileSize() -
                                                    fileOffset));
   mRWBufPos = pos + toRead;
 
   rv = CacheFileIOManager::Read(mIndexHandle, fileOffset, mRWBuf + pos, toRead,
                                 this);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::ParseRecords() - CacheFileIOManager::Read() failed "
-         "synchronously [rv=0x%08x]", rv));
+         "synchronously [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
     FinishRead(false);
     return;
   } else {
     mRWPending = true;
   }
 }
 
 void
@@ -2274,17 +2276,17 @@ CacheIndex::StartReadingJournal()
   mRWHash = new CacheHash();
 
   mRWBufPos = std::min(mRWBufSize,
                        static_cast<uint32_t>(mJournalHandle->FileSize()));
 
   rv = CacheFileIOManager::Read(mJournalHandle, 0, mRWBuf, mRWBufPos, this);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::StartReadingJournal() - CacheFileIOManager::Read() failed"
-         " synchronously [rv=0x%08x]", rv));
+         " synchronously [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
     FinishRead(false);
   } else {
     mRWPending = true;
   }
 }
 
 void
 CacheIndex::ParseJournal()
@@ -2353,17 +2355,17 @@ CacheIndex::ParseJournal()
                              static_cast<uint32_t>(mJournalHandle->FileSize() -
                                                    fileOffset));
   mRWBufPos = pos + toRead;
 
   rv = CacheFileIOManager::Read(mJournalHandle, fileOffset, mRWBuf + pos,
                                 toRead, this);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::ParseJournal() - CacheFileIOManager::Read() failed "
-         "synchronously [rv=0x%08x]", rv));
+         "synchronously [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(rv)));
     FinishRead(false);
     return;
   } else {
     mRWPending = true;
   }
 }
 
 void
@@ -2992,18 +2994,18 @@ CacheIndex::UpdateIndex()
       }
       if (NS_FAILED(rv)) {
         LOG(("CacheIndex::UpdateIndex() - Cannot get lastModifiedTime. "
              "[name=%s]", leaf.get()));
         // Assume the file is newer than index
       } else {
         if (mIndexTimeStamp > (lastModifiedTime / PR_MSEC_PER_SEC)) {
           LOG(("CacheIndex::UpdateIndex() - Skipping file because of last "
-               "modified time. [name=%s, indexTimeStamp=%u, "
-               "lastModifiedTime=%u]", leaf.get(), mIndexTimeStamp,
+               "modified time. [name=%s, indexTimeStamp=%" PRIu32 ", "
+               "lastModifiedTime=%" PRId64 "]", leaf.get(), mIndexTimeStamp,
                lastModifiedTime / PR_MSEC_PER_SEC));
 
           CacheIndexEntryAutoManage entryMng(&hash, this);
           entry->MarkFresh();
           continue;
         }
       }
     }
@@ -3385,17 +3387,17 @@ CacheIndex::Run()
   return NS_OK;
 }
 
 nsresult
 CacheIndex::OnFileOpenedInternal(FileOpenHelper *aOpener,
                                  CacheFileHandle *aHandle, nsresult aResult)
 {
   LOG(("CacheIndex::OnFileOpenedInternal() [opener=%p, handle=%p, "
-       "result=0x%08x]", aOpener, aHandle, aResult));
+       "result=0x%08" PRIx32 "]", aOpener, aHandle, static_cast<uint32_t>(aResult)));
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   nsresult rv;
 
   sLock.AssertCurrentThreadOwns();
 
   MOZ_RELEASE_ASSERT(IsIndexUsable());
@@ -3406,17 +3408,17 @@ CacheIndex::OnFileOpenedInternal(FileOpe
 
   switch (mState) {
     case WRITING:
       MOZ_ASSERT(aOpener == mIndexFileOpener);
       mIndexFileOpener = nullptr;
 
       if (NS_FAILED(aResult)) {
         LOG(("CacheIndex::OnFileOpenedInternal() - Can't open index file for "
-             "writing [rv=0x%08x]", aResult));
+             "writing [rv=0x%08" PRIx32 "]", static_cast<uint32_t>(aResult)));
         FinishWrite(false);
       } else {
         mIndexHandle = aHandle;
         WriteRecords();
       }
       break;
     case READING:
       if (aOpener == mIndexFileOpener) {
@@ -3467,17 +3469,18 @@ CacheIndex::OnFileOpenedInternal(FileOpe
 
       if (mJournalHandle) {
         // Rename journal to make sure we update index on next start in case
         // firefox crashes
         rv = CacheFileIOManager::RenameFile(
           mJournalHandle, NS_LITERAL_CSTRING(TEMP_INDEX_NAME), this);
         if (NS_FAILED(rv)) {
           LOG(("CacheIndex::OnFileOpenedInternal() - CacheFileIOManager::"
-               "RenameFile() failed synchronously [rv=0x%08x]", rv));
+               "RenameFile() failed synchronously [rv=0x%08" PRIx32 "]",
+               static_cast<uint32_t>(rv)));
           FinishRead(false);
           break;
         }
       } else {
         StartReadingIndex();
       }
 
       break;
@@ -3494,18 +3497,18 @@ CacheIndex::OnFileOpened(CacheFileHandle
   MOZ_CRASH("CacheIndex::OnFileOpened should not be called!");
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 CacheIndex::OnDataWritten(CacheFileHandle *aHandle, const char *aBuf,
                           nsresult aResult)
 {
-  LOG(("CacheIndex::OnDataWritten() [handle=%p, result=0x%08x]", aHandle,
-       aResult));
+  LOG(("CacheIndex::OnDataWritten() [handle=%p, result=0x%08" PRIx32 "]", aHandle,
+       static_cast<uint32_t>(aResult)));
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   nsresult rv;
 
   StaticMutexAutoLock lock(sLock);
 
   MOZ_RELEASE_ASSERT(IsIndexUsable());
@@ -3524,17 +3527,18 @@ CacheIndex::OnDataWritten(CacheFileHandl
         FinishWrite(false);
       } else {
         if (mSkipEntries == mProcessEntries) {
           rv = CacheFileIOManager::RenameFile(mIndexHandle,
                                               NS_LITERAL_CSTRING(INDEX_NAME),
                                               this);
           if (NS_FAILED(rv)) {
             LOG(("CacheIndex::OnDataWritten() - CacheFileIOManager::"
-                 "RenameFile() failed synchronously [rv=0x%08x]", rv));
+                 "RenameFile() failed synchronously [rv=0x%08" PRIx32 "]",
+                 static_cast<uint32_t>(rv)));
             FinishWrite(false);
           }
         } else {
           WriteRecords();
         }
       }
       break;
     default:
@@ -3545,18 +3549,18 @@ CacheIndex::OnDataWritten(CacheFileHandl
   }
 
   return NS_OK;
 }
 
 nsresult
 CacheIndex::OnDataRead(CacheFileHandle *aHandle, char *aBuf, nsresult aResult)
 {
-  LOG(("CacheIndex::OnDataRead() [handle=%p, result=0x%08x]", aHandle,
-       aResult));
+  LOG(("CacheIndex::OnDataRead() [handle=%p, result=0x%08" PRIx32 "]", aHandle,
+       static_cast<uint32_t>(aResult)));
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   StaticMutexAutoLock lock(sLock);
 
   MOZ_RELEASE_ASSERT(IsIndexUsable());
   MOZ_RELEASE_ASSERT(mRWPending);
   mRWPending = false;
@@ -3597,18 +3601,18 @@ CacheIndex::OnEOFSet(CacheFileHandle *aH
 {
   MOZ_CRASH("CacheIndex::OnEOFSet should not be called!");
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 CacheIndex::OnFileRenamed(CacheFileHandle *aHandle, nsresult aResult)
 {
-  LOG(("CacheIndex::OnFileRenamed() [handle=%p, result=0x%08x]", aHandle,
-       aResult));
+  LOG(("CacheIndex::OnFileRenamed() [handle=%p, result=0x%08" PRIx32 "]", aHandle,
+       static_cast<uint32_t>(aResult)));
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   StaticMutexAutoLock lock(sLock);
 
   MOZ_RELEASE_ASSERT(IsIndexUsable());
 
   if (mState == READY && mShuttingDown) {
--- a/netwerk/cache2/CacheIndex.h
+++ b/netwerk/cache2/CacheIndex.h
@@ -10,16 +10,17 @@
 #include "nsIRunnable.h"
 #include "CacheHashUtils.h"
 #include "nsICacheStorageService.h"
 #include "nsICacheEntry.h"
 #include "nsILoadContextInfo.h"
 #include "nsTHashtable.h"
 #include "nsThreadUtils.h"
 #include "nsWeakReference.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/SHA1.h"
 #include "mozilla/StaticMutex.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/EndianUtils.h"
 #include "mozilla/TimeStamp.h"
 
 class nsIFile;
 class nsIDirectoryEnumerator;
@@ -250,17 +251,17 @@ public:
     mRec->mOriginAttrsHash = NetworkEndian::readUint64(ptr); ptr += sizeof(uint64_t);
     mRec->mExpirationTime = NetworkEndian::readUint32(ptr); ptr += sizeof(uint32_t);
     mRec->mFlags = NetworkEndian::readUint32(ptr);
   }
 
   void Log() const {
     LOG(("CacheIndexEntry::Log() [this=%p, hash=%08x%08x%08x%08x%08x, fresh=%u,"
          " initialized=%u, removed=%u, dirty=%u, anonymous=%u, "
-         "originAttrsHash=%llx, frecency=%u, expirationTime=%u, size=%u]",
+         "originAttrsHash=%" PRIx64 ", frecency=%u, expirationTime=%u, size=%u]",
          this, LOGSHA1(mRec->mHash), IsFresh(), IsInitialized(), IsRemoved(),
          IsDirty(), Anonymous(), OriginAttrsHash(), GetFrecency(),
          GetExpirationTime(), GetFileSize()));
   }
 
   static bool RecordMatchesLoadContextInfo(CacheIndexRecord *aRec,
                                            nsILoadContextInfo *aInfo)
   {
--- a/netwerk/cache2/CacheIndexIterator.cpp
+++ b/netwerk/cache2/CacheIndexIterator.cpp
@@ -57,18 +57,18 @@ CacheIndexIterator::Close()
   StaticMutexAutoLock lock(CacheIndex::sLock);
 
   return CloseInternal(NS_ERROR_NOT_AVAILABLE);
 }
 
 nsresult
 CacheIndexIterator::CloseInternal(nsresult aStatus)
 {
-  LOG(("CacheIndexIterator::CloseInternal() [this=%p, status=0x%08x]", this,
-       aStatus));
+  LOG(("CacheIndexIterator::CloseInternal() [this=%p, status=0x%08" PRIx32 "]", this,
+       static_cast<uint32_t>(aStatus)));
 
   // Make sure status will be a failure
   MOZ_ASSERT(NS_FAILED(aStatus));
   if (NS_SUCCEEDED(aStatus)) {
     aStatus = NS_ERROR_UNEXPECTED;
   }
 
   if (NS_FAILED(mStatus)) {
--- a/netwerk/cache2/CacheStorageService.cpp
+++ b/netwerk/cache2/CacheStorageService.cpp
@@ -27,16 +27,18 @@
 #include "nsAutoPtr.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsServiceManagerUtils.h"
 #include "nsWeakReference.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Services.h"
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/SizePrintfMacros.h"
 
 namespace mozilla {
 namespace net {
 
 namespace {
 
 void AppendMemoryStorageID(nsAutoCString &key)
 {
@@ -286,17 +288,17 @@ private:
         mCallback->OnCacheStorageInfo(mEntryArray.Length(), mSize,
                                       CacheObserver::MemoryCacheCapacity(), nullptr);
         if (!mVisitEntries)
           return NS_OK; // done
 
         mNotifyStorage = false;
 
       } else {
-        LOG(("  entry [left=%d, canceled=%d]", mEntryArray.Length(), (bool)mCancel));
+        LOG(("  entry [left=%" PRIuSIZE ", canceled=%d]", mEntryArray.Length(), (bool)mCancel));
 
         // Third, notify each entry until depleted or canceled
         if (!mEntryArray.Length() || mCancel) {
           mCallback->OnCacheEntryVisitCompleted();
           return NS_OK; // done
         }
 
         // Grab the next entry
@@ -1297,17 +1299,17 @@ CacheStorageService::SchedulePurgeOverMe
     LOG(("  timer already up"));
     return;
   }
 
   mPurgeTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
   if (mPurgeTimer) {
     nsresult rv;
     rv = mPurgeTimer->InitWithCallback(this, 1000, nsITimer::TYPE_ONE_SHOT);
-    LOG(("  timer init rv=0x%08x", rv));
+    LOG(("  timer init rv=0x%08" PRIx32, static_cast<uint32_t>(rv)));
   }
 }
 
 NS_IMETHODIMP
 CacheStorageService::Notify(nsITimer* aTimer)
 {
   LOG(("CacheStorageService::Notify"));
 
@@ -1619,17 +1621,17 @@ CacheStorageService::CheckStorageEntry(C
 
   // Disk entry, not found in the hashtable, check the index.
   nsAutoCString fileKey;
   rv = CacheEntry::HashingKey(contextKey, aIdExtension, aURI, fileKey);
 
   CacheIndex::EntryStatus status;
   rv = CacheIndex::HasEntry(fileKey, &status);
   if (NS_FAILED(rv) || status == CacheIndex::DO_NOT_KNOW) {
-    LOG(("  index doesn't know, rv=0x%08x", rv));
+    LOG(("  index doesn't know, rv=0x%08" PRIx32, static_cast<uint32_t>(rv)));
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   *aResult = status == CacheIndex::EXISTS;
   LOG(("  %sfound in index", *aResult ? "" : "not "));
   return NS_OK;
 }
 
--- a/netwerk/cache2/OldWrappers.cpp
+++ b/netwerk/cache2/OldWrappers.cpp
@@ -16,16 +16,17 @@
 #include "nsICacheEntryDoomCallback.h"
 #include "nsICacheListener.h"
 #include "nsICacheStorageVisitor.h"
 
 #include "nsServiceManagerUtils.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsProxyRelease.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Telemetry.h"
 
 static NS_DEFINE_CID(kStreamTransportServiceCID,
                      NS_STREAMTRANSPORTSERVICE_CID);
 
 static uint32_t const CHECK_MULTITHREADED = nsICacheStorage::CHECK_MULTITHREADED;
 
 namespace mozilla {
@@ -768,17 +769,17 @@ NS_IMETHODIMP
       }
 
       rv = session->AsyncOpenCacheEntry(mCacheKey, cacheAccess, this, bypassBusy);
       if (NS_SUCCEEDED(rv))
         return NS_OK;
     }
 
     // Opening failed, propagate the error to the consumer
-    LOG(("  Opening cache entry failed with rv=0x%08x", rv));
+    LOG(("  Opening cache entry failed with rv=0x%08" PRIx32, static_cast<uint32_t>(rv)));
     mStatus = rv;
     mNew = false;
     NS_DispatchToMainThread(this);
   } else {
     if (!mCallback) {
       LOG(("  duplicate call, bypassed"));
       return NS_OK;
     }
@@ -807,17 +808,18 @@ NS_IMETHODIMP
     // break cycles
     nsCOMPtr<nsICacheEntryOpenCallback> cb = mCallback.forget();
     mCacheThread = nullptr;
     nsCOMPtr<nsICacheEntry> entry = mCacheEntry.forget();
 
     rv = cb->OnCacheEntryAvailable(entry, mNew, mAppCache, mStatus);
 
     if (NS_FAILED(rv) && entry) {
-      LOG(("  cb->OnCacheEntryAvailable failed with rv=0x%08x", rv));
+      LOG(("  cb->OnCacheEntryAvailable failed with rv=0x%08" PRIx32,
+           static_cast<uint32_t>(rv)));
       if (mNew)
         entry->AsyncDoom(nullptr);
       else
         entry->Close();
     }
   }
 
   return rv;
@@ -857,18 +859,20 @@ void
   if (!mCacheEntry)
     return;
 
   if (mNew)
     return;
 
   uint32_t result;
   nsresult rv = mCallback->OnCacheEntryCheck(mCacheEntry, mAppCache, &result);
-  LOG(("  OnCacheEntryCheck result ent=%p, cb=%p, appcache=%p, rv=0x%08x, result=%d",
-    mCacheEntry.get(), mCallback.get(), mAppCache.get(), rv, result));
+  LOG(("  OnCacheEntryCheck result ent=%p, cb=%p, appcache=%p, rv=0x%08"
+       PRIx32 ", result=%d",
+      mCacheEntry.get(), mCallback.get(), mAppCache.get(), static_cast<uint32_t>(rv),
+      result));
 
   if (NS_FAILED(rv)) {
     NS_WARNING("cache check failed");
   }
 
   if (NS_FAILED(rv) || result == nsICacheEntryOpenCallback::ENTRY_NOT_WANTED) {
     mCacheEntry->Close();
     mCacheEntry = nullptr;
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Printf.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Unused.h"
 
 #include "mozilla/net/CookieServiceChild.h"
 #include "mozilla/net/NeckoCommon.h"
 
 #include "nsCookieService.h"
 #include "nsContentUtils.h"
 #include "nsIServiceManager.h"
@@ -1740,17 +1741,17 @@ nsCookieService::CleanupDefaultDBConnect
   mDefaultDBState->removeListener = nullptr;
   mDefaultDBState->closeListener = nullptr;
 }
 
 void
 nsCookieService::HandleDBClosed(DBState* aDBState)
 {
   COOKIE_LOGSTRING(LogLevel::Debug,
-    ("HandleDBClosed(): DBState %x closed", aDBState));
+    ("HandleDBClosed(): DBState %p closed", aDBState));
 
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
 
   switch (aDBState->corruptFlag) {
   case DBState::OK: {
     // Database is healthy. Notify of closure.
     if (os) {
       os->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
@@ -1768,39 +1769,40 @@ nsCookieService::HandleDBClosed(DBState*
     // dead database; we don't want to overwrite it, so let's move this one to
     // 'cookies.sqlite.bak-rebuild'.
     nsCOMPtr<nsIFile> backupFile;
     aDBState->cookieFile->Clone(getter_AddRefs(backupFile));
     nsresult rv = backupFile->MoveToNative(nullptr,
       NS_LITERAL_CSTRING(COOKIES_FILE ".bak-rebuild"));
 
     COOKIE_LOGSTRING(LogLevel::Warning,
-      ("HandleDBClosed(): DBState %x encountered error rebuilding db; move to "
-       "'cookies.sqlite.bak-rebuild' gave rv 0x%x", aDBState, rv));
+      ("HandleDBClosed(): DBState %p encountered error rebuilding db; move to "
+       "'cookies.sqlite.bak-rebuild' gave rv 0x%" PRIx32,
+       aDBState, static_cast<uint32_t>(rv)));
     if (os) {
       os->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
     }
     break;
   }
   }
 }
 
 void
 nsCookieService::HandleCorruptDB(DBState* aDBState)
 {
   if (mDefaultDBState != aDBState) {
     // We've either closed the state or we've switched profiles. It's getting
     // a bit late to rebuild -- bail instead.
     COOKIE_LOGSTRING(LogLevel::Warning,
-      ("HandleCorruptDB(): DBState %x is already closed, aborting", aDBState));
+      ("HandleCorruptDB(): DBState %p is already closed, aborting", aDBState));
     return;
   }
 
   COOKIE_LOGSTRING(LogLevel::Debug,
-    ("HandleCorruptDB(): DBState %x has corruptFlag %u", aDBState,
+    ("HandleCorruptDB(): DBState %p has corruptFlag %u", aDBState,
       aDBState->corruptFlag));
 
   // Mark the database corrupt, so the close listener can begin reconstructing
   // it.
   switch (mDefaultDBState->corruptFlag) {
   case DBState::OK: {
     // Move to 'closing' state.
     mDefaultDBState->corruptFlag = DBState::CLOSING_FOR_REBUILD;
@@ -1850,17 +1852,17 @@ nsCookieService::RebuildCorruptDB(DBStat
   aDBState->corruptFlag = DBState::REBUILDING;
 
   if (mDefaultDBState != aDBState) {
     // We've either closed the state or we've switched profiles. It's getting
     // a bit late to rebuild -- bail instead. In any case, we were waiting
     // on rebuild completion to notify of the db closure, which won't happen --
     // do so now.
     COOKIE_LOGSTRING(LogLevel::Warning,
-      ("RebuildCorruptDB(): DBState %x is stale, aborting", aDBState));
+      ("RebuildCorruptDB(): DBState %p is stale, aborting", aDBState));
     if (os) {
       os->NotifyObservers(nullptr, "cookie-db-closed", nullptr);
     }
     return;
   }
 
   COOKIE_LOGSTRING(LogLevel::Debug,
     ("RebuildCorruptDB(): creating new database"));
@@ -2327,17 +2329,17 @@ nsCookieService::RemoveAll()
     if (NS_SUCCEEDED(rv)) {
       nsCOMPtr<mozIStoragePendingStatement> handle;
       rv = stmt->ExecuteAsync(mDefaultDBState->removeListener,
         getter_AddRefs(handle));
       NS_ASSERT_SUCCESS(rv);
     } else {
       // Recreate the database.
       COOKIE_LOGSTRING(LogLevel::Debug,
-        ("RemoveAll(): corruption detected with rv 0x%x", rv));
+                       ("RemoveAll(): corruption detected with rv 0x%" PRIx32, static_cast<uint32_t>(rv)));
       HandleCorruptDB(mDefaultDBState);
     }
   }
 
   NotifyChanged(nullptr, u"cleared");
   return NS_OK;
 }
 
@@ -2719,17 +2721,17 @@ nsCookieService::AsyncReadComplete()
 
   mDefaultDBState->stmtReadDomain = nullptr;
   mDefaultDBState->pendingRead = nullptr;
   mDefaultDBState->readListener = nullptr;
   mDefaultDBState->syncConn = nullptr;
   mDefaultDBState->hostArray.Clear();
   mDefaultDBState->readSet.Clear();
 
-  COOKIE_LOGSTRING(LogLevel::Debug, ("Read(): %ld cookies read",
+  COOKIE_LOGSTRING(LogLevel::Debug, ("Read(): %" PRIu32 " cookies read",
                                   mDefaultDBState->cookieCount));
 
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
     os->NotifyObservers(nullptr, "cookie-db-read", nullptr);
   }
 }
 
@@ -2794,17 +2796,17 @@ nsCookieService::EnsureReadDomain(const 
       "WHERE baseDomain = :baseDomain "
       "  AND originAttributes = :originAttributes"),
       getter_AddRefs(mDefaultDBState->stmtReadDomain));
 
     if (NS_FAILED(rv)) {
       // Recreate the database.
       COOKIE_LOGSTRING(LogLevel::Debug,
         ("EnsureReadDomain(): corruption detected when creating statement "
-         "with rv 0x%x", rv));
+         "with rv 0x%" PRIx32, static_cast<uint32_t>(rv)));
       HandleCorruptDB(mDefaultDBState);
       return;
     }
   }
 
   NS_ASSERTION(mDefaultDBState->syncConn, "should have a sync db connection");
 
   mozStorageStatementScoper scoper(mDefaultDBState->stmtReadDomain);
@@ -2823,17 +2825,17 @@ nsCookieService::EnsureReadDomain(const 
   nsCString name, value, host, path;
   AutoTArray<RefPtr<nsCookie>, kMaxCookiesPerHost> array;
   while (true) {
     rv = mDefaultDBState->stmtReadDomain->ExecuteStep(&hasResult);
     if (NS_FAILED(rv)) {
       // Recreate the database.
       COOKIE_LOGSTRING(LogLevel::Debug,
         ("EnsureReadDomain(): corruption detected when reading result "
-         "with rv 0x%x", rv));
+         "with rv 0x%" PRIx32, static_cast<uint32_t>(rv)));
       HandleCorruptDB(mDefaultDBState);
       return;
     }
 
     if (!hasResult)
       break;
 
     array.AppendElement(GetCookieFromRow(mDefaultDBState->stmtReadDomain,
@@ -2845,17 +2847,17 @@ nsCookieService::EnsureReadDomain(const 
   for (uint32_t i = 0; i < array.Length(); ++i) {
     AddCookieToList(aKey, array[i], mDefaultDBState, nullptr, false);
   }
 
   // Add it to the hashset of read entries, so we don't read it again.
   mDefaultDBState->readSet.PutEntry(aKey);
 
   COOKIE_LOGSTRING(LogLevel::Debug,
-    ("EnsureReadDomain(): %ld cookies read for base domain %s, "
+    ("EnsureReadDomain(): %" PRIuSIZE " cookies read for base domain %s, "
      " originAttributes = %s", array.Length(), aKey.mBaseDomain.get(),
      suffix.get()));
 }
 
 void
 nsCookieService::EnsureReadComplete()
 {
   NS_ASSERTION(!mDBState->dbConn || mDBState == mDefaultDBState,
@@ -2886,31 +2888,31 @@ nsCookieService::EnsureReadComplete()
       "originAttributes  "
     "FROM moz_cookies "
     "WHERE baseDomain NOTNULL"), getter_AddRefs(stmt));
 
   if (NS_FAILED(rv)) {
     // Recreate the database.
     COOKIE_LOGSTRING(LogLevel::Debug,
       ("EnsureReadComplete(): corruption detected when creating statement "
-       "with rv 0x%x", rv));
+       "with rv 0x%" PRIx32, static_cast<uint32_t>(rv)));
     HandleCorruptDB(mDefaultDBState);
     return;
   }
 
   nsCString baseDomain, name, value, host, path;
   bool hasResult;
   nsTArray<CookieDomainTuple> array(kMaxNumberOfCookies);
   while (true) {
     rv = stmt->ExecuteStep(&hasResult);
     if (NS_FAILED(rv)) {
       // Recreate the database.
       COOKIE_LOGSTRING(LogLevel::Debug,
         ("EnsureReadComplete(): corruption detected when reading result "
-         "with rv 0x%x", rv));
+         "with rv 0x%" PRIx32, static_cast<uint32_t>(rv)));
       HandleCorruptDB(mDefaultDBState);
       return;
     }
 
     if (!hasResult)
       break;
 
     // Make sure we haven't already read the data.
@@ -2939,17 +2941,17 @@ nsCookieService::EnsureReadComplete()
     AddCookieToList(tuple.key, tuple.cookie, mDefaultDBState, nullptr,
       false);
   }
 
   mDefaultDBState->syncConn = nullptr;
   mDefaultDBState->readSet.Clear();
 
   COOKIE_LOGSTRING(LogLevel::Debug,
-    ("EnsureReadComplete(): %ld cookies read", array.Length()));
+    ("EnsureReadComplete(): %" PRIuSIZE " cookies read", array.Length()));
 }
 
 NS_IMETHODIMP
 nsCookieService::ImportCookies(nsIFile *aCookieFile)
 {
   if (!mDBState) {
     NS_WARNING("No DBState! Profile already closed?");
     return NS_ERROR_NOT_AVAILABLE;
@@ -3112,17 +3114,17 @@ nsCookieService::ImportCookies(nsIFile *
       nsCOMPtr<mozIStoragePendingStatement> handle;
       rv = mDefaultDBState->stmtInsert->ExecuteAsync(
         mDefaultDBState->insertListener, getter_AddRefs(handle));
       NS_ASSERT_SUCCESS(rv);
     }
   }
 
 
-  COOKIE_LOGSTRING(LogLevel::Debug, ("ImportCookies(): %ld cookies imported",
+  COOKIE_LOGSTRING(LogLevel::Debug, ("ImportCookies(): %" PRIu32 " cookies imported",
     mDefaultDBState->cookieCount));
 
   return NS_OK;
 }
 
 /******************************************************************************
  * nsCookieService impl:
  * private GetCookie/SetCookie helpers
@@ -4433,17 +4435,17 @@ public:
 already_AddRefed<nsIArray>
 nsCookieService::PurgeCookies(int64_t aCurrentTimeInUsec)
 {
   NS_ASSERTION(mDBState->hostTable.Count() > 0, "table is empty");
   EnsureReadComplete();
 
   uint32_t initialCookieCount = mDBState->cookieCount;
   COOKIE_LOGSTRING(LogLevel::Debug,
-    ("PurgeCookies(): beginning purge with %ld cookies and %lld oldest age",
+    ("PurgeCookies(): beginning purge with %" PRIu32 " cookies and %" PRId64 " oldest age",
      mDBState->cookieCount, aCurrentTimeInUsec - mDBState->cookieOldestTime));
 
   typedef nsTArray<nsListIter> PurgeList;
   PurgeList purgeList(kMaxNumberOfCookies);
 
   nsCOMPtr<nsIMutableArray> removedList = do_CreateInstance(NS_ARRAY_CONTRACTID);
 
   // Create a params array to batch the removals. This is OK here because
@@ -4529,17 +4531,18 @@ nsCookieService::PurgeCookies(int64_t aC
       NS_ASSERT_SUCCESS(rv);
     }
   }
 
   // reset the oldest time indicator
   mDBState->cookieOldestTime = oldestTime;
 
   COOKIE_LOGSTRING(LogLevel::Debug,
-    ("PurgeCookies(): %ld expired; %ld purged; %ld remain; %lld oldest age",
+    ("PurgeCookies(): %" PRIu32 " expired; %" PRIu32 " purged; %" PRIu32
+     " remain; %" PRId64 " oldest age",
      initialCookieCount - postExpiryCookieCount,
      postExpiryCookieCount - mDBState->cookieCount,
      mDBState->cookieCount,
      aCurrentTimeInUsec - mDBState->cookieOldestTime));
 
   return removedList.forget();
 }
 
--- a/netwerk/protocol/ftp/FTPChannelChild.cpp
+++ b/netwerk/protocol/ftp/FTPChannelChild.cpp
@@ -35,30 +35,30 @@ FTPChannelChild::FTPChannelChild(nsIURI*
 , mSuspendCount(0)
 , mIsPending(false)
 , mLastModifiedTime(0)
 , mStartPos(0)
 , mDivertingToParent(false)
 , mFlushedForDiversion(false)
 , mSuspendSent(false)
 {
-  LOG(("Creating FTPChannelChild @%x\n", this));
+  LOG(("Creating FTPChannelChild @%p\n", this));
   // grab a reference to the handler to ensure that it doesn't go away.
   NS_ADDREF(gFtpHandler);
   SetURI(uri);
   mEventQ = new ChannelEventQueue(static_cast<nsIFTPChannel*>(this));
 
   // We could support thread retargeting, but as long as we're being driven by
   // IPDL on the main thread it doesn't buy us anything.
   DisallowThreadRetargeting();
 }
 
 FTPChannelChild::~FTPChannelChild()
 {
-  LOG(("Destroying FTPChannelChild @%x\n", this));
+  LOG(("Destroying FTPChannelChild @%p\n", this));
   gFtpHandler->Release();
 }
 
 void
 FTPChannelChild::AddIPDLReference()
 {
   MOZ_ASSERT(!mIPCOpen, "Attempt to retain more than one IPDL reference");
   mIPCOpen = true;
@@ -503,18 +503,18 @@ private:
 mozilla::ipc::IPCResult
 FTPChannelChild::RecvOnStopRequest(const nsresult& aChannelStatus,
                                    const nsCString &aErrorMsg,
                                    const bool &aUseUTF8)
 {
   MOZ_RELEASE_ASSERT(!mFlushedForDiversion,
     "Should not be receiving any more callbacks from parent!");
 
-  LOG(("FTPChannelChild::RecvOnStopRequest [this=%p status=%x]\n",
-       this, aChannelStatus));
+  LOG(("FTPChannelChild::RecvOnStopRequest [this=%p status=%" PRIx32"]\n",
+       this, static_cast<uint32_t>(aChannelStatus)));
 
   mEventQ->RunOrEnqueue(new FTPStopRequestEvent(this, aChannelStatus, aErrorMsg,
                                                 aUseUTF8));
   return IPC_OK();
 }
 
 class nsFtpChildAsyncAlert : public Runnable
 {
@@ -567,18 +567,18 @@ FTPChannelChild::MaybeDivertOnStop(const
   }
 }
 
 void
 FTPChannelChild::DoOnStopRequest(const nsresult& aChannelStatus,
                                  const nsCString &aErrorMsg,
                                  bool aUseUTF8)
 {
-  LOG(("FTPChannelChild::DoOnStopRequest [this=%p status=%x]\n",
-       this, aChannelStatus));
+  LOG(("FTPChannelChild::DoOnStopRequest [this=%p status=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(aChannelStatus)));
 
   if (mDivertingToParent) {
     MOZ_RELEASE_ASSERT(!mFlushedForDiversion,
       "Should not be processing any more callbacks from parent!");
 
     SendDivertOnStopRequest(aChannelStatus);
     return;
   }
@@ -634,27 +634,27 @@ class FTPFailedAsyncOpenEvent : public C
  private:
   FTPChannelChild* mChild;
   nsresult mStatus;
 };
 
 mozilla::ipc::IPCResult
 FTPChannelChild::RecvFailedAsyncOpen(const nsresult& statusCode)
 {
-  LOG(("FTPChannelChild::RecvFailedAsyncOpen [this=%p status=%x]\n",
-       this, statusCode));
+  LOG(("FTPChannelChild::RecvFailedAsyncOpen [this=%p status=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(statusCode)));
   mEventQ->RunOrEnqueue(new FTPFailedAsyncOpenEvent(this, statusCode));
   return IPC_OK();
 }
 
 void
 FTPChannelChild::DoFailedAsyncOpen(const nsresult& statusCode)
 {
-  LOG(("FTPChannelChild::DoFailedAsyncOpen [this=%p status=%x]\n",
-       this, statusCode));
+  LOG(("FTPChannelChild::DoFailedAsyncOpen [this=%p status=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(statusCode)));
   mStatus = statusCode;
 
   if (mLoadGroup)
     mLoadGroup->RemoveRequest(this, nullptr, statusCode);
 
   if (mListener) {
     mListener->OnStartRequest(this, mListenerContext);
     mIsPending = false;
--- a/netwerk/protocol/ftp/FTPChannelParent.cpp
+++ b/netwerk/protocol/ftp/FTPChannelParent.cpp
@@ -203,17 +203,17 @@ FTPChannelParent::ConnectChannel(const u
 
   LOG(("Looking for a registered channel [this=%p, id=%d]", this, channelId));
 
   nsCOMPtr<nsIChannel> channel;
   rv = NS_LinkRedirectChannels(channelId, this, getter_AddRefs(channel));
   if (NS_SUCCEEDED(rv))
     mChannel = channel;
 
-  LOG(("  found channel %p, rv=%08x", mChannel.get(), rv));
+  LOG(("  found channel %p, rv=%08" PRIx32, mChannel.get(), static_cast<uint32_t>(rv)));
 
   return true;
 }
 
 mozilla::ipc::IPCResult
 FTPChannelParent::RecvCancel(const nsresult& status)
 {
   if (mChannel)
@@ -493,18 +493,18 @@ FTPChannelParent::OnStartRequest(nsIRequ
   return NS_OK;
 }
 
 NS_IMETHODIMP
 FTPChannelParent::OnStopRequest(nsIRequest* aRequest,
                                 nsISupports* aContext,
                                 nsresult aStatusCode)
 {
-  LOG(("FTPChannelParent::OnStopRequest: [this=%p status=%ul]\n",
-       this, aStatusCode));
+  LOG(("FTPChannelParent::OnStopRequest: [this=%p status=%" PRIu32 "]\n",
+       this, static_cast<uint32_t>(aStatusCode)));
 
   if (mDivertingFromChild) {
     MOZ_RELEASE_ASSERT(mDivertToListener,
                        "Cannot divert if listener is unset!");
     return mDivertToListener->OnStopRequest(aRequest, aContext, aStatusCode);
   }
 
   if (mIPCClosed || !SendOnStopRequest(aStatusCode, mErrorMsg, mUseUTF8)) {
--- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
+++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
@@ -92,25 +92,25 @@ nsFtpState::nsFtpState()
     , mCacheConnection(true)
     , mPort(21)
     , mAddressChecked(false)
     , mServerIsIPv6(false)
     , mUseUTF8(false)
     , mControlStatus(NS_OK)
     , mDeferredCallbackPending(false)
 {
-    LOG_INFO(("FTP:(%x) nsFtpState created", this));
+    LOG_INFO(("FTP:(%p) nsFtpState created", this));
 
     // make sure handler stays around
     NS_ADDREF(gFtpHandler);
 }
 
 nsFtpState::~nsFtpState() 
 {
-    LOG_INFO(("FTP:(%x) nsFtpState destroyed", this));
+    LOG_INFO(("FTP:(%p) nsFtpState destroyed", this));
 
     if (mProxyRequest)
         mProxyRequest->Cancel(NS_ERROR_FAILURE);
 
     // release reference to handler
     nsFtpProtocolHandler *handler = gFtpHandler;
     NS_RELEASE(handler);
 }
@@ -230,18 +230,19 @@ nsFtpState::OnControlDataAvailable(const
     }
 }
 
 void
 nsFtpState::OnControlError(nsresult status)
 {
     NS_ASSERTION(NS_FAILED(status), "expecting error condition");
 
-    LOG(("FTP:(%p) CC(%p) error [%x was-cached=%u]\n",
-         this, mControlConnection.get(), status, mTryingCachedControl));
+    LOG(("FTP:(%p) CC(%p) error [%" PRIx32 " was-cached=%u]\n",
+         this, mControlConnection.get(), static_cast<uint32_t>(status),
+         mTryingCachedControl));
 
     mControlStatus = status;
     if (mReconnectAndLoginAgain && NS_SUCCEEDED(mInternalError)) {
         mReconnectAndLoginAgain = false;
         mAnonymous = false;
         mControlStatus = NS_OK;
         Connect();
     } else if (mTryingCachedControl && NS_SUCCEEDED(mInternalError)) {
@@ -254,17 +255,17 @@ nsFtpState::OnControlError(nsresult stat
 
 nsresult
 nsFtpState::EstablishControlConnection()
 {
     NS_ASSERTION(!mControlConnection, "we already have a control connection");
             
     nsresult rv;
 
-    LOG(("FTP:(%x) trying cached control\n", this));
+    LOG(("FTP:(%p) trying cached control\n", this));
         
     // Look to see if we can use a cached control connection:
     RefPtr<nsFtpControlConnection> connection;
     // Don't use cached control if anonymous (bug #473371)
     if (!mChannel->HasLoadFlag(nsIRequest::LOAD_ANONYMOUS))
         gFtpHandler->RemoveConnection(mChannel->URI(), getter_AddRefs(connection));
 
     if (connection) {
@@ -314,31 +315,31 @@ nsFtpState::EstablishControlConnection()
         return rv;
 
     mControlConnection = new nsFtpControlConnection(host, mPort);
     if (!mControlConnection)
         return NS_ERROR_OUT_OF_MEMORY;
 
     rv = mControlConnection->Connect(mChannel->ProxyInfo(), this);
     if (NS_FAILED(rv)) {
-        LOG(("FTP:(%p) CC(%p) failed to connect [rv=%x]\n", this,
-            mControlConnection.get(), rv));
+        LOG(("FTP:(%p) CC(%p) failed to connect [rv=%" PRIx32 "]\n", this,
+             mControlConnection.get(), static_cast<uint32_t>(rv)));
         mControlConnection = nullptr;
         return rv;
     }
 
     return mControlConnection->WaitData(this);
 }
 
 void 
 nsFtpState::MoveToNextState(FTP_STATE nextState)
 {
     if (NS_FAILED(mInternalError)) {
         mState = FTP_ERROR;
-        LOG(("FTP:(%x) FAILED (%x)\n", this, mInternalError));
+        LOG(("FTP:(%p) FAILED (%" PRIx32 ")\n", this, static_cast<uint32_t>(mInternalError)));
     } else {
         mState = FTP_READ_BUF;
         mNextState = nextState;
     }  
 }
 
 nsresult
 nsFtpState::Process() 
@@ -384,25 +385,25 @@ nsFtpState::Process()
                 mState = FTP_COMMAND_CONNECT;
             } else if (mAnonymous && 
                        mInternalError == NS_ERROR_FTP_LOGIN) {
                 // If the login was anonymous, and it failed, try again with a username
                 // Don't reuse old control connection, see #386167
                 mAnonymous = false;
                 mState = FTP_COMMAND_CONNECT;
             } else {
-                LOG(("FTP:(%x) FTP_ERROR - calling StopProcessing\n", this));
+                LOG(("FTP:(%p) FTP_ERROR - calling StopProcessing\n", this));
                 rv = StopProcessing();
                 NS_ASSERTION(NS_SUCCEEDED(rv), "StopProcessing failed.");
                 processingRead = false;
             }
             break;
           
           case FTP_COMPLETE:
-            LOG(("FTP:(%x) COMPLETE\n", this));
+            LOG(("FTP:(%p) COMPLETE\n", this));
             rv = StopProcessing();
             NS_ASSERTION(NS_SUCCEEDED(rv), "StopProcessing failed.");
             processingRead = false;
             break;
 
 // USER           
           case FTP_S_USER:
             rv = S_user();
@@ -1306,17 +1307,17 @@ nsFtpState::R_stor() {
         // Call Close() if it was not called in nsFtpState::OnStoprequest()
         if (!mUploadRequest && !IsClosed())
             Close();
 
         return FTP_COMPLETE;
     }
 
     if (mResponseCode/100 == 1) {
-        LOG(("FTP:(%x) writing on DT\n", this));
+        LOG(("FTP:(%p) writing on DT\n", this));
         return FTP_READ_BUF;
     }
 
    mStorReplyReceived = true;
    return FTP_ERROR;
 }
 
 
@@ -1500,17 +1501,17 @@ nsFtpState::R_pasv() {
                                    port, mChannel->ProxyInfo(),
                                    getter_AddRefs(strans)); // the data socket
         if (NS_FAILED(rv))
             return FTP_ERROR;
         mDataTransport = strans;
 
         strans->SetQoSBits(gFtpHandler->GetDataQoSBits());
         
-        LOG(("FTP:(%x) created DT (%s:%x)\n", this, host.get(), port));
+        LOG(("FTP:(%p) created DT (%s:%x)\n", this, host.get(), port));
         
         // hook ourself up as a proxy for status notifications
         rv = mDataTransport->SetEventSink(this, NS_GetCurrentThread());
         NS_ENSURE_SUCCESS(rv, FTP_ERROR);
 
         if (mAction == PUT) {
             NS_ASSERTION(!mRETRFailed, "Failed before uploading");
 
@@ -1729,17 +1730,17 @@ nsFtpState::Connect()
 {
     mState = FTP_COMMAND_CONNECT;
     mNextState = FTP_S_USER;
 
     nsresult rv = Process();
 
     // check for errors.
     if (NS_FAILED(rv)) {
-        LOG(("FTP:Process() failed: %x\n", rv));
+        LOG(("FTP:Process() failed: %" PRIx32 "\n", static_cast<uint32_t>(rv)));
         mInternalError = NS_ERROR_FAILURE;
         mState = FTP_ERROR;
         CloseWithStatus(mInternalError);
     }
 }
 
 void
 nsFtpState::KillControlConnection()
@@ -1816,17 +1817,17 @@ private:
 nsresult
 nsFtpState::StopProcessing()
 {
     // Only do this function once.
     if (!mKeepRunning)
         return NS_OK;
     mKeepRunning = false;
 
-    LOG_INFO(("FTP:(%x) nsFtpState stopping", this));
+    LOG_INFO(("FTP:(%p) nsFtpState stopping", this));
 
     if (NS_FAILED(mInternalError) && !mResponseMsg.IsEmpty()) {
         // check to see if the control status is bad.
         // web shell wont throw an alert.  we better:
 
         // XXX(darin): this code should not be dictating UI like this!
         nsCOMPtr<nsIPrompt> prompter;
         mChannel->GetCallback(prompter);
@@ -1870,17 +1871,17 @@ nsFtpState::SendFTPCommand(const nsCSubs
 {
     NS_ASSERTION(mControlConnection, "null control connection");        
     
     // we don't want to log the password:
     nsAutoCString logcmd(command);
     if (StringBeginsWith(command, NS_LITERAL_CSTRING("PASS "))) 
         logcmd = "PASS xxxxx";
     
-    LOG(("FTP:(%x) writing \"%s\"\n", this, logcmd.get()));
+    LOG(("FTP:(%p) writing \"%s\"\n", this, logcmd.get()));
 
     nsCOMPtr<nsIFTPEventSink> ftpSink;
     mChannel->GetFTPEventSink(ftpSink);
     if (ftpSink)
         ftpSink->OnFTPControlLog(false, logcmd.get());
     
     if (mControlConnection)
         return mControlConnection->Write(command);
@@ -1899,18 +1900,18 @@ nsFtpState::ConvertFilespecToVMS(nsCStri
     nsAutoCString fileStringCopy;
 
     // Get a writeable copy we can strtok with.
     fileStringCopy = fileString;
     t = nsCRT::strtok(fileStringCopy.BeginWriting(), "/", &nextToken);
     if (t)
         while (nsCRT::strtok(nextToken, "/", &nextToken))
             ntok++; // count number of terms (tokens)
-    LOG(("FTP:(%x) ConvertFilespecToVMS ntok: %d\n", this, ntok));
-    LOG(("FTP:(%x) ConvertFilespecToVMS from: \"%s\"\n", this, fileString.get()));
+    LOG(("FTP:(%p) ConvertFilespecToVMS ntok: %d\n", this, ntok));
+    LOG(("FTP:(%p) ConvertFilespecToVMS from: \"%s\"\n", this, fileString.get()));
 
     if (fileString.First() == '/') {
         // absolute filespec
         //   /        -> []
         //   /a       -> a (doesn't really make much sense)
         //   /a/b     -> a:[000000]b
         //   /a/b/c   -> a:[b]c
         //   /a/b/c/d -> a:[b.c]d
@@ -1964,53 +1965,53 @@ nsFtpState::ConvertFilespecToVMS(nsCStri
                     fileString.Append(nsCRT::strtok(nextToken,
                                       "/", &nextToken));
                 }
             }
             fileString.Append(']');
             fileString.Append(nsCRT::strtok(nextToken, "/", &nextToken));
         }
     }
-    LOG(("FTP:(%x) ConvertFilespecToVMS   to: \"%s\"\n", this, fileString.get()));
+    LOG(("FTP:(%p) ConvertFilespecToVMS   to: \"%s\"\n", this, fileString.get()));
 }
 
 // Convert a unix-style dirspec to VMS format
 // /foo/fred/barney/rubble -> foo:[fred.barney.rubble]
 // /foo/fred -> foo:[fred]
 // /foo -> foo:[000000]
 // (null) -> (null)
 void
 nsFtpState::ConvertDirspecToVMS(nsCString& dirSpec)
 {
-    LOG(("FTP:(%x) ConvertDirspecToVMS from: \"%s\"\n", this, dirSpec.get()));
+    LOG(("FTP:(%p) ConvertDirspecToVMS from: \"%s\"\n", this, dirSpec.get()));
     if (!dirSpec.IsEmpty()) {
         if (dirSpec.Last() != '/')
             dirSpec.Append('/');
         // we can use the filespec routine if we make it look like a file name
         dirSpec.Append('x');
         ConvertFilespecToVMS(dirSpec);
         dirSpec.Truncate(dirSpec.Length()-1);
     }
-    LOG(("FTP:(%x) ConvertDirspecToVMS   to: \"%s\"\n", this, dirSpec.get()));
+    LOG(("FTP:(%p) ConvertDirspecToVMS   to: \"%s\"\n", this, dirSpec.get()));
 }
 
 // Convert an absolute VMS style dirspec to UNIX format
 void
 nsFtpState::ConvertDirspecFromVMS(nsCString& dirSpec)
 {
-    LOG(("FTP:(%x) ConvertDirspecFromVMS from: \"%s\"\n", this, dirSpec.get()));
+    LOG(("FTP:(%p) ConvertDirspecFromVMS from: \"%s\"\n", this, dirSpec.get()));
     if (dirSpec.IsEmpty()) {
         dirSpec.Insert('.', 0);
     } else {
         dirSpec.Insert('/', 0);
         dirSpec.ReplaceSubstring(":[", "/");
         dirSpec.ReplaceChar('.', '/');
         dirSpec.ReplaceChar(']', '/');
     }
-    LOG(("FTP:(%x) ConvertDirspecFromVMS   to: \"%s\"\n", this, dirSpec.get()));
+    LOG(("FTP:(%p) ConvertDirspecFromVMS   to: \"%s\"\n", this, dirSpec.get()));
 }
 
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsFtpState::OnTransportStatus(nsITransport *transport, nsresult status,
                               int64_t progress, int64_t progressMax)
 {
@@ -2089,17 +2090,17 @@ nsFtpState::ReadSegments(nsWriteSegmentF
     }
 
     return nsBaseContentStream::ReadSegments(writer, closure, count, result);
 }
 
 NS_IMETHODIMP
 nsFtpState::CloseWithStatus(nsresult status)
 {
-    LOG(("FTP:(%p) close [%x]\n", this, status));
+    LOG(("FTP:(%p) close [%" PRIx32 "]\n", this, static_cast<uint32_t>(status)));
 
     // Shutdown the control connection processing if we are being closed with an
     // error.  Note: This method may be called several times.
     if (!IsClosed() && status != NS_BASE_STREAM_CLOSED && NS_FAILED(status)) {
         if (NS_SUCCEEDED(mInternalError))
             mInternalError = status;
         StopProcessing();
     }
--- a/netwerk/protocol/ftp/nsFtpControlConnection.cpp
+++ b/netwerk/protocol/ftp/nsFtpControlConnection.cpp
@@ -151,17 +151,18 @@ nsFtpControlConnection::WaitData(nsFtpCo
 }
 
 nsresult 
 nsFtpControlConnection::Disconnect(nsresult status)
 {
     if (!mSocket)
         return NS_OK;  // already disconnected
     
-    LOG_INFO(("FTP:(%p) CC disconnecting (%x)", this, status));
+    LOG_INFO(("FTP:(%p) CC disconnecting (%" PRIx32 ")", this,
+              static_cast<uint32_t>(status)));
 
     if (NS_FAILED(status)) {
         // break cyclic reference!
         mSocket->Close(status);
         mSocket = nullptr;
         mSocketInput->AsyncWait(nullptr, 0, 0, nullptr);  // clear any observer
         mSocketInput = nullptr;
         mSocketOutput = nullptr;
--- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
+++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
@@ -62,24 +62,24 @@ nsFtpProtocolHandler *gFtpHandler = null
 //-----------------------------------------------------------------------------
 
 nsFtpProtocolHandler::nsFtpProtocolHandler()
     : mIdleTimeout(-1)
     , mSessionId(0)
     , mControlQoSBits(0x00)
     , mDataQoSBits(0x00)
 {
-    LOG(("FTP:creating handler @%x\n", this));
+    LOG(("FTP:creating handler @%p\n", this));
 
     gFtpHandler = this;
 }
 
 nsFtpProtocolHandler::~nsFtpProtocolHandler()
 {
-    LOG(("FTP:destroying handler @%x\n", this));
+    LOG(("FTP:destroying handler @%p\n", this));
 
     NS_ASSERTION(mRootConnectionList.Length() == 0, "why wasn't Observe called?");
 
     gFtpHandler = nullptr;
 }
 
 NS_IMPL_ISUPPORTS(nsFtpProtocolHandler,
                   nsIProtocolHandler,
--- a/netwerk/protocol/http/AlternateServices.cpp
+++ b/netwerk/protocol/http/AlternateServices.cpp
@@ -464,18 +464,18 @@ private:
   {
     MOZ_ASSERT(mMapping->HTTPS()); // http:// uses the .wk path
 
     if (mTriedToValidate) {
       return;
     }
     mTriedToValidate = true;
 
-    LOG(("AltSvcTransaction::MaybeValidate() %p reason=%x running=%d conn=%p write=%d",
-         this, reason, mRunning, mConnection.get(), mTriedToWrite));
+    LOG(("AltSvcTransaction::MaybeValidate() %p reason=%" PRIx32 " running=%d conn=%p write=%d",
+         this, static_cast<uint32_t>(reason), mRunning, mConnection.get(), mTriedToWrite));
 
     if (mTriedToWrite && reason == NS_BASE_STREAM_CLOSED) {
       // The normal course of events is to cause the transaction to fail with CLOSED
       // on a write - so that's a success that means the HTTP/2 session is setup.
       reason = NS_OK;
     }
 
     if (NS_FAILED(reason) || !mRunning || !mConnection) {
@@ -507,30 +507,30 @@ private:
     LOG(("AltSvcTransaction::MaybeValidate() %p "
          "validating alternate service with successful auth check", this));
     mMapping->SetValidated(true);
   }
 
 public:
   void Close(nsresult reason) override
   {
-    LOG(("AltSvcTransaction::Close() %p reason=%x running %d",
-         this, reason, mRunning));
+    LOG(("AltSvcTransaction::Close() %p reason=%" PRIx32 " running %d",
+         this, static_cast<uint32_t>(reason), mRunning));
 
     MaybeValidate(reason);
     if (!mMapping->Validated() && mConnection) {
       mConnection->DontReuse();
     }
     NullHttpTransaction::Close(reason);
   }
 
   nsresult ReadSegments(nsAHttpSegmentReader *reader,
                         uint32_t count, uint32_t *countRead) override
   {
-    LOG(("AltSvcTransaction::ReadSegements() %p\n"));
+    LOG(("AltSvcTransaction::ReadSegements() %p\n", this));
     mTriedToWrite = true;
     return NullHttpTransaction::ReadSegments(reader, count, countRead);
   }
 
 private:
   RefPtr<AltSvcMapping>   mMapping;
   uint32_t                mRunning : 1;
   uint32_t                mTriedToValidate : 1;
@@ -720,18 +720,18 @@ TransactionObserver::Complete(nsHttpTran
   // socket thread
   MOZ_ASSERT(!NS_IsMainThread());
   if (mRanOnce) {
     return;
   }
   mRanOnce = true;
 
   RefPtr<nsAHttpConnection> conn = aTrans->GetConnectionReference();
-  LOG(("TransactionObserver::Complete %p aTrans %p reason %x conn %p\n",
-       this, aTrans, reason, conn.get()));
+  LOG(("TransactionObserver::Complete %p aTrans %p reason %" PRIx32 " conn %p\n",
+       this, aTrans, static_cast<uint32_t>(reason), conn.get()));
   if (!conn) {
     return;
   }
   uint32_t version = conn->Version();
   mVersionOK = (((reason == NS_BASE_STREAM_CLOSED) || (reason == NS_OK)) &&
                 conn->Version() == HTTP_VERSION_2);
 
   nsCOMPtr<nsISupports> secInfo;
@@ -779,17 +779,18 @@ TransactionObserver::OnDataAvailable(nsI
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TransactionObserver::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, nsresult code)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  LOG(("TransactionObserver onStopRequest %p code %x\n", this, code));
+  LOG(("TransactionObserver onStopRequest %p code %" PRIx32 "\n",
+       this, static_cast<uint32_t>(code)));
   if (NS_SUCCEEDED(code)) {
     nsHttpResponseHead *hdrs = mChannel->GetResponseHead();
     LOG(("TransactionObserver onStopRequest %p http resp %d\n",
          this, hdrs ? hdrs->Status() : -1));
     mStatusOK = hdrs && (hdrs->Status() == 200);
   }
   if (mChecker) {
     mChecker->Done(this);
--- a/netwerk/protocol/http/Http2Push.cpp
+++ b/netwerk/protocol/http/Http2Push.cpp
@@ -104,31 +104,36 @@ Http2PushedStream::WriteSegments(nsAHttp
   if (rv != NS_BASE_STREAM_WOULD_BLOCK && NS_FAILED(rv))
     mStatus = rv;
   return rv;
 }
 
 bool
 Http2PushedStream::DeferCleanup(nsresult status)
 {
-  LOG3(("Http2PushedStream::DeferCleanup Query %p %x\n", this, status));
+  LOG3(("Http2PushedStream::DeferCleanup Query %p %" PRIx32 "\n", this,
+        static_cast<uint32_t>(status)));
 
   if (NS_SUCCEEDED(status) && mDeferCleanupOnSuccess) {
-    LOG3(("Http2PushedStream::DeferCleanup %p %x defer on success\n", this, status));
+    LOG3(("Http2PushedStream::DeferCleanup %p %" PRIx32 " defer on success\n", this,
+          static_cast<uint32_t>(status)));
     return true;
   }
   if (mDeferCleanupOnPush) {
-    LOG3(("Http2PushedStream::DeferCleanup %p %x defer onPush ref\n", this, status));
+    LOG3(("Http2PushedStream::DeferCleanup %p %" PRIx32 " defer onPush ref\n", this,
+          static_cast<uint32_t>(status)));
     return true;
   }
   if (mConsumerStream) {
-    LOG3(("Http2PushedStream::DeferCleanup %p %x defer active consumer\n", this, status));
+    LOG3(("Http2PushedStream::DeferCleanup %p %" PRIx32 " defer active consumer\n", this,
+          static_cast<uint32_t>(status)));
     return true;
   }
-  LOG3(("Http2PushedStream::DeferCleanup Query %p %x not deferred\n", this, status));
+  LOG3(("Http2PushedStream::DeferCleanup Query %p %" PRIx32 " not deferred\n", this,
+        static_cast<uint32_t>(status)));
   return false;
 }
 
 // return true if channel implements nsIHttpPushListener
 bool
 Http2PushedStream::TryOnPush()
 {
   nsHttpTransaction *trans = mAssociatedTransaction->QueryHttpTransaction();
@@ -415,17 +420,17 @@ Http2PushTransactionBuffer::WriteSegment
     mIsDone = true;
   }
 
   if (Available() || mIsDone) {
     Http2Stream *consumer = mPushStream->GetConsumerStream();
 
     if (consumer) {
       LOG3(("Http2PushTransactionBuffer::WriteSegments notifying connection "
-            "consumer data available 0x%X [%u] done=%d\n",
+            "consumer data available 0x%X [%" PRIu64 "] done=%d\n",
             mPushStream->StreamID(), Available(), mIsDone));
       mPushStream->ConnectPushedStream(consumer);
     }
   }
 
   return rv;
 }
 
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -113,17 +113,17 @@ Http2Session::Http2Session(nsISocketTran
   , mGoAwayOnPush(false)
   , mUseH2Deps(false)
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
   static uint64_t sSerial;
   mSerial = ++sSerial;
 
-  LOG3(("Http2Session::Http2Session %p serial=0x%X\n", this, mSerial));
+  LOG3(("Http2Session::Http2Session %p serial=0x%" PRIX64 "\n", this, mSerial));
 
   mInputFrameBuffer = MakeUnique<char[]>(mInputFrameBufferSize);
   mOutputQueueBuffer = MakeUnique<char[]>(mOutputQueueSize);
   mDecompressBuffer.SetCapacity(kDefaultBufferSize);
 
   mPushAllowance = gHttpHandler->SpdyPushAllowance();
   mInitialRwin = std::max(gHttpHandler->SpdyPullAllowance(), mPushAllowance);
   mMaxConcurrent = gHttpHandler->DefaultSpdyConcurrent();
@@ -272,17 +272,17 @@ Http2Session::ReadTimeoutTick(PRInterval
       }
     }
 
     return PR_IntervalToSeconds(mPingThreshold) -
       PR_IntervalToSeconds(now - mLastReadEpoch);
   }
 
   if (mPingSentEpoch) {
-    LOG3(("Http2Session::ReadTimeoutTick %p handle outstanding ping\n"));
+    LOG3(("Http2Session::ReadTimeoutTick %p handle outstanding ping\n", this));
     if ((now - mPingSentEpoch) >= gHttpHandler->SpdyPingTimeout()) {
       LOG3(("Http2Session::ReadTimeoutTick %p Ping Timer Exhaustion\n", this));
       mPingSentEpoch = 0;
       Close(NS_ERROR_NET_TIMEOUT);
       return UINT32_MAX;
     }
     return 1; // run the tick aggressively while ping is outstanding
   }
@@ -401,17 +401,17 @@ Http2Session::AddStream(nsAHttpTransacti
     LOG3(("Http2Session::AddStream session=%p trans=%p OnTunnel",
           this, aHttpTransaction));
     DispatchOnTunnel(aHttpTransaction, aCallbacks);
     return true;
   }
 
   Http2Stream *stream = new Http2Stream(aHttpTransaction, this, aPriority);
 
-  LOG3(("Http2Session::AddStream session=%p stream=%p serial=%u "
+  LOG3(("Http2Session::AddStream session=%p stream=%p serial=%" PRIu64 " "
         "NextID=0x%X (tentative)", this, stream, mSerial, mNextStreamID));
 
   mStreamTransactionHash.Put(aHttpTransaction, stream);
 
   mReadyForWrite.Push(stream);
   SetWriteCallbacks();
 
   // Kick off the SYN transmit without waiting for the poll loop
@@ -516,18 +516,18 @@ Http2Session::FlushOutputQueue()
 
   nsresult rv;
   uint32_t countRead;
   uint32_t avail = mOutputQueueUsed - mOutputQueueSent;
 
   rv = mSegmentReader->
     OnReadSegment(mOutputQueueBuffer.get() + mOutputQueueSent, avail,
                   &countRead);
-  LOG3(("Http2Session::FlushOutputQueue %p sz=%d rv=%x actual=%d",
-        this, avail, rv, countRead));
+  LOG3(("Http2Session::FlushOutputQueue %p sz=%d rv=%" PRIx32 " actual=%d",
+        this, avail, static_cast<uint32_t>(rv), countRead));
 
   // Dont worry about errors on write, we will pick this up as a read error too
   if (NS_FAILED(rv))
     return;
 
   if (countRead == avail) {
     mOutputQueueUsed = 0;
     mOutputQueueSent = 0;
@@ -598,17 +598,17 @@ Http2Session::TryToActivate(Http2Stream 
 {
   if (aStream->Queued()) {
     LOG3(("Http2Session::TryToActivate %p stream=%p already queued.\n", this, aStream));
     return false;
   }
 
   if (!RoomForMoreConcurrent()) {
     LOG3(("Http2Session::TryToActivate %p stream=%p no room for more concurrent "
-          "streams %d\n", this, aStream));
+          "streams\n", this, aStream));
     QueueStream(aStream);
     return false;
   }
 
   LOG3(("Http2Session::TryToActivate %p stream=%p\n", this, aStream));
   IncrementConcurrent(aStream);
   return true;
 }
@@ -1008,18 +1008,18 @@ Http2Session::VerifyStream(Http2Stream *
   return false;
 }
 
 void
 Http2Session::CleanupStream(Http2Stream *aStream, nsresult aResult,
                             errorType aResetCode)
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
-  LOG3(("Http2Session::CleanupStream %p %p 0x%X %X\n",
-        this, aStream, aStream ? aStream->StreamID() : 0, aResult));
+  LOG3(("Http2Session::CleanupStream %p %p 0x%X %" PRIX32 "\n",
+        this, aStream, aStream ? aStream->StreamID() : 0, static_cast<uint32_t>(aResult)));
   if (!aStream) {
     return;
   }
 
   if (aStream->DeferCleanup(aResult)) {
     LOG3(("Http2Session::CleanupStream 0x%X deferred\n", aStream->StreamID()));
     return;
   }
@@ -1117,18 +1117,18 @@ Http2Session::RemoveStreamFromQueues(Htt
   RemoveStreamFromQueue(aStream, mPushesReadyForRead);
   RemoveStreamFromQueue(aStream, mSlowConsumersReadyForRead);
 }
 
 void
 Http2Session::CloseStream(Http2Stream *aStream, nsresult aResult)
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
-  LOG3(("Http2Session::CloseStream %p %p 0x%x %X\n",
-        this, aStream, aStream->StreamID(), aResult));
+  LOG3(("Http2Session::CloseStream %p %p 0x%x %" PRIX32 "\n",
+        this, aStream, aStream->StreamID(), static_cast<uint32_t>(aResult)));
 
   MaybeDecrementConcurrent(aStream);
 
   // Check if partial frame reader
   if (aStream == mInputFrameDataStream) {
     LOG3(("Stream had active partial read frame on close"));
     ChangeDownstreamState(DISCARDING_DATA_FRAME);
     mInputFrameDataStream = nullptr;
@@ -1464,17 +1464,17 @@ Http2Session::RecvSettings(Http2Session 
   }
 
   uint32_t numEntries = self->mInputFrameDataSize / 6;
   LOG3(("Http2Session::RecvSettings %p SETTINGS Control Frame "
         "with %d entries ack=%X", self, numEntries,
         self->mInputFrameFlags & kFlag_ACK));
 
   if ((self->mInputFrameFlags & kFlag_ACK) && self->mInputFrameDataSize) {
-    LOG3(("Http2Session::RecvSettings %p ACK with non zero payload is err\n"));
+    LOG3(("Http2Session::RecvSettings %p ACK with non zero payload is err\n", self));
     RETURN_SESSION_ERROR(self, PROTOCOL_ERROR);
   }
 
   for (uint32_t index = 0; index < numEntries; ++index) {
     uint8_t *setting = reinterpret_cast<uint8_t *>
       (self->mInputFrameBuffer.get()) + kFrameHeaderBytes + index * 6;
 
     uint16_t id = NetworkEndian::readUint16(setting);
@@ -1975,18 +1975,18 @@ Http2Session::RecvWindowUpdate(Http2Sess
             "exceeds 2^31 - 1\n", self));
       self->CleanupStream(self->mInputFrameDataStream, NS_ERROR_ILLEGAL_VALUE,
                           FLOW_CONTROL_ERROR);
       self->ResetDownstreamState();
       return NS_OK;
     }
 
     LOG3(("Http2Session::RecvWindowUpdate %p stream 0x%X window "
-          "%d increased by %d now %d.\n", self, self->mInputFrameID,
-          oldRemoteWindow, delta, oldRemoteWindow + delta));
+          "%" PRId64 " increased by %" PRIu32 " now %" PRId64 ".\n",
+          self, self->mInputFrameID, oldRemoteWindow, delta, oldRemoteWindow + delta));
 
   } else { // session window update
     if (delta == 0) {
       LOG3(("Http2Session::RecvWindowUpdate %p received 0 session window update",
             self));
       RETURN_SESSION_ERROR(self, PROTOCOL_ERROR);
     }
 
@@ -2014,17 +2014,17 @@ Http2Session::RecvWindowUpdate(Http2Sess
           continue;
         }
 
         self->mReadyForWrite.Push(stream);
         self->SetWriteCallbacks();
       }
     }
     LOG3(("Http2Session::RecvWindowUpdate %p session window "
-          "%d increased by %d now %d.\n", self,
+          "%" PRId64 " increased by %d now %" PRId64 ".\n", self,
           oldRemoteWindow, delta, oldRemoteWindow + delta));
   }
 
   self->ResetDownstreamState();
   return NS_OK;
 }
 
 nsresult
@@ -2319,18 +2319,18 @@ Http2Session::ReadSegmentsAgain(nsAHttpS
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
   MOZ_ASSERT(!mSegmentReader || !reader || (mSegmentReader == reader),
              "Inconsistent Write Function Callback");
 
   nsresult rv = ConfirmTLSProfile();
   if (NS_FAILED(rv)) {
     if (mGoAwayReason == INADEQUATE_SECURITY) {
-      LOG3(("Http2Session::ReadSegments %p returning INADEQUATE_SECURITY %x",
-            this, NS_ERROR_NET_INADEQUATE_SECURITY));
+      LOG3(("Http2Session::ReadSegments %p returning INADEQUATE_SECURITY %" PRIx32,
+            this, static_cast<uint32_t>(NS_ERROR_NET_INADEQUATE_SECURITY)));
       rv = NS_ERROR_NET_INADEQUATE_SECURITY;
     }
     return rv;
   }
 
   if (reader)
     mSegmentReader = reader;
 
@@ -2378,18 +2378,18 @@ Http2Session::ReadSegmentsAgain(nsAHttpS
     } else {
       rv = NS_BASE_STREAM_WOULD_BLOCK;
     }
     SetWriteCallbacks();
     return rv;
   }
 
   if (NS_FAILED(rv)) {
-    LOG3(("Http2Session::ReadSegments %p may return FAIL code %X",
-          this, rv));
+    LOG3(("Http2Session::ReadSegments %p may return FAIL code %" PRIX32,
+          this, static_cast<uint32_t>(rv)));
     if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
       return rv;
     }
 
     CleanupStream(stream, rv, CANCEL_ERROR);
     if (SoftStreamError(rv)) {
       LOG3(("Http2Session::ReadSegments %p soft error override\n", this));
       *again = false;
@@ -2560,18 +2560,18 @@ Http2Session::WriteSegmentsAgain(nsAHttp
 
     MOZ_ASSERT(mInputFrameBufferUsed < kFrameHeaderBytes,
                "Frame Buffer Used Too Large for State");
 
     rv = NetworkRead(writer, &mInputFrameBuffer[mInputFrameBufferUsed],
                      kFrameHeaderBytes - mInputFrameBufferUsed, countWritten);
 
     if (NS_FAILED(rv)) {
-      LOG3(("Http2Session %p buffering frame header read failure %x\n",
-            this, rv));
+      LOG3(("Http2Session %p buffering frame header read failure %" PRIx32 "\n",
+            this, static_cast<uint32_t>(rv)));
       // maybe just blocked reading from network
       if (rv == NS_BASE_STREAM_WOULD_BLOCK)
         rv = NS_OK;
       return rv;
     }
 
     LogIO(this, nullptr, "Reading Frame Header",
           &mInputFrameBuffer[mInputFrameBufferUsed], *countWritten);
@@ -2604,17 +2604,17 @@ Http2Session::WriteSegmentsAgain(nsAHttp
     if (mInputFrameType == FRAME_TYPE_DATA || mInputFrameType == FRAME_TYPE_HEADERS)  {
       mInputFrameFinal = mInputFrameFlags & kFlag_END_STREAM;
     } else {
       mInputFrameFinal = 0;
     }
 
     mPaddingLength = 0;
 
-    LOG3(("Http2Session::WriteSegments[%p::%x] Frame Header Read "
+    LOG3(("Http2Session::WriteSegments[%p::%" PRIu64 "] Frame Header Read "
           "type %X data len %u flags %x id 0x%X",
           this, mSerial, mInputFrameType, mInputFrameDataSize, mInputFrameFlags,
           mInputFrameID));
 
     // if mExpectedHeaderID is non 0, it means this frame must be a CONTINUATION of
     // a HEADERS frame with a matching ID (section 6.2)
     if (mExpectedHeaderID &&
         ((mInputFrameType != FRAME_TYPE_CONTINUATION) ||
@@ -2660,18 +2660,18 @@ Http2Session::WriteSegmentsAgain(nsAHttp
     MOZ_ASSERT(mInputFrameBufferUsed < (kFrameHeaderBytes + 1),
                "Frame buffer used too large for state");
 
     rv = NetworkRead(writer, &mInputFrameBuffer[mInputFrameBufferUsed],
                      (kFrameHeaderBytes + 1) - mInputFrameBufferUsed,
                      countWritten);
 
     if (NS_FAILED(rv)) {
-      LOG3(("Http2Session %p buffering data frame padding control read failure %x\n",
-            this, rv));
+      LOG3(("Http2Session %p buffering data frame padding control read failure %" PRIx32 "\n",
+            this, static_cast<uint32_t>(rv)));
       // maybe just blocked reading from network
       if (rv == NS_BASE_STREAM_WOULD_BLOCK)
         rv = NS_OK;
       return rv;
     }
 
     LogIO(this, nullptr, "Reading Data Frame Padding Control",
           &mInputFrameBuffer[mInputFrameBufferUsed], *countWritten);
@@ -2767,18 +2767,18 @@ Http2Session::WriteSegmentsAgain(nsAHttp
       // if we were doing PROCESSING_COMPLETE_HEADERS need to pop the state
       // back to PROCESSING_DATA_FRAME where we came from
       mDownstreamState = PROCESSING_DATA_FRAME;
 
       if (mInputFrameDataRead == mInputFrameDataSize)
         ResetDownstreamState();
       LOG3(("Http2Session::WriteSegments session=%p id 0x%X "
             "needscleanup=%p. cleanup stream based on "
-            "stream->writeSegments returning code %x\n",
-            this, streamID, mNeedsCleanup, rv));
+            "stream->writeSegments returning code %" PRIx32 "\n",
+            this, streamID, mNeedsCleanup, static_cast<uint32_t>(rv)));
       MOZ_ASSERT(!mNeedsCleanup || mNeedsCleanup->StreamID() == streamID);
       CleanupStream(streamID, NS_OK, CANCEL_ERROR);
       mNeedsCleanup = nullptr;
       *again = false;
       ResumeRecv();
       return NS_OK;
     }
 
@@ -2786,17 +2786,18 @@ Http2Session::WriteSegmentsAgain(nsAHttp
       LOG3(("Http2Session::WriteSegments session=%p stream=%p 0x%X "
             "cleanup stream based on mNeedsCleanup.\n",
             this, mNeedsCleanup, mNeedsCleanup ? mNeedsCleanup->StreamID() : 0));
       CleanupStream(mNeedsCleanup, NS_OK, CANCEL_ERROR);
       mNeedsCleanup = nullptr;
     }
 
     if (NS_FAILED(rv)) {
-      LOG3(("Http2Session %p data frame read failure %x\n", this, rv));
+      LOG3(("Http2Session %p data frame read failure %" PRIx32 "\n", this,
+            static_cast<uint32_t>(rv)));
       // maybe just blocked reading from network
       if (rv == NS_BASE_STREAM_WOULD_BLOCK)
         rv = NS_OK;
     }
 
     return rv;
   }
 
@@ -2812,17 +2813,18 @@ Http2Session::WriteSegmentsAgain(nsAHttp
       ResetDownstreamState();
       ResumeRecv();
       return NS_BASE_STREAM_WOULD_BLOCK;
     }
 
     rv = NetworkRead(writer, trash, discardCount, countWritten);
 
     if (NS_FAILED(rv)) {
-      LOG3(("Http2Session %p discard frame read failure %x\n", this, rv));
+      LOG3(("Http2Session %p discard frame read failure %" PRIx32 "\n", this,
+            static_cast<uint32_t>(rv)));
       // maybe just blocked reading from network
       if (rv == NS_BASE_STREAM_WOULD_BLOCK)
         rv = NS_OK;
       return rv;
     }
 
     LogIO(this, nullptr, "Discarding Frame", trash, *countWritten);
 
@@ -2851,18 +2853,18 @@ Http2Session::WriteSegmentsAgain(nsAHttp
   MOZ_ASSERT(mInputFrameBufferUsed == kFrameHeaderBytes, "Frame Buffer Header Not Present");
   MOZ_ASSERT(mInputFrameDataSize + kFrameHeaderBytes <= mInputFrameBufferSize,
              "allocation for control frame insufficient");
 
   rv = NetworkRead(writer, &mInputFrameBuffer[kFrameHeaderBytes + mInputFrameDataRead],
                    mInputFrameDataSize - mInputFrameDataRead, countWritten);
 
   if (NS_FAILED(rv)) {
-    LOG3(("Http2Session %p buffering control frame read failure %x\n",
-          this, rv));
+    LOG3(("Http2Session %p buffering control frame read failure %" PRIx32 "\n",
+          this, static_cast<uint32_t>(rv)));
     // maybe just blocked reading from network
     if (rv == NS_BASE_STREAM_WOULD_BLOCK)
       rv = NS_OK;
     return rv;
   }
 
   LogIO(this, nullptr, "Reading Control Frame",
         &mInputFrameBuffer[kFrameHeaderBytes + mInputFrameDataRead], *countWritten);
@@ -2940,18 +2942,18 @@ Http2Session::ProcessSlowConsumer(Http2S
                                   nsAHttpSegmentWriter * writer,
                                   uint32_t count, uint32_t *countWritten)
 {
   LOG3(("Http2Session::ProcessSlowConsumer %p 0x%X\n",
         this, slowConsumer->StreamID()));
   mSegmentWriter = writer;
   nsresult rv = slowConsumer->WriteSegments(this, count, countWritten);
   mSegmentWriter = nullptr;
-  LOG3(("Http2Session::ProcessSlowConsumer Writesegments %p 0x%X rv %X %d\n",
-        this, slowConsumer->StreamID(), rv, *countWritten));
+  LOG3(("Http2Session::ProcessSlowConsumer Writesegments %p 0x%X rv %" PRIX32 " %d\n",
+        this, slowConsumer->StreamID(), static_cast<uint32_t>(rv), *countWritten));
   if (NS_SUCCEEDED(rv) && !*countWritten && slowConsumer->RecvdFin()) {
     rv = NS_BASE_STREAM_CLOSED;
   }
 
   if (NS_SUCCEEDED(rv) && (*countWritten > 0)) {
     // There have been buffered bytes successfully fed into the
     // formerly blocked consumer. Repeat until buffer empty or
     // consumer is blocked again.
@@ -2983,17 +2985,17 @@ Http2Session::UpdateLocalStreamWindow(Ht
   stream->DecrementClientReceiveWindow(bytes);
 
   // Don't necessarily ack every data packet. Only do it
   // after a significant amount of data.
   uint64_t unacked = stream->LocalUnAcked();
   int64_t  localWindow = stream->ClientReceiveWindow();
 
   LOG3(("Http2Session::UpdateLocalStreamWindow this=%p id=0x%X newbytes=%u "
-        "unacked=%llu localWindow=%lld\n",
+        "unacked=%" PRIu64 " localWindow=%" PRId64 "\n",
         this, stream->StreamID(), bytes, unacked, localWindow));
 
   if (!unacked)
     return;
 
   if ((unacked < kMinimumToAck) && (localWindow > kEmergencyWindowThreshold))
     return;
 
@@ -3032,17 +3034,17 @@ void
 Http2Session::UpdateLocalSessionWindow(uint32_t bytes)
 {
   if (!bytes)
     return;
 
   mLocalSessionWindow -= bytes;
 
   LOG3(("Http2Session::UpdateLocalSessionWindow this=%p newbytes=%u "
-        "localWindow=%lld\n", this, bytes, mLocalSessionWindow));
+        "localWindow=%" PRId64 "\n", this, bytes, mLocalSessionWindow));
 
   // Don't necessarily ack every data packet. Only do it
   // after a significant amount of data.
   if ((mLocalSessionWindow > (mInitialRwin - kMinimumToAck)) &&
       (mLocalSessionWindow > kEmergencyWindowThreshold))
     return;
 
   // Only send max  bits of window updates at a time.
@@ -3085,17 +3087,17 @@ Http2Session::UpdateLocalRwin(Http2Strea
 void
 Http2Session::Close(nsresult aReason)
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
   if (mClosed)
     return;
 
-  LOG3(("Http2Session::Close %p %X", this, aReason));
+  LOG3(("Http2Session::Close %p %" PRIX32, this, static_cast<uint32_t>(aReason)));
 
   mClosed = true;
 
   Shutdown();
 
   mStreamIDHash.Clear();
   mStreamTransactionHash.Clear();
 
@@ -3123,30 +3125,31 @@ Http2Session::ConnectionInfo()
   return ci.get();
 }
 
 void
 Http2Session::CloseTransaction(nsAHttpTransaction *aTransaction,
                                nsresult aResult)
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
-  LOG3(("Http2Session::CloseTransaction %p %p %x", this, aTransaction, aResult));
+  LOG3(("Http2Session::CloseTransaction %p %p %" PRIx32, this, aTransaction,
+        static_cast<uint32_t>(aResult)));
 
   // Generally this arrives as a cancel event from the connection manager.
 
   // need to find the stream and call CleanupStream() on it.
   Http2Stream *stream = mStreamTransactionHash.Get(aTransaction);
   if (!stream) {
-    LOG3(("Http2Session::CloseTransaction %p %p %x - not found.",
-          this, aTransaction, aResult));
+    LOG3(("Http2Session::CloseTransaction %p %p %" PRIx32 " - not found.",
+          this, aTransaction, static_cast<uint32_t>(aResult)));
     return;
   }
   LOG3(("Http2Session::CloseTransaction probably a cancel. "
-        "this=%p, trans=%p, result=%x, streamID=0x%X stream=%p",
-        this, aTransaction, aResult, stream->StreamID(), stream));
+        "this=%p, trans=%p, result=%" PRIx32 ", streamID=0x%X stream=%p",
+        this, aTransaction, static_cast<uint32_t>(aResult), stream->StreamID(), stream));
   CleanupStream(stream, aResult, CANCEL_ERROR);
   ResumeRecv();
 }
 
 //-----------------------------------------------------------------------------
 // nsAHttpSegmentReader
 //-----------------------------------------------------------------------------
 
--- a/netwerk/protocol/http/Http2Stream.cpp
+++ b/netwerk/protocol/http/Http2Stream.cpp
@@ -143,18 +143,18 @@ Http2Stream::ReadSegments(nsAHttpSegment
   case GENERATING_BODY:
   case SENDING_BODY:
     // Call into the HTTP Transaction to generate the HTTP request
     // stream. That stream will show up in OnReadSegment().
     mSegmentReader = reader;
     rv = mTransaction->ReadSegments(this, count, countRead);
     mSegmentReader = nullptr;
 
-    LOG3(("Http2Stream::ReadSegments %p trans readsegments rv %x read=%d\n",
-          this, rv, *countRead));
+    LOG3(("Http2Stream::ReadSegments %p trans readsegments rv %" PRIx32 " read=%d\n",
+          this, static_cast<uint32_t>(rv), *countRead));
 
     // Check to see if the transaction's request could be written out now.
     // If not, mark the stream for callback when writing can proceed.
     if (NS_SUCCEEDED(rv) &&
         mUpstreamState == GENERATING_HEADERS &&
         !mRequestHeadersDone)
       mSession->TransactionHasDataToWrite(this);
 
@@ -307,17 +307,18 @@ Http2Stream::WriteSegments(nsAHttpSegmen
       RefPtr<SpdyConnectTransaction> qiTrans(mTransaction->QuerySpdyConnectTransaction());
       if (qiTrans) {
         doBuffer = qiTrans->ConnectedReadyForInput();
       }
     }
     // stash this data
     if (doBuffer) {
       rv = BufferInput(count, countWritten);
-      LOG3(("Http2Stream::WriteSegments %p Buffered %X %d\n", this, rv, *countWritten));
+      LOG3(("Http2Stream::WriteSegments %p Buffered %" PRIX32 " %d\n", this,
+            static_cast<uint32_t>(rv), *countWritten));
     }
   }
   mSegmentWriter = nullptr;
   return rv;
 }
 
 nsresult
 Http2Stream::MakeOriginURL(const nsACString &origin, RefPtr<nsStandardURL> &url)
@@ -436,18 +437,18 @@ Http2Stream::ParseHttpRequestHeaders(con
 
     // If a push stream is attached to the transaction via onPush, match only with that
     // one. This occurs when a push was made with in conjunction with a nsIHttpPushListener
     nsHttpTransaction *trans = mTransaction->QueryHttpTransaction();
     if (trans && (pushedStream = trans->TakePushedStream())) {
       if (pushedStream->mSession == mSession) {
         LOG3(("Pushed Stream match based on OnPush correlation %p", pushedStream));
       } else {
-        LOG3(("Pushed Stream match failed due to stream mismatch %p %d %d\n", pushedStream,
-              pushedStream->mSession->Serial(), mSession->Serial()));
+        LOG3(("Pushed Stream match failed due to stream mismatch %p %" PRId64 " %" PRId64 "\n",
+              pushedStream, pushedStream->mSession->Serial(), mSession->Serial()));
         pushedStream->OnPushFailed();
         pushedStream = nullptr;
       }
     }
 
     // we remove the pushedstream from the push cache so that
     // it will not be used for another GET. This does not destroy the
     // stream itself - that is done when the transactionhash is done with it.
@@ -866,18 +867,18 @@ Http2Stream::TransmitFrame(const char *b
   // bytes through to the session object and then the HttpConnection which calls
   // the socket write function. It will accept all of the inline and stream
   // data because of the above 'commitment' even if it has to buffer
 
   rv = mSession->BufferOutput(reinterpret_cast<char*>(mTxInlineFrame.get()),
                               mTxInlineFrameUsed,
                               &transmittedCount);
   LOG3(("Http2Stream::TransmitFrame for inline BufferOutput session=%p "
-        "stream=%p result %x len=%d",
-        mSession, this, rv, transmittedCount));
+        "stream=%p result %" PRIx32 " len=%d",
+        mSession, this, static_cast<uint32_t>(rv), transmittedCount));
 
   MOZ_ASSERT(rv != NS_BASE_STREAM_WOULD_BLOCK,
              "inconsistent inline commitment result");
 
   if (NS_FAILED(rv))
     return rv;
 
   MOZ_ASSERT(transmittedCount == mTxInlineFrameUsed,
@@ -902,18 +903,18 @@ Http2Stream::TransmitFrame(const char *b
       rv = mSession->BufferOutput(buf, mTxStreamFrameSize,
                                   &transmittedCount);
     } else {
       rv = mSession->OnReadSegment(buf, mTxStreamFrameSize,
                                    &transmittedCount);
     }
 
     LOG3(("Http2Stream::TransmitFrame for regular session=%p "
-          "stream=%p result %x len=%d",
-          mSession, this, rv, transmittedCount));
+          "stream=%p result %" PRIx32 " len=%d",
+          mSession, this, static_cast<uint32_t>(rv), transmittedCount));
 
     MOZ_ASSERT(rv != NS_BASE_STREAM_WOULD_BLOCK,
                "inconsistent stream commitment result");
 
     if (NS_FAILED(rv))
       return rv;
 
     MOZ_ASSERT(transmittedCount == mTxStreamFrameSize,
@@ -1309,17 +1310,17 @@ Http2Stream::OnReadSegment(const char *b
     break;
 
   case GENERATING_BODY:
     // if there is session flow control and either the stream window is active and
     // exhaused or the session window is exhausted then suspend
     if (!AllowFlowControlledWrite()) {
       *countRead = 0;
       LOG3(("Http2Stream this=%p, id 0x%X request body suspended because "
-            "remote window is stream=%ld session=%ld.\n", this, mStreamID,
+            "remote window is stream=%" PRId64 " session=%" PRId64 ".\n", this, mStreamID,
             mServerReceiveWindow, mSession->ServerSessionWindow()));
       mBlockedOnRwin = true;
       return NS_BASE_STREAM_WOULD_BLOCK;
     }
     mBlockedOnRwin = false;
 
     // The chunk is the smallest of: availableData, configured chunkSize,
     // stream window, session window, or 14 bit framing limit.
@@ -1359,19 +1360,19 @@ Http2Stream::OnReadSegment(const char *b
     MOZ_FALLTHROUGH;
 
   case SENDING_BODY:
     MOZ_ASSERT(mTxInlineFrameUsed, "OnReadSegment Send Data Header 0b");
     rv = TransmitFrame(buf, countRead, false);
     MOZ_ASSERT(NS_FAILED(rv) || !mTxInlineFrameUsed,
                "Transmit Frame should be all or nothing");
 
-    LOG3(("TransmitFrame() rv=%x returning %d data bytes. "
+    LOG3(("TransmitFrame() rv=%" PRIx32 " returning %d data bytes. "
           "Header is %d Body is %d.",
-          rv, *countRead, mTxInlineFrameUsed, mTxStreamFrameSize));
+          static_cast<uint32_t>(rv), *countRead, mTxInlineFrameUsed, mTxStreamFrameSize));
 
     // normalize a partial write with a WOULD_BLOCK into just a partial write
     // as some code will take WOULD_BLOCK to mean an error with nothing
     // written (e.g. nsHttpTransaction::ReadRequestSegment()
     if (rv == NS_BASE_STREAM_WOULD_BLOCK && *countRead)
       rv = NS_OK;
 
     // If that frame was all sent, look for another one
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -200,33 +200,33 @@ HttpBaseChannel::HttpBaseChannel()
   , mDecodedBodySize(0)
   , mEncodedBodySize(0)
   , mContentWindowId(0)
   , mRequireCORSPreflight(false)
   , mReportCollector(new ConsoleReportCollector())
   , mForceMainDocumentChannel(false)
   , mIsTrackingResource(false)
 {
-  LOG(("Creating HttpBaseChannel @%x\n", this));
+  LOG(("Creating HttpBaseChannel @%p\n", this));
 
   // Subfields of unions cannot be targeted in an initializer list.
 #ifdef MOZ_VALGRIND
   // Zero the entire unions so that Valgrind doesn't complain when we send them
   // to another process.
   memset(&mSelfAddr, 0, sizeof(NetAddr));
   memset(&mPeerAddr, 0, sizeof(NetAddr));
 #endif
   mSelfAddr.raw.family = PR_AF_UNSPEC;
   mPeerAddr.raw.family = PR_AF_UNSPEC;
   mRequestContextID.Clear();
 }
 
 HttpBaseChannel::~HttpBaseChannel()
 {
-  LOG(("Destroying HttpBaseChannel @%x\n", this));
+  LOG(("Destroying HttpBaseChannel @%p\n", this));
 
   // Make sure we don't leak
   CleanRedirectCacheChainIfNecessary();
 
   ReleaseMainThreadOnlyReferences();
 }
 
 void
@@ -1038,17 +1038,18 @@ public:
   NS_IMETHOD OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) override
   {
     return mNext->OnStartRequest(aRequest, aContext);
   }
 
   NS_IMETHOD OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, nsresult aStatusCode) override
   {
     if (NS_FAILED(aStatusCode) && NS_SUCCEEDED(mChannel->mStatus)) {
-      LOG(("HttpBaseChannel::InterceptFailedOnStop %p seting status %x", mChannel, aStatusCode));
+      LOG(("HttpBaseChannel::InterceptFailedOnStop %p seting status %" PRIx32,
+           mChannel, static_cast<uint32_t>(aStatusCode)));
       mChannel->mStatus = aStatusCode;
     }
     return mNext->OnStopRequest(aRequest, aContext, aStatusCode);
   }
 
   NS_IMETHOD OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext,
                            nsIInputStream *aInputStream, uint64_t aOffset,
                            uint32_t aCount) override
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -42,16 +42,17 @@
 #include "nsIHttpChannel.h"
 #include "nsISecurityConsoleMessage.h"
 #include "nsCOMArray.h"
 #include "mozilla/net/ChannelEventQueue.h"
 #include "mozilla/Move.h"
 #include "nsIThrottledInputChannel.h"
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
+#include "mozilla/IntegerPrintfMacros.h"
 
 #define HTTP_BASE_CHANNEL_IID \
 { 0x9d5cde03, 0xe6e9, 0x4612, \
     { 0xbf, 0xef, 0xbb, 0x66, 0xf3, 0xbb, 0x74, 0x46 } }
 
 
 class nsISecurityConsoleMessage;
 class nsIPrincipal;
@@ -636,17 +637,18 @@ protected:
   // Function to be called at resume time
   void (T::* mCallOnResume)(void);
 };
 
 template <class T>
 nsresult HttpAsyncAborter<T>::AsyncAbort(nsresult status)
 {
   MOZ_LOG(gHttpLog, LogLevel::Debug,
-         ("HttpAsyncAborter::AsyncAbort [this=%p status=%x]\n", mThis, status));
+         ("HttpAsyncAborter::AsyncAbort [this=%p status=%" PRIx32 "]\n",
+          mThis, static_cast<uint32_t>(status)));
 
   mThis->mStatus = status;
 
   // if this fails?  Callers ignore our return value anyway....
   return AsyncCall(&T::HandleAsyncAbort);
 }
 
 // Each subclass needs to define its own version of this (which just calls this
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -176,27 +176,27 @@ HttpChannelChild::HttpChannelChild()
   , mSynthesizedResponse(false)
   , mShouldInterceptSubsequentRedirect(false)
   , mRedirectingForSubsequentSynthesizedResponse(false)
   , mPostRedirectChannelShouldIntercept(false)
   , mPostRedirectChannelShouldUpgrade(false)
   , mShouldParentIntercept(false)
   , mSuspendParentAfterSynthesizeResponse(false)
 {
-  LOG(("Creating HttpChannelChild @%x\n", this));
+  LOG(("Creating HttpChannelChild @%p\n", this));
 
   mChannelCreationTime = PR_Now();
   mChannelCreationTimestamp = TimeStamp::Now();
   mAsyncOpenTime = TimeStamp::Now();
   mEventQ = new ChannelEventQueue(static_cast<nsIHttpChannel*>(this));
 }
 
 HttpChannelChild::~HttpChannelChild()
 {
-  LOG(("Destroying HttpChannelChild @%x\n", this));
+  LOG(("Destroying HttpChannelChild @%p\n", this));
 }
 
 //-----------------------------------------------------------------------------
 // HttpChannelChild::nsISupports
 //-----------------------------------------------------------------------------
 
 // Override nsHashPropertyBag's AddRef: we don't need thread-safe refcnt
 NS_IMPL_ADDREF(HttpChannelChild)
@@ -850,29 +850,29 @@ class MaybeDivertOnStopHttpEvent : publi
   HttpChannelChild* mChild;
   nsresult mChannelStatus;
 };
 
 void
 HttpChannelChild::MaybeDivertOnStop(const nsresult& aChannelStatus)
 {
   LOG(("HttpChannelChild::MaybeDivertOnStop [this=%p, "
-       "mDivertingToParent=%d status=%x]", this, mDivertingToParent,
-       aChannelStatus));
+       "mDivertingToParent=%d status=%" PRIx32 "]", this, mDivertingToParent,
+       static_cast<uint32_t>(aChannelStatus)));
   if (mDivertingToParent) {
     SendDivertOnStopRequest(aChannelStatus);
   }
 }
 
 void
 HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
                                 const ResourceTimingStruct& timing)
 {
-  LOG(("HttpChannelChild::OnStopRequest [this=%p status=%x]\n",
-       this, channelStatus));
+  LOG(("HttpChannelChild::OnStopRequest [this=%p status=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(channelStatus)));
 
   if (mDivertingToParent) {
     MOZ_RELEASE_ASSERT(!mFlushedForDiversion,
       "Should not be processing any more callbacks from parent!");
 
     SendDivertOnStopRequest(channelStatus);
     return;
   }
@@ -946,18 +946,18 @@ HttpChannelChild::OnStopRequest(const ns
     // making sure not to send any more messages after that.
     SendDeletingChannel();
   }
 }
 
 void
 HttpChannelChild::DoPreOnStopRequest(nsresult aStatus)
 {
-  LOG(("HttpChannelChild::DoPreOnStopRequest [this=%p status=%x]\n",
-       this, aStatus));
+  LOG(("HttpChannelChild::DoPreOnStopRequest [this=%p status=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(aStatus)));
   mIsPending = false;
 
   if (!mCanceled && NS_SUCCEEDED(mStatus)) {
     mStatus = aStatus;
   }
 }
 
 void
@@ -1013,17 +1013,17 @@ HttpChannelChild::RecvOnProgress(const i
   mEventQ->RunOrEnqueue(new ProgressEvent(this, progress, progressMax));
   return IPC_OK();
 }
 
 void
 HttpChannelChild::OnProgress(const int64_t& progress,
                              const int64_t& progressMax)
 {
-  LOG(("HttpChannelChild::OnProgress [this=%p progress=%lld/%lld]\n",
+  LOG(("HttpChannelChild::OnProgress [this=%p progress=%" PRId64 "/%" PRId64 "]\n",
        this, progress, progressMax));
 
   if (mCanceled)
     return;
 
   // cache the progress sink so we don't have to query for it each time.
   if (!mProgressSink) {
     GetCallback(mProgressSink);
@@ -1059,17 +1059,18 @@ HttpChannelChild::RecvOnStatus(const nsr
 {
   mEventQ->RunOrEnqueue(new StatusEvent(this, status));
   return IPC_OK();
 }
 
 void
 HttpChannelChild::OnStatus(const nsresult& status)
 {
-  LOG(("HttpChannelChild::OnStatus [this=%p status=%x]\n", this, status));
+  LOG(("HttpChannelChild::OnStatus [this=%p status=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(status)));
 
   if (mCanceled)
     return;
 
   // cache the progress sink so we don't have to query for it each time.
   if (!mProgressSink)
     GetCallback(mProgressSink);
 
@@ -1115,17 +1116,18 @@ void
 HttpChannelChild::HandleAsyncAbort()
 {
   HttpAsyncAborter<HttpChannelChild>::HandleAsyncAbort();
 }
 
 void
 HttpChannelChild::FailedAsyncOpen(const nsresult& status)
 {
-  LOG(("HttpChannelChild::FailedAsyncOpen [this=%p status=%x]\n", this, status));
+  LOG(("HttpChannelChild::FailedAsyncOpen [this=%p status=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(status)));
 
   mStatus = status;
 
   // We're already being called from IPDL, therefore already "async"
   HandleAsyncAbort();
 
   if (mIPCOpen) {
     SendDeletingChannel();
@@ -1841,17 +1843,17 @@ HttpChannelChild::Cancel(nsresult status
     mInterceptListener = nullptr;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelChild::Suspend()
 {
-  LOG(("HttpChannelChild::Suspend [this=%p, mSuspendCount=%lu, "
+  LOG(("HttpChannelChild::Suspend [this=%p, mSuspendCount=%" PRIu32 ", "
        "mDivertingToParent=%d]\n", this, mSuspendCount+1, mDivertingToParent));
   NS_ENSURE_TRUE(RemoteChannelExists() || mInterceptListener,
                  NS_ERROR_NOT_AVAILABLE);
 
   // SendSuspend only once, when suspend goes from 0 to 1.
   // Don't SendSuspend at all if we're diverting callbacks to the parent;
   // suspend will be called at the correct time in the parent itself.
   if (!mSuspendCount++ && !mDivertingToParent) {
@@ -1866,17 +1868,17 @@ HttpChannelChild::Suspend()
   mEventQ->Suspend();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelChild::Resume()
 {
-  LOG(("HttpChannelChild::Resume [this=%p, mSuspendCount=%lu, "
+  LOG(("HttpChannelChild::Resume [this=%p, mSuspendCount=%" PRIu32 ", "
        "mDivertingToParent=%d]\n", this, mSuspendCount-1, mDivertingToParent));
   NS_ENSURE_TRUE(RemoteChannelExists() || mInterceptListener,
                  NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mSuspendCount > 0, NS_ERROR_UNEXPECTED);
 
   nsresult rv = NS_OK;
 
   // SendResume only once, when suspend count drops to 0.
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -584,33 +584,33 @@ HttpChannelParent::DoAsyncOpen(  const U
 }
 
 bool
 HttpChannelParent::ConnectChannel(const uint32_t& registrarId, const bool& shouldIntercept)
 {
   nsresult rv;
 
   LOG(("HttpChannelParent::ConnectChannel: Looking for a registered channel "
-       "[this=%p, id=%lu]\n", this, registrarId));
+       "[this=%p, id=%" PRIu32 "]\n", this, registrarId));
   nsCOMPtr<nsIChannel> channel;
   rv = NS_LinkRedirectChannels(registrarId, this, getter_AddRefs(channel));
   if (NS_FAILED(rv)) {
     NS_ERROR("Could not find the http channel to connect its IPC parent");
     // This makes the channel delete itself safely.  It's the only thing
     // we can do now, since this parent channel cannot be used and there is
     // no other way to tell the child side there were something wrong.
     Delete();
     return true;
   }
 
   // It's safe to cast here since the found parent-side real channel is ensured
   // to be http (nsHttpChannel).  ConnectChannel called from HttpChannelParent::Init
   // can only be called for http channels.  It's bound by ipdl.
   mChannel = static_cast<nsHttpChannel*>(channel.get());
-  LOG(("  found channel %p, rv=%08x", mChannel.get(), rv));
+  LOG(("  found channel %p, rv=%08" PRIx32, mChannel.get(), static_cast<uint32_t>(rv)));
 
   nsCOMPtr<nsINetworkInterceptController> controller;
   NS_QueryNotificationCallbacks(channel, controller);
   RefPtr<HttpChannelParentListener> parentListener = do_QueryObject(controller);
   MOZ_ASSERT(parentListener);
   parentListener->SetupInterceptionAfterRedirect(shouldIntercept);
 
   if (mPBOverride != kPBOverride_Unset) {
@@ -712,18 +712,18 @@ HttpChannelParent::RecvRedirect2Verify(c
                                        const uint32_t& referrerPolicy,
                                        const OptionalURIParams& aReferrerURI,
                                        const OptionalURIParams& aAPIRedirectURI,
                                        const OptionalCorsPreflightArgs& aCorsPreflightArgs,
                                        const bool& aForceHSTSPriming,
                                        const bool& aMixedContentWouldBlock,
                                        const bool& aChooseAppcache)
 {
-  LOG(("HttpChannelParent::RecvRedirect2Verify [this=%p result=%x]\n",
-       this, result));
+  LOG(("HttpChannelParent::RecvRedirect2Verify [this=%p result=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(result)));
   nsresult rv;
   if (NS_SUCCEEDED(result)) {
     nsCOMPtr<nsIHttpChannel> newHttpChannel =
         do_QueryInterface(mRedirectChannel);
 
     if (newHttpChannel) {
       nsCOMPtr<nsIURI> apiRedirectUri = DeserializeURI(aAPIRedirectURI);
 
@@ -789,18 +789,18 @@ HttpChannelParent::RecvRedirect2Verify(c
     NS_ERROR("Unexpcted call to HttpChannelParent::RecvRedirect2Verify, "
              "mRedirectCallback null");
   }
 
   mReceivedRedirect2Verify = true;
 
   if (mRedirectCallback) {
     LOG(("HttpChannelParent::RecvRedirect2Verify call OnRedirectVerifyCallback"
-         " [this=%p result=%x, mRedirectCallback=%p]\n",
-         this, result, mRedirectCallback.get()));
+         " [this=%p result=%" PRIx32 ", mRedirectCallback=%p]\n",
+         this, static_cast<uint32_t>(result), mRedirectCallback.get()));
     mRedirectCallback->OnRedirectVerifyCallback(result);
     mRedirectCallback = nullptr;
   }
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
@@ -1204,18 +1204,18 @@ HttpChannelParent::OnStartRequest(nsIReq
   return rv;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::OnStopRequest(nsIRequest *aRequest,
                                  nsISupports *aContext,
                                  nsresult aStatusCode)
 {
-  LOG(("HttpChannelParent::OnStopRequest: [this=%p aRequest=%p status=%x]\n",
-       this, aRequest, aStatusCode));
+  LOG(("HttpChannelParent::OnStopRequest: [this=%p aRequest=%p status=%" PRIx32 "]\n",
+       this, aRequest, static_cast<uint32_t>(aStatusCode)));
 
   MOZ_RELEASE_ASSERT(!mDivertingFromChild,
     "Cannot call OnStopRequest if diverting is set!");
   ResourceTimingStruct timing;
   mChannel->GetDomainLookupStart(&timing.domainLookupStart);
   mChannel->GetDomainLookupEnd(&timing.domainLookupEnd);
   mChannel->GetConnectStart(&timing.connectStart);
   mChannel->GetConnectEnd(&timing.connectEnd);
@@ -1388,17 +1388,17 @@ HttpChannelParent::Delete()
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 HttpChannelParent::StartRedirect(uint32_t registrarId,
                                  nsIChannel* newChannel,
                                  uint32_t redirectFlags,
                                  nsIAsyncVerifyRedirectCallback* callback)
 {
-  LOG(("HttpChannelParent::StartRedirect [this=%p, registrarId=%lu "
+  LOG(("HttpChannelParent::StartRedirect [this=%p, registrarId=%" PRIu32 " "
        "newChannel=%p callback=%p]\n", this, registrarId, newChannel,
        callback));
 
   if (mIPCClosed)
     return NS_BINDING_ABORTED;
 
   nsCOMPtr<nsIURI> newURI;
   newChannel->GetURI(getter_AddRefs(newURI));
@@ -1701,18 +1701,18 @@ HttpChannelParent::FailDiversion(nsresul
   NS_DispatchToCurrentThread(
     new HTTPFailDiversionEvent(this, aErrorCode, aSkipResume));
 }
 
 void
 HttpChannelParent::NotifyDiversionFailed(nsresult aErrorCode,
                                          bool aSkipResume)
 {
-  LOG(("HttpChannelParent::NotifyDiversionFailed [this=%p aErrorCode=%x]\n",
-       this, aErrorCode));
+  LOG(("HttpChannelParent::NotifyDiversionFailed [this=%p aErrorCode=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(aErrorCode)));
   MOZ_RELEASE_ASSERT(NS_FAILED(aErrorCode));
   MOZ_RELEASE_ASSERT(mDivertingFromChild);
   MOZ_RELEASE_ASSERT(mParentListener);
   MOZ_RELEASE_ASSERT(mChannel);
 
   mChannel->Cancel(aErrorCode);
 
   mChannel->ForcePending(false);
--- a/netwerk/protocol/http/HttpChannelParentListener.cpp
+++ b/netwerk/protocol/http/HttpChannelParentListener.cpp
@@ -78,18 +78,18 @@ HttpChannelParentListener::OnStopRequest
                                          nsresult aStatusCode)
 {
   MOZ_RELEASE_ASSERT(!mSuspendedForDiversion,
     "Cannot call OnStopRequest if suspended for diversion!");
 
   if (!mNextListener)
     return NS_ERROR_UNEXPECTED;
 
-  LOG(("HttpChannelParentListener::OnStopRequest: [this=%p status=%ul]\n",
-       this, aStatusCode));
+  LOG(("HttpChannelParentListener::OnStopRequest: [this=%p status=%" PRIu32 "]\n",
+       this, static_cast<uint32_t>(aStatusCode)));
   nsresult rv = mNextListener->OnStopRequest(aRequest, aContext, aStatusCode);
 
   mNextListener = nullptr;
   return rv;
 }
 
 //-----------------------------------------------------------------------------
 // HttpChannelParentListener::nsIStreamListener
--- a/netwerk/protocol/http/TunnelUtils.cpp
+++ b/netwerk/protocol/http/TunnelUtils.cpp
@@ -277,33 +277,35 @@ TLSFilterTransaction::OnWriteSegment(cha
   *outCountRead = bytesRead;
 
   if (NS_SUCCEEDED(mFilterReadCode) && !bytesRead) {
     LOG(("TLSFilterTransaction::OnWriteSegment %p "
          "Second layer of TLS stripping results in STREAM_CLOSED\n", this));
     mFilterReadCode = NS_BASE_STREAM_CLOSED;
   }
 
-  LOG(("TLSFilterTransaction::OnWriteSegment %p rv=%x didread=%d "
-        "2 layers of ssl stripped to plaintext\n", this, mFilterReadCode, bytesRead));
+  LOG(("TLSFilterTransaction::OnWriteSegment %p rv=%" PRIx32 " didread=%d "
+       "2 layers of ssl stripped to plaintext\n",
+       this, static_cast<uint32_t>(mFilterReadCode), bytesRead));
   return mFilterReadCode;
 }
 
 int32_t
 TLSFilterTransaction::FilterInput(char *aBuf, int32_t aAmount)
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
   MOZ_ASSERT(mSegmentWriter);
   LOG(("TLSFilterTransaction::FilterInput max=%d\n", aAmount));
 
   uint32_t outCountRead = 0;
   mFilterReadCode = mSegmentWriter->OnWriteSegment(aBuf, aAmount, &outCountRead);
   if (NS_SUCCEEDED(mFilterReadCode) && outCountRead) {
-    LOG(("TLSFilterTransaction::FilterInput rv=%x read=%d input from net "
-         "1 layer stripped, 1 still on\n", mFilterReadCode, outCountRead));
+    LOG(("TLSFilterTransaction::FilterInput rv=%" PRIx32 " read=%d input from net "
+         "1 layer stripped, 1 still on\n",
+         static_cast<uint32_t>(mFilterReadCode), outCountRead));
     if (mReadSegmentBlocked) {
       mNudgeCounter = 0;
     }
   }
   if (mFilterReadCode == NS_BASE_STREAM_WOULD_BLOCK) {
     PR_SetError(PR_WOULD_BLOCK_ERROR, 0);
     return -1;
   }
@@ -319,22 +321,22 @@ TLSFilterTransaction::ReadSegments(nsAHt
 
   if (!mTransaction) {
     return NS_ERROR_UNEXPECTED;
   }
 
   mReadSegmentBlocked = false;
   mSegmentReader = aReader;
   nsresult rv = mTransaction->ReadSegments(this, aCount, outCountRead);
-  LOG(("TLSFilterTransaction %p called trans->ReadSegments rv=%x %d\n",
-       this, rv, *outCountRead));
+  LOG(("TLSFilterTransaction %p called trans->ReadSegments rv=%" PRIx32 " %d\n",
+       this, static_cast<uint32_t>(rv), *outCountRead));
   if (NS_SUCCEEDED(rv) && mReadSegmentBlocked) {
     rv = NS_BASE_STREAM_WOULD_BLOCK;
-    LOG(("TLSFilterTransaction %p read segment blocked found rv=%x\n",
-         this, rv));
+    LOG(("TLSFilterTransaction %p read segment blocked found rv=%" PRIx32 "\n",
+         this, static_cast<uint32_t>(rv)));
     Connection()->ForceSend();
   }
 
   return rv;
 }
 
 nsresult
 TLSFilterTransaction::WriteSegments(nsAHttpSegmentWriter *aWriter,
@@ -351,18 +353,18 @@ TLSFilterTransaction::WriteSegments(nsAH
   nsresult rv = mTransaction->WriteSegments(this, aCount, outCountWritten);
   if (NS_SUCCEEDED(rv) && NS_FAILED(mFilterReadCode) && !(*outCountWritten)) {
     // nsPipe turns failures into silent OK.. undo that!
     rv = mFilterReadCode;
     if (Connection() && (mFilterReadCode == NS_BASE_STREAM_WOULD_BLOCK)) {
       Connection()->ResumeRecv();
     }
   }
-  LOG(("TLSFilterTransaction %p called trans->WriteSegments rv=%x %d\n",
-       this, rv, *outCountWritten));
+  LOG(("TLSFilterTransaction %p called trans->WriteSegments rv=%" PRIx32 " %d\n",
+       this, static_cast<uint32_t>(rv), *outCountWritten));
   return rv;
 }
 
 nsresult
 TLSFilterTransaction::GetTransactionSecurityInfo(nsISupports **outSecInfo)
 {
   if (!mSecInfo) {
     return NS_ERROR_FAILURE;
@@ -812,18 +814,18 @@ private:
 };
 
 nsresult
 SocketInWrapper::OnWriteSegment(char *segment, uint32_t count, uint32_t *countWritten)
 {
   LOG(("SocketInWrapper OnWriteSegment %d %p filter=%p\n", count, this, mTLSFilter.get()));
 
   nsresult rv = mStream->Read(segment, count, countWritten);
-  LOG(("SocketInWrapper OnWriteSegment %p wrapped read %x %d\n",
-       this, rv, *countWritten));
+  LOG(("SocketInWrapper OnWriteSegment %p wrapped read %" PRIx32 " %d\n",
+       this, static_cast<uint32_t>(rv), *countWritten));
   return rv;
 }
 
 NS_IMETHODIMP
 SocketInWrapper::Read(char *aBuf, uint32_t aCount, uint32_t *_retval)
 {
   LOG(("SocketInWrapper Read %d %p filter=%p\n", aCount, this, mTLSFilter.get()));
 
@@ -1100,17 +1102,18 @@ SpdyConnectTransaction::Flush(uint32_t c
 
   *countRead = 0;
   count = std::min(count, (mOutputDataUsed - mOutputDataOffset));
   if (count) {
     nsresult rv;
     rv = mSegmentReader->OnReadSegment(&mOutputData[mOutputDataOffset],
                                        count, countRead);
     if (NS_FAILED(rv) && (rv != NS_BASE_STREAM_WOULD_BLOCK)) {
-      LOG(("SpdyConnectTransaction::Flush %p Error %x\n", this, rv));
+      LOG(("SpdyConnectTransaction::Flush %p Error %" PRIx32 "\n",
+           this, static_cast<uint32_t>(rv)));
       CreateShimError(rv);
       return rv;
     }
   }
 
   mOutputDataOffset += *countRead;
   if (mOutputDataOffset == mOutputDataUsed) {
     mOutputDataOffset = mOutputDataUsed = 0;
@@ -1144,18 +1147,18 @@ SpdyConnectTransaction::ReadSegments(nsA
     uint32_t toWrite = mConnectString.Length() - mConnectStringOffset;
     toWrite = std::min(toWrite, count);
     *countRead = toWrite;
     if (toWrite) {
       nsresult rv = mSegmentReader->
         OnReadSegment(mConnectString.BeginReading() + mConnectStringOffset,
                       toWrite, countRead);
       if (NS_FAILED(rv) && (rv != NS_BASE_STREAM_WOULD_BLOCK)) {
-        LOG(("SpdyConnectTransaction::ReadSegments %p OnReadSegmentError %x\n",
-             this, rv));
+        LOG(("SpdyConnectTransaction::ReadSegments %p OnReadSegmentError %" PRIx32 "\n",
+             this, static_cast<uint32_t>(rv)));
         CreateShimError(rv);
       } else {
         mConnectStringOffset += toWrite;
         if (mConnectString.Length() == mConnectStringOffset) {
           mConnectString.Truncate();
           mConnectStringOffset = 0;
         }
       }
@@ -1228,35 +1231,37 @@ SpdyConnectTransaction::WriteSegments(ns
 
   // first call into the tunnel stream to get the demux'd data out of the
   // spdy session.
   EnsureBuffer(mInputData, mInputDataUsed + count, mInputDataUsed, mInputDataSize);
   nsresult rv = writer->OnWriteSegment(&mInputData[mInputDataUsed],
                                        count, countWritten);
   if (NS_FAILED(rv)) {
     if (rv != NS_BASE_STREAM_WOULD_BLOCK) {
-      LOG(("SpdyConnectTransaction::WriteSegments wrapped writer %p Error %x\n", this, rv));
+      LOG(("SpdyConnectTransaction::WriteSegments wrapped writer %p Error %" PRIx32 "\n",
+           this, static_cast<uint32_t>(rv)));
       CreateShimError(rv);
     }
     return rv;
   }
   mInputDataUsed += *countWritten;
   LOG(("SpdyConnectTransaction %p %d new bytes [%d total] of ciphered data buffered\n",
        this, *countWritten, mInputDataUsed - mInputDataOffset));
 
   if (!mTunneledConn || !mTunnelStreamIn->mCallback) {
     return NS_BASE_STREAM_WOULD_BLOCK;
   }
 
   rv = mTunnelStreamIn->mCallback->OnInputStreamReady(mTunnelStreamIn);
   LOG(("SpdyConnectTransaction::WriteSegments %p "
-       "after InputStreamReady callback %d total of ciphered data buffered rv=%x\n",
-       this, mInputDataUsed - mInputDataOffset, rv));
+       "after InputStreamReady callback %d total of ciphered data buffered rv=%"
+       PRIx32 "\n",
+       this, mInputDataUsed - mInputDataOffset, static_cast<uint32_t>(rv)));
   LOG(("SpdyConnectTransaction::WriteSegments %p "
-       "goodput %p out %llu\n", this, mTunneledConn.get(),
+       "goodput %p out %" PRId64 "\n", this, mTunneledConn.get(),
        mTunneledConn->ContentBytesWritten()));
   if (NS_SUCCEEDED(rv) && !mTunneledConn->ContentBytesWritten()) {
     mTunnelStreamOut->AsyncWait(mTunnelStreamOut->mCallback, 0, 0, nullptr);
   }
   return rv;
 }
 
 bool
@@ -1269,17 +1274,17 @@ nsHttpRequestHead *
 SpdyConnectTransaction::RequestHead()
 {
   return mRequestHead;
 }
 
 void
 SpdyConnectTransaction::Close(nsresult code)
 {
-  LOG(("SpdyConnectTransaction close %p %x\n", this, code));
+  LOG(("SpdyConnectTransaction close %p %" PRIx32 "\n", this, static_cast<uint32_t>(code)));
 
   NullHttpTransaction::Close(code);
   if (NS_FAILED(code) && (code != NS_BASE_STREAM_WOULD_BLOCK)) {
     CreateShimError(code);
   } else {
     CreateShimError(NS_BASE_STREAM_CLOSED);
   }
 }
--- a/netwerk/protocol/http/nsHttp.cpp
+++ b/netwerk/protocol/http/nsHttp.cpp
@@ -299,17 +299,17 @@ nsHttp::ParseInt64(const char *input, co
     char *end = nullptr;
     errno = 0; // Clear errno to make sure its value is set by strtoll
     int64_t value = strtoll(input, &end, /* base */ 10);
 
     // Fail if: - the parsed number overflows.
     //          - the end points to the start of the input string.
     //          - we parsed a negative value. Consumers don't expect that.
     if (errno != 0 || end == input || value < 0) {
-        LOG(("nsHttp::ParseInt64 value=%ld errno=%d", value, errno));
+        LOG(("nsHttp::ParseInt64 value=%" PRId64 " errno=%d", value, errno));
         return false;
     }
 
     if (next) {
         *next = end;
     }
     *r = value;
     return true;
--- a/netwerk/protocol/http/nsHttpAuthCache.cpp
+++ b/netwerk/protocol/http/nsHttpAuthCache.cpp
@@ -140,17 +140,17 @@ nsHttpAuthCache::SetAuthEntry(const char
                               const char *creds,
                               const char *challenge,
                               nsACString const &originSuffix,
                               const nsHttpAuthIdentity *ident,
                               nsISupports *metadata)
 {
     nsresult rv;
 
-    LOG(("nsHttpAuthCache::SetAuthEntry [key=%s://%s:%d realm=%s path=%s metadata=%x]\n",
+    LOG(("nsHttpAuthCache::SetAuthEntry [key=%s://%s:%d realm=%s path=%s metadata=%p]\n",
         scheme, host, port, realm, path, metadata));
 
     if (!mDB) {
         rv = Init();
         if (NS_FAILED(rv)) return rv;
     }
 
     nsAutoCString key;
@@ -499,22 +499,22 @@ nsHttpAuthEntry::Set(const char *path,
 }
 
 //-----------------------------------------------------------------------------
 // nsHttpAuthNode
 //-----------------------------------------------------------------------------
 
 nsHttpAuthNode::nsHttpAuthNode()
 {
-    LOG(("Creating nsHttpAuthNode @%x\n", this));
+    LOG(("Creating nsHttpAuthNode @%p\n", this));
 }
 
 nsHttpAuthNode::~nsHttpAuthNode()
 {
-    LOG(("Destroying nsHttpAuthNode @%x\n", this));
+    LOG(("Destroying nsHttpAuthNode @%p\n", this));
 
     mList.Clear();
 }
 
 nsHttpAuthEntry *
 nsHttpAuthNode::LookupEntryByPath(const char *path)
 {
     nsHttpAuthEntry *entry;
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // HttpLog.h should generally be included first
 #include "HttpLog.h"
 
 #include <inttypes.h>
 
 #include "mozilla/dom/nsCSPContext.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Sprintf.h"
 
 #include "nsHttp.h"
 #include "nsHttpChannel.h"
 #include "nsHttpHandler.h"
 #include "nsIApplicationCacheService.h"
 #include "nsIApplicationCacheContainer.h"
 #include "nsICacheStorageService.h"
@@ -437,17 +438,17 @@ nsHttpChannel::Connect()
             mWaitingForProxy = false;
             return TryHSTSPriming();
         }
 
         return NS_OK;
     }
 
     if (NS_FAILED(rv)) {
-        LOG(("OpenCacheEntry failed [rv=%x]\n", rv));
+        LOG(("OpenCacheEntry failed [rv=%" PRIx32 "]\n", static_cast<uint32_t>(rv)));
         // if this channel is only allowed to pull from the cache, then
         // we must fail if we were unable to open a cache entry.
         if (mLoadFlags & LOAD_ONLY_FROM_CACHE) {
             // If we have a fallback URI (and we're not already
             // falling back), process the fallback asynchronously.
             if (!mFallbackChannel && !mFallbackKey.IsEmpty()) {
                 return AsyncCall(&nsHttpChannel::HandleAsyncFallback);
             }
@@ -655,17 +656,18 @@ nsHttpChannel::HandleAsyncRedirect()
 }
 
 nsresult
 nsHttpChannel::ContinueHandleAsyncRedirect(nsresult rv)
 {
     if (NS_FAILED(rv)) {
         // If AsyncProcessRedirection fails, then we have to send out the
         // OnStart/OnStop notifications.
-        LOG(("ContinueHandleAsyncRedirect got failure result [rv=%x]\n", rv));
+        LOG(("ContinueHandleAsyncRedirect got failure result [rv=%" PRIx32 "]\n",
+             static_cast<uint32_t>(rv)));
 
         bool redirectsEnabled =
             !mLoadInfo || !mLoadInfo->GetDontFollowRedirects();
 
         if (redirectsEnabled) {
             // TODO: stop failing original channel if redirect vetoed?
             mStatus = rv;
 
@@ -747,17 +749,18 @@ nsHttpChannel::HandleAsyncFallback()
 }
 
 nsresult
 nsHttpChannel::ContinueHandleAsyncFallback(nsresult rv)
 {
     if (!mCanceled && (NS_FAILED(rv) || !mFallingBack)) {
         // If ProcessFallback fails, then we have to send out the
         // OnStart/OnStop notifications.
-        LOG(("ProcessFallback failed [rv=%x, %d]\n", rv, mFallingBack));
+        LOG(("ProcessFallback failed [rv=%" PRIx32 ", %d]\n",
+             static_cast<uint32_t>(rv), mFallingBack));
         mStatus = NS_FAILED(rv) ? rv : NS_ERROR_DOCUMENT_NOT_CACHED;
         DoNotifyListener();
     }
 
     mIsPending = false;
 
     if (mLoadGroup)
         mLoadGroup->RemoveRequest(this, nullptr, mStatus);
@@ -2193,17 +2196,18 @@ nsHttpChannel::ContinueProcessResponse2(
     case 305: // disabled as a security measure (see bug 187996).
 #endif
         // don't store the response body for redirects
         MaybeInvalidateCacheEntryForSubsequentGet();
         PushRedirectAsyncFunc(&nsHttpChannel::ContinueProcessResponse3);
         rv = AsyncProcessRedirection(httpStatus);
         if (NS_FAILED(rv)) {
             PopRedirectAsyncFunc(&nsHttpChannel::ContinueProcessResponse3);
-            LOG(("AsyncProcessRedirection failed [rv=%x]\n", rv));
+            LOG(("AsyncProcessRedirection failed [rv=%" PRIx32 "]\n",
+                 static_cast<uint32_t>(rv)));
             // don't cache failed redirect responses.
             if (mCacheEntry)
                 mCacheEntry->AsyncDoom(nullptr);
             if (DoNotRender3xxBody(rv)) {
                 mStatus = rv;
                 DoNotifyListener();
             } else {
                 rv = ContinueProcessResponse3(rv);
@@ -2213,17 +2217,18 @@ nsHttpChannel::ContinueProcessResponse2(
     case 304:
         if (!ShouldBypassProcessNotModified()) {
             rv = ProcessNotModified();
             if (NS_SUCCEEDED(rv)) {
                 successfulReval = true;
                 break;
             }
 
-            LOG(("ProcessNotModified failed [rv=%x]\n", rv));
+            LOG(("ProcessNotModified failed [rv=%" PRIx32 "]\n",
+                 static_cast<uint32_t>(rv)));
 
             // We cannot read from the cache entry, it might be in an
             // incosistent state.  Doom it and redirect the channel
             // to the same URI to reload from the network.
             mCacheInputStream.CloseAndRelease();
             if (mCacheEntry) {
                 mCacheEntry->AsyncDoom(nullptr);
                 mCacheEntry = nullptr;
@@ -2267,17 +2272,18 @@ nsHttpChannel::ContinueProcessResponse2(
             // suspend the transaction pump to stop receiving the
             // unauthenticated content data. We will throw that data
             // away when user provides credentials or resume the pump
             // when user refuses to authenticate.
             LOG(("Suspending the transaction, asynchronously prompting for credentials"));
             mTransactionPump->Suspend();
             rv = NS_OK;
         } else if (NS_FAILED(rv)) {
-            LOG(("ProcessAuthentication failed [rv=%x]\n", rv));
+            LOG(("ProcessAuthentication failed [rv=%" PRIx32 "]\n",
+                 static_cast<uint32_t>(rv)));
             if (mTransaction->ProxyConnectFailed())
                 return ProcessFailedProxyConnect(httpStatus);
             if (!mAuthRetryPending)
                 mAuthProvider->CheckForSuperfluousAuth();
             rv = ProcessNormal();
         } else {
             mAuthRetryPending = true; // see DoAuthRetry
         }
@@ -2356,17 +2362,18 @@ nsHttpChannel::ContinueProcessResponse3(
         if (mApplicationCacheForWrite) {
             // Store response in the offline cache
             InitOfflineCacheEntry();
             CloseOfflineCacheEntry();
         }
         return NS_OK;
     }
 
-    LOG(("ContinueProcessResponse3 got failure result [rv=%x]\n", rv));
+    LOG(("ContinueProcessResponse3 got failure result [rv=%" PRIx32 "]\n",
+         static_cast<uint32_t>(rv)));
     if (mTransaction->ProxyConnectFailed()) {
         return ProcessFailedProxyConnect(mRedirectType);
     }
     return ProcessNormal();
 }
 
 nsresult
 nsHttpChannel::ProcessNormal()
@@ -3118,17 +3125,18 @@ nsHttpChannel::ProcessPartialContent()
     nsresult rv;
 
     int64_t cachedContentLength = mCachedResponseHead->ContentLength();
     int64_t entitySize = mResponseHead->TotalEntitySize();
 
     nsAutoCString contentRange;
     mResponseHead->GetHeader(nsHttp::Content_Range, contentRange);
     LOG(("nsHttpChannel::ProcessPartialContent [this=%p trans=%p] "
-         "original content-length %lld, entity-size %lld, content-range %s\n",
+         "original content-length %" PRId64
+         ", entity-size %" PRId64 ", content-range %s\n",
          this, mTransaction.get(), cachedContentLength, entitySize,
          contentRange.get()));
 
     if ((entitySize >= 0) && (cachedContentLength >= 0) &&
         (entitySize != cachedContentLength)) {
         LOG(("nsHttpChannel::ProcessPartialContent [this=%p] "
              "206 has different total entity size than the content length "
              "of the original partially cached entity.\n", this));
@@ -3913,17 +3921,17 @@ nsHttpChannel::OnCacheEntryCheck(nsICach
                 wantCompleteEntry = true;
             }
             else {
                 mConcurrentCacheAccess = 1;
             }
         }
         else if (contentLength != int64_t(-1) && contentLength != size) {
             LOG(("Cached data size does not match the Content-Length header "
-                 "[content-length=%lld size=%lld]\n", contentLength, size));
+                 "[content-length=%" PRId64 " size=%" PRId64 "]\n", contentLength, size));
 
             rv = MaybeSetupByteRangeRequest(size, contentLength);
             mCachedContentIsPartial = NS_SUCCEEDED(rv) && mIsPartialRequest;
             if (mCachedContentIsPartial) {
                 rv = OpenCacheInputStream(entry, false, !!appCache);
                 if (NS_FAILED(rv)) {
                     UntieByteRangeRequest();
                     return rv;
@@ -4239,18 +4247,18 @@ nsHttpChannel::OnCacheEntryAvailable(nsI
                                      nsresult status)
 {
     MOZ_ASSERT(NS_IsMainThread());
     mOnCacheAvailableCalled = true;
 
     nsresult rv;
 
     LOG(("nsHttpChannel::OnCacheEntryAvailable [this=%p entry=%p "
-         "new=%d appcache=%p status=%x mAppCache=%p mAppCacheForWrite=%p]\n",
-         this, entry, aNew, aAppCache, status,
+         "new=%d appcache=%p status=%" PRIx32 " mAppCache=%p mAppCacheForWrite=%p]\n",
+         this, entry, aNew, aAppCache, static_cast<uint32_t>(status),
          mApplicationCache.get(), mApplicationCacheForWrite.get()));
 
     // if the channel's already fired onStopRequest, then we should ignore
     // this event.
     if (!mIsPending) {
         mCacheInputStream.CloseAndRelease();
         return NS_OK;
     }
@@ -4268,17 +4276,18 @@ nsresult
 nsHttpChannel::OnCacheEntryAvailableInternal(nsICacheEntry *entry,
                                              bool aNew,
                                              nsIApplicationCache* aAppCache,
                                              nsresult status)
 {
     nsresult rv;
 
     if (mCanceled) {
-        LOG(("channel was canceled [this=%p status=%x]\n", this, mStatus));
+        LOG(("channel was canceled [this=%p status=%" PRIx32 "]\n",
+             this, static_cast<uint32_t>(mStatus)));
         return mStatus;
     }
 
     if (aAppCache) {
         if (mApplicationCache == aAppCache && !mCacheEntry) {
             rv = OnOfflineCacheEntryAvailable(entry, aNew, aAppCache, status);
         }
         else if (mApplicationCacheForWrite == aAppCache && aNew && !mOfflineCacheEntry) {
@@ -4859,18 +4868,18 @@ nsHttpChannel::ReadFromCache(bool alread
 void
 nsHttpChannel::CloseCacheEntry(bool doomOnFailure)
 {
     mCacheInputStream.CloseAndRelease();
 
     if (!mCacheEntry)
         return;
 
-    LOG(("nsHttpChannel::CloseCacheEntry [this=%p] mStatus=%x mCacheEntryIsWriteOnly=%x",
-         this, mStatus, mCacheEntryIsWriteOnly));
+    LOG(("nsHttpChannel::CloseCacheEntry [this=%p] mStatus=%" PRIx32 " mCacheEntryIsWriteOnly=%x",
+         this, static_cast<uint32_t>(mStatus), mCacheEntryIsWriteOnly));
 
     // If we have begun to create or replace a cache entry, and that cache
     // entry is not complete and not resumable, then it needs to be doomed.
     // Otherwise, CheckCache will make the mistake of thinking that the
     // partial cache entry is complete.
 
     bool doom = false;
     if (mInitedCacheEntry) {
@@ -5275,18 +5284,19 @@ nsHttpChannel::InstallCacheListener(int6
         nsCOMPtr<nsICacheStorageService> serv =
             do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv);
         NS_ENSURE_SUCCESS(rv, rv);
 
         serv->GetIoTarget(getter_AddRefs(cacheIOTarget));
     }
 
     if (!cacheIOTarget) {
-        LOG(("nsHttpChannel::InstallCacheListener sync tee %p rv=%x "
-             "cacheIOTarget=%p", tee.get(), rv, cacheIOTarget.get()));
+        LOG(("nsHttpChannel::InstallCacheListener sync tee %p rv=%" PRIx32
+             " cacheIOTarget=%p",
+             tee.get(), static_cast<uint32_t>(rv), cacheIOTarget.get()));
         rv = tee->Init(mListener, out, nullptr);
     } else {
         LOG(("nsHttpChannel::InstallCacheListener async tee %p", tee.get()));
         rv = tee->InitAsync(mListener, cacheIOTarget, out, nullptr);
     }
 
     if (NS_FAILED(rv)) return rv;
     mListener = tee;
@@ -5539,18 +5549,18 @@ nsHttpChannel::ContinueProcessRedirectio
     return rv;
 }
 
 nsresult
 nsHttpChannel::ContinueProcessRedirection(nsresult rv)
 {
     AutoRedirectVetoNotifier notifier(this);
 
-    LOG(("nsHttpChannel::ContinueProcessRedirection [rv=%x,this=%p]\n", rv,
-         this));
+    LOG(("nsHttpChannel::ContinueProcessRedirection [rv=%" PRIx32 ",this=%p]\n",
+         static_cast<uint32_t>(rv), this));
     if (NS_FAILED(rv))
         return rv;
 
     NS_PRECONDITION(mRedirectChannel, "No redirect channel?");
 
     // Make sure to do this after we received redirect veto answer,
     // i.e. after all sinks had been notified
     mRedirectChannel->SetOriginalURI(mOriginalURI);
@@ -5730,17 +5740,18 @@ NS_INTERFACE_MAP_END_INHERITING(HttpBase
 
 NS_IMETHODIMP
 nsHttpChannel::Cancel(nsresult status)
 {
     MOZ_ASSERT(NS_IsMainThread());
     // We should never have a pump open while a CORS preflight is in progress.
     MOZ_ASSERT_IF(mPreflightChannel, !mCachePump);
 
-    LOG(("nsHttpChannel::Cancel [this=%p status=%x]\n", this, status));
+    LOG(("nsHttpChannel::Cancel [this=%p status=%" PRIx32 "]\n",
+         this, static_cast<uint32_t>(status)));
     if (mCanceled) {
         LOG(("  ignoring; already canceled\n"));
         return NS_OK;
     }
     if (mWaitingForRedirectCallback) {
         LOG(("channel canceled during wait for redirect callback"));
     }
     mCanceled = true;
@@ -6310,18 +6321,19 @@ nsHttpChannel::ContinueBeginConnectWithR
     } else if (mCanceled) {
         // We may have been cancelled already, by nsChannelClassifier in that
         // case, we should not send the request to the server
         rv = mStatus;
     } else {
         rv = Connect();
     }
 
-    LOG(("nsHttpChannel::ContinueBeginConnectWithResult result [this=%p rv=%x "
-         "mCanceled=%i]\n", this, rv, mCanceled));
+    LOG(("nsHttpChannel::ContinueBeginConnectWithResult result [this=%p rv=%" PRIx32
+         " mCanceled=%i]\n",
+         this, static_cast<uint32_t>(rv), mCanceled));
     return rv;
 }
 
 void
 nsHttpChannel::ContinueBeginConnect()
 {
     nsresult rv = ContinueBeginConnectWithResult();
     if (NS_FAILED(rv)) {
@@ -6357,18 +6369,19 @@ nsHttpChannel::ClearClassFlags(uint32_t 
 //-----------------------------------------------------------------------------
 // nsHttpChannel::nsIProtocolProxyCallback
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsHttpChannel::OnProxyAvailable(nsICancelable *request, nsIChannel *channel,
                                 nsIProxyInfo *pi, nsresult status)
 {
-    LOG(("nsHttpChannel::OnProxyAvailable [this=%p pi=%p status=%x mStatus=%x]\n",
-         this, pi, status, mStatus));
+    LOG(("nsHttpChannel::OnProxyAvailable [this=%p pi=%p status=%" PRIx32
+         " mStatus=%" PRIx32 "]\n",
+         this, pi, static_cast<uint32_t>(status), static_cast<uint32_t>(mStatus)));
     mProxyRequest = nullptr;
 
     nsresult rv;
 
     // If status is a failure code, then it means that we failed to resolve
     // proxy info.  That is a non-fatal error assuming it wasn't because the
     // request was canceled.  We just failover to DIRECT when proxy resolution
     // fails (failure can mean that the PAC URL could not be loaded).
@@ -6578,18 +6591,18 @@ nsHttpChannel::OnStartRequest(nsIRequest
         js::ProfileEntry::Category::NETWORK);
 
     if (!(mCanceled || NS_FAILED(mStatus)) && !WRONG_RACING_RESPONSE_SOURCE(request)) {
         // capture the request's status, so our consumers will know ASAP of any
         // connection failures, etc - bug 93581
         request->GetStatus(&mStatus);
     }
 
-    LOG(("nsHttpChannel::OnStartRequest [this=%p request=%p status=%x]\n",
-        this, request, mStatus));
+    LOG(("nsHttpChannel::OnStartRequest [this=%p request=%p status=%" PRIx32 "]\n",
+         this, request, static_cast<uint32_t>(mStatus)));
 
     if (mRacingNetAndCache) {
         LOG(("  racingNetAndCache - mFirstResponseSource:%d fromCache:%d fromNet:%d\n",
              mFirstResponseSource, request == mCachePump, request == mTransactionPump));
         if (mFirstResponseSource == RESPONSE_PENDING &&
             request == mTransactionPump) {
             LOG(("  First response from network\n"));
             mFirstResponseSource = RESPONSE_FROM_NETWORK;
@@ -6739,18 +6752,18 @@ nsHttpChannel::ContinueOnStartRequest3(n
 }
 
 NS_IMETHODIMP
 nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status)
 {
     PROFILER_LABEL("nsHttpChannel", "OnStopRequest",
         js::ProfileEntry::Category::NETWORK);
 
-    LOG(("nsHttpChannel::OnStopRequest [this=%p request=%p status=%x]\n",
-        this, request, status));
+    LOG(("nsHttpChannel::OnStopRequest [this=%p request=%p status=%" PRIx32 "]\n",
+         this, request, static_cast<uint32_t>(status)));
 
     LOG(("OnStopRequest %p requestFromCache: %d mFirstResponseSource: %d\n", this, request == mCachePump, mFirstResponseSource));
 
     MOZ_ASSERT(NS_IsMainThread(),
                "OnStopRequest should only be called from the main thread");
 
     if (WRONG_RACING_RESPONSE_SOURCE(request)) {
         return NS_OK;
@@ -6952,22 +6965,24 @@ nsHttpChannel::OnStopRequest(nsIRequest 
 
                     // Perform the range request
                     rv = ContinueConnect();
                     if (NS_SUCCEEDED(rv)) {
                         LOG(("  performing range request"));
                         mCachePump = nullptr;
                         return NS_OK;
                     } else {
-                        LOG(("  but range request perform failed 0x%08x", rv));
+                        LOG(("  but range request perform failed 0x%08" PRIx32,
+                             static_cast<uint32_t>(rv)));
                         status = NS_ERROR_NET_INTERRUPT;
                     }
                 }
                 else {
-                    LOG(("  but range request setup failed rv=0x%08x, failing load", rv));
+                    LOG(("  but range request setup failed rv=0x%08" PRIx32 ", failing load",
+                         static_cast<uint32_t>(rv)));
                 }
             }
         }
     }
 
     mIsPending = false;
     mStatus = status;
 
@@ -7058,17 +7073,18 @@ private:
 NS_IMETHODIMP
 nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
                                nsIInputStream *input,
                                uint64_t offset, uint32_t count)
 {
     PROFILER_LABEL("nsHttpChannel", "OnDataAvailable",
         js::ProfileEntry::Category::NETWORK);
 
-    LOG(("nsHttpChannel::OnDataAvailable [this=%p request=%p offset=%llu count=%u]\n",
+    LOG(("nsHttpChannel::OnDataAvailable [this=%p request=%p offset=%" PRIu64
+         " count=%" PRIu32 "]\n",
         this, request, offset, count));
 
     LOG(("OnDataAvailable %p requestFromCache: %d mFirstResponseSource: %d\n", this, request == mCachePump, mFirstResponseSource));
 
     // don't send out OnDataAvailable notifications if we've been canceled.
     if (mCanceled)
         return mStatus;
 
@@ -7265,20 +7281,20 @@ nsHttpChannel::OnTransportStatus(nsITran
                 socketTransport->GetSelfAddr(&mSelfAddr);
                 socketTransport->GetPeerAddr(&mPeerAddr);
             }
         }
     }
 
     // block socket status event after Cancel or OnStopRequest has been called.
     if (mProgressSink && NS_SUCCEEDED(mStatus) && mIsPending) {
-        LOG(("sending progress%s notification [this=%p status=%x"
-             " progress=%lld/%lld]\n",
+        LOG(("sending progress%s notification [this=%p status=%" PRIx32
+             " progress=%" PRId64 "/%" PRId64 "]\n",
             (mLoadFlags & LOAD_BACKGROUND)? "" : " and status",
-            this, status, progress, progressMax));
+             this, static_cast<uint32_t>(status), progress, progressMax));
 
         if (!(mLoadFlags & LOAD_BACKGROUND)) {
             nsAutoCString host;
             mURI->GetHost(host);
             mProgressSink->OnStatus(this, nullptr, status,
                                     NS_ConvertUTF8toUTF16(host).get());
         }
 
@@ -7554,17 +7570,17 @@ nsHttpChannel::ForceCacheEntryValidFor(u
 //-----------------------------------------------------------------------------
 // nsHttpChannel::nsIResumableChannel
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsHttpChannel::ResumeAt(uint64_t aStartPos,
                         const nsACString& aEntityID)
 {
-    LOG(("nsHttpChannel::ResumeAt [this=%p startPos=%llu id='%s']\n",
+    LOG(("nsHttpChannel::ResumeAt [this=%p startPos=%" PRIu64 " id='%s']\n",
          this, aStartPos, PromiseFlatCString(aEntityID).get()));
     mEntityID = aEntityID;
     mStartPos = aStartPos;
     mResuming = true;
     return NS_OK;
 }
 
 nsresult
@@ -7773,18 +7789,19 @@ nsHttpChannel::WaitForRedirectCallback()
     mWaitingForRedirectCallback = true;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHttpChannel::OnRedirectVerifyCallback(nsresult result)
 {
     LOG(("nsHttpChannel::OnRedirectVerifyCallback [this=%p] "
-         "result=%x stack=%d mWaitingForRedirectCallback=%u\n",
-         this, result, mRedirectFuncStack.Length(), mWaitingForRedirectCallback));
+         "result=%" PRIx32 " stack=%" PRIuSIZE " mWaitingForRedirectCallback=%u\n",
+         this, static_cast<uint32_t>(result), mRedirectFuncStack.Length(),
+         mWaitingForRedirectCallback));
     MOZ_ASSERT(mWaitingForRedirectCallback,
                "Someone forgot to call WaitForRedirectCallback() ?!");
     mWaitingForRedirectCallback = false;
 
     if (mCanceled && NS_SUCCEEDED(result))
         result = NS_BINDING_ABORTED;
 
     for (uint32_t i = mRedirectFuncStack.Length(); i > 0;) {
@@ -7850,19 +7867,19 @@ nsHttpChannel::PopRedirectAsyncFunc(nsCo
 NS_IMETHODIMP
 nsHttpChannel::OnLookupComplete(nsICancelable *request,
                                 nsIDNSRecord  *rec,
                                 nsresult       status)
 {
     MOZ_ASSERT(NS_IsMainThread(), "Expecting DNS callback on main thread.");
 
     LOG(("nsHttpChannel::OnLookupComplete [this=%p] prefetch complete%s: "
-         "%s status[0x%x]\n",
+         "%s status[0x%" PRIx32 "]\n",
          this, mCaps & NS_HTTP_REFRESH_DNS ? ", refresh requested" : "",
-         NS_SUCCEEDED(status) ? "success" : "failure", status));
+         NS_SUCCEEDED(status) ? "success" : "failure", static_cast<uint32_t>(status)));
 
     // We no longer need the dns prefetch object. Note: mDNSPrefetch could be
     // validly null if OnStopRequest has already been called.
     // We only need the domainLookup timestamps when not loading from cache
     if (mDNSPrefetch && mDNSPrefetch->TimingsValid() && mTransaction) {
         TimeStamp connectStart = mTransaction->GetConnectStart();
         TimeStamp requestStart = mTransaction->GetRequestStart();
         // We only set the domainLookup timestamps if we're not using a
--- a/netwerk/protocol/http/nsHttpConnection.cpp
+++ b/netwerk/protocol/http/nsHttpConnection.cpp
@@ -257,17 +257,17 @@ nsHttpConnection::StartSpdy(uint8_t spdy
             }
         }
     }
 
     // Disable TCP Keepalives - use SPDY ping instead.
     rv = DisableTCPKeepalives();
     if (NS_FAILED(rv)) {
         LOG(("nsHttpConnection::StartSpdy [%p] DisableTCPKeepalives failed "
-             "rv[0x%x]", this, rv));
+             "rv[0x%" PRIx32 "]", this, static_cast<uint32_t>(rv)));
     }
 
     mSupportsPipelining = false; // don't use http/1 pipelines with spdy
     mIdleTimeout = gHttpHandler->SpdyTimeout();
 
     if (!mTLSFilter) {
         mTransaction = mSpdySession;
     } else {
@@ -427,17 +427,17 @@ nsHttpConnection::EnsureNPNComplete(nsre
 
         if (!ealyDataAccepted) {
             uint32_t infoIndex;
             const SpdyInformation *info = gHttpHandler->SpdyInfo();
             if (NS_SUCCEEDED(info->GetNPNIndex(negotiatedNPN, &infoIndex))) {
                 StartSpdy(info->Version[infoIndex]);
             }
         } else {
-          LOG(("nsHttpConnection::EnsureNPNComplete [this=%p] - %d bytes "
+          LOG(("nsHttpConnection::EnsureNPNComplete [this=%p] - %" PRId64 " bytes "
                "has been sent during 0RTT.", this, mContentBytesWritten0RTT));
           mContentBytesWritten = mContentBytesWritten0RTT;
         }
 
         Telemetry::Accumulate(Telemetry::SPDY_NPN_CONNECT, UsingSpdy());
     }
 
 npnComplete:
@@ -494,18 +494,18 @@ nsHttpConnection::Activate(nsAHttpTransa
     if (!mConnectedTransport) {
         uint32_t count;
         mSocketOutCondition = NS_ERROR_FAILURE;
         if (mSocketOut) {
             mSocketOutCondition = mSocketOut->Write("", 0, &count);
         }
         if (NS_FAILED(mSocketOutCondition) &&
             mSocketOutCondition != NS_BASE_STREAM_WOULD_BLOCK) {
-            LOG(("nsHttpConnection::Activate [this=%p] Bad Socket %x\n",
-                 this, mSocketOutCondition));
+            LOG(("nsHttpConnection::Activate [this=%p] Bad Socket %" PRIx32 "\n",
+                 this, static_cast<uint32_t>(mSocketOutCondition)));
             mSocketOut->AsyncWait(nullptr, 0, 0, nullptr);
             mTransaction = trans;
             CloseTransaction(mTransaction, mSocketOutCondition);
             return mSocketOutCondition;
         }
     }
 
     // Update security callbacks
@@ -541,18 +541,18 @@ nsHttpConnection::Activate(nsAHttpTransa
 
     mResponseTimeoutEnabled = gHttpHandler->ResponseTimeoutEnabled() &&
                               mTransaction->ResponseTimeout() > 0 &&
                               mTransaction->ResponseTimeoutEnabled();
 
     rv = StartShortLivedTCPKeepalives();
     if (NS_FAILED(rv)) {
         LOG(("nsHttpConnection::Activate [%p] "
-             "StartShortLivedTCPKeepalives failed rv[0x%x]",
-             this, rv));
+             "StartShortLivedTCPKeepalives failed rv[0x%" PRIx32 "]",
+             this, static_cast<uint32_t>(rv)));
     }
 
     if (mTLSFilter) {
         mTLSFilter->SetProxiedTransaction(trans);
         mTransaction = mTLSFilter;
     }
 
     rv = OnOutputStreamReady(mSocketOut);
@@ -629,17 +629,18 @@ nsHttpConnection::SetupNPNList(nsISSLSoc
         }
     } else {
         LOG(("nsHttpConnection::SetupSSL limiting NPN selection to %s",
              npnToken.get()));
         protocolArray.AppendElement(npnToken);
     }
 
     nsresult rv = ssl->SetNPNList(protocolArray);
-    LOG(("nsHttpConnection::SetupNPNList %p %x\n",this, rv));
+    LOG(("nsHttpConnection::SetupNPNList %p %" PRIx32 "\n",
+         this, static_cast<uint32_t>(rv)));
     return rv;
 }
 
 nsresult
 nsHttpConnection::AddTransaction(nsAHttpTransaction *httpTransaction,
                                  int32_t priority)
 {
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
@@ -669,17 +670,18 @@ nsHttpConnection::AddTransaction(nsAHttp
 
     ResumeSend();
     return NS_OK;
 }
 
 void
 nsHttpConnection::Close(nsresult reason, bool aIsShutdown)
 {
-    LOG(("nsHttpConnection::Close [this=%p reason=%x]\n", this, reason));
+    LOG(("nsHttpConnection::Close [this=%p reason=%" PRIx32 "]\n",
+         this, static_cast<uint32_t>(reason)));
 
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
     // Ensure TCP keepalive timer is stopped.
     if (mTCPKeepaliveTransitionTimer) {
         mTCPKeepaliveTransitionTimer->Cancel();
         mTCPKeepaliveTransitionTimer = nullptr;
     }
@@ -818,17 +820,17 @@ nsHttpConnection::CanReuse()
     // before a request is sent. Data here is likely a 408 timeout response
     // which we would deal with later on through the restart logic, but that
     // path is more expensive than just closing the socket now.
 
     uint64_t dataSize;
     if (canReuse && mSocketIn && !mUsingSpdyVersion && mHttp1xTransactionCount &&
         NS_SUCCEEDED(mSocketIn->Available(&dataSize)) && dataSize) {
         LOG(("nsHttpConnection::CanReuse %p %s"
-             "Socket not reusable because read data pending (%llu) on it.\n",
+             "Socket not reusable because read data pending (%" PRIu64 ") on it.\n",
              this, mConnInfo->Origin(), dataSize));
         canReuse = false;
     }
     return canReuse;
 }
 
 bool
 nsHttpConnection::CanDirectlyActivate()
@@ -1129,17 +1131,17 @@ nsHttpConnection::OnHeadersAvailable(nsA
             if (isHttps) {
                 if (mConnInfo->UsingHttpsProxy()) {
                     LOG(("%p new TLSFilterTransaction %s %d\n",
                          this, mConnInfo->Origin(), mConnInfo->OriginPort()));
                     SetupSecondaryTLS();
                 }
 
                 rv = InitSSLParams(false, true);
-                LOG(("InitSSLParams [rv=%x]\n", rv));
+                LOG(("InitSSLParams [rv=%" PRIx32 "]\n", static_cast<uint32_t>(rv)));
             }
             mCompletedProxyConnect = true;
             mProxyConnectInProgress = false;
             rv = mSocketOut->AsyncWait(this, 0, 0, nullptr);
             // XXX what if this fails -- need to handle this error
             MOZ_ASSERT(NS_SUCCEEDED(rv), "mSocketOut->AsyncWait failed");
         }
         else {
@@ -1224,17 +1226,18 @@ nsHttpConnection::TakeTransport(nsISocke
             mTCPKeepaliveTransitionTimer->Cancel();
             mTCPKeepaliveTransitionTimer = nullptr;
         }
         nsresult rv = StartLongLivedTCPKeepalives();
         LOG(("nsHttpConnection::TakeTransport [%p] calling "
              "StartLongLivedTCPKeepalives", this));
         if (NS_FAILED(rv)) {
             LOG(("nsHttpConnection::TakeTransport [%p] "
-                 "StartLongLivedTCPKeepalives failed rv[0x%x]", this, rv));
+                 "StartLongLivedTCPKeepalives failed rv[0x%" PRIx32 "]",
+                 this, static_cast<uint32_t>(rv)));
         }
     }
 
     mSocketTransport->SetSecurityCallbacks(nullptr);
     mSocketTransport->SetEventSink(nullptr, nullptr);
 
     // The nsHttpConnection will go away soon, so if there is a TLS Filter
     // being used (e.g. for wss CONNECT tunnel from a proxy connected to
@@ -1373,18 +1376,18 @@ nsHttpConnection::UpdateTCPKeepalive(nsI
     // Do not reduce keepalive probe frequency for idle connections.
     if (self->mIdleMonitoring) {
         return;
     }
 
     nsresult rv = self->StartLongLivedTCPKeepalives();
     if (NS_FAILED(rv)) {
         LOG(("nsHttpConnection::UpdateTCPKeepalive [%p] "
-             "StartLongLivedTCPKeepalives failed rv[0x%x]",
-             self, rv));
+             "StartLongLivedTCPKeepalives failed rv[0x%" PRIx32 "]",
+             self, static_cast<uint32_t>(rv)));
     }
 }
 
 void
 nsHttpConnection::GetSecurityInfo(nsISupports **secinfo)
 {
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
     LOG(("nsHttpConnection::GetSecurityInfo trans=%p tlsfilter=%p socket=%p\n",
@@ -1591,18 +1594,18 @@ nsHttpConnection::Version()
 
 //-----------------------------------------------------------------------------
 // nsHttpConnection <private>
 //-----------------------------------------------------------------------------
 
 void
 nsHttpConnection::CloseTransaction(nsAHttpTransaction *trans, nsresult reason)
 {
-    LOG(("nsHttpConnection::CloseTransaction[this=%p trans=%p reason=%x]\n",
-        this, trans, reason));
+    LOG(("nsHttpConnection::CloseTransaction[this=%p trans=%p reason=%" PRIx32 "]\n",
+         this, trans, static_cast<uint32_t>(reason)));
 
     MOZ_ASSERT((trans == mTransaction) ||
                (mTLSFilter && mTLSFilter->Transaction() == trans));
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
     if (mCurrentBytesRead > mMaxBytesRead)
         mMaxBytesRead = mCurrentBytesRead;
 
@@ -1734,18 +1737,19 @@ nsHttpConnection::OnSocketWritable()
             LOG(("  writing transaction request stream\n"));
             mProxyConnectInProgress = false;
             rv = mTransaction->ReadSegmentsAgain(this, nsIOService::gDefaultSegmentSize,
                                                  &transactionBytes, &again);
             mContentBytesWritten += transactionBytes;
         }
 
         LOG(("nsHttpConnection::OnSocketWritable %p "
-             "ReadSegments returned [rv=%x read=%u sock-cond=%x]\n",
-             this, rv, transactionBytes, mSocketOutCondition));
+             "ReadSegments returned [rv=%" PRIx32 " read=%u sock-cond=%" PRIx32 "]\n",
+             this, static_cast<uint32_t>(rv), transactionBytes,
+             static_cast<uint32_t>(mSocketOutCondition)));
 
         // XXX some streams return NS_BASE_STREAM_CLOSED to indicate EOF.
         if (rv == NS_BASE_STREAM_CLOSED && !mTransaction->IsDone()) {
             rv = NS_OK;
             transactionBytes = 0;
         }
 
         if (NS_FAILED(rv)) {
@@ -1905,18 +1909,19 @@ nsHttpConnection::OnSocketReadable()
                  "tunnel setup but incomplete NPN state\n", this));
             rv = NS_OK;
             break;
         }
 
         mSocketInCondition = NS_OK;
         rv = mTransaction->
             WriteSegmentsAgain(this, nsIOService::gDefaultSegmentSize, &n, &again);
-        LOG(("nsHttpConnection::OnSocketReadable %p trans->ws rv=%x n=%d socketin=%x\n",
-             this, rv, n, mSocketInCondition));
+        LOG(("nsHttpConnection::OnSocketReadable %p trans->ws rv=%" PRIx32
+             " n=%d socketin=%" PRIx32 "\n",
+             this, static_cast<uint32_t>(rv), n, static_cast<uint32_t>(mSocketInCondition)));
         if (NS_FAILED(rv)) {
             // if the transaction didn't want to take any more data, then
             // wait for the transaction to call ResumeRecv.
             if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
                 rv = NS_OK;
             }
             again = false;
         } else {
--- a/netwerk/protocol/http/nsHttpConnectionInfo.h
+++ b/netwerk/protocol/http/nsHttpConnectionInfo.h
@@ -53,17 +53,17 @@ public:
                          nsProxyInfo *proxyInfo,
                          const OriginAttributes &originAttributes,
                          const nsACString &routedHost,
                          int32_t routedPort);
 
 private:
     virtual ~nsHttpConnectionInfo()
     {
-        MOZ_LOG(gHttpLog, LogLevel::Debug, ("Destroying nsHttpConnectionInfo @%x\n", this));
+        MOZ_LOG(gHttpLog, LogLevel::Debug, ("Destroying nsHttpConnectionInfo @%p\n", this));
     }
 
     void BuildHashKey();
 
 public:
     const nsAFlatCString &HashKey() const { return mHashKey; }
 
     const nsCString &GetOrigin() const { return mOrigin; }
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -339,17 +339,18 @@ nsHttpConnectionMgr::RescheduleTransacti
 {
     LOG(("nsHttpConnectionMgr::RescheduleTransaction [trans=%p %d]\n", trans, priority));
     return PostEvent(&nsHttpConnectionMgr::OnMsgReschedTransaction, priority, trans);
 }
 
 nsresult
 nsHttpConnectionMgr::CancelTransaction(nsHttpTransaction *trans, nsresult reason)
 {
-    LOG(("nsHttpConnectionMgr::CancelTransaction [trans=%p reason=%x]\n", trans, reason));
+    LOG(("nsHttpConnectionMgr::CancelTransaction [trans=%p reason=%" PRIx32 "]\n",
+         trans, static_cast<uint32_t>(reason)));
     return PostEvent(&nsHttpConnectionMgr::OnMsgCancelTransaction,
                      static_cast<int32_t>(reason), trans);
 }
 
 nsresult
 nsHttpConnectionMgr::PruneDeadConnections()
 {
     return PostEvent(&nsHttpConnectionMgr::OnMsgPruneDeadConnections);
@@ -839,19 +840,19 @@ nsHttpConnectionMgr::GetSpdyPreferredEnt
                 break;
             }
         }
     }
 
     if (NS_FAILED(rv) || !isJoined) {
         LOG(("nsHttpConnectionMgr::GetSpdyPreferredEnt "
              "Host %s cannot be confirmed to be joined "
-             "with %s connections. rv=%x isJoined=%d",
+             "with %s connections. rv=%" PRIx32 " isJoined=%d",
              preferred->mConnInfo->Origin(), aOriginalEntry->mConnInfo->Origin(),
-             rv, isJoined));
+             static_cast<uint32_t>(rv), isJoined));
         Telemetry::Accumulate(Telemetry::SPDY_NPN_JOIN, false);
         return nullptr;
     }
 
     // IP pooling confirmed
     LOG(("nsHttpConnectionMgr::GetSpdyPreferredEnt "
          "Host %s has cert valid for %s connections, "
          "so %s will be coalesced with %s",
@@ -864,17 +865,17 @@ nsHttpConnectionMgr::GetSpdyPreferredEnt
 //-----------------------------------------------------------------------------
 
 bool
 nsHttpConnectionMgr::ProcessPendingQForEntry(nsConnectionEntry *ent, bool considerAll)
 {
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
     LOG(("nsHttpConnectionMgr::ProcessPendingQForEntry "
-         "[ci=%s ent=%p active=%d idle=%d queued=%d]\n",
+         "[ci=%s ent=%p active=%" PRIuSIZE " idle=%" PRIuSIZE " queued=%" PRIuSIZE "]\n",
          ent->mConnInfo->HashKey().get(), ent, ent->mActiveConns.Length(),
          ent->mIdleConns.Length(), ent->mPendingQ.Length()));
 
     ProcessSpdyPendingQ(ent);
 
     nsHttpTransaction *trans;
     nsresult rv;
     bool dispatchedSuccessfully = false;
@@ -901,17 +902,18 @@ nsHttpConnectionMgr::ProcessPendingQForE
         rv = TryDispatchTransaction(ent,
                                     alreadyHalfOpen || !!trans->TunnelProvider(),
                                     trans);
         if (NS_SUCCEEDED(rv) || (rv != NS_ERROR_NOT_AVAILABLE)) {
             if (NS_SUCCEEDED(rv))
                 LOG(("  dispatching pending transaction...\n"));
             else
                 LOG(("  removing pending transaction based on "
-                     "TryDispatchTransaction returning hard error %x\n", rv));
+                     "TryDispatchTransaction returning hard error %" PRIx32 "\n",
+                     static_cast<uint32_t>(rv)));
 
             if (ent->mPendingQ.RemoveElement(trans)) {
                 // trans is now potentially destroyed
                 dispatchedSuccessfully = true;
                 continue; // dont ++i as we just made the array shorter
             }
 
             LOG(("  transaction not found in pending queue\n"));
@@ -1448,17 +1450,17 @@ nsHttpConnectionMgr::IsUnderPressure(nsC
 nsresult
 nsHttpConnectionMgr::TryDispatchTransaction(nsConnectionEntry *ent,
                                             bool onlyReusedConnection,
                                             nsHttpTransaction *trans)
 {
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
     LOG(("nsHttpConnectionMgr::TryDispatchTransaction without conn "
          "[trans=%p ci=%p ci=%s caps=%x tunnelprovider=%p onlyreused=%d "
-         "active=%d idle=%d]\n", trans,
+         "active=%" PRIuSIZE " idle=%" PRIuSIZE "]\n", trans,
          ent->mConnInfo.get(), ent->mConnInfo->HashKey().get(),
          uint32_t(trans->Caps()), trans->TunnelProvider(),
          onlyReusedConnection, ent->mActiveConns.Length(),
          ent->mIdleConns.Length()));
 
     nsHttpTransaction::Classifier classification = trans->Classification();
     uint32_t caps = trans->Caps();
 
@@ -1618,17 +1620,18 @@ nsHttpConnectionMgr::TryDispatchTransact
             // this function returns NOT_AVAILABLE for asynchronous connects
             LOG(("   dispatched step 4 (async new conn) trans=%p\n", trans));
             return NS_ERROR_NOT_AVAILABLE;
         }
 
         if (rv != NS_ERROR_NOT_AVAILABLE) {
             // not available return codes should try next step as they are
             // not hard errors. Other codes should stop now
-            LOG(("   failed step 4 (%x) trans=%p\n", rv, trans));
+            LOG(("   failed step 4 (%" PRIx32 ") trans=%p\n",
+                 static_cast<uint32_t>(rv), trans));
             return rv;
         }
     } else if (trans->TunnelProvider() && trans->TunnelProvider()->MaybeReTunnel(trans)) {
         LOG(("   sort of dispatched step 4a tunnel requeue trans=%p\n", trans));
         // the tunnel provider took responsibility for making a new tunnel
         return NS_OK;
     }
 
@@ -1787,17 +1790,17 @@ nsHttpConnectionMgr::DispatchAbstractTra
 
     RefPtr<ConnectionHandle> handle = new ConnectionHandle(conn);
 
     // give the transaction the indirect reference to the connection.
     transaction->SetConnection(handle);
 
     rv = conn->Activate(transaction, caps, priority);
     if (NS_FAILED(rv)) {
-        LOG(("  conn->Activate failed [rv=%x]\n", rv));
+      LOG(("  conn->Activate failed [rv=%" PRIx32 "]\n", static_cast<uint32_t>(rv)));
         ent->mActiveConns.RemoveElement(conn);
         if (conn == ent->mYellowConnection)
             ent->OnYellowComplete();
         DecrementActiveConnCount(conn);
         ConditionallyStopTimeoutTick();
 
         // sever back references to connection, and do so without triggering
         // a call to ReclaimConnection ;-)
@@ -1926,24 +1929,25 @@ nsHttpConnectionMgr::ProcessNewTransacti
 
     if (NS_SUCCEEDED(rv)) {
         LOG(("  ProcessNewTransaction Dispatch Immediately trans=%p\n", trans));
         return rv;
     }
 
     if (rv == NS_ERROR_NOT_AVAILABLE) {
         LOG(("  adding transaction to pending queue "
-             "[trans=%p pending-count=%u]\n",
+             "[trans=%p pending-count=%" PRIuSIZE "]\n",
              trans, ent->mPendingQ.Length()+1));
         // put this transaction on the pending queue...
         InsertTransactionSorted(ent->mPendingQ, trans);
         return NS_OK;
     }
 
-    LOG(("  ProcessNewTransaction Hard Error trans=%p rv=%x\n", trans, rv));
+    LOG(("  ProcessNewTransaction Hard Error trans=%p rv=%" PRIx32 "\n",
+         trans, static_cast<uint32_t>(rv)));
     return rv;
 }
 
 
 void
 nsHttpConnectionMgr::AddActiveConn(nsHttpConnection *conn,
                                    nsConnectionEntry *ent)
 {
@@ -2762,17 +2766,18 @@ nsHttpConnectionMgr::TimeoutTick()
     // Set it to the max value here, and the TimeoutTick()s can
     // reduce it to their local needs.
     mTimeoutTickNext = 3600; // 1hr
 
     for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
         nsAutoPtr<nsConnectionEntry>& ent = iter.Data();
 
         LOG(("nsHttpConnectionMgr::TimeoutTick() this=%p host=%s "
-             "idle=%d active=%d half-len=%d pending=%d\n",
+             "idle=%" PRIuSIZE " active=%" PRIuSIZE
+             " half-len=%" PRIuSIZE " pending=%" PRIuSIZE "\n",
              this, ent->mConnInfo->Origin(), ent->mIdleConns.Length(),
              ent->mActiveConns.Length(), ent->mHalfOpens.Length(),
              ent->mPendingQ.Length()));
 
         // First call the tick handler for each active connection.
         PRIntervalTime tickTime = PR_IntervalNow();
         for (uint32_t index = 0; index < ent->mActiveConns.Length(); ++index) {
             uint32_t connNextTimeout =
@@ -3137,18 +3142,18 @@ nsHttpConnectionMgr::nsHalfOpenSocket::S
 
     nsresult rv;
 
     mPrimarySynStarted = TimeStamp::Now();
     rv = SetupStreams(getter_AddRefs(mSocketTransport),
                       getter_AddRefs(mStreamIn),
                       getter_AddRefs(mStreamOut),
                       false);
-    LOG(("nsHalfOpenSocket::SetupPrimaryStream [this=%p ent=%s rv=%x]",
-         this, mEnt->mConnInfo->Origin(), rv));
+    LOG(("nsHalfOpenSocket::SetupPrimaryStream [this=%p ent=%s rv=%" PRIx32 "]",
+         this, mEnt->mConnInfo->Origin(), static_cast<uint32_t>(rv)));
     if (NS_FAILED(rv)) {
         if (mStreamOut)
             mStreamOut->AsyncWait(nullptr, 0, 0, nullptr);
         mStreamOut = nullptr;
         mStreamIn = nullptr;
         mSocketTransport = nullptr;
     }
     return rv;
@@ -3161,18 +3166,18 @@ nsHttpConnectionMgr::nsHalfOpenSocket::S
     MOZ_ASSERT(!mTransaction->IsNullTransaction(),
                "null transactions dont have backup streams");
 
     mBackupSynStarted = TimeStamp::Now();
     nsresult rv = SetupStreams(getter_AddRefs(mBackupTransport),
                                getter_AddRefs(mBackupStreamIn),
                                getter_AddRefs(mBackupStreamOut),
                                true);
-    LOG(("nsHalfOpenSocket::SetupBackupStream [this=%p ent=%s rv=%x]",
-         this, mEnt->mConnInfo->Origin(), rv));
+    LOG(("nsHalfOpenSocket::SetupBackupStream [this=%p ent=%s rv=%" PRIx32 "]",
+         this, mEnt->mConnInfo->Origin(), static_cast<uint32_t>(rv)));
     if (NS_FAILED(rv)) {
         if (mBackupStreamOut)
             mBackupStreamOut->AsyncWait(nullptr, 0, 0, nullptr);
         mBackupStreamOut = nullptr;
         mBackupStreamIn = nullptr;
         mBackupTransport = nullptr;
     }
     return rv;
@@ -3353,17 +3358,18 @@ nsHalfOpenSocket::OnOutputStreamReady(ns
         mBackupTransport = nullptr;
     } else {
         MOZ_ASSERT(false, "unexpected stream");
         rv = NS_ERROR_UNEXPECTED;
     }
 
     if (NS_FAILED(rv)) {
         LOG(("nsHalfOpenSocket::OnOutputStreamReady "
-             "conn->init (%p) failed %x\n", conn.get(), rv));
+             "conn->init (%p) failed %" PRIx32 "\n",
+             conn.get(), static_cast<uint32_t>(rv)));
         return rv;
     }
 
     // This half-open socket has created a connection.  This flag excludes it
     // from counter of actual connections used for checking limits.
     mHasConnected = true;
 
     // if this is still in the pending list, remove it and dispatch it
@@ -3964,23 +3970,23 @@ nsHttpConnectionMgr::MoveToWildCardConnE
     nsConnectionEntry *wcEnt = GetOrCreateConnectionEntry(wildCardCI, true);
     if (wcEnt == ent) {
         // nothing to do!
         return;
     }
     wcEnt->mUsingSpdy = true;
 
     LOG(("nsHttpConnectionMgr::MakeConnEntryWildCard ent %p "
-         "idle=%d active=%d half=%d pending=%d\n", ent,
-         ent->mIdleConns.Length(), ent->mActiveConns.Length(),
+         "idle=%" PRIuSIZE " active=%" PRIuSIZE " half=%" PRIuSIZE " pending=%" PRIuSIZE "\n",
+         ent, ent->mIdleConns.Length(), ent->mActiveConns.Length(),
          ent->mHalfOpens.Length(), ent->mPendingQ.Length()));
 
     LOG(("nsHttpConnectionMgr::MakeConnEntryWildCard wc-ent %p "
-         "idle=%d active=%d half=%d pending=%d\n", wcEnt,
-         wcEnt->mIdleConns.Length(), wcEnt->mActiveConns.Length(),
+         "idle=%" PRIuSIZE " active=%" PRIuSIZE " half=%" PRIuSIZE " pending=%" PRIuSIZE "\n",
+         wcEnt, wcEnt->mIdleConns.Length(), wcEnt->mActiveConns.Length(),
          wcEnt->mHalfOpens.Length(), wcEnt->mPendingQ.Length()));
 
     int32_t count = ent->mActiveConns.Length();
     RefPtr<nsHttpConnection> deleteProtector(proxyConn);
     for (int32_t i = 0; i < count; ++i) {
         if (ent->mActiveConns[i] == proxyConn) {
             ent->mActiveConns.RemoveElementAt(i);
             wcEnt->mActiveConns.InsertElementAt(0, proxyConn);
--- a/netwerk/protocol/http/nsHttpDigestAuth.cpp
+++ b/netwerk/protocol/http/nsHttpDigestAuth.cpp
@@ -218,17 +218,18 @@ nsHttpDigestAuth::GenerateCredentials(ns
 
   nsAutoCString realm, domain, nonce, opaque;
   bool stale;
   uint16_t algorithm, qop;
 
   rv = ParseChallenge(challenge, realm, domain, nonce, opaque,
                       &stale, &algorithm, &qop);
   if (NS_FAILED(rv)) {
-    LOG(("nsHttpDigestAuth::GenerateCredentials [ParseChallenge failed rv=%x]\n", rv));
+    LOG(("nsHttpDigestAuth::GenerateCredentials [ParseChallenge failed rv=%" PRIx32 "]\n",
+         static_cast<uint32_t>(rv)));
     return rv;
   }
 
   char ha1_digest[EXPANDED_DIGEST_LENGTH+1];
   char ha2_digest[EXPANDED_DIGEST_LENGTH+1];
   char response_digest[EXPANDED_DIGEST_LENGTH+1];
   char upload_data_digest[EXPANDED_DIGEST_LENGTH+1];
 
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -621,17 +621,17 @@ nsHttpHandler::Get32BitsOfPseudoRandom()
 #else
     return (uint32_t) rand();
 #endif
 }
 
 void
 nsHttpHandler::NotifyObservers(nsIHttpChannel *chan, const char *event)
 {
-    LOG(("nsHttpHandler::NotifyObservers [chan=%x event=\"%s\"]\n", chan, event));
+    LOG(("nsHttpHandler::NotifyObservers [chan=%p event=\"%s\"]\n", chan, event));
     nsCOMPtr<nsIObserverService> obsService = services::GetObserverService();
     if (obsService)
         obsService->NotifyObservers(chan, event, nullptr);
 }
 
 nsresult
 nsHttpHandler::AsyncOnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan,
                                  uint32_t flags)
--- a/netwerk/protocol/http/nsHttpPipeline.cpp
+++ b/netwerk/protocol/http/nsHttpPipeline.cpp
@@ -204,18 +204,18 @@ nsHttpPipeline::OnHeadersAvailable(nsAHt
     }
 
     return rv;
 }
 
 void
 nsHttpPipeline::CloseTransaction(nsAHttpTransaction *aTrans, nsresult reason)
 {
-    LOG(("nsHttpPipeline::CloseTransaction [this=%p trans=%p reason=%x]\n",
-        this, aTrans, reason));
+    LOG(("nsHttpPipeline::CloseTransaction [this=%p trans=%p reason=%" PRIx32 "]\n",
+         this, aTrans, static_cast<uint32_t>(reason)));
 
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
     MOZ_ASSERT(NS_FAILED(reason), "expecting failure code");
 
     // the specified transaction is to be closed with the given "reason"
     RefPtr<nsAHttpTransaction> trans(aTrans);
     int32_t index;
     bool killPipeline = false;
@@ -437,18 +437,18 @@ nsHttpPipeline::GetSecurityCallbacks(nsI
         *result = nullptr;
     }
 }
 
 void
 nsHttpPipeline::OnTransportStatus(nsITransport* transport,
                                   nsresult status, int64_t progress)
 {
-    LOG(("nsHttpPipeline::OnStatus [this=%p status=%x progress=%lld]\n",
-        this, status, progress));
+    LOG(("nsHttpPipeline::OnStatus [this=%p status=%" PRIx32 " progress=%" PRId64 "]\n",
+         this, static_cast<uint32_t>(status), progress));
 
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
     nsAHttpTransaction *trans;
     int32_t i, count;
 
     switch (status) {
 
@@ -776,17 +776,18 @@ nsHttpPipeline::CancelPipeline(nsresult 
     Classify(nsAHttpTransaction::CLASS_SOLO);
 
     return total;
 }
 
 void
 nsHttpPipeline::Close(nsresult reason)
 {
-    LOG(("nsHttpPipeline::Close [this=%p reason=%x]\n", this, reason));
+    LOG(("nsHttpPipeline::Close [this=%p reason=%" PRIx32 "]\n",
+         this, static_cast<uint32_t>(reason)));
 
     if (mClosed) {
         LOG(("  already closed\n"));
         return;
     }
 
     // the connection is going away!
     mStatus = reason;
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -527,18 +527,18 @@ nsHttpTransaction::SetSecurityCallbacks(
         gSocketTransportService->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
     }
 }
 
 void
 nsHttpTransaction::OnTransportStatus(nsITransport* transport,
                                      nsresult status, int64_t progress)
 {
-    LOG(("nsHttpTransaction::OnSocketStatus [this=%p status=%x progress=%lld]\n",
-        this, status, progress));
+    LOG(("nsHttpTransaction::OnSocketStatus [this=%p status=%" PRIx32 " progress=%" PRId64 "]\n",
+         this, static_cast<uint32_t>(status), progress));
 
     if (status == NS_NET_STATUS_CONNECTED_TO ||
         status == NS_NET_STATUS_WAITING_FOR) {
         nsISocketTransport *socketTransport =
             mConnection ? mConnection->Transport() : nullptr;
         if (socketTransport) {
             MutexAutoLock lock(mLock);
             socketTransport->GetSelfAddr(&mSelfAddr);
@@ -861,17 +861,18 @@ nsHttpTransaction::WriteSegments(nsAHttp
 
     reentrantFlag = false;
     return rv;
 }
 
 void
 nsHttpTransaction::Close(nsresult reason)
 {
-    LOG(("nsHttpTransaction::Close [this=%p reason=%x]\n", this, reason));
+    LOG(("nsHttpTransaction::Close [this=%p reason=%" PRIx32 "]\n",
+         this, static_cast<uint32_t>(reason)));
 
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
     if (reason == NS_BINDING_RETARGETED) {
         LOG(("  close %p skipped due to ERETARGETED\n", this));
         return;
     }
 
     if (mClosed) {
@@ -1183,18 +1184,18 @@ nsHttpTransaction::RestartInProgress()
     if (mCaps & NS_HTTP_STICKY_CONNECTION) {
         return NS_ERROR_NET_RESET;
     }
 
     // don't try and restart 0.9 or non 200/Get HTTP/1
     if (!mRestartInProgressVerifier.IsSetup())
         return NS_ERROR_NET_RESET;
 
-    LOG(("Will restart transaction %p and skip first %lld bytes, "
-         "old Content-Length %lld",
+    LOG(("Will restart transaction %p and skip first %" PRId64 " bytes, "
+         "old Content-Length %" PRId64,
          this, mContentRead, mContentLength));
 
     mRestartInProgressVerifier.SetAlreadyProcessed(
         std::max(mRestartInProgressVerifier.AlreadyProcessed(), mContentRead));
 
     if (!mResponseHeadTaken && !mForTakeResponseHead) {
         // TakeResponseHeader() has not been called yet and this
         // is the first restart. Store the resp headers exclusively
@@ -1730,30 +1731,30 @@ nsHttpTransaction::HandleContent(char *b
 
     int64_t toReadBeforeRestart =
         mRestartInProgressVerifier.ToReadBeforeRestart();
 
     if (toReadBeforeRestart && *contentRead) {
         uint32_t ignore =
             static_cast<uint32_t>(std::min<int64_t>(toReadBeforeRestart, UINT32_MAX));
         ignore = std::min(*contentRead, ignore);
-        LOG(("Due To Restart ignoring %d of remaining %ld",
+        LOG(("Due To Restart ignoring %d of remaining %" PRId64,
              ignore, toReadBeforeRestart));
         *contentRead -= ignore;
         mContentRead += ignore;
         mRestartInProgressVerifier.HaveReadBeforeRestart(ignore);
         memmove(buf, buf + ignore, *contentRead + *contentRemaining);
     }
 
     if (*contentRead) {
         // update count of content bytes read and report progress...
         mContentRead += *contentRead;
     }
 
-    LOG(("nsHttpTransaction::HandleContent [this=%p count=%u read=%u mContentRead=%lld mContentLength=%lld]\n",
+    LOG(("nsHttpTransaction::HandleContent [this=%p count=%u read=%u mContentRead=%" PRId64 " mContentLength=%" PRId64 "]\n",
         this, count, *contentRead, mContentRead, mContentLength));
 
     // Check the size of chunked responses. If we exceed the max pipeline size
     // for this response reschedule the pipeline
     if ((mClassification != CLASS_SOLO) &&
         mChunkedDecoder &&
         ((mContentRead + mChunkedDecoder->GetChunkRemaining()) >
          mMaxPipelineObjectSize)) {
@@ -1963,17 +1964,17 @@ nsHttpTransaction::DisableSpdy()
         // is owned by the connection manager, so we're safe to change this here
         mConnInfo->SetNoSpdy(true);
     }
 }
 
 void
 nsHttpTransaction::CheckForStickyAuthScheme()
 {
-  LOG(("nsHttpTransaction::CheckForStickyAuthScheme this=%p"));
+  LOG(("nsHttpTransaction::CheckForStickyAuthScheme this=%p", this));
 
   MOZ_ASSERT(mHaveAllHeaders);
   MOZ_ASSERT(mResponseHead);
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
   CheckForStickyAuthSchemeAt(nsHttp::WWW_Authenticate);
   CheckForStickyAuthSchemeAt(nsHttp::Proxy_Authenticate);
 }
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -147,17 +147,17 @@ public:
   // Called to update settings when connection fails again.
   void FailedAgain()
   {
     mLastFailure = TimeStamp::Now();
     // We use a truncated exponential backoff as suggested by RFC 6455,
     // but multiply by 1.5 instead of 2 to be more gradual.
     mNextDelay = static_cast<uint32_t>(
       std::min<double>(kWSReconnectMaxDelay, mNextDelay * 1.5));
-    LOG(("WebSocket: FailedAgain: host=%s, port=%d: incremented delay to %lu",
+    LOG(("WebSocket: FailedAgain: host=%s, port=%d: incremented delay to %" PRIu32,
          mAddress.get(), mPort, mNextDelay));
   }
 
   // returns 0 if there is no need to delay (i.e. delay interval is over)
   uint32_t RemainingDelay(TimeStamp rightNow)
   {
     TimeDuration dur = rightNow - mLastFailure;
     uint32_t sinceFail = (uint32_t) dur.ToMilliseconds();
@@ -400,18 +400,18 @@ public:
     // host may have different port
     sManager->ConnectNext(aChannel->mAddress);
   }
 
   // Called every time a websocket channel ends its session (including going away
   // w/o ever successfully creating a connection)
   static void OnStopSession(WebSocketChannel *aChannel, nsresult aReason)
   {
-    LOG(("Websocket: OnStopSession: [this=%p, reason=0x%08x]", aChannel,
-         aReason));
+    LOG(("Websocket: OnStopSession: [this=%p, reason=0x%08" PRIx32 "]", aChannel,
+         static_cast<uint32_t>(aReason)));
 
     StaticMutexAutoLock lock(sLock);
     if (!sManager) {
       return;
     }
 
     if (NS_FAILED(aReason)) {
       // Have we seen this failure before?
@@ -600,17 +600,17 @@ public:
         rv = mListenerMT->mListener->OnMessageAvailable(mListenerMT->mContext,
                                                         mData);
       } else {
         rv = mListenerMT->mListener->OnBinaryMessageAvailable(mListenerMT->mContext,
                                                               mData);
       }
       if (NS_FAILED(rv)) {
         LOG(("OnMessageAvailable or OnBinaryMessageAvailable "
-             "failed with 0x%08x", rv));
+             "failed with 0x%08" PRIx32, static_cast<uint32_t>(rv)));
       }
     }
 
     return NS_OK;
   }
 
 private:
   ~CallOnMessageAvailable() {}
@@ -641,17 +641,17 @@ public:
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(mChannel->IsOnTargetThread());
 
     if (mListenerMT) {
       nsresult rv = mListenerMT->mListener->OnStop(mListenerMT->mContext, mReason);
       if (NS_FAILED(rv)) {
         LOG(("WebSocketChannel::CallOnStop "
-             "OnStop failed (%08x)\n", rv));
+             "OnStop failed (%08" PRIx32 ")\n", static_cast<uint32_t>(rv)));
       }
       mChannel->mListenerMT = nullptr;
     }
 
     return NS_OK;
   }
 
 private:
@@ -685,17 +685,17 @@ public:
     MOZ_ASSERT(mChannel->IsOnTargetThread());
 
     if (mListenerMT) {
       nsresult rv =
         mListenerMT->mListener->OnServerClose(mListenerMT->mContext, mCode,
                                               mReason);
       if (NS_FAILED(rv)) {
         LOG(("WebSocketChannel::CallOnServerClose "
-             "OnServerClose failed (%08x)\n", rv));
+             "OnServerClose failed (%08" PRIx32 ")\n", static_cast<uint32_t>(rv)));
       }
     }
     return NS_OK;
   }
 
 private:
   ~CallOnServerClose() {}
 
@@ -722,17 +722,18 @@ public:
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(mChannel->IsOnTargetThread());
 
     LOG(("WebSocketChannel::CallAcknowledge: Size %u\n", mSize));
     if (mListenerMT) {
       nsresult rv = mListenerMT->mListener->OnAcknowledge(mListenerMT->mContext, mSize);
       if (NS_FAILED(rv)) {
-        LOG(("WebSocketChannel::CallAcknowledge: Acknowledge failed (%08x)\n", rv));
+        LOG(("WebSocketChannel::CallAcknowledge: Acknowledge failed (%08" PRIx32 ")\n",
+             static_cast<uint32_t>(rv)));
       }
     }
     return NS_OK;
   }
 
 private:
   ~CallAcknowledge() {}
 
@@ -1084,17 +1085,17 @@ public:
       // Empty message
       return false;
     }
 
     nsAutoPtr<nsCString> temp(new nsCString());
     rv = aCompressor->Deflate(BeginReading(), mLength, *temp);
     if (NS_FAILED(rv)) {
       LOG(("WebSocketChannel::OutboundMessage: Deflating payload failed "
-           "[rv=0x%08x]\n", rv));
+           "[rv=0x%08" PRIx32 "]\n", static_cast<uint32_t>(rv)));
       return false;
     }
 
     if (!aCompressor->UsingContextTakeover() && temp->Length() > mLength) {
       // When "<local>_no_context_takeover" was negotiated, do not send deflated
       // payload if it's larger that the original one. OTOH, it makes sense
       // to send the larger deflated payload when the sliding window is not
       // reset between messages because if we would skip some deflated block
@@ -1266,17 +1267,18 @@ WebSocketChannel::Observe(nsISupports *s
         // Next we check mDataStarted, which we need to do on mTargetThread.
         if (!IsOnTargetThread()) {
           mTargetThread->Dispatch(
             NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged),
             NS_DISPATCH_NORMAL);
         } else {
           nsresult rv = OnNetworkChanged();
           if (NS_FAILED(rv)) {
-            LOG(("WebSocket: OnNetworkChanged failed (%08x)", rv));
+            LOG(("WebSocket: OnNetworkChanged failed (%08" PRIx32 ")",
+                 static_cast<uint32_t>(rv)));
           }
         }
       }
     }
   }
 
   return NS_OK;
 }
@@ -1564,17 +1566,17 @@ WebSocketChannel::ProcessInput(uint8_t *
 
       // copy this in case it is unaligned
       payloadLength64 = NetworkEndian::readInt64(mFramePtr + 2);
     }
 
     payload = mFramePtr + framingLength;
     avail -= framingLength;
 
-    LOG(("WebSocketChannel::ProcessInput: payload %lld avail %lu\n",
+    LOG(("WebSocketChannel::ProcessInput: payload %" PRId64 " avail %" PRIu32 "\n",
          payloadLength64, avail));
 
     CheckedInt<int64_t> payloadLengthChecked(payloadLength64);
     payloadLengthChecked += mFragmentAccumulator;
     if (!payloadLengthChecked.isValid() || payloadLengthChecked.value() >
         mMaxMessageSize) {
       return NS_ERROR_FILE_TOO_BIG;
     }
@@ -1639,17 +1641,17 @@ WebSocketChannel::ProcessInput(uint8_t *
       // Only the first frame has a non zero op code: Make sure we don't see a
       // first frame while some old fragments are open
       if ((mFragmentAccumulator != 0) &&
           (opcode != nsIWebSocketFrame::OPCODE_CONTINUATION)) {
         LOG(("WebSocketChannel:: nested fragments\n"));
         return NS_ERROR_ILLEGAL_VALUE;
       }
 
-      LOG(("WebSocketChannel:: Accumulating Fragment %ld\n", payloadLength));
+      LOG(("WebSocketChannel:: Accumulating Fragment %" PRIu32 "\n", payloadLength));
 
       if (opcode == nsIWebSocketFrame::OPCODE_CONTINUATION) {
 
         // Make sure this continuation fragment isn't the first fragment
         if (mFragmentOpcode == nsIWebSocketFrame::OPCODE_CONTINUATION) {
           LOG(("WebSocketHeandler:: continuation code in first fragment\n"));
           return NS_ERROR_ILLEGAL_VALUE;
         }
@@ -2186,17 +2188,17 @@ WebSocketChannel::PrimeNewOutgoingMessag
     // Perform the sending mask. Never use a zero mask
     do {
       uint8_t *buffer;
       static_assert(4 == sizeof(mask), "Size of the mask should be equal to 4");
       nsresult rv = mRandomGenerator->GenerateRandomBytes(sizeof(mask),
                                                           &buffer);
       if (NS_FAILED(rv)) {
         LOG(("WebSocketChannel::PrimeNewOutgoingMessage(): "
-             "GenerateRandomBytes failure %x\n", rv));
+             "GenerateRandomBytes failure %" PRIx32 "\n", static_cast<uint32_t>(rv)));
         StopSession(rv);
         return;
       }
       memcpy(&mask, buffer, sizeof(mask));
       free(buffer);
     } while (!mask);
     NetworkEndian::writeUint32(payload - sizeof(uint32_t), mask);
   }
@@ -2337,17 +2339,18 @@ WebSocketChannel::CleanupConnection()
   NS_DispatchToMainThread(new RemoveObserverRunnable(this));
 
   DecrementSessionCount();
 }
 
 void
 WebSocketChannel::StopSession(nsresult reason)
 {
-  LOG(("WebSocketChannel::StopSession() %p [%x]\n", this, reason));
+  LOG(("WebSocketChannel::StopSession() %p [%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(reason)));
 
   // normally this should be called on socket thread, but it is ok to call it
   // from OnStartRequest before the socket thread machine has gotten underway
 
   mStopped = 1;
 
   if (!mOpenedHttpChannel) {
     // The HTTP channel information will never be used in this case
@@ -2442,18 +2445,18 @@ WebSocketChannel::StopSession(nsresult r
     RefPtr<CallOnStop> runnable = new CallOnStop(this, reason);
     mTargetThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
   }
 }
 
 void
 WebSocketChannel::AbortSession(nsresult reason)
 {
-  LOG(("WebSocketChannel::AbortSession() %p [reason %x] stopped = %d\n",
-       this, reason, !!mStopped));
+  LOG(("WebSocketChannel::AbortSession() %p [reason %" PRIx32 "] stopped = %d\n",
+       this, static_cast<uint32_t>(reason), !!mStopped));
 
   // normally this should be called on socket thread, but it is ok to call it
   // from the main thread before StartWebsocketData() has completed
 
   // When we are failing we need to close the TCP connection immediately
   // as per 7.1.1
   mTCPClosed = true;
 
@@ -2922,43 +2925,44 @@ WebSocketChannel::StartWebsocketData()
 
   LOG(("WebSocketChannel::StartWebsocketData() %p", this));
   MOZ_ASSERT(!mDataStarted, "StartWebsocketData twice");
   mDataStarted = 1;
 
   rv = mSocketIn->AsyncWait(this, 0, 0, mSocketThread);
   if (NS_FAILED(rv)) {
     LOG(("WebSocketChannel::StartWebsocketData mSocketIn->AsyncWait() failed "
-         "with error 0x%08x", rv));
+         "with error 0x%08" PRIx32, static_cast<uint32_t>(rv)));
     return mSocketThread->Dispatch(
       NewRunnableMethod<nsresult>(this,
                                   &WebSocketChannel::AbortSession,
                                   rv),
       NS_DISPATCH_NORMAL);
   }
 
   if (mPingInterval) {
     rv = mSocketThread->Dispatch(
       NewRunnableMethod(this, &WebSocketChannel::StartPinging),
       NS_DISPATCH_NORMAL);
     if (NS_FAILED(rv)) {
       LOG(("WebSocketChannel::StartWebsocketData Could not start pinging, "
-           "rv=0x%08x", rv));
+           "rv=0x%08" PRIx32, static_cast<uint32_t>(rv)));
       return rv;
     }
   }
 
   LOG(("WebSocketChannel::StartWebsocketData Notifying Listener %p",
        mListenerMT ? mListenerMT->mListener.get() : nullptr));
 
   if (mListenerMT) {
     rv = mListenerMT->mListener->OnStart(mListenerMT->mContext);
     if (NS_FAILED(rv)) {
       LOG(("WebSocketChannel::StartWebsocketData "
-           "mListenerMT->mListener->OnStart() failed with error 0x%08x", rv));
+           "mListenerMT->mListener->OnStart() failed with error 0x%08" PRIx32,
+           static_cast<uint32_t>(rv)));
     }
   }
 
   return NS_OK;
 }
 
 nsresult
 WebSocketChannel::StartPinging()
@@ -3014,18 +3018,18 @@ WebSocketChannel::ReportConnectionTeleme
 
 // nsIDNSListener
 
 NS_IMETHODIMP
 WebSocketChannel::OnLookupComplete(nsICancelable *aRequest,
                                    nsIDNSRecord *aRecord,
                                    nsresult aStatus)
 {
-  LOG(("WebSocketChannel::OnLookupComplete() %p [%p %p %x]\n",
-       this, aRequest, aRecord, aStatus));
+  LOG(("WebSocketChannel::OnLookupComplete() %p [%p %p %" PRIx32 "]\n",
+       this, aRequest, aRecord, static_cast<uint32_t>(aStatus)));
 
   MOZ_ASSERT(NS_IsMainThread(), "not main thread");
 
   if (mStopped) {
     LOG(("WebSocketChannel::OnLookupComplete: Request Already Stopped\n"));
     mCancelable = nullptr;
     return NS_OK;
   }
@@ -3883,18 +3887,18 @@ WebSocketChannel::OnStartRequest(nsIRequ
   return NS_OK;
 }
 
 NS_IMETHODIMP
 WebSocketChannel::OnStopRequest(nsIRequest *aRequest,
                                 nsISupports *aContext,
                                 nsresult aStatusCode)
 {
-  LOG(("WebSocketChannel::OnStopRequest() %p [%p %p %x]\n",
-       this, aRequest, mHttpChannel.get(), aStatusCode));
+  LOG(("WebSocketChannel::OnStopRequest() %p [%p %p %" PRIx32 "]\n",
+       this, aRequest, mHttpChannel.get(), static_cast<uint32_t>(aStatusCode)));
   MOZ_ASSERT(NS_IsMainThread(), "not main thread");
 
   ReportConnectionTelemetry();
 
   // This is the end of the HTTP upgrade transaction, the
   // upgraded streams live on
 
   mChannel = nullptr;
@@ -3918,17 +3922,18 @@ WebSocketChannel::OnInputStreamReady(nsI
 
   // this is after the http upgrade - so we are speaking websockets
   char  buffer[2048];
   uint32_t count;
   nsresult rv;
 
   do {
     rv = mSocketIn->Read((char *)buffer, 2048, &count);
-    LOG(("WebSocketChannel::OnInputStreamReady: read %u rv %x\n", count, rv));
+    LOG(("WebSocketChannel::OnInputStreamReady: read %u rv %" PRIx32 "\n",
+         count, static_cast<uint32_t>(rv)));
 
     if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
       mSocketIn->AsyncWait(this, 0, 0, mSocketThread);
       return NS_OK;
     }
 
     if (NS_FAILED(rv)) {
       mTCPClosed = true;
@@ -3987,18 +3992,18 @@ WebSocketChannel::OnOutputStreamReady(ns
              "Try to send %u of data\n", toSend));
       }
     }
 
     if (toSend == 0) {
       amtSent = 0;
     } else {
       rv = mSocketOut->Write(sndBuf, toSend, &amtSent);
-      LOG(("WebSocketChannel::OnOutputStreamReady: write %u rv %x\n",
-           amtSent, rv));
+      LOG(("WebSocketChannel::OnOutputStreamReady: write %u rv %" PRIx32 "\n",
+           amtSent, static_cast<uint32_t>(rv)));
 
       if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
         mSocketOut->AsyncWait(this, 0, 0, mSocketThread);
         return NS_OK;
       }
 
       if (NS_FAILED(rv)) {
         AbortSession(rv);
@@ -4040,17 +4045,17 @@ WebSocketChannel::OnOutputStreamReady(ns
 
 NS_IMETHODIMP
 WebSocketChannel::OnDataAvailable(nsIRequest *aRequest,
                                     nsISupports *aContext,
                                     nsIInputStream *aInputStream,
                                     uint64_t aOffset,
                                     uint32_t aCount)
 {
-  LOG(("WebSocketChannel::OnDataAvailable() %p [%p %p %p %llu %u]\n",
+  LOG(("WebSocketChannel::OnDataAvailable() %p [%p %p %p %" PRIu64 " %u]\n",
          this, aRequest, mHttpChannel.get(), aInputStream, aOffset, aCount));
 
   // This is the HTTP OnDataAvailable Method, which means this is http data in
   // response to the upgrade request and there should be no http response body
   // if the upgrade succeeded. This generally should be caught by a non 101
   // response code in OnStartRequest().. so we can ignore the data here
 
   LOG(("WebSocketChannel::OnDataAvailable: HTTP data unexpected len>=%u\n",
--- a/netwerk/protocol/websocket/WebSocketChannelChild.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannelChild.cpp
@@ -234,17 +234,18 @@ WebSocketChannelChild::OnStart(const nsC
   mEffectiveURL = aEffectiveURL;
   mEncrypted = aEncrypted;
 
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
     nsresult rv = mListenerMT->mListener->OnStart(mListenerMT->mContext);
     if (NS_FAILED(rv)) {
       LOG(("WebSocketChannelChild::OnStart "
-           "mListenerMT->mListener->OnStart() failed with error 0x%08x", rv));
+           "mListenerMT->mListener->OnStart() failed with error 0x%08" PRIx32,
+           static_cast<uint32_t>(rv)));
     }
   }
 }
 
 class StopEvent : public ChannelEvent
 {
  public:
   StopEvent(WebSocketChannelChild* aChild,
@@ -277,17 +278,18 @@ WebSocketChannelChild::OnStop(const nsre
 {
   LOG(("WebSocketChannelChild::RecvOnStop() %p\n", this));
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
     nsresult rv =
       mListenerMT->mListener->OnStop(mListenerMT->mContext, aStatusCode);
     if (NS_FAILED(rv)) {
       LOG(("WebSocketChannel::OnStop "
-           "mListenerMT->mListener->OnStop() failed with error 0x%08x", rv));
+           "mListenerMT->mListener->OnStop() failed with error 0x%08" PRIx32,
+           static_cast<uint32_t>(rv)));
     }
   }
 }
 
 class MessageEvent : public ChannelEvent
 {
  public:
   MessageEvent(WebSocketChannelChild* aChild,
@@ -328,17 +330,17 @@ WebSocketChannelChild::OnMessageAvailabl
   LOG(("WebSocketChannelChild::RecvOnMessageAvailable() %p\n", this));
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
     nsresult rv =
       mListenerMT->mListener->OnMessageAvailable(mListenerMT->mContext, aMsg);
     if (NS_FAILED(rv)) {
       LOG(("WebSocketChannelChild::OnMessageAvailable "
            "mListenerMT->mListener->OnMessageAvailable() "
-           "failed with error 0x%08x", rv));
+           "failed with error 0x%08" PRIx32, static_cast<uint32_t>(rv)));
     }
   }
 }
 
 mozilla::ipc::IPCResult
 WebSocketChannelChild::RecvOnBinaryMessageAvailable(const nsCString& aMsg)
 {
   mEventQ->RunOrEnqueue(
@@ -355,17 +357,17 @@ WebSocketChannelChild::OnBinaryMessageAv
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
     nsresult rv =
       mListenerMT->mListener->OnBinaryMessageAvailable(mListenerMT->mContext,
                                                        aMsg);
     if (NS_FAILED(rv)) {
       LOG(("WebSocketChannelChild::OnBinaryMessageAvailable "
            "mListenerMT->mListener->OnBinaryMessageAvailable() "
-           "failed with error 0x%08x", rv));
+           "failed with error 0x%08" PRIx32, static_cast<uint32_t>(rv)));
     }
   }
 }
 
 class AcknowledgeEvent : public ChannelEvent
 {
  public:
   AcknowledgeEvent(WebSocketChannelChild* aChild,
@@ -399,17 +401,17 @@ WebSocketChannelChild::OnAcknowledge(con
   LOG(("WebSocketChannelChild::RecvOnAcknowledge() %p\n", this));
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
     nsresult rv =
       mListenerMT->mListener->OnAcknowledge(mListenerMT->mContext, aSize);
     if (NS_FAILED(rv)) {
       LOG(("WebSocketChannel::OnAcknowledge "
            "mListenerMT->mListener->OnAcknowledge() "
-           "failed with error 0x%08x", rv));
+           "failed with error 0x%08" PRIx32, static_cast<uint32_t>(rv)));
     }
   }
 }
 
 class ServerCloseEvent : public ChannelEvent
 {
  public:
   ServerCloseEvent(WebSocketChannelChild* aChild,
@@ -668,17 +670,17 @@ public:
     MOZ_ASSERT(aChild);
   }
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
     nsresult rv = mChild->SendBinaryStream(mStream, mLength);
     if (NS_FAILED(rv)) {
       LOG(("WebSocketChannelChild::BinaryStreamEvent %p "
-           "SendBinaryStream failed (%08x)\n", this, rv));
+           "SendBinaryStream failed (%08" PRIx32 ")\n", this, static_cast<uint32_t>(rv)));
     }
     return NS_OK;
   }
 private:
   RefPtr<WebSocketChannelChild>      mChild;
   nsAutoPtr<OptionalInputStreamParams> mStream;
   uint32_t                             mLength;
 };
--- a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
@@ -43,23 +43,23 @@ WyciwygChannelChild::WyciwygChannelChild
   , mCanceled(false)
   , mLoadFlags(LOAD_NORMAL)
   , mContentLength(-1)
   , mCharsetSource(kCharsetUninitialized)
   , mState(WCC_NEW)
   , mIPCOpen(false)
   , mSentAppData(false)
 {
-  LOG(("Creating WyciwygChannelChild @%x\n", this));
+  LOG(("Creating WyciwygChannelChild @%p\n", this));
   mEventQ = new ChannelEventQueue(NS_ISUPPORTS_CAST(nsIWyciwygChannel*, this));
 }
 
 WyciwygChannelChild::~WyciwygChannelChild()
 {
-  LOG(("Destroying WyciwygChannelChild @%x\n", this));
+  LOG(("Destroying WyciwygChannelChild @%p\n", this));
   if (mLoadInfo) {
     NS_ReleaseOnMainThread(mLoadInfo.forget());
   }
 }
 
 void
 WyciwygChannelChild::AddIPDLReference()
 {
@@ -270,18 +270,18 @@ WyciwygChannelChild::RecvOnStopRequest(c
 {
   mEventQ->RunOrEnqueue(new WyciwygStopRequestEvent(this, statusCode));
   return IPC_OK();
 }
 
 void
 WyciwygChannelChild::OnStopRequest(const nsresult& statusCode)
 {
-  LOG(("WyciwygChannelChild::RecvOnStopRequest [this=%p status=%u]\n",
-           this, statusCode));
+  LOG(("WyciwygChannelChild::RecvOnStopRequest [this=%p status=%" PRIu32 "]\n",
+       this, static_cast<uint32_t>(statusCode)));
 
   { // We need to ensure that all IPDL message dispatching occurs
     // before we delete the protocol below
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
 
     mState = WCC_ONSTOP;
 
     mIsPending = false;
--- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
@@ -351,18 +351,18 @@ WyciwygChannelParent::OnStartRequest(nsI
   return NS_OK;
 }
 
 NS_IMETHODIMP
 WyciwygChannelParent::OnStopRequest(nsIRequest *aRequest,
                                     nsISupports *aContext,
                                     nsresult aStatusCode)
 {
-  LOG(("WyciwygChannelParent::OnStopRequest: [this=%p status=%ul]\n",
-       this, aStatusCode));
+  LOG(("WyciwygChannelParent::OnStopRequest: [this=%p status=%" PRIu32 "]\n",
+       this, static_cast<uint32_t>(aStatusCode)));
 
   if (mIPCClosed || !SendOnStopRequest(aStatusCode)) {
     return NS_ERROR_UNEXPECTED;
   }
 
   return NS_OK;
 }
 
--- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
@@ -439,17 +439,17 @@ nsWyciwygChannel::AsyncOpen(nsIStreamLis
 
   // open a cache entry for this channel...
   // mIsPending set to true since OnCacheEntryAvailable may be called
   // synchronously and fails when mIsPending found false.
   mIsPending = true;
   nsresult rv = OpenCacheEntry(mURI, nsICacheStorage::OPEN_READONLY |
                                      nsICacheStorage::CHECK_MULTITHREADED);
   if (NS_FAILED(rv)) {
-    LOG(("nsWyciwygChannel::OpenCacheEntry failed [rv=%x]\n", rv));
+    LOG(("nsWyciwygChannel::OpenCacheEntry failed [rv=%" PRIx32 "]\n", static_cast<uint32_t>(rv)));
     mIsPending = false;
     mCallbacks = nullptr;
     return rv;
   }
 
   // There is no code path that would invoke the listener sooner than
   // we get to this line in case OnCacheEntryAvailable is invoked
   // synchronously.
@@ -671,32 +671,32 @@ nsWyciwygChannel::OnCacheEntryCheck(nsIC
 
 NS_IMETHODIMP
 nsWyciwygChannel::OnCacheEntryAvailable(nsICacheEntry *aCacheEntry,
                                         bool aNew,
                                         nsIApplicationCache* aAppCache,
                                         nsresult aStatus)
 {
   LOG(("nsWyciwygChannel::OnCacheEntryAvailable [this=%p entry=%p "
-       "new=%d status=%x]\n", this, aCacheEntry, aNew, aStatus));
+       "new=%d status=%" PRIx32 "]\n", this, aCacheEntry, aNew, static_cast<uint32_t>(aStatus)));
 
   // if the channel's already fired onStopRequest, 
   // then we should ignore this event.
   if (!mIsPending && !aNew)
     return NS_OK;
 
   // otherwise, we have to handle this event.
   if (NS_SUCCEEDED(aStatus))
     mCacheEntry = aCacheEntry;
   else if (NS_SUCCEEDED(mStatus))
     mStatus = aStatus;
 
   nsresult rv = NS_OK;
   if (NS_FAILED(mStatus)) {
-    LOG(("channel was canceled [this=%p status=%x]\n", this, mStatus));
+    LOG(("channel was canceled [this=%p status=%" PRIx32 "]\n", this, static_cast<uint32_t>(mStatus)));
     rv = mStatus;
   }
   else if (!aNew) { // advance to the next state...
     rv = ReadFromCache();
   }
 
   // a failure from Connect means that we have to abort the channel.
   if (NS_FAILED(rv)) {
@@ -717,17 +717,17 @@ nsWyciwygChannel::OnCacheEntryAvailable(
 // nsWyciwygChannel::nsIStreamListener
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsWyciwygChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctx,
                                   nsIInputStream *input,
                                   uint64_t offset, uint32_t count)
 {
-  LOG(("nsWyciwygChannel::OnDataAvailable [this=%p request=%x offset=%llu count=%u]\n",
+  LOG(("nsWyciwygChannel::OnDataAvailable [this=%p request=%p offset=%" PRIu64 " count=%u]\n",
       this, request, offset, count));
 
   nsresult rv;
   
   rv = mListener->OnDataAvailable(this, mListenerContext, input, offset, count);
 
   // XXX handle 64-bit stuff for real
   if (mProgressSink && NS_SUCCEEDED(rv)) {
@@ -739,28 +739,28 @@ nsWyciwygChannel::OnDataAvailable(nsIReq
 
 //////////////////////////////////////////////////////////////////////////////
 // nsIRequestObserver
 //////////////////////////////////////////////////////////////////////////////
 
 NS_IMETHODIMP
 nsWyciwygChannel::OnStartRequest(nsIRequest *request, nsISupports *ctx)
 {
-  LOG(("nsWyciwygChannel::OnStartRequest [this=%p request=%x\n",
+  LOG(("nsWyciwygChannel::OnStartRequest [this=%p request=%p]\n",
       this, request));
 
   return mListener->OnStartRequest(this, mListenerContext);
 }
 
 
 NS_IMETHODIMP
 nsWyciwygChannel::OnStopRequest(nsIRequest *request, nsISupports *ctx, nsresult status)
 {
-  LOG(("nsWyciwygChannel::OnStopRequest [this=%p request=%x status=%d\n",
-      this, request, status));
+  LOG(("nsWyciwygChannel::OnStopRequest [this=%p request=%p status=%" PRIu32 "]\n",
+       this, request, static_cast<uint32_t>(status)));
 
   if (NS_SUCCEEDED(mStatus))
     mStatus = status;
 
   mListener->OnStopRequest(this, mListenerContext, mStatus);
   mListener = nullptr;
   mListenerContext = nullptr;
 
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -31,16 +31,17 @@
 #endif
 
 #include "DataChannelLog.h"
 
 #include "nsServiceManagerUtils.h"
 #include "nsIObserverService.h"
 #include "nsIObserver.h"
 #include "mozilla/Services.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Sprintf.h"
 #include "nsProxyRelease.h"
 #include "nsThread.h"
 #include "nsThreadUtils.h"
 #include "nsAutoPtr.h"
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
 #include "mozilla/StaticPtr.h"
@@ -1094,23 +1095,23 @@ DataChannelConnection::SendDeferredMessa
         if ((result = usrsctp_sendv(mSocket, data, len,
                                     nullptr, 0,
                                     (void *)spa, (socklen_t)sizeof(struct sctp_sendv_spa),
                                     SCTP_SENDV_SPA,
                                     0)) < 0) {
           if (errno == EAGAIN || errno == EWOULDBLOCK) {
             // leave queued for resend
             failed_send = true;
-            LOG(("queue full again when resending %d bytes (%d)", len, result));
+            LOG(("queue full again when resending %" PRIuSIZE " bytes (%d)", len, result));
           } else {
             LOG(("error %d re-sending string", errno));
             failed_send = true;
           }
         } else {
-          LOG(("Resent buffer of %d bytes (%d)", len, result));
+          LOG(("Resent buffer of %" PRIuSIZE " bytes (%d)", len, result));
           // In theory this could underflow if >4GB was buffered and re
           // truncated in GetBufferedAmount(), but this won't cause any problems.
           buffered_amount -= channel->mBufferedData[0]->mLength;
           channel->mBufferedData.RemoveElementAt(0);
           // can never fire with default threshold of 0
           if (was_over_threshold && buffered_amount < threshold) {
             LOG(("%s: sending BUFFER_LOW_THRESHOLD for %s/%s: %u", __FUNCTION__,
                  channel->mLabel.get(), channel->mProtocol.get(), channel->mStream));
@@ -1150,39 +1151,39 @@ DataChannelConnection::HandleOpenRequest
   RefPtr<DataChannel> channel;
   uint32_t prValue;
   uint16_t prPolicy;
   uint32_t flags;
 
   mLock.AssertCurrentThreadOwns();
 
   if (length != (sizeof(*req) - 1) + ntohs(req->label_length) + ntohs(req->protocol_length)) {
-    LOG(("%s: Inconsistent length: %u, should be %u", __FUNCTION__, length,
+    LOG(("%s: Inconsistent length: %" PRIuSIZE ", should be %" PRIuSIZE, __FUNCTION__, length,
          (sizeof(*req) - 1) + ntohs(req->label_length) + ntohs(req->protocol_length)));
     if (length < (sizeof(*req) - 1) + ntohs(req->label_length) + ntohs(req->protocol_length))
       return;
   }
 
-  LOG(("%s: length %u, sizeof(*req) = %u", __FUNCTION__, length, sizeof(*req)));
+  LOG(("%s: length %" PRIuSIZE ", sizeof(*req) = %" PRIuSIZE, __FUNCTION__, length, sizeof(*req)));
 
   switch (req->channel_type) {
     case DATA_CHANNEL_RELIABLE:
     case DATA_CHANNEL_RELIABLE_UNORDERED:
       prPolicy = SCTP_PR_SCTP_NONE;
       break;
     case DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT:
     case DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT_UNORDERED:
       prPolicy = SCTP_PR_SCTP_RTX;
       break;
     case DATA_CHANNEL_PARTIAL_RELIABLE_TIMED:
     case DATA_CHANNEL_PARTIAL_RELIABLE_TIMED_UNORDERED:
       prPolicy = SCTP_PR_SCTP_TTL;
       break;
     default:
-      LOG(("Unknown channel type", req->channel_type));
+      LOG(("Unknown channel type %d", req->channel_type));
       /* XXX error handling */
       return;
   }
   prValue = ntohl(req->reliability_param);
   flags = (req->channel_type & 0x80) ? DATA_CHANNEL_FLAGS_OUT_OF_ORDER_ALLOWED : 0;
 
   if ((channel = FindChannelByStream(stream))) {
     if (!(channel->mFlags & DATA_CHANNEL_FLAGS_EXTERNAL_NEGOTIATED)) {
@@ -1200,17 +1201,17 @@ DataChannelConnection::HandleOpenRequest
              "channel %u, policy %u/%u, value %u/%u, flags %x/%x",
              stream, prPolicy, channel->mPrPolicy,
              prValue, channel->mPrValue, flags, channel->mFlags));
       }
     }
     return;
   }
   if (stream >= mStreams.Length()) {
-    LOG(("%s: stream %u out of bounds (%u)", __FUNCTION__, stream, mStreams.Length()));
+    LOG(("%s: stream %u out of bounds (%" PRIuSIZE ")", __FUNCTION__, stream, mStreams.Length()));
     return;
   }
 
   nsCString label(nsDependentCSubstring(&req->label[0], ntohs(req->label_length)));
   nsCString protocol(nsDependentCSubstring(&req->label[ntohs(req->label_length)],
                                            ntohs(req->protocol_length)));
 
   channel = new DataChannel(this,
@@ -1286,17 +1287,17 @@ DataChannelConnection::HandleOpenAckMess
 
   channel->mFlags &= ~DATA_CHANNEL_FLAGS_WAITING_ACK;
 }
 
 void
 DataChannelConnection::HandleUnknownMessage(uint32_t ppid, size_t length, uint16_t stream)
 {
   /* XXX: Send an error message? */
-  LOG(("unknown DataChannel message received: %u, len %ld on stream %lu", ppid, length, stream));
+  LOG(("unknown DataChannel message received: %u, len %" PRIuSIZE " on stream %d", ppid, length, stream));
   // XXX Log to JS error console if possible
 }
 
 void
 DataChannelConnection::HandleDataMessage(uint32_t ppid,
                                          const void *data, size_t length,
                                          uint16_t stream)
 {
@@ -1316,17 +1317,17 @@ DataChannelConnection::HandleDataMessage
     // response or ack).  Also, with external negotiation, data can come in
     // before we're told about the external negotiation.  We need to buffer
     // data until either a) Open comes in, if the ordering get messed up,
     // or b) the app tells us this channel was externally negotiated.  When
     // these occur, we deliver the data.
 
     // Since this is rare and non-performance, keep a single list of queued
     // data messages to deliver once the channel opens.
-    LOG(("Queuing data for stream %u, length %u", stream, length));
+    LOG(("Queuing data for stream %u, length %" PRIuSIZE, stream, length));
     // Copies data
     mQueuedData.AppendElement(new QueuedDataMessage(stream, ppid, data, length));
     return;
   }
 
   // XXX should this be a simple if, no warnings/debugbreaks?
   NS_ENSURE_TRUE_VOID(channel->mState != CLOSED);
 
@@ -1343,23 +1344,23 @@ DataChannelConnection::HandleDataMessage
       channel->mRecvBuffer.Truncate(0);
     }
     channel->mIsRecvBinary = is_binary;
 
     switch (ppid) {
       case DATA_CHANNEL_PPID_DOMSTRING:
       case DATA_CHANNEL_PPID_BINARY:
         channel->mRecvBuffer += recvData;
-        LOG(("DataChannel: Partial %s message of length %lu (total %u) on channel id %u",
+        LOG(("DataChannel: Partial %s message of length %" PRIuSIZE " (total %u) on channel id %u",
              is_binary ? "binary" : "string", length, channel->mRecvBuffer.Length(),
              channel->mStream));
         return; // Not ready to notify application
 
       case DATA_CHANNEL_PPID_DOMSTRING_LAST:
-        LOG(("DataChannel: String message received of length %lu on channel %u",
+        LOG(("DataChannel: String message received of length %" PRIuSIZE " on channel %u",
              length, channel->mStream));
         if (!channel->mRecvBuffer.IsEmpty()) {
           channel->mRecvBuffer += recvData;
           LOG(("%s: sending ON_DATA (string fragmented) for %p", __FUNCTION__, channel));
           channel->SendOrQueue(new DataChannelOnMessageAvailable(
                                  DataChannelOnMessageAvailable::ON_DATA, this,
                                  channel, channel->mRecvBuffer, -1));
           channel->mRecvBuffer.Truncate(0);
@@ -1367,17 +1368,17 @@ DataChannelConnection::HandleDataMessage
         }
         // else send using recvData normally
         length = -1; // Flag for DOMString
 
         // WebSockets checks IsUTF8() here; we can try to deliver it
         break;
 
       case DATA_CHANNEL_PPID_BINARY_LAST:
-        LOG(("DataChannel: Received binary message of length %lu on channel id %u",
+        LOG(("DataChannel: Received binary message of length %" PRIuSIZE " on channel id %u",
              length, channel->mStream));
         if (!channel->mRecvBuffer.IsEmpty()) {
           channel->mRecvBuffer += recvData;
           LOG(("%s: sending ON_DATA (binary fragmented) for %p", __FUNCTION__, channel));
           channel->SendOrQueue(new DataChannelOnMessageAvailable(
                                  DataChannelOnMessageAvailable::ON_DATA, this,
                                  channel, channel->mRecvBuffer,
                                  channel->mRecvBuffer.Length()));
@@ -1433,17 +1434,17 @@ DataChannelConnection::HandleMessage(con
       break;
     case DATA_CHANNEL_PPID_DOMSTRING:
     case DATA_CHANNEL_PPID_DOMSTRING_LAST:
     case DATA_CHANNEL_PPID_BINARY:
     case DATA_CHANNEL_PPID_BINARY_LAST:
       HandleDataMessage(ppid, buffer, length, stream);
       break;
     default:
-      LOG(("Message of length %lu, PPID %u on stream %u received.",
+      LOG(("Message of length %" PRIuSIZE ", PPID %u on stream %u received.",
            length, ppid, stream));
       break;
   }
 }
 
 void
 DataChannelConnection::HandleAssociationChangeEvent(const struct sctp_assoc_change *sac)
 {
@@ -1643,17 +1644,17 @@ DataChannelConnection::HandleSendFailedE
   }
 }
 
 void
 DataChannelConnection::ClearResets()
 {
   // Clear all pending resets
   if (!mStreamsResetting.IsEmpty()) {
-    LOG(("Clearing resets for %d streams", mStreamsResetting.Length()));
+    LOG(("Clearing resets for %" PRIuSIZE " streams", mStreamsResetting.Length()));
   }
 
   for (uint32_t i = 0; i < mStreamsResetting.Length(); ++i) {
     RefPtr<DataChannel> channel;
     channel = FindChannelByStream(mStreamsResetting[i]);
     if (channel) {
       LOG(("Forgetting channel %u (%p) with pending reset",channel->mStream, channel.get()));
       mStreams[channel->mStream] = nullptr;
@@ -1681,17 +1682,17 @@ DataChannelConnection::ResetOutgoingStre
 
 void
 DataChannelConnection::SendOutgoingStreamReset()
 {
   struct sctp_reset_streams *srs;
   uint32_t i;
   size_t len;
 
-  LOG(("Connection %p: Sending outgoing stream reset for %d streams",
+  LOG(("Connection %p: Sending outgoing stream reset for %" PRIuSIZE " streams",
        (void *) this, mStreamsResetting.Length()));
   mLock.AssertCurrentThreadOwns();
   if (mStreamsResetting.IsEmpty()) {
     LOG(("No streams to reset"));
     return;
   }
   len = sizeof(sctp_assoc_t) + (2 + mStreamsResetting.Length()) * sizeof(uint16_t);
   srs = static_cast<struct sctp_reset_streams *> (moz_xmalloc(len)); // infallible malloc
@@ -1759,67 +1760,67 @@ DataChannelConnection::HandleStreamReset
           LOG(("Can't find incoming channel %d",i));
         }
       }
     }
   }
 
   // Process any pending resets now:
   if (!mStreamsResetting.IsEmpty()) {
-    LOG(("Sending %d pending resets", mStreamsResetting.Length()));
+    LOG(("Sending %" PRIuSIZE " pending resets", mStreamsResetting.Length()));
     SendOutgoingStreamReset();
   }
 }
 
 void
 DataChannelConnection::HandleStreamChangeEvent(const struct sctp_stream_change_event *strchg)
 {
   uint16_t stream;
   RefPtr<DataChannel> channel;
 
   if (strchg->strchange_flags == SCTP_STREAM_CHANGE_DENIED) {
-    LOG(("*** Failed increasing number of streams from %u (%u/%u)",
+    LOG(("*** Failed increasing number of streams from %" PRIuSIZE " (%u/%u)",
          mStreams.Length(),
          strchg->strchange_instrms,
          strchg->strchange_outstrms));
     // XXX FIX! notify pending opens of failure
     return;
   }
   if (strchg->strchange_instrms > mStreams.Length()) {
-    LOG(("Other side increased streams from %u to %u",
+    LOG(("Other side increased streams from %" PRIuSIZE " to %u",
          mStreams.Length(), strchg->strchange_instrms));
   }
   if (strchg->strchange_outstrms > mStreams.Length() ||
       strchg->strchange_instrms > mStreams.Length()) {
     uint16_t old_len = mStreams.Length();
     uint16_t new_len = std::max(strchg->strchange_outstrms,
                                 strchg->strchange_instrms);
     LOG(("Increasing number of streams from %u to %u - adding %u (in: %u)",
          old_len, new_len, new_len - old_len,
          strchg->strchange_instrms));
     // make sure both are the same length
     mStreams.AppendElements(new_len - old_len);
-    LOG(("New length = %d (was %d)", mStreams.Length(), old_len));
+    LOG(("New length = %" PRIuSIZE " (was %d)", mStreams.Length(), old_len));
     for (size_t i = old_len; i < mStreams.Length(); ++i) {
       mStreams[i] = nullptr;
     }
     // Re-process any channels waiting for streams.
     // Linear search, but we don't increase channels often and
     // the array would only get long in case of an app error normally
 
     // Make sure we request enough streams if there's a big jump in streams
     // Could make a more complex API for OpenXxxFinish() and avoid this loop
     size_t num_needed = mPending.GetSize();
-    LOG(("%d of %d new streams already needed", num_needed,
+    LOG(("%" PRIuSIZE " of %d new streams already needed", num_needed,
          new_len - old_len));
     num_needed -= (new_len - old_len); // number we added
     if (num_needed > 0) {
       if (num_needed < 16)
         num_needed = 16;
-      LOG(("Not enough new streams, asking for %d more", num_needed));
+      LOG(("Not enough new streams, asking for %" PRIuSIZE " more", num_needed));
       RequestMoreStreams(num_needed);
     } else if (strchg->strchange_outstrms < strchg->strchange_instrms) {
       LOG(("Requesting %d output streams to match partner",
            strchg->strchange_instrms - strchg->strchange_outstrms));
       RequestMoreStreams(strchg->strchange_instrms - strchg->strchange_outstrms);
     }
 
     ProcessQueuedOpens();
@@ -2214,30 +2215,31 @@ DataChannelConnection::SendMsgInternal(D
 
   // Must lock before empty check for similar reasons!
   MutexAutoLock lock(mLock);
   if (channel->mBufferedData.IsEmpty()) {
     result = usrsctp_sendv(mSocket, data, length,
                            nullptr, 0,
                            (void *)&spa, (socklen_t)sizeof(struct sctp_sendv_spa),
                            SCTP_SENDV_SPA, 0);
-    LOG(("Sent buffer (len=%u), result=%d", length, result));
+    LOG(("Sent buffer (len=%" PRIuSIZE "), result=%d", length, result));
   } else {
     // Fake EAGAIN if we're already buffering data
     result = -1;
     errno = EAGAIN;
   }
   if (result < 0) {
     if (errno == EAGAIN || errno == EWOULDBLOCK) {
 
       // queue data for resend!  And queue any further data for the stream until it is...
       auto *buffered = new BufferedMsg(spa, data, length); // infallible malloc
       channel->mBufferedData.AppendElement(buffered); // owned by mBufferedData array
       channel->mFlags |= DATA_CHANNEL_FLAGS_SEND_DATA;
-      LOG(("Queued %u buffers (len=%u)", channel->mBufferedData.Length(), length));
+      LOG(("Queued %" PRIuSIZE " buffers (len=%" PRIuSIZE ")",
+           channel->mBufferedData.Length(), length));
       return 0;
     }
     LOG(("error %d sending string", errno));
   }
   return result;
 }
 
 // Handles fragmenting binary messages
@@ -2260,29 +2262,29 @@ DataChannelConnection::SendBinary(DataCh
   // We *really* don't want to do this from main thread! - and SendMsgInternal
   // avoids blocking.
   // This MUST be reliable and in-order for the reassembly to work
   if (len > DATA_CHANNEL_MAX_BINARY_FRAGMENT &&
       channel->mPrPolicy == DATA_CHANNEL_RELIABLE &&
       !(channel->mFlags & DATA_CHANNEL_FLAGS_OUT_OF_ORDER_ALLOWED)) {
     int32_t sent=0;
     uint32_t origlen = len;
-    LOG(("Sending binary message length %u in chunks", len));
+    LOG(("Sending binary message length %" PRIuSIZE " in chunks", len));
     // XXX check flags for out-of-order, or force in-order for large binary messages
     while (len > 0) {
       size_t sendlen = std::min<size_t>(len, DATA_CHANNEL_MAX_BINARY_FRAGMENT);
       uint32_t ppid;
       len -= sendlen;
       ppid = len > 0 ? ppid_partial : ppid_final;
-      LOG(("Send chunk of %u bytes, ppid %u", sendlen, ppid));
+      LOG(("Send chunk of %" PRIuSIZE " bytes, ppid %u", sendlen, ppid));
       // Note that these might end up being deferred and queued.
       sent += SendMsgInternal(channel, data, sendlen, ppid);
       data += sendlen;
     }
-    LOG(("Sent %d buffers for %u bytes, %d sent immediately, %d buffers queued",
+    LOG(("Sent %d buffers for %u bytes, %d sent immediately, %" PRIuSIZE " buffers queued",
          (origlen+DATA_CHANNEL_MAX_BINARY_FRAGMENT-1)/DATA_CHANNEL_MAX_BINARY_FRAGMENT,
          origlen, sent,
          channel->mBufferedData.Length()));
     return sent;
   }
   NS_WARNING_ASSERTION(len <= DATA_CHANNEL_MAX_BINARY_FRAGMENT,
                        "Sending too-large data on unreliable channel!");
 
--- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
+++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
@@ -13,16 +13,17 @@
 #include "nsIStreamListener.h"
 #include "nsCRT.h"
 #include "nsIChannel.h"
 #include "nsIURI.h"
 
 #include "ParseFTPList.h"
 #include <algorithm>
 
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "mozilla/Unused.h"
 
 //
 // Log module for FTP dir listing stream converter logging...
 //
 // To enable logging (see prlog.h for full details):
 //
@@ -92,17 +93,17 @@ nsFTPDirListingConv::OnDataAvailable(nsI
     NS_ENSURE_TRUE(buffer, NS_ERROR_OUT_OF_MEMORY);
 
     rv = inStr->Read(buffer.get(), streamLen, &read);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // the dir listings are ascii text, null terminate this sucker.
     buffer[streamLen] = '\0';
 
-    MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("nsFTPDirListingConv::OnData(request = %x, ctxt = %x, inStr = %x, sourceOffset = %llu, count = %u)\n", request, ctxt, inStr, sourceOffset, count));
+    MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("nsFTPDirListingConv::OnData(request = %p, ctxt = %p, inStr = %p, sourceOffset = %" PRIu64 ", count = %u)\n", request, ctxt, inStr, sourceOffset, count));
 
     if (!mBuffer.IsEmpty()) {
         // we have data left over from a previous OnDataAvailable() call.
         // combine the buffers so we don't lose any data.
         mBuffer.Append(buffer.get());
 
         buffer = MakeUniqueFallible<char[]>(mBuffer.Length()+1);
         NS_ENSURE_TRUE(buffer, NS_ERROR_OUT_OF_MEMORY);
@@ -130,17 +131,17 @@ nsFTPDirListingConv::OnDataAvailable(nsI
     line = DigestBufferLines(line, indexFormat);
 
     MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("::OnData() sending the following %d bytes...\n\n%s\n\n", 
         indexFormat.Length(), indexFormat.get()) );
 
     // if there's any data left over, buffer it.
     if (line && *line) {
         mBuffer.Append(line);
-        MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("::OnData() buffering the following %d bytes...\n\n%s\n\n",
+        MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("::OnData() buffering the following %" PRIuSIZE " bytes...\n\n%s\n\n",
             strlen(line), line) );
     }
 
     // send the converted data out.
     nsCOMPtr<nsIInputStream> inputData;
 
     rv = NS_NewCStringInputStream(getter_AddRefs(inputData), indexFormat);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
+++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
@@ -10,16 +10,17 @@
 #include "nsCOMPtr.h"
 #include "nsError.h"
 #include "nsStreamUtils.h"
 #include "nsStringStream.h"
 #include "nsComponentManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "nsIForcePendingChannel.h"
 #include "nsIRequest.h"
 
 // brotli headers
 #include "state.h"
 #include "decode.h"
 
 namespace mozilla {
@@ -119,17 +120,17 @@ nsHTTPCompressConv::OnStartRequest(nsIRe
   return mListener->OnStartRequest(request, aContext);
 }
 
 NS_IMETHODIMP
 nsHTTPCompressConv::OnStopRequest(nsIRequest* request, nsISupports *aContext,
                                   nsresult aStatus)
 {
   nsresult status = aStatus;
-  LOG(("nsHttpCompresssConv %p onstop %x\n", this, aStatus));
+  LOG(("nsHttpCompresssConv %p onstop %" PRIx32 "\n", this, static_cast<uint32_t>(aStatus)));
   
   // Framing integrity is enforced for content-encoding: gzip, but not for
   // content-encoding: deflate. Note that gzip vs deflate is NOT determined
   // by content sniffing but only via header.
   if (!mStreamEnded && NS_SUCCEEDED(status) &&
       (mFailUncleanStops && (mMode == HTTP_COMPRESS_GZIP)) ) {
     // This is not a clean end of gzip stream: the transfer is incomplete.
     status = NS_ERROR_NET_PARTIAL_TRANSFER;
@@ -142,17 +143,18 @@ nsHTTPCompressConv::OnStopRequest(nsIReq
       request->IsPending(&isPending);
     }
     if (fpChannel && !isPending) {
       fpChannel->ForcePending(true);
     }
     if (mBrotli && (mBrotli->mTotalOut == 0) && !BrotliStateIsStreamEnd(&mBrotli->mState)) {
       status = NS_ERROR_INVALID_CONTENT_ENCODING;
     }
-    LOG(("nsHttpCompresssConv %p onstop brotlihandler rv %x\n", this, status));
+    LOG(("nsHttpCompresssConv %p onstop brotlihandler rv %" PRIx32 "\n",
+         this, static_cast<uint32_t>(status)));
     if (fpChannel && !isPending) {
       fpChannel->ForcePending(false);
     }
   }
   return mListener->OnStopRequest(request, aContext, status);
 }
 
 
@@ -181,23 +183,23 @@ nsHTTPCompressConv::BrotliHandler(nsIInp
     return self->mBrotli->mStatus;
   }
 
   do {
     outSize = kOutSize;
     outPtr = outBuffer.get();
 
     // brotli api is documented in brotli/dec/decode.h and brotli/dec/decode.c
-    LOG(("nsHttpCompresssConv %p brotlihandler decompress %d\n", self, avail));
+    LOG(("nsHttpCompresssConv %p brotlihandler decompress %" PRIuSIZE "\n", self, avail));
     res = ::BrotliDecompressStream(
       &avail, reinterpret_cast<const unsigned char **>(&dataIn),
       &outSize, &outPtr, &self->mBrotli->mTotalOut, &self->mBrotli->mState);
     outSize = kOutSize - outSize;
-    LOG(("nsHttpCompresssConv %p brotlihandler decompress rv=%x out=%d\n",
-         self, res, outSize));
+    LOG(("nsHttpCompresssConv %p brotlihandler decompress rv=%" PRIx32 " out=%" PRIuSIZE "\n",
+         self, static_cast<uint32_t>(res), outSize));
 
     if (res == BROTLI_RESULT_ERROR) {
       LOG(("nsHttpCompressConv %p marking invalid encoding", self));
       self->mBrotli->mStatus = NS_ERROR_INVALID_CONTENT_ENCODING;
       return self->mBrotli->mStatus;
     }
 
     // in 'the current implementation' brotli must consume everything before
@@ -211,17 +213,17 @@ nsHTTPCompressConv::BrotliHandler(nsIInp
       }
     }
     if (outSize > 0) {
       nsresult rv = self->do_OnDataAvailable(self->mBrotli->mRequest,
                                              self->mBrotli->mContext,
                                              self->mBrotli->mSourceOffset,
                                              reinterpret_cast<const char *>(outBuffer.get()),
                                              outSize);
-      LOG(("nsHttpCompressConv %p BrotliHandler ODA rv=%x", self, rv));
+      LOG(("nsHttpCompressConv %p BrotliHandler ODA rv=%" PRIx32, self, static_cast<uint32_t>(rv)));
       if (NS_FAILED(rv)) {
         self->mBrotli->mStatus = rv;
         return self->mBrotli->mStatus;
       }
     }
 
     if (res == BROTLI_RESULT_SUCCESS ||
         res == BROTLI_RESULT_NEEDS_MORE_INPUT) {
--- a/netwerk/wifi/nsWifiMonitor.cpp
+++ b/netwerk/wifi/nsWifiMonitor.cpp
@@ -11,16 +11,17 @@
 #include "nsXPCOMCID.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsWifiMonitor.h"
 #include "nsWifiAccessPoint.h"
 
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Services.h"
 
 using namespace mozilla;
 
 LazyLogModule gWifiMonitorLog("WifiMonitor");
 
 NS_IMPL_ISUPPORTS(nsWifiMonitor,
                   nsIRunnable,
@@ -151,17 +152,17 @@ NS_IMETHODIMP nsPassErrorToWifiListeners
   return NS_OK;
 }
 
 NS_IMETHODIMP nsWifiMonitor::Run()
 {
   LOG(("@@@@@ wifi monitor run called\n"));
 
   nsresult rv = DoScan();
-  LOG(("@@@@@ wifi monitor run::doscan complete %x\n", rv));
+  LOG(("@@@@@ wifi monitor run::doscan complete %" PRIx32 "\n", static_cast<uint32_t>(rv)));
 
   nsAutoPtr<WifiListenerArray> currentListeners;
   bool doError = false;
 
   {
       ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       if (mKeepGoing && NS_FAILED(rv)) {
           doError = true;
--- a/parser/htmlparser/nsExpatDriver.cpp
+++ b/parser/htmlparser/nsExpatDriver.cpp
@@ -25,16 +25,17 @@
 #include "nsContentPolicyUtils.h"
 #include "nsError.h"
 #include "nsXPCOMCIDInternal.h"
 #include "nsUnicharInputStream.h"
 #include "nsContentUtils.h"
 #include "nsNullPrincipal.h"
 
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 
 using mozilla::fallible;
 using mozilla::LogLevel;
 
 #define kExpatSeparatorChar 0xFFFF
 
 static const char16_t kUTF16[] = { 'U', 'T', 'F', '-', '1', '6', '\0' };
 
@@ -1053,17 +1054,17 @@ nsExpatDriver::ConsumeToken(nsScanner& a
   start.advance(mExpatBuffered);
 
   // This is the end of the last buffer (at this point, more data could come in
   // later).
   nsScannerIterator end;
   aScanner.EndReading(end);
 
   MOZ_LOG(gExpatDriverLog, LogLevel::Debug,
-         ("Remaining in expat's buffer: %i, remaining in scanner: %i.",
+         ("Remaining in expat's buffer: %i, remaining in scanner: %" PRIuSIZE ".",
           mExpatBuffered, Distance(start, end)));
 
   // We want to call Expat if we have more buffers, or if we know there won't
   // be more buffers (and so we want to flush the remaining data), or if we're
   // currently blocked and there's data in Expat's buffer.
   while (start != end || (mIsFinalChunk && !mMadeFinalCallToExpat) ||
          (BlockedOrInterrupted() && mExpatBuffered > 0)) {
     bool noMoreBuffers = start == end && mIsFinalChunk;
@@ -1201,17 +1202,17 @@ nsExpatDriver::ConsumeToken(nsScanner& a
     // to compensate.
     aScanner.EndReading(end);
   }
 
   aScanner.SetPosition(currentExpatPosition, true);
   aScanner.Mark();
 
   MOZ_LOG(gExpatDriverLog, LogLevel::Debug,
-         ("Remaining in expat's buffer: %i, remaining in scanner: %i.",
+         ("Remaining in expat's buffer: %i, remaining in scanner: %" PRIuSIZE ".",
           mExpatBuffered, Distance(currentExpatPosition, end)));
 
   return NS_SUCCEEDED(mInternalState) ? NS_ERROR_HTMLPARSER_EOF : NS_OK;
 }
 
 NS_IMETHODIMP
 nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
                               nsITokenizer* aTokenizer,
--- a/rdf/base/nsRDFService.cpp
+++ b/rdf/base/nsRDFService.cpp
@@ -52,16 +52,17 @@
 #include "plstr.h"
 #include "mozilla/Logging.h"
 #include "prprf.h"
 #include "prmem.h"
 #include "rdf.h"
 #include "nsCRT.h"
 #include "nsCRTGlue.h"
 #include "mozilla/HashFunctions.h"
+#include "mozilla/IntegerPrintfMacros.h"
 
 using namespace mozilla;
 
 ////////////////////////////////////////////////////////////////////////
 
 static NS_DEFINE_CID(kRDFXMLDataSourceCID,    NS_RDFXMLDATASOURCE_CID);
 static NS_DEFINE_CID(kRDFDefaultResourceCID,  NS_RDFDEFAULTRESOURCE_CID);
 
@@ -1380,17 +1381,17 @@ RDFServiceImpl::RegisterLiteral(nsIRDFLi
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateLiteral() call
     // made will be owned by the callee.
     entry->mLiteral = aLiteral;
     entry->mKey = value;
 
     MOZ_LOG(gLog, LogLevel::Debug,
            ("rdfserv   register-literal [%p] %s",
-            aLiteral, (const char16_t*) value));
+            aLiteral, NS_ConvertUTF16toUTF8(value).get()));
 
     return NS_OK;
 }
 
 
 nsresult
 RDFServiceImpl::UnregisterLiteral(nsIRDFLiteral* aLiteral)
 {
@@ -1400,17 +1401,17 @@ RDFServiceImpl::UnregisterLiteral(nsIRDF
     NS_ASSERTION(mLiterals.Search(value), "literal was never registered");
 
     mLiterals.Remove(value);
 
     // N.B. that we _don't_ release the literal: we only held a weak
     // reference to it in the hashtable.
     MOZ_LOG(gLog, LogLevel::Debug,
            ("rdfserv unregister-literal [%p] %s",
-            aLiteral, (const char16_t*) value));
+            aLiteral, NS_ConvertUTF16toUTF8(value).get()));
 
     return NS_OK;
 }
 
 //----------------------------------------------------------------------
 
 nsresult
 RDFServiceImpl::RegisterInt(nsIRDFInt* aInt)
@@ -1479,17 +1480,17 @@ RDFServiceImpl::RegisterDate(nsIRDFDate*
     // N.B., we only hold a weak reference to the literal: that
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateDate() call
     // made will be owned by the callee.
     entry->mDate = aDate;
     entry->mKey = value;
 
     MOZ_LOG(gLog, LogLevel::Debug,
-           ("rdfserv   register-date [%p] %ld",
+           ("rdfserv   register-date [%p] %" PRId64,
             aDate, value));
 
     return NS_OK;
 }
 
 
 nsresult
 RDFServiceImpl::UnregisterDate(nsIRDFDate* aDate)
@@ -1499,17 +1500,17 @@ RDFServiceImpl::UnregisterDate(nsIRDFDat
 
     NS_ASSERTION(mDates.Search(&value), "date was never registered");
 
     mDates.Remove(&value);
 
     // N.B. that we _don't_ release the literal: we only held a weak
     // reference to it in the hashtable.
     MOZ_LOG(gLog, LogLevel::Debug,
-           ("rdfserv unregister-date [%p] %ld",
+           ("rdfserv unregister-date [%p] %" PRId64,
             aDate, value));
 
     return NS_OK;
 }
 
 nsresult
 RDFServiceImpl::RegisterBlob(BlobImpl *aBlob)
 {
--- a/security/certverifier/CertVerifier.cpp
+++ b/security/certverifier/CertVerifier.cpp
@@ -13,16 +13,17 @@
 #include "CTLogVerifier.h"
 #include "ExtendedValidation.h"
 #include "MultiLogCTVerifier.h"
 #include "NSSCertDBTrustDomain.h"
 #include "NSSErrorsService.h"
 #include "cert.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Casting.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "nsNSSComponent.h"
 #include "nsServiceManagerUtils.h"
 #include "pk11pub.h"
 #include "pkix/pkix.h"
 #include "pkix/pkixnss.h"
 #include "secmod.h"
 
 using namespace mozilla::ct;
@@ -304,17 +305,18 @@ CertVerifier::VerifyCertificateTranspare
   }
 
   CTVerifyResult result;
   rv = mCTVerifier->Verify(endEntityDER, issuerPublicKeyDER,
                            embeddedSCTs, sctsFromOCSP, sctsFromTLS, time,
                            result);
   if (rv != Success) {
     MOZ_LOG(gCertVerifierLog, LogLevel::Debug,
-            ("SCT verification failed with fatal error %i\n", rv));
+            ("SCT verification failed with fatal error %" PRId32 "\n",
+             static_cast<uint32_t>(rv)));
     return rv;
   }
 
   if (MOZ_LOG_TEST(gCertVerifierLog, LogLevel::Debug)) {
     size_t validCount = 0;
     size_t unknownLogCount = 0;
     size_t disqualifiedLogCount = 0;
     size_t invalidSignatureCount = 0;
@@ -377,17 +379,18 @@ CertVerifier::VerifyCertificateTranspare
   }
 
   CTPolicyEnforcer ctPolicyEnforcer;
   CTPolicyCompliance ctPolicyCompliance;
   rv = ctPolicyEnforcer.CheckCompliance(result.verifiedScts, lifetimeInMonths,
                                         dependentOperators, ctPolicyCompliance);
   if (rv != Success) {
     MOZ_LOG(gCertVerifierLog, LogLevel::Debug,
-            ("CT policy check failed with fatal error %i\n", rv));
+            ("CT policy check failed with fatal error %" PRIu32 "\n",
+             static_cast<uint32_t>(rv)));
     return rv;
   }
 
   if (ctInfo) {
     ctInfo->verifyResult = Move(result);
     ctInfo->policyCompliance = ctPolicyCompliance;
   }
   return Success;
@@ -608,17 +611,17 @@ CertVerifier::VerifyCert(CERTCertificate
             break;
           }
           if (isBuiltInRoot) {
             rv = Result::ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED;
           }
         }
         if (rv == Success) {
           MOZ_LOG(gCertVerifierLog, LogLevel::Debug,
-                  ("cert is EV with status %i\n", sha1ModeResults[i]));
+                  ("cert is EV with status %i\n", static_cast<int>(sha1ModeResults[i])));
           if (evOidPolicy) {
             *evOidPolicy = evPolicyOidTag;
           }
           if (sha1ModeResult) {
             *sha1ModeResult = sha1ModeResults[i];
           }
           rv = VerifyCertificateTransparencyPolicy(trustDomain, builtChain,
                                                    sctsFromTLSInput, time,
--- a/security/certverifier/NSSCertDBTrustDomain.cpp
+++ b/security/certverifier/NSSCertDBTrustDomain.cpp
@@ -432,17 +432,17 @@ NSSCertDBTrustDomain::CheckRevocation(En
              ("NSSCertDBTrustDomain: cached OCSP response: revoked"));
       return Result::ERROR_REVOKED_CERTIFICATE;
     }
     // The cached response may indicate an unknown certificate or it may be
     // expired. Don't return with either of these statuses yet - we may be
     // able to fetch a more recent one.
     MOZ_LOG(gCertVerifierLog, LogLevel::Debug,
            ("NSSCertDBTrustDomain: cached OCSP response: error %d",
-           cachedResponseResult));
+            static_cast<int>(cachedResponseResult)));
     // When a good cached response has expired, it is more convenient
     // to convert that to an error code and just deal with
     // cachedResponseResult from here on out.
     if (cachedResponseResult == Success && cachedResponseValidThrough < time) {
       cachedResponseResult = Result::ERROR_OCSP_OLD_RESPONSE;
     }
     // We may have a cached indication of server failure. Ignore it if
     // it has expired.
--- a/security/manager/ssl/CertBlocklist.cpp
+++ b/security/manager/ssl/CertBlocklist.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CertBlocklist.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Base64.h"
 #include "mozilla/Casting.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Unused.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsCRTGlue.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsICryptoHash.h"
 #include "nsIFileStreams.h"
@@ -633,17 +634,17 @@ CertBlocklist::IsBlocklistFresh(bool* _r
   MOZ_LOG(gCertBlockPRLog, LogLevel::Warning,
           ("CertBlocklist::IsBlocklistFresh using AMO? %i lastUpdate is %i",
            sUseAMO, lastUpdate));
 
   if (now > lastUpdate) {
     int64_t interval = now - lastUpdate;
     MOZ_LOG(gCertBlockPRLog, LogLevel::Warning,
            ("CertBlocklist::IsBlocklistFresh we're after the last BlocklistUpdate "
-            "interval is %i, staleness %u", interval, sMaxStaleness));
+            "interval is %" PRId64 ", staleness %u", interval, sMaxStaleness));
     *_retval = sMaxStaleness > interval;
   }
   MOZ_LOG(gCertBlockPRLog, LogLevel::Warning,
          ("CertBlocklist::IsBlocklistFresh ? %s", *_retval ? "true" : "false"));
   return NS_OK;
 }
 
 
--- a/security/manager/ssl/RootCertificateTelemetryUtils.cpp
+++ b/security/manager/ssl/RootCertificateTelemetryUtils.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "RootCertificateTelemetryUtils.h"
 
 #include "mozilla/Logging.h"
 #include "RootHashes.inc" // Note: Generated by genRootCAHashes.js
 #include "ScopedNSSTypes.h"
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/SizePrintfMacros.h"
 
 namespace mozilla { namespace psm {
 
 mozilla::LazyLogModule gPublicKeyPinningTelemetryLog("PublicKeyPinningTelemetryService");
 
 // Used in the BinarySearch method, this does a memcmp between the pointer
 // provided to its construtor and whatever the binary search is looking for.
 //
@@ -49,26 +50,26 @@ RootCABinNumber(const SECItem* cert)
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return ROOT_CERTIFICATE_HASH_FAILURE;
   }
 
   // Compare against list of stored hashes
   size_t idx;
 
   MOZ_LOG(gPublicKeyPinningTelemetryLog, LogLevel::Debug,
-           ("pkpinTelem: First bytes %02hx %02hx %02hx %02hx\n",
+           ("pkpinTelem: First bytes %02x %02x %02x %02x\n",
             digest.get().data[0], digest.get().data[1], digest.get().data[2], digest.get().data[3]));
 
   if (mozilla::BinarySearchIf(ROOT_TABLE, 0, ArrayLength(ROOT_TABLE),
         BinaryHashSearchArrayComparator(static_cast<uint8_t*>(digest.get().data),
                                         digest.get().len),
         &idx)) {
 
     MOZ_LOG(gPublicKeyPinningTelemetryLog, LogLevel::Debug,
-          ("pkpinTelem: Telemetry index was %lu, bin is %d\n",
+          ("pkpinTelem: Telemetry index was %" PRIuSIZE ", bin is %d\n",
            idx, ROOT_TABLE[idx].binNumber));
     return (int32_t) ROOT_TABLE[idx].binNumber;
   }
 
   // Didn't match.
   return ROOT_CERTIFICATE_UNKNOWN;
 }
 
--- a/security/manager/ssl/nsNSSCallbacks.cpp
+++ b/security/manager/ssl/nsNSSCallbacks.cpp
@@ -620,17 +620,18 @@ nsHTTPListener::OnStreamComplete(nsIStre
   nsCOMPtr<nsIRequest> req;
   nsCOMPtr<nsIHttpChannel> hchan;
 
   nsresult rv = aLoader->GetRequest(getter_AddRefs(req));
   
   if (NS_FAILED(aStatus))
   {
     MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
-           ("nsHTTPListener::OnStreamComplete status failed %d", aStatus));
+           ("nsHTTPListener::OnStreamComplete status failed %" PRIu32,
+            static_cast<uint32_t>(aStatus)));
   }
 
   if (NS_SUCCEEDED(rv))
     hchan = do_QueryInterface(req, &rv);
 
   if (NS_SUCCEEDED(rv))
   {
     rv = hchan->GetRequestSucceeded(&mHttpRequestSucceeded);
--- a/security/manager/ssl/nsSecureBrowserUIImpl.cpp
+++ b/security/manager/ssl/nsSecureBrowserUIImpl.cpp
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsSecureBrowserUIImpl.h"
 
 #include "imgIRequest.h"
 #include "mozilla/Assertions.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 #include "nsCURILoader.h"
 #include "nsIAssociatedContentSecurity.h"
 #include "nsIChannel.h"
 #include "nsIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocument.h"
@@ -292,18 +293,18 @@ static uint32_t GetSecurityStateFromSecu
                                          (nsISupports *)info));
     return nsIWebProgressListener::STATE_IS_INSECURE;
   }
   MOZ_LOG(gSecureDocLog, LogLevel::Debug, ("SecureUI: GetSecurityState: - info is %p\n", 
                                        (nsISupports *)info));
   
   res = psmInfo->GetSecurityState(&securityState);
   if (NS_FAILED(res)) {
-    MOZ_LOG(gSecureDocLog, LogLevel::Debug, ("SecureUI: GetSecurityState: - GetSecurityState failed: %d\n",
-                                         res));
+    MOZ_LOG(gSecureDocLog, LogLevel::Debug, ("SecureUI: GetSecurityState: - GetSecurityState failed: %" PRIu32 "\n",
+                                             static_cast<uint32_t>(res)));
     securityState = nsIWebProgressListener::STATE_IS_BROKEN;
   }
 
   if (securityState != nsIWebProgressListener::STATE_IS_INSECURE) {
     // A secure connection does not yield a secure per-uri channel if the
     // scheme is plain http.
 
     nsCOMPtr<nsIURI> uri;
--- a/security/manager/ssl/nsSiteSecurityService.cpp
+++ b/security/manager/ssl/nsSiteSecurityService.cpp
@@ -736,17 +736,17 @@ ParseSSSHeaders(uint32_t aType,
         }
       }
 
       if (PR_sscanf(directive->mValue.get(), "%llu", &maxAge) != 1) {
         SSSLOG(("SSS: could not parse delta-seconds"));
         return nsISiteSecurityService::ERROR_INVALID_MAX_AGE;
       }
 
-      SSSLOG(("SSS: parsed delta-seconds: %llu", maxAge));
+      SSSLOG(("SSS: parsed delta-seconds: %" PRIu64, maxAge));
     } else if (directive->mName.Length() == include_subd_var.Length() &&
                directive->mName.EqualsIgnoreCase(include_subd_var.get(),
                                                  include_subd_var.Length())) {
       if (foundIncludeSubdomains) {
         SSSLOG(("SSS: found two includeSubdomains directives"));
         return nsISiteSecurityService::ERROR_MULTIPLE_INCLUDE_SUBDOMAINS;
       }
 
@@ -934,17 +934,17 @@ nsSiteSecurityService::ProcessPKPHeader(
     }
     return NS_ERROR_FAILURE;
   }
 
   int64_t expireTime = ExpireTimeFromMaxAge(maxAge);
   RefPtr<SiteHPKPState> dynamicEntry =
     new SiteHPKPState(host, expireTime, SecurityPropertySet,
                       foundIncludeSubdomains, sha256keys);
-  SSSLOG(("SSS: about to set pins for  %s, expires=%ld now=%ld maxAge=%lu\n",
+  SSSLOG(("SSS: about to set pins for  %s, expires=%" PRId64 " now=%" PRId64 " maxAge=%" PRIu64 "\n",
            host.get(), expireTime, PR_Now() / PR_USEC_PER_MSEC, maxAge));
 
   rv = SetHPKPState(host.get(), *dynamicEntry, aFlags, false);
   if (NS_FAILED(rv)) {
     SSSLOG(("SSS: failed to set pins for %s\n", host.get()));
     if (aFailureResult) {
       *aFailureResult = nsISiteSecurityService::ERROR_COULD_NOT_SAVE_STATE;
     }
--- a/storage/mozStorageAsyncStatement.cpp
+++ b/storage/mozStorageAsyncStatement.cpp
@@ -121,17 +121,17 @@ AsyncStatement::initialize(Connection *a
   MOZ_ASSERT(!aDBConnection->isClosed(), "Database connection should be valid");
   MOZ_ASSERT(aNativeConnection, "No native connection given!");
 
   mDBConnection = aDBConnection;
   mNativeConnection = aNativeConnection;
   mSQLString = aSQLStatement;
 
   MOZ_LOG(gStorageLog, LogLevel::Debug, ("Inited async statement '%s' (0x%p)",
-                                      mSQLString.get()));
+                                      mSQLString.get(), this));
 
 #ifdef DEBUG
   // We want to try and test for LIKE and that consumers are using
   // escapeStringForLIKE instead of just trusting user input.  The idea to
   // check to see if they are binding a parameter after like instead of just
   // using a string.  We only do this in debug builds because it's expensive!
   const nsCaseInsensitiveCStringComparator c;
   nsACString::const_iterator start, end, e;
--- a/storage/mozStorageConnection.cpp
+++ b/storage/mozStorageConnection.cpp
@@ -216,17 +216,17 @@ int tracefunc (unsigned aReason, void *a
       break;
     }
     case SQLITE_TRACE_PROFILE: {
       // aX is pointer to a 64bit integer containing nanoseconds it took to
       // execute the last command.
       sqlite_int64 time = *(static_cast<sqlite_int64*>(aX)) / 1000000;
       if (time > 0) {
         MOZ_LOG(gStorageLog, LogLevel::Debug,
-          ("TRACE_TIME on %p: %dms", aClosure, time));
+          ("TRACE_TIME on %p: %lldms", aClosure, time));
       }
       break;
     }
   }
   return 0;
 }
 
 void
--- a/storage/mozStorageStatement.cpp
+++ b/storage/mozStorageStatement.cpp
@@ -395,17 +395,18 @@ Statement::internalFinalize(bool aDestru
     //
 
 #if 0
     // Deactivate the warning until we have fixed the exising culprit
     // (see bug 914070).
     NS_WARNING(msg);
 #endif // 0
 
-    MOZ_LOG(gStorageLog, LogLevel::Warning, (msg));
+    // Use %s so we aren't exposing random strings to printf interpolation.
+    MOZ_LOG(gStorageLog, LogLevel::Warning, ("%s", msg));
 
     ::mozilla::SmprintfFree(msg);
   }
 
 #endif
 
   mDBStatement = nullptr;
 
--- a/toolkit/components/downloads/ApplicationReputation.cpp
+++ b/toolkit/components/downloads/ApplicationReputation.cpp
@@ -28,16 +28,17 @@
 #include "nsIX509CertList.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/ErrorNames.h"
 #include "mozilla/LoadContext.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsDependentSubstring.h"
 #include "nsError.h"
@@ -766,17 +767,17 @@ PendingLookup::LookupNext()
     LOG(("PendingLookup::LookupNext: checking %s on allowlist", spec.get()));
     mAllowlistSpecs.RemoveElementAt(index);
     RefPtr<PendingDBLookup> lookup(new PendingDBLookup(this));
     return lookup->LookupSpec(spec, true);
   }
   // There are no more URIs to check against local list. If the file is
   // not eligible for remote lookup, bail.
   if (!IsBinaryFile()) {
-    LOG(("Not eligible for remote lookups [this=%x]", this));
+    LOG(("Not eligible for remote lookups [this=%p]", this));
     return OnComplete(false, NS_OK);
   }
   nsresult rv = SendRemoteQuery();
   if (NS_FAILED(rv)) {
     return OnComplete(false, rv);
   }
   return NS_OK;
 }
@@ -1069,17 +1070,17 @@ PendingLookup::OnComplete(bool shouldBlo
   if (mTimeoutTimer) {
     mTimeoutTimer->Cancel();
     mTimeoutTimer = nullptr;
   }
 
   Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SHOULD_BLOCK,
     shouldBlock);
   double t = (TimeStamp::Now() - mStartTime).ToMilliseconds();
-  LOG(("Application Reputation verdict is %lu, obtained in %f ms [this = %p]",
+  LOG(("Application Reputation verdict is %u, obtained in %f ms [this = %p]",
        verdict, t, this));
   if (shouldBlock) {
     LOG(("Application Reputation check failed, blocking bad binary [this = %p]",
         this));
   } else {
     LOG(("Application Reputation check passed [this = %p]", this));
   }
   nsresult res = mCallback->OnComplete(shouldBlock, rv, verdict);
@@ -1249,17 +1250,17 @@ PendingLookup::SendRemoteQueryInternal()
 
   // Serialize the protocol buffer to a string. This can only fail if we are
   // out of memory, or if the protocol buffer req is missing required fields
   // (only the URL for now).
   std::string serialized;
   if (!mRequest.SerializeToString(&serialized)) {
     return NS_ERROR_UNEXPECTED;
   }
-  LOG(("Serialized protocol buffer [this = %p]: (length=%d) %s", this,
+  LOG(("Serialized protocol buffer [this = %p]: (length=%" PRIuSIZE ") %s", this,
        serialized.length(), serialized.c_str()));
 
   // Set the input stream to the serialized protocol buffer
   nsCOMPtr<nsIStringInputStream> sstream =
     do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = sstream->SetData(serialized.c_str(), serialized.length());
--- a/toolkit/components/url-classifier/Classifier.cpp
+++ b/toolkit/components/url-classifier/Classifier.cpp
@@ -11,20 +11,22 @@
 #include "nsIRandomGenerator.h"
 #include "nsIInputStream.h"
 #include "nsISeekableStream.h"
 #include "nsIFile.h"
 #include "nsNetCID.h"
 #include "nsPrintfCString.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Telemetry.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 #include "mozilla/SyncRunnable.h"
 #include "mozilla/Base64.h"
 #include "mozilla/Unused.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/TypedEnumBits.h"
 #include "nsIUrlClassifierUtils.h"
 #include "nsUrlClassifierDBService.h"
 
 // MOZ_LOG=UrlClassifierDbService:5
 extern mozilla::LazyLogModule gUrlClassifierDbServiceLog;
 #define LOG(args) MOZ_LOG(gUrlClassifierDbServiceLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gUrlClassifierDbServiceLog, mozilla::LogLevel::Debug)
@@ -552,17 +554,17 @@ Classifier::ApplyUpdates(nsTArray<TableU
   {
     ScopedUpdatesClearer scopedUpdatesClearer(aUpdates);
 
     LOG(("Backup before update."));
 
     rv = BackupTables();
     NS_ENSURE_SUCCESS(rv, rv);
 
-    LOG(("Applying %d table updates.", aUpdates->Length()));
+    LOG(("Applying %" PRIuSIZE " table updates.", aUpdates->Length()));
 
     for (uint32_t i = 0; i < aUpdates->Length(); i++) {
       // Previous UpdateHashStore() may have consumed this update..
       if ((*aUpdates)[i]) {
         // Run all updates for one table
         nsCString updateTable(aUpdates->ElementAt(i)->TableName());
 
         if (TableUpdate::Cast<TableUpdateV2>((*aUpdates)[i])) {
@@ -612,17 +614,17 @@ Classifier::ApplyUpdates(nsTArray<TableU
   }
 
   return NS_OK;
 }
 
 nsresult
 Classifier::ApplyFullHashes(nsTArray<TableUpdate*>* aUpdates)
 {
-  LOG(("Applying %d table gethashes.", aUpdates->Length()));
+  LOG(("Applying %" PRIuSIZE " table gethashes.", aUpdates->Length()));
 
   ScopedUpdatesClearer scopedUpdatesClearer(aUpdates);
   for (uint32_t i = 0; i < aUpdates->Length(); i++) {
     TableUpdate *update = aUpdates->ElementAt(i);
 
     nsresult rv = UpdateCache(update);
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -639,17 +641,17 @@ Classifier::GetLastUpdateTime(const nsAC
   bool found = mTableFreshness.Get(aTableName, &age);
   return found ? (age * PR_MSEC_PER_SEC) : 0;
 }
 
 void
 Classifier::SetLastUpdateTime(const nsACString &aTable,
                               uint64_t updateTime)
 {
-  LOG(("Marking table %s as last updated on %u",
+  LOG(("Marking table %s as last updated on %" PRIu64,
        PromiseFlatCString(aTable).get(), updateTime));
   mTableFreshness.Put(aTable, updateTime / PR_MSEC_PER_SEC);
 }
 
 void
 Classifier::DropStores()
 {
   for (uint32_t i = 0; i < mLookupCaches.Length(); i++) {
@@ -999,40 +1001,40 @@ Classifier::UpdateHashStore(nsTArray<Tab
     NS_ENSURE_SUCCESS(rv, rv);
 
     applied++;
 
     auto updateV2 = TableUpdate::Cast<TableUpdateV2>(update);
     if (updateV2) {
       LOG(("Applied update to table %s:", store.TableName().get()));
       LOG(("  %d add chunks", updateV2->AddChunks().Length()));
-      LOG(("  %d add prefixes", updateV2->AddPrefixes().Length()));
-      LOG(("  %d add completions", updateV2->AddCompletes().Length()));
+      LOG(("  %" PRIuSIZE " add prefixes", updateV2->AddPrefixes().Length()));
+      LOG(("  %" PRIuSIZE " add completions", updateV2->AddCompletes().Length()));
       LOG(("  %d sub chunks", updateV2->SubChunks().Length()));
-      LOG(("  %d sub prefixes", updateV2->SubPrefixes().Length()));
-      LOG(("  %d sub completions", updateV2->SubCompletes().Length()));
+      LOG(("  %" PRIuSIZE " sub prefixes", updateV2->SubPrefixes().Length()));
+      LOG(("  %" PRIuSIZE " sub completions", updateV2->SubCompletes().Length()));
       LOG(("  %d add expirations", updateV2->AddExpirations().Length()));
       LOG(("  %d sub expirations", updateV2->SubExpirations().Length()));
     }
 
     aUpdates->ElementAt(i) = nullptr;
   }
 
   LOG(("Applied %d update(s) to %s.", applied, store.TableName().get()));
 
   rv = store.Rebuild();
   NS_ENSURE_SUCCESS(rv, rv);
 
   LOG(("Table %s now has:", store.TableName().get()));
   LOG(("  %d add chunks", store.AddChunks().Length()));
-  LOG(("  %d add prefixes", store.AddPrefixes().Length()));
-  LOG(("  %d add completions", store.AddCompletes().Length()));
+  LOG(("  %" PRIuSIZE " add prefixes", store.AddPrefixes().Length()));
+  LOG(("  %" PRIuSIZE " add completions", store.AddCompletes().Length()));
   LOG(("  %d sub chunks", store.SubChunks().Length()));
-  LOG(("  %d sub prefixes", store.SubPrefixes().Length()));
-  LOG(("  %d sub completions", store.SubCompletes().Length()));
+  LOG(("  %" PRIuSIZE " sub prefixes", store.SubPrefixes().Length()));
+  LOG(("  %" PRIuSIZE " sub completions", store.SubCompletes().Length()));
 
   rv = store.WriteFile();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // At this point the store is updated and written out to disk, but
   // the data is still in memory.  Build our quick-lookup table here.
   rv = lookupCache->Build(store.AddPrefixes(), store.AddCompletes());
   NS_ENSURE_SUCCESS(rv, rv);
--- a/toolkit/components/url-classifier/HashStore.cpp
+++ b/toolkit/components/url-classifier/HashStore.cpp
@@ -32,16 +32,18 @@
 #include "HashStore.h"
 #include "nsICryptoHash.h"
 #include "nsISeekableStream.h"
 #include "nsIStreamConverterService.h"
 #include "nsNetUtil.h"
 #include "nsCheckSummedOutputStream.h"
 #include "prio.h"
 #include "mozilla/Logging.h"
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "zlib.h"
 #include "Classifier.h"
 #include "nsUrlClassifierDBService.h"
 
 // Main store for SafeBrowsing protocol data. We store
 // known add/sub chunks, prefixes and completions in memory
 // during an update, and serialize to disk.
 // We do not store the add prefixes, those are retrieved by
@@ -181,17 +183,17 @@ TableUpdateV4::NewPrefixes(int32_t aSize
     }
 
     LOG(("* The last 10 (maximum) fixed-length prefixes: "));
     for (int i = std::max(0, numOfPrefixes - 10); i < numOfPrefixes; i++) {
       uint8_t* c = (uint8_t*)&p[i];
       LOG(("%.2X%.2X%.2X%.2X", c[0], c[1], c[2], c[3]));
     }
 
-    LOG(("---- %d fixed-length prefixes in total.", aPrefixes.size() / aSize));
+    LOG(("---- %" PRIuSIZE " fixed-length prefixes in total.", aPrefixes.size() / aSize));
   }
 
   PrefixStdString* prefix = new PrefixStdString(aPrefixes);
   mPrefixesMap.Put(aSize, prefix);
 }
 
 void
 TableUpdateV4::NewRemovalIndices(const uint32_t* aIndices, size_t aNumOfIndices)
@@ -696,17 +698,17 @@ nsresult DeflateWriteTArray(nsIOutputStr
 
   int zerr = compress(reinterpret_cast<Bytef*>(outBuff.Elements()),
                       &outsize,
                       reinterpret_cast<const Bytef*>(aIn.Elements()),
                       insize);
   if (zerr != Z_OK) {
     return NS_ERROR_FAILURE;
   }
-  LOG(("DeflateWriteTArray: %d in %d out", insize, outsize));
+  LOG(("DeflateWriteTArray: %lu in %lu out", insize, outsize));
 
   outBuff.TruncateLength(outsize);
 
   // Length of compressed data stream
   uint32_t dataLen = outBuff.Length();
   uint32_t written;
   nsresult rv = aStream->Write(reinterpret_cast<char*>(&dataLen), sizeof(dataLen), &written);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -748,17 +750,17 @@ nsresult InflateReadTArray(nsIInputStrea
 
   int zerr = uncompress(reinterpret_cast<Bytef*>(aOut->Elements()),
                         &outsize,
                         reinterpret_cast<const Bytef*>(inBuff.Elements()),
                         insize);
   if (zerr != Z_OK) {
     return NS_ERROR_FAILURE;
   }
-  LOG(("InflateReadTArray: %d in %d out", insize, outsize));
+  LOG(("InflateReadTArray: %lu in %lu out", insize, outsize));
 
   NS_ASSERTION(outsize == aExpectedSize * sizeof(T), "Decompression size mismatch");
 
   return NS_OK;
 }
 
 static nsresult
 ByteSliceWrite(nsIOutputStream* aOut, nsTArray<uint32_t>& aData)
@@ -1104,17 +1106,18 @@ RemoveDeadSubPrefixes(SubPrefixArray& aS
     // Keep the subprefix if the chunk it refers to is one
     // we haven't seen it yet.
     if (!hasChunk) {
       *subIter = sub;
       subIter++;
     }
   }
 
-  LOG(("Removed %u dead SubPrefix entries.", aSubs.end() - subIter));
+  LOG(("Removed %" PRId64 " dead SubPrefix entries.",
+       static_cast<int64_t>(aSubs.end() - subIter)));
   aSubs.TruncateLength(subIter - aSubs.begin());
 }
 
 #ifdef DEBUG
 template <class T>
 static void EnsureSorted(FallibleTArray<T>* aArray)
 {
   auto start = aArray->begin();
@@ -1168,17 +1171,17 @@ HashStore::ProcessSubs()
   return NS_OK;
 }
 
 nsresult
 HashStore::AugmentAdds(const nsTArray<uint32_t>& aPrefixes)
 {
   uint32_t cnt = aPrefixes.Length();
   if (cnt != mAddPrefixes.Length()) {
-    LOG(("Amount of prefixes in cache not consistent with store (%d vs %d)",
+    LOG(("Amount of prefixes in cache not consistent with store (%" PRIuSIZE " vs %" PRIuSIZE ")",
          aPrefixes.Length(), mAddPrefixes.Length()));
     return NS_ERROR_FAILURE;
   }
   for (uint32_t i = 0; i < cnt; i++) {
     mAddPrefixes[i].prefix.FromUint32(aPrefixes[i]);
   }
   return NS_OK;
 }
--- a/toolkit/components/url-classifier/ProtocolParser.cpp
+++ b/toolkit/components/url-classifier/ProtocolParser.cpp
@@ -11,16 +11,18 @@
 #include "prprf.h"
 
 #include "nsUrlClassifierDBService.h"
 #include "nsUrlClassifierUtils.h"
 #include "nsPrintfCString.h"
 #include "mozilla/Base64.h"
 #include "RiceDeltaDecoder.h"
 #include "mozilla/EndianUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/SizePrintfMacros.h"
 
 // MOZ_LOG=UrlClassifierProtocolParser:5
 mozilla::LazyLogModule gUrlClassifierProtocolParserLog("UrlClassifierProtocolParser");
 #define PARSER_LOG(args) MOZ_LOG(gUrlClassifierProtocolParserLog, mozilla::LogLevel::Debug, args)
 
 namespace mozilla {
 namespace safebrowsing {
 
@@ -930,17 +932,17 @@ ProtocolParserProtobuf::ProcessRawAdditi
   }
 
   auto prefixes = rawHashes.raw_hashes();
   if (4 == rawHashes.prefix_size()) {
     // Process fixed length prefixes separately.
     uint32_t* fixedLengthPrefixes = (uint32_t*)prefixes.c_str();
     size_t numOfFixedLengthPrefixes = prefixes.size() / 4;
     PARSER_LOG(("* Raw addition (4 bytes)"));
-    PARSER_LOG(("  - # of prefixes: %d", numOfFixedLengthPrefixes));
+    PARSER_LOG(("  - # of prefixes: %" PRIuSIZE, numOfFixedLengthPrefixes));
     PARSER_LOG(("  - Memory address: 0x%p", fixedLengthPrefixes));
   } else {
     // TODO: Process variable length prefixes including full hashes.
     // See Bug 1283009.
     PARSER_LOG((" Raw addition (%d bytes)", rawHashes.prefix_size()));
   }
 
   if (!rawHashes.mutable_raw_hashes()) {
@@ -984,17 +986,17 @@ DoRiceDeltaDecode(const RiceDeltaEncodin
   }
   if (aEncoding.num_entries() > 0 &&
       (!aEncoding.has_rice_parameter() || !aEncoding.has_encoded_data())) {
     PARSER_LOG(("Rice parameter or encoded data is missing."));
     return NS_ERROR_FAILURE;
   }
 
   PARSER_LOG(("* Encoding info:"));
-  PARSER_LOG(("  - First value: %d", aEncoding.first_value()));
+  PARSER_LOG(("  - First value: %" PRId64, aEncoding.first_value()));
   PARSER_LOG(("  - Num of entries: %d", aEncoding.num_entries()));
   PARSER_LOG(("  - Rice parameter: %d", aEncoding.rice_parameter()));
 
   // Set up the input buffer. Note that the bits should be read
   // from LSB to MSB so that we in-place reverse the bits before
   // feeding to the decoder.
   auto encoded = const_cast<RiceDeltaEncoding&>(aEncoding).mutable_encoded_data();
   RiceDeltaDecoder decoder((uint8_t*)encoded->c_str(), encoded->size());
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -31,16 +31,17 @@
 #include "nsXPCOMStrings.h"
 #include "nsProxyRelease.h"
 #include "nsString.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/ErrorNames.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Logging.h"
 #include "prnetdb.h"
 #include "Entries.h"
 #include "HashStore.h"
 #include "Classifier.h"
 #include "ProtocolParser.h"
@@ -206,17 +207,17 @@ nsUrlClassifierDBServiceWorker::DoLocalL
   if (!mClassifier) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // We ignore failures from Check because we'd rather return the
   // results that were found than fail.
   mClassifier->Check(spec, tables, gFreshnessGuarantee, *results);
 
-  LOG(("Found %d results.", results->Length()));
+  LOG(("Found %" PRIuSIZE " results.", results->Length()));
   return NS_OK;
 }
 
 static nsresult
 ProcessLookupResults(LookupResultArray* results, nsTArray<nsCString>& tables)
 {
   // Build the result array.
   for (uint32_t i = 0; i < results->Length(); i++) {
@@ -263,17 +264,17 @@ nsUrlClassifierDBServiceWorker::DoLookup
   }
 
   nsresult rv = DoLocalLookup(spec, tables, results);
   if (NS_FAILED(rv)) {
     c->LookupComplete(nullptr);
     return rv;
   }
 
-  LOG(("Found %d results.", results->Length()));
+  LOG(("Found %" PRIuSIZE " results.", results->Length()));
 
 
   if (LOG_ENABLED()) {
     PRIntervalTime clockEnd = PR_IntervalNow();
     LOG(("query took %dms\n",
          PR_IntervalToMilliseconds(clockEnd - clockStart)));
   }
 
@@ -645,17 +646,18 @@ nsUrlClassifierDBServiceWorker::FinishUp
     LOG(("Treating NS_ERROR_NOT_IMPLEMENTED a successful update "
          "but still mark it spoiled."));
     mUpdateObserver->UpdateSuccess(0);
     mClassifier->ResetTables(Classifier::Clear_Cache, mUpdateTables);
   } else {
     if (LOG_ENABLED()) {
       nsAutoCString errorName;
       mozilla::GetErrorName(mUpdateStatus, errorName);
-      LOG(("Notifying error: %s (%d)", errorName.get(), mUpdateStatus));
+      LOG(("Notifying error: %s (%" PRIu32 ")", errorName.get(),
+           static_cast<uint32_t>(mUpdateStatus)));
     }
 
     mUpdateObserver->UpdateError(mUpdateStatus);
     /*
      * mark the tables as spoiled(clear cache in LookupCache), we don't want to
      * block hosts longer than normal because our update failed
     */
     mClassifier->ResetTables(Classifier::Clear_Cache, mUpdateTables);
@@ -840,17 +842,17 @@ nsUrlClassifierDBServiceWorker::CacheCom
   mClassifier->ApplyFullHashes(&updates);
   mLastResults = *resultsPtr;
   return NS_OK;
 }
 
 nsresult
 nsUrlClassifierDBServiceWorker::CacheMisses(PrefixArray *results)
 {
-  LOG(("nsUrlClassifierDBServiceWorker::CacheMisses [%p] %d",
+  LOG(("nsUrlClassifierDBServiceWorker::CacheMisses [%p] %" PRIuSIZE,
        this, results->Length()));
 
   // Ownership is transferred in to us
   nsAutoPtr<PrefixArray> resultsPtr(results);
 
   for (uint32_t i = 0; i < resultsPtr->Length(); i++) {
     mMissCache.AppendElement(resultsPtr->ElementAt(i));
   }
@@ -1104,38 +1106,38 @@ nsUrlClassifierLookupCallback::HandleRes
   if (!mResults) {
     // No results, this URI is clean.
     LOG(("nsUrlClassifierLookupCallback::HandleResults [%p, no results]", this));
     return mCallback->HandleEvent(NS_LITERAL_CSTRING(""));
   }
   MOZ_ASSERT(mPendingCompletions == 0, "HandleResults() should never be "
              "called while there are pending completions");
 
-  LOG(("nsUrlClassifierLookupCallback::HandleResults [%p, %u results]",
+  LOG(("nsUrlClassifierLookupCallback::HandleResults [%p, %" PRIuSIZE " results]",
        this, mResults->Length()));
 
   nsTArray<nsCString> tables;
   // Build a stringified list of result tables.
   for (uint32_t i = 0; i < mResults->Length(); i++) {
     LookupResult& result = mResults->ElementAt(i);
 
     // Leave out results that weren't confirmed, as their existence on
     // the list can't be verified.  Also leave out randomly-generated
     // noise.
     if (result.mNoise) {
       LOG(("Skipping result %s from table %s (noise)",
            result.PartialHashHex().get(), result.mTableName.get()));
       continue;
     } else if (!result.Confirmed()) {
-      LOG(("Skipping result %X from table %s (not confirmed)",
+      LOG(("Skipping result %s from table %s (not confirmed)",
            result.PartialHashHex().get(), result.mTableName.get()));
       continue;
     }
 
-    LOG(("Confirmed result %X from table %s",
+    LOG(("Confirmed result %s from table %s",
          result.PartialHashHex().get(), result.mTableName.get()));
 
     if (tables.IndexOf(result.mTableName) == nsTArray<nsCString>::NoIndex) {
       tables.AppendElement(result.mTableName);
     }
   }
 
   // TODO: Bug 1333328, Refactor cache miss mechanism for v2.
--- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp
@@ -15,16 +15,17 @@
 #include "nsToolkitCompsCID.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsISeekableStream.h"
 #include "nsIBufferedStreams.h"
 #include "nsIFileStreams.h"
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Unused.h"
 #include <algorithm>
 
 using namespace mozilla;
 
@@ -131,17 +132,17 @@ nsUrlClassifierPrefixSet::MakePrefixSet(
   }
 
   mIndexDeltas.LastElement().Compact();
   mIndexDeltas.Compact();
   mIndexPrefixes.Compact();
 
   LOG(("Total number of indices: %d", aLength));
   LOG(("Total number of deltas: %d", totalDeltas));
-  LOG(("Total number of delta chunks: %d", mIndexDeltas.Length()));
+  LOG(("Total number of delta chunks: %" PRIuSIZE, mIndexDeltas.Length()));
 
   return NS_OK;
 }
 
 nsresult
 nsUrlClassifierPrefixSet::GetPrefixesNative(FallibleTArray<uint32_t>& outArray)
 {
   MutexAutoLock lock(mLock);
--- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
@@ -52,19 +52,20 @@ static void TrimAndLog(const char* aFmt,
     do_GetService("@mozilla.org/toolkit/URLFormatterService;1");
 
   nsString trimmed;
   nsresult rv = urlFormatter->TrimSensitiveURLs(raw, trimmed);
   if (NS_FAILED(rv)) {
     trimmed = EmptyString();
   }
 
+  // Use %s so we aren't exposing random strings to printf interpolation.
   MOZ_LOG(gUrlClassifierStreamUpdaterLog,
           mozilla::LogLevel::Debug,
-          (NS_ConvertUTF16toUTF8(trimmed).get()));
+          ("%s", NS_ConvertUTF16toUTF8(trimmed).get()));
 }
 
 // This class does absolutely nothing, except pass requests onto the DBService.
 
 ///////////////////////////////////////////////////////////////////////////////
 // nsIUrlClassiferStreamUpdater implementation
 // Handles creating/running the stream listener
 
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nspr.h"
 #include "mozilla/Logging.h"
+#include "mozilla/IntegerPrintfMacros.h"
 
 #include "nsDocLoader.h"
 #include "nsCURILoader.h"
 #include "nsNetUtil.h"
 #include "nsIHttpChannel.h"
 #include "nsIWebProgressListener2.h"
 
 #include "nsIServiceManager.h"
@@ -132,17 +133,17 @@ nsDocLoader::SetDocLoaderParent(nsDocLoa
 
 nsresult
 nsDocLoader::Init()
 {
   nsresult rv = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), this);
   if (NS_FAILED(rv)) return rv;
 
   MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
-         ("DocLoader:%p: load group %x.\n", this, mLoadGroup.get()));
+         ("DocLoader:%p: load group %p.\n", this, mLoadGroup.get()));
 
   return NS_OK;
 }
 
 nsDocLoader::~nsDocLoader()
 {
 		/*
 			|ClearWeakReferences()| here is intended to prevent people holding weak references
@@ -476,19 +477,19 @@ nsDocLoader::OnStopRequest(nsIRequest *a
     nsAutoCString name;
     aRequest->GetName(name);
 
     uint32_t count = 0;
     if (mLoadGroup)
       mLoadGroup->GetActiveCount(&count);
 
     MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
-           ("DocLoader:%p: OnStopRequest[%p](%s) status=%x mIsLoadingDocument=%s, %u active URLs",
+           ("DocLoader:%p: OnStopRequest[%p](%s) status=%" PRIx32 " mIsLoadingDocument=%s, %u active URLs",
            this, aRequest, name.get(),
-           aStatus, (mIsLoadingDocument ? "true" : "false"),
+            static_cast<uint32_t>(aStatus), (mIsLoadingDocument ? "true" : "false"),
            count));
   }
 
   bool bFireTransferring = false;
 
   //
   // Set the Maximum progress to the same value as the current progress.
   // Since the URI has finished loading, all the data is there.  Also,
@@ -786,18 +787,18 @@ void nsDocLoader::doStartURLLoad(nsIRequ
 void nsDocLoader::doStopURLLoad(nsIRequest *request, nsresult aStatus)
 {
 #if defined(DEBUG)
   nsAutoCString buffer;
 
   GetURIStringFromRequest(request, buffer);
     MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
           ("DocLoader:%p: ++ Firing OnStateChange for end url load (...)."
-           "\tURI: %s status=%x\n",
-            this, buffer.get(), aStatus));
+           "\tURI: %s status=%" PRIx32 "\n",
+           this, buffer.get(), static_cast<uint32_t>(aStatus)));
 #endif /* DEBUG */
 
   FireOnStateChange(this,
                     request,
                     nsIWebProgressListener::STATE_STOP |
                     nsIWebProgressListener::STATE_IS_REQUEST,
                     aStatus);
 
@@ -815,18 +816,18 @@ void nsDocLoader::doStopDocumentLoad(nsI
                                          nsresult aStatus)
 {
 #if defined(DEBUG)
   nsAutoCString buffer;
 
   GetURIStringFromRequest(request, buffer);
   MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
          ("DocLoader:%p: ++ Firing OnStateChange for end document load (...)."
-         "\tURI: %s Status=%x\n",
-          this, buffer.get(), aStatus));
+         "\tURI: %s Status=%" PRIx32 "\n",
+          this, buffer.get(), static_cast<uint32_t>(aStatus)));
 #endif /* DEBUG */
 
   // Firing STATE_STOP|STATE_IS_DOCUMENT will fire onload handlers.
   // Grab our parent chain before doing that so we can still dispatch
   // STATE_STOP|STATE_IS_WINDW_STATE_IS_NETWORK to them all, even if
   // the onload handlers rearrange the docshell tree.
   WebProgressList list;
   GatherAncestorWebProgresses(list);
@@ -1176,17 +1177,18 @@ void nsDocLoader::FireOnProgressChange(n
     aMaxTotalProgress = mMaxTotalProgress;
   }
 
 #if defined(DEBUG)
   nsAutoCString buffer;
 
   GetURIStringFromRequest(request, buffer);
   MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
-         ("DocLoader:%p: Progress (%s): curSelf: %d maxSelf: %d curTotal: %d maxTotal %d\n",
+         ("DocLoader:%p: Progress (%s): curSelf: %" PRId64 " maxSelf: %"
+          PRId64 " curTotal: %" PRId64 " maxTotal %" PRId64 "\n",
           this, buffer.get(), aProgress, aProgressMax, aTotalProgress, aMaxTotalProgress));
 #endif /* DEBUG */
 
   NOTIFY_LISTENERS(nsIWebProgress::NOTIFY_PROGRESS,
     // XXX truncates 64-bit to 32-bit
     listener->OnProgressChange(aLoadInitiator,request,
                                int32_t(aProgress), int32_t(aProgressMax),
                                int32_t(aTotalProgress), int32_t(aMaxTotalProgress));
--- a/uriloader/base/nsURILoader.cpp
+++ b/uriloader/base/nsURILoader.cpp
@@ -43,16 +43,17 @@
 
 #include "nsIMIMEHeaderParam.h"
 #include "nsNetCID.h"
 
 #include "nsMimeTypes.h"
 
 #include "nsDocLoader.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "nsContentUtils.h"
 
 mozilla::LazyLogModule nsURILoader::mLog("URILoader");
 
 #define LOG(args) MOZ_LOG(nsURILoader::mLog, mozilla::LogLevel::Debug, args)
 #define LOG_ERROR(args) MOZ_LOG(nsURILoader::mLog, mozilla::LogLevel::Error, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(nsURILoader::mLog, mozilla::LogLevel::Debug)
@@ -260,55 +261,56 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStar
   nsresult status;
 
   rv = request->GetStatus(&status);
   
   NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to get request status!");
   if (NS_FAILED(rv)) return rv;
 
   if (NS_FAILED(status)) {
-    LOG_ERROR(("  Request failed, status: 0x%08X", rv));
+    LOG_ERROR(("  Request failed, status: 0x%08" PRIX32, static_cast<uint32_t>(rv)));
   
     //
     // The transaction has already reported an error - so it will be torn
     // down. Therefore, it is not necessary to return an error code...
     //
     return NS_OK;
   }
 
   rv = DispatchContent(request, aCtxt);
 
-  LOG(("  After dispatch, m_targetStreamListener: 0x%p, rv: 0x%08X", m_targetStreamListener.get(), rv));
+  LOG(("  After dispatch, m_targetStreamListener: 0x%p, rv: 0x%08" PRIX32,
+       m_targetStreamListener.get(), static_cast<uint32_t>(rv)));
 
   NS_ASSERTION(NS_SUCCEEDED(rv) || !m_targetStreamListener,
                "Must not have an m_targetStreamListener with a failure return!");
 
   NS_ENSURE_SUCCESS(rv, rv);
   
   if (m_targetStreamListener)
     rv = m_targetStreamListener->OnStartRequest(request, aCtxt);
 
-  LOG(("  OnStartRequest returning: 0x%08X", rv));
+  LOG(("  OnStartRequest returning: 0x%08" PRIX32, static_cast<uint32_t>(rv)));
   
   return rv;
 }
 
 NS_IMETHODIMP
 nsDocumentOpenInfo::CheckListenerChain()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread!");
   nsresult rv = NS_OK;
   nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
     do_QueryInterface(m_targetStreamListener, &rv);
   if (retargetableListener) {
     rv = retargetableListener->CheckListenerChain();
   }
-  LOG(("[0x%p] nsDocumentOpenInfo::CheckListenerChain %s listener %p rv %x",
+  LOG(("[0x%p] nsDocumentOpenInfo::CheckListenerChain %s listener %p rv %" PRIx32,
        this, (NS_SUCCEEDED(rv) ? "success" : "failure"),
-       (nsIStreamListener*)m_targetStreamListener, rv));
+       (nsIStreamListener*)m_targetStreamListener, static_cast<uint32_t>(rv)));
   return rv;
 }
 
 NS_IMETHODIMP
 nsDocumentOpenInfo::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt,
                                     nsIInputStream * inStr,
                                     uint64_t sourceOffset, uint32_t count)
 {
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -98,16 +98,17 @@
 #ifdef XP_WIN
 #include "nsWindowsHelpers.h"
 #endif
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "FennecJNIWrappers.h"
 #endif
 
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ipc/URIUtils.h"
 
 #ifdef MOZ_WIDGET_GONK
 #include "nsDeviceStorage.h"
 #endif
 
 using namespace mozilla;
@@ -1909,18 +1910,19 @@ void nsExternalAppHandler::SendStatusCha
         case kLaunchError:
           msgId.AssignLiteral("launchError");
           break;
         }
         break;
     }
 
     MOZ_LOG(nsExternalHelperAppService::mLog, LogLevel::Error,
-        ("Error: %s, type=%i, listener=0x%p, transfer=0x%p, rv=0x%08X\n",
-         NS_LossyConvertUTF16toASCII(msgId).get(), type, mDialogProgressListener.get(), mTransfer.get(), rv));
+        ("Error: %s, type=%i, listener=0x%p, transfer=0x%p, rv=0x%08" PRIX32 "\n",
+         NS_LossyConvertUTF16toASCII(msgId).get(), type, mDialogProgressListener.get(), mTransfer.get(),
+         static_cast<uint32_t>(rv)));
 
     MOZ_LOG(nsExternalHelperAppService::mLog, LogLevel::Error,
         ("       path='%s'\n", NS_ConvertUTF16toUTF8(path).get()));
 
     // Get properties file bundle and extract status string.
     nsCOMPtr<nsIStringBundleService> stringService =
         mozilla::services::GetStringBundleService();
     if (stringService) {
@@ -1942,41 +1944,42 @@ void nsExternalAppHandler::SendStatusCha
                 nsCOMPtr<nsIPrompt> prompter(do_GetInterface(GetDialogParent(), &qiRv));
                 nsXPIDLString title;
                 bundle->FormatStringFromName(u"title",
                                              strings,
                                              1,
                                              getter_Copies(title));
 
                 MOZ_LOG(nsExternalHelperAppService::mLog, LogLevel::Debug,
-                       ("mContentContext=0x%p, prompter=0x%p, qi rv=0x%08X, title='%s', msg='%s'",
+                       ("mContentContext=0x%p, prompter=0x%p, qi rv=0x%08"
+                        PRIX32 ", title='%s', msg='%s'",
                        mContentContext.get(),
                        prompter.get(),
-                       qiRv,
+                        static_cast<uint32_t>(qiRv),
                        NS_ConvertUTF16toUTF8(title).get(),
                        NS_ConvertUTF16toUTF8(msgText).get()));
 
                 // If we didn't have a prompter we will try and get a window
                 // instead, get it's docshell and use it to alert the user.
                 if (!prompter) {
                   nsCOMPtr<nsPIDOMWindowOuter> window(do_GetInterface(GetDialogParent()));
                   if (!window || !window->GetDocShell()) {
                     return;
                   }
 
                   prompter = do_GetInterface(window->GetDocShell(), &qiRv);
 
                   MOZ_LOG(nsExternalHelperAppService::mLog, LogLevel::Debug,
                          ("No prompter from mContentContext, using DocShell, " \
                           "window=0x%p, docShell=0x%p, " \
-                          "prompter=0x%p, qi rv=0x%08X",
+                          "prompter=0x%p, qi rv=0x%08" PRIX32,
                           window.get(),
                           window->GetDocShell(),
                           prompter.get(),
-                          qiRv));
+                          static_cast<uint32_t>(qiRv)));
 
                   // If we still don't have a prompter, there's nothing else we
                   // can do so just return.
                   if (!prompter) {
                     MOZ_LOG(nsExternalHelperAppService::mLog, LogLevel::Error,
                            ("No prompter from DocShell, no way to alert user"));
                     return;
                   }
@@ -2029,18 +2032,18 @@ nsExternalAppHandler::OnDataAvailable(ns
   }
   return rv;
 }
 
 NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIRequest *request, nsISupports *aCtxt,
                                                   nsresult aStatus)
 {
   LOG(("nsExternalAppHandler::OnStopRequest\n"
-       "  mCanceled=%d, mTransfer=0x%p, aStatus=0x%08X\n",
-       mCanceled, mTransfer.get(), aStatus));
+       "  mCanceled=%d, mTransfer=0x%p, aStatus=0x%08" PRIX32 "\n",
+       mCanceled, mTransfer.get(), static_cast<uint32_t>(aStatus)));
 
   mStopRequestIssued = true;
 
   // Cancel if the request did not complete successfully.
   if (!mCanceled && NS_FAILED(aStatus)) {
     // Send error notification.
     nsAutoString tempFilePath;
     if (mTempFile)
@@ -2065,18 +2068,18 @@ nsExternalAppHandler::OnTargetChange(nsI
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsExternalAppHandler::OnSaveComplete(nsIBackgroundFileSaver *aSaver,
                                      nsresult aStatus)
 {
   LOG(("nsExternalAppHandler::OnSaveComplete\n"
-       "  aSaver=0x%p, aStatus=0x%08X, mCanceled=%d, mTransfer=0x%p\n",
-       aSaver, aStatus, mCanceled, mTransfer.get()));
+       "  aSaver=0x%p, aStatus=0x%08" PRIX32 ", mCanceled=%d, mTransfer=0x%p\n",
+       aSaver, static_cast<uint32_t>(aStatus), mCanceled, mTransfer.get()));
 
   if (!mCanceled) {
     // Save the hash and signature information
     (void)mSaver->GetSha256Hash(mHash);
     (void)mSaver->GetSignatureInfo(getter_AddRefs(mSignatureInfo));
 
     // Free the reference that the saver keeps on us, even if we couldn't get
     // the hash.
@@ -2086,17 +2089,18 @@ nsExternalAppHandler::OnSaveComplete(nsI
     nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
     if (channel) {
       nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
       if (loadInfo) {
         nsresult rv = NS_OK;
         nsCOMPtr<nsIMutableArray> redirectChain =
           do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
         NS_ENSURE_SUCCESS(rv, rv);
-        LOG(("nsExternalAppHandler: Got %u redirects\n", loadInfo->RedirectChain().Length()));
+        LOG(("nsExternalAppHandler: Got %" PRIuSIZE " redirects\n",
+             loadInfo->RedirectChain().Length()));
         for (nsIPrincipal* principal : loadInfo->RedirectChain()) {
           redirectChain->AppendElement(principal, false);
         }
         mRedirects = redirectChain;
       }
     }
 
     if (NS_FAILED(aStatus)) {
@@ -2660,34 +2664,35 @@ NS_IMETHODIMP nsExternalHelperAppService
   // (i.e. default application, default app. description)
   nsresult rv;
   nsCOMPtr<nsIHandlerService> handlerSvc = do_GetService(NS_HANDLERSERVICE_CONTRACTID);
   if (handlerSvc) {
     bool hasHandler = false;
     (void) handlerSvc->Exists(*_retval, &hasHandler);
     if (hasHandler) {
       rv = handlerSvc->FillHandlerInfo(*_retval, EmptyCString());
-      LOG(("Data source: Via type: retval 0x%08x\n", rv));
+      LOG(("Data source: Via type: retval 0x%08" PRIx32 "\n", static_cast<uint32_t>(rv)));
     } else {
       rv = NS_ERROR_NOT_AVAILABLE;
     }
  
     found = found || NS_SUCCEEDED(rv);
 
     if (!found || NS_FAILED(rv)) {
       // No type match, try extension match
       if (!aFileExt.IsEmpty()) {
         nsAutoCString overrideType;
         rv = handlerSvc->GetTypeFromExtension(aFileExt, overrideType);
         if (NS_SUCCEEDED(rv) && !overrideType.IsEmpty()) {
           // We can't check handlerSvc->Exists() here, because we have a
           // overideType. That's ok, it just results in some console noise.
           // (If there's no handler for the override type, it throws)
           rv = handlerSvc->FillHandlerInfo(*_retval, overrideType);
-          LOG(("Data source: Via ext: retval 0x%08x\n", rv));
+          LOG(("Data source: Via ext: retval 0x%08" PRIx32 "\n",
+               static_cast<uint32_t>(rv)));
           found = found || NS_SUCCEEDED(rv);
         }
       }
     }
   }
 
   // (3) No match yet. Ask extras.
   if (!found) {
@@ -2698,21 +2703,21 @@ NS_IMETHODIMP nsExternalHelperAppService
      * 120327, comment 271 for why this is needed.  Not even sure we
      * want to remove this once we have fixed all this stuff to work
      * right; any info we get from extras on this type is pretty much
      * useless....
      */
     if (!typeToUse.Equals(APPLICATION_OCTET_STREAM, nsCaseInsensitiveCStringComparator()))
 #endif
       rv = FillMIMEInfoForMimeTypeFromExtras(typeToUse, *_retval);
-    LOG(("Searched extras (by type), rv 0x%08X\n", rv));
+    LOG(("Searched extras (by type), rv 0x%08" PRIX32 "\n", static_cast<uint32_t>(rv)));
     // If that didn't work out, try file extension from extras
     if (NS_FAILED(rv) && !aFileExt.IsEmpty()) {
       rv = FillMIMEInfoForExtensionFromExtras(aFileExt, *_retval);
-      LOG(("Searched extras (by ext), rv 0x%08X\n", rv));
+      LOG(("Searched extras (by ext), rv 0x%08" PRIX32 "\n", static_cast<uint32_t>(rv)));
     }
     // If that still didn't work, set the file description to "ext File"
     if (NS_FAILED(rv) && !aFileExt.IsEmpty()) {
       // XXXzpao This should probably be localized
       nsAutoCString desc(aFileExt);
       desc.AppendLiteral(" File");
       (*_retval)->SetDescription(NS_ConvertASCIItoUTF16(desc));
       LOG(("Falling back to 'File' file description\n"));
--- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
@@ -33,16 +33,17 @@
 #include "nsProxyRelease.h"
 #include "nsIConsoleService.h"
 #include "mozilla/Logging.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Attributes.h"
 #include "nsContentUtils.h"
 #include "nsIPrincipal.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #include "nsXULAppAPI.h"
 
 using namespace mozilla;
 
 static const uint32_t kRescheduleLimit = 3;
 // Max number of retries for every entry of pinned app.
 static const uint32_t kPinnedEntryRetriesLimit = 3;
@@ -447,32 +448,32 @@ nsOfflineCacheUpdateItem::OnDataAvailabl
                                           nsISupports *aContext,
                                           nsIInputStream *aStream,
                                           uint64_t aOffset,
                                           uint32_t aCount)
 {
     uint32_t bytesRead = 0;
     aStream->ReadSegments(NS_DiscardSegment, nullptr, aCount, &bytesRead);
     mBytesRead += bytesRead;
-    LOG(("loaded %u bytes into offline cache [offset=%llu]\n",
+    LOG(("loaded %u bytes into offline cache [offset=%" PRIu64 "]\n",
          bytesRead, aOffset));
 
     mUpdate->OnByteProgress(bytesRead);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsOfflineCacheUpdateItem::OnStopRequest(nsIRequest *aRequest,
                                         nsISupports *aContext,
                                         nsresult aStatus)
 {
     if (LOG_ENABLED()) {
-        LOG(("%p: Done fetching offline item %s [status=%x]\n",
-             this, mURI->GetSpecOrDefault().get(), aStatus));
+        LOG(("%p: Done fetching offline item %s [status=%" PRIx32 "]\n",
+             this, mURI->GetSpecOrDefault().get(), static_cast<uint32_t>(aStatus)));
     }
 
     if (mBytesRead == 0 && aStatus == NS_OK) {
         // we didn't need to read (because LOAD_ONLY_IF_MODIFIED was
         // specified), but the object should report loadedSize as if it
         // did.
         mChannel->GetContentLength(&mBytesRead);
         mUpdate->OnByteProgress(mBytesRead);
@@ -611,17 +612,17 @@ nsOfflineCacheUpdateItem::GetRequestSucc
         return NS_OK;
     }
 
     nsresult channelStatus;
     rv = httpChannel->GetStatus(&channelStatus);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (NS_FAILED(channelStatus)) {
-        LOG(("Channel status=0x%08x", channelStatus));
+        LOG(("Channel status=0x%08" PRIx32, static_cast<uint32_t>(channelStatus)));
         return NS_OK;
     }
 
     *succeeded = true;
     return NS_OK;
 }
 
 bool
@@ -724,41 +725,42 @@ nsOfflineManifestItem::ReadManifest(nsII
         // Avoid re-creation of crypto hash when it fails from some reason the first time
         manifest->mManifestHashInitialized = true;
 
         manifest->mManifestHash = do_CreateInstance("@mozilla.org/security/hash;1", &rv);
         if (NS_SUCCEEDED(rv)) {
             rv = manifest->mManifestHash->Init(nsICryptoHash::MD5);
             if (NS_FAILED(rv)) {
                 manifest->mManifestHash = nullptr;
-                LOG(("Could not initialize manifest hash for byte-to-byte check, rv=%08x", rv));
+                LOG(("Could not initialize manifest hash for byte-to-byte check, rv=%08" PRIx32,
+                     static_cast<uint32_t>(rv)));
             }
         }
     }
 
     if (manifest->mManifestHash) {
         rv = manifest->mManifestHash->Update(reinterpret_cast<const uint8_t *>(aFromSegment), aCount);
         if (NS_FAILED(rv)) {
             manifest->mManifestHash = nullptr;
-            LOG(("Could not update manifest hash, rv=%08x", rv));
+            LOG(("Could not update manifest hash, rv=%08" PRIx32, static_cast<uint32_t>(rv)));
         }
     }
 
     manifest->mReadBuf.Append(aFromSegment, aCount);
 
     nsCString::const_iterator begin, iter, end;
     manifest->mReadBuf.BeginReading(begin);
     manifest->mReadBuf.EndReading(end);
 
     for (iter = begin; iter != end; iter++) {
         if (*iter == '\r' || *iter == '\n') {
             rv = manifest->HandleManifestLine(begin, iter);
 
             if (NS_FAILED(rv)) {
-                LOG(("HandleManifestLine failed with 0x%08x", rv));
+                LOG(("HandleManifestLine failed with 0x%08" PRIx32, static_cast<uint32_t>(rv)));
                 *aBytesConsumed = 0; // Avoid assertion failure in stream tee
                 return NS_ERROR_ABORT;
             }
 
             begin = iter;
             begin++;
         }
     }
@@ -1027,17 +1029,17 @@ nsOfflineManifestItem::CheckNewManifestC
         return NS_OK;
     }
 
     nsCString newManifestHashValue;
     rv = mManifestHash->Finish(true, mManifestHashValue);
     mManifestHash = nullptr;
 
     if (NS_FAILED(rv)) {
-        LOG(("Could not finish manifest hash, rv=%08x", rv));
+        LOG(("Could not finish manifest hash, rv=%08" PRIx32, static_cast<uint32_t>(rv)));
         // This is not critical error
         return NS_OK;
     }
 
     if (!ParseSucceeded()) {
         // Parsing failed, the hash is not valid
         return NS_OK;
     }
@@ -1109,17 +1111,17 @@ nsOfflineManifestItem::OnDataAvailable(n
     aStream->ReadSegments(ReadManifest, this, aCount, &bytesRead);
     mBytesRead += bytesRead;
 
     if (mParserState == PARSE_ERROR) {
         LOG(("OnDataAvailable is canceling the request due a parse error\n"));
         return NS_ERROR_ABORT;
     }
 
-    LOG(("loaded %u bytes into offline cache [offset=%u]\n",
+    LOG(("loaded %u bytes into offline cache [offset=%" PRIu64 "]\n",
          bytesRead, aOffset));
 
     // All the parent method does is read and discard, don't bother
     // chaining up.
 
     return NS_OK;
 }
 
@@ -1829,17 +1831,17 @@ nsOfflineCacheUpdate::AddExistingItems(u
 }
 
 nsresult
 nsOfflineCacheUpdate::ProcessNextURI()
 {
     // Keep the object alive through a Finish() call.
     nsCOMPtr<nsIOfflineCacheUpdate> kungFuDeathGrip(this);
 
-    LOG(("nsOfflineCacheUpdate::ProcessNextURI [%p, inprogress=%d, numItems=%d]",
+    LOG(("nsOfflineCacheUpdate::ProcessNextURI [%p, inprogress=%d, numItems=%" PRIuSIZE "]",
          this, mItemsInProgress, mItems.Length()));
 
     if (mState != STATE_DOWNLOADING) {
         LOG(("  should only be called from the DOWNLOADING state, ignoring"));
         return NS_ERROR_UNEXPECTED;
     }
 
     nsOfflineCacheUpdateItem * runItem = nullptr;
--- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
@@ -33,16 +33,17 @@
 #include "nsServiceManagerUtils.h"
 #include "nsStreamUtils.h"
 #include "nsThreadUtils.h"
 #include "nsProxyRelease.h"
 #include "mozilla/Logging.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/Unused.h"
 #include "nsIDiskSpaceWatcher.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/PermissionMessageUtils.h"
 #include "nsContentUtils.h"
@@ -391,17 +392,17 @@ nsOfflineCacheUpdateService::UpdateFinis
 
 //-----------------------------------------------------------------------------
 // nsOfflineCacheUpdateService <private>
 //-----------------------------------------------------------------------------
 
 nsresult
 nsOfflineCacheUpdateService::ProcessNextUpdate()
 {
-    LOG(("nsOfflineCacheUpdateService::ProcessNextUpdate [%p, num=%d]",
+    LOG(("nsOfflineCacheUpdateService::ProcessNextUpdate [%p, num=%" PRIuSIZE "]",
          this, mUpdates.Length()));
 
     if (mDisabled)
         return NS_ERROR_ABORT;
 
     if (mUpdateRunning)
         return NS_OK;
 
--- a/uriloader/prefetch/nsPrefetchService.cpp
+++ b/uriloader/prefetch/nsPrefetchService.cpp
@@ -258,27 +258,27 @@ nsPrefetchNode::OnDataAvailable(nsIReque
                                 nsISupports *aContext,
                                 nsIInputStream *aStream,
                                 uint64_t aOffset,
                                 uint32_t aCount)
 {
     uint32_t bytesRead = 0;
     aStream->ReadSegments(NS_DiscardSegment, nullptr, aCount, &bytesRead);
     mBytesRead += bytesRead;
-    LOG(("prefetched %u bytes [offset=%llu]\n", bytesRead, aOffset));
+    LOG(("prefetched %u bytes [offset=%" PRIu64 "]\n", bytesRead, aOffset));
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsPrefetchNode::OnStopRequest(nsIRequest *aRequest,
                               nsISupports *aContext,
                               nsresult aStatus)
 {
-    LOG(("done prefetching [status=%x]\n", aStatus));
+    LOG(("done prefetching [status=%" PRIx32 "]\n", static_cast<uint32_t>(aStatus)));
 
     if (mBytesRead == 0 && aStatus == NS_OK && mChannel) {
         // we didn't need to read (because LOAD_ONLY_IF_MODIFIED was
         // specified), but the object should report loadedSize as if it
         // did.
         mChannel->GetContentLength(&mBytesRead);
     }
 
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -8,16 +8,18 @@
 #include "mozilla/ContentCache.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/Logging.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "nsIWidget.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Move.h"
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/SizePrintfMacros.h"
 
 namespace mozilla {
 
 using namespace widget;
 
 static const char*
 GetBoolName(bool aBool)
 {
@@ -453,18 +455,18 @@ ContentCacheInChild::CacheTextRects(nsIW
          "couldn't retrieve first char rect", this));
     } else {
       mFirstCharRect = charRect;
     }
   }
 
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("0x%p CacheTextRects(), Succeeded, "
-     "mText.Length()=%u, mTextRectArray={ mStart=%u, mRects.Length()=%u }, "
-     "mSelection={ mAnchor=%u, mAnchorCharRects[eNextCharRect]=%s, "
+     "mText.Length()=%x, mTextRectArray={ mStart=%u, mRects.Length()=%"
+     PRIuSIZE " }, mSelection={ mAnchor=%u, mAnchorCharRects[eNextCharRect]=%s, "
      "mAnchorCharRects[ePrevCharRect]=%s, mFocus=%u, "
      "mFocusCharRects[eNextCharRect]=%s, mFocusCharRects[ePrevCharRect]=%s, "
      "mRect=%s }, mFirstCharRect=%s",
      this, mText.Length(), mTextRectArray.mStart,
      mTextRectArray.mRects.Length(), mSelection.mAnchor,
      GetRectText(mSelection.mAnchorCharRects[eNextCharRect]).get(),
      GetRectText(mSelection.mAnchorCharRects[ePrevCharRect]).get(),
      mSelection.mFocus,
@@ -556,17 +558,17 @@ ContentCacheInParent::AssignContent(cons
 
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("0x%p AssignContent(aNotification=%s), "
      "Succeeded, mText.Length()=%u, mSelection={ mAnchor=%u, mFocus=%u, "
      "mWritingMode=%s, mAnchorCharRects[eNextCharRect]=%s, "
      "mAnchorCharRects[ePrevCharRect]=%s, mFocusCharRects[eNextCharRect]=%s, "
      "mFocusCharRects[ePrevCharRect]=%s, mRect=%s }, "
      "mFirstCharRect=%s, mCaret={ mOffset=%u, mRect=%s }, mTextRectArray={ "
-     "mStart=%u, mRects.Length()=%u }, mWidgetHasComposition=%s, "
+     "mStart=%u, mRects.Length()=%" PRIuSIZE " }, mWidgetHasComposition=%s, "
      "mPendingCompositionCount=%u, mCompositionStart=%u, mEditorRect=%s",
      this, GetNotificationName(aNotification),
      mText.Length(), mSelection.mAnchor, mSelection.mFocus,
      GetWritingModeName(mSelection.mWritingMode).get(),
      GetRectText(mSelection.mAnchorCharRects[eNextCharRect]).get(),
      GetRectText(mSelection.mAnchorCharRects[ePrevCharRect]).get(),
      GetRectText(mSelection.mFocusCharRects[eNextCharRect]).get(),
      GetRectText(mSelection.mFocusCharRects[ePrevCharRect]).get(),
@@ -612,44 +614,44 @@ ContentCacheInParent::HandleQueryContent
 
   bool isRelativeToInsertionPoint = aEvent.mInput.mRelativeToInsertionPoint;
   if (isRelativeToInsertionPoint) {
     if (aWidget->PluginHasFocus()) {
       if (NS_WARN_IF(!aEvent.mInput.MakeOffsetAbsolute(0))) {
         MOZ_LOG(sContentCacheLog, LogLevel::Error,
           ("0x%p HandleQueryContentEvent(), FAILED due to "
            "aEvent.mInput.MakeOffsetAbsolute(0) failure, aEvent={ mMessage=%s, "
-           "mInput={ mOffset=%d, mLength=%d } }",
+           "mInput={ mOffset=%" PRId64 ", mLength=%" PRIu32 " } }",
            this, ToChar(aEvent.mMessage), aEvent.mInput.mOffset,
            aEvent.mInput.mLength));
         return false;
       }
     } else if (mWidgetHasComposition) {
       if (NS_WARN_IF(!aEvent.mInput.MakeOffsetAbsolute(mCompositionStart))) {
         MOZ_LOG(sContentCacheLog, LogLevel::Error,
           ("0x%p HandleQueryContentEvent(), FAILED due to "
            "aEvent.mInput.MakeOffsetAbsolute(mCompositionStart) failure, "
            "mCompositionStart=%d, aEvent={ mMessage=%s, "
-           "mInput={ mOffset=%d, mLength=%d } }",
+           "mInput={ mOffset=%" PRId64 ", mLength=%" PRIu32 " } }",
            this, mCompositionStart, ToChar(aEvent.mMessage),
            aEvent.mInput.mOffset, aEvent.mInput.mLength));
         return false;
       }
     } else if (NS_WARN_IF(!mSelection.IsValid())) {
       MOZ_LOG(sContentCacheLog, LogLevel::Error,
         ("0x%p HandleQueryContentEvent(), FAILED due to mSelection is invalid",
          this));
       return false;
     } else if (NS_WARN_IF(!aEvent.mInput.MakeOffsetAbsolute(
                                            mSelection.StartOffset()))) {
       MOZ_LOG(sContentCacheLog, LogLevel::Error,
         ("0x%p HandleQueryContentEvent(), FAILED due to "
          "aEvent.mInput.MakeOffsetAbsolute(mSelection.StartOffset()) "
          "failure, mSelection={ StartOffset()=%d, Length()=%d }, "
-         "aEvent={ mMessage=%s, mInput={ mOffset=%d, mLength=%d } }",
+         "aEvent={ mMessage=%s, mInput={ mOffset=%" PRId64 ", mLength=%" PRIu32 " } }",
          this, mSelection.StartOffset(), mSelection.Length(),
          ToChar(aEvent.mMessage), aEvent.mInput.mOffset,
          aEvent.mInput.mLength));
       return false;
     }
   }
 
   switch (aEvent.mMessage) {
@@ -703,18 +705,18 @@ ContentCacheInParent::HandleQueryContent
          GetEscapedUTF8String(aEvent.mReply.mString).get(),
          GetBoolName(aEvent.mReply.mReversed),
          GetBoolName(aEvent.mReply.mHasSelection),
          GetWritingModeName(aEvent.mReply.mWritingMode).get()));
       break;
     case eQueryTextContent: {
       MOZ_LOG(sContentCacheLog, LogLevel::Info,
         ("0x%p HandleQueryContentEvent("
-         "aEvent={ mMessage=eQueryTextContent, mInput={ mOffset=%u, "
-         "mLength=%u } }, aWidget=0x%p), mText.Length()=%u",
+         "aEvent={ mMessage=eQueryTextContent, mInput={ mOffset=%" PRId64
+         ", mLength=%u } }, aWidget=0x%p), mText.Length()=%u",
          this, aEvent.mInput.mOffset,
          aEvent.mInput.mLength, aWidget, mText.Length()));
       uint32_t inputOffset = aEvent.mInput.mOffset;
       uint32_t inputEndOffset =
         std::min(aEvent.mInput.EndOffset(), mText.Length());
       if (NS_WARN_IF(inputEndOffset < inputOffset)) {
         MOZ_LOG(sContentCacheLog, LogLevel::Error,
           ("0x%p HandleQueryContentEvent(), "
@@ -729,18 +731,18 @@ ContentCacheInParent::HandleQueryContent
         ("0x%p HandleQueryContentEvent(), "
          "Succeeded, aEvent={ mReply={ mOffset=%u, mString.Length()=%u } }",
          this, aEvent.mReply.mOffset, aEvent.mReply.mString.Length()));
       break;
     }
     case eQueryTextRect:
       MOZ_LOG(sContentCacheLog, LogLevel::Info,
         ("0x%p HandleQueryContentEvent("
-         "aEvent={ mMessage=eQueryTextRect, mInput={ mOffset=%u, "
-         "mLength=%u } }, aWidget=0x%p), mText.Length()=%u",
+         "aEvent={ mMessage=eQueryTextRect, mInput={ mOffset=%" PRId64
+         ", mLength=%u } }, aWidget=0x%p), mText.Length()=%u",
          this, aEvent.mInput.mOffset, aEvent.mInput.mLength, aWidget,
          mText.Length()));
       if (NS_WARN_IF(!IsSelectionValid())) {
         // If content cache hasn't been initialized properly, make the query
         // failed.
         MOZ_LOG(sContentCacheLog, LogLevel::Error,
           ("0x%p HandleQueryContentEvent(), "
            "FAILED because mSelection is not valid", this));
@@ -790,17 +792,17 @@ ContentCacheInParent::HandleQueryContent
          this, aEvent.mReply.mOffset,
          GetEscapedUTF8String(aEvent.mReply.mString).get(),
          GetWritingModeName(aEvent.mReply.mWritingMode).get(),
          GetRectText(aEvent.mReply.mRect).get()));
       break;
     case eQueryCaretRect:
       MOZ_LOG(sContentCacheLog, LogLevel::Info,
         ("0x%p HandleQueryContentEvent("
-         "aEvent={ mMessage=eQueryCaretRect, mInput={ mOffset=%u } }, "
+         "aEvent={ mMessage=eQueryCaretRect, mInput={ mOffset=%" PRId64 " } }, "
          "aWidget=0x%p), mText.Length()=%u",
          this, aEvent.mInput.mOffset, aWidget, mText.Length()));
       if (NS_WARN_IF(!IsSelectionValid())) {
         // If content cache hasn't been initialized properly, make the query
         // failed.
         MOZ_LOG(sContentCacheLog, LogLevel::Error,
           ("0x%p HandleQueryContentEvent(), "
            "FAILED because mSelection is not valid", this));
@@ -845,17 +847,17 @@ ContentCacheInParent::HandleQueryContent
 bool
 ContentCacheInParent::GetTextRect(uint32_t aOffset,
                                   bool aRoundToExistingOffset,
                                   LayoutDeviceIntRect& aTextRect) const
 {
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("0x%p GetTextRect(aOffset=%u, "
      "aRoundToExistingOffset=%s), "
-     "mTextRectArray={ mStart=%u, mRects.Length()=%u }, "
+     "mTextRectArray={ mStart=%u, mRects.Length()=%" PRIuSIZE " }, "
      "mSelection={ mAnchor=%u, mFocus=%u }",
      this, aOffset, GetBoolName(aRoundToExistingOffset),
      mTextRectArray.mStart, mTextRectArray.mRects.Length(),
      mSelection.mAnchor, mSelection.mFocus));
 
   if (!aOffset) {
     NS_WARNING_ASSERTION(!mFirstCharRect.IsEmpty(), "empty rect");
     aTextRect = mFirstCharRect;
@@ -914,17 +916,17 @@ ContentCacheInParent::GetUnionTextRects(
                         uint32_t aOffset,
                         uint32_t aLength,
                         bool aRoundToExistingOffset,
                         LayoutDeviceIntRect& aUnionTextRect) const
 {
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("0x%p GetUnionTextRects(aOffset=%u, "
      "aLength=%u, aRoundToExistingOffset=%s), mTextRectArray={ "
-     "mStart=%u, mRects.Length()=%u }, "
+     "mStart=%u, mRects.Length()=%" PRIuSIZE " }, "
      "mSelection={ mAnchor=%u, mFocus=%u }",
      this, aOffset, aLength, GetBoolName(aRoundToExistingOffset),
      mTextRectArray.mStart, mTextRectArray.mRects.Length(),
      mSelection.mAnchor, mSelection.mFocus));
 
   CheckedInt<uint32_t> endOffset =
     CheckedInt<uint32_t>(aOffset) + aLength;
   if (!endOffset.isValid()) {
@@ -1019,17 +1021,17 @@ bool
 ContentCacheInParent::GetCaretRect(uint32_t aOffset,
                                    bool aRoundToExistingOffset,
                                    LayoutDeviceIntRect& aCaretRect) const
 {
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("0x%p GetCaretRect(aOffset=%u, "
      "aRoundToExistingOffset=%s), "
      "mCaret={ mOffset=%u, mRect=%s, IsValid()=%s }, mTextRectArray={ "
-     "mStart=%u, mRects.Length()=%u }, mSelection={ mAnchor=%u, mFocus=%u, "
+     "mStart=%u, mRects.Length()=%" PRIuSIZE " }, mSelection={ mAnchor=%u, mFocus=%u, "
      "mWritingMode=%s, mAnchorCharRects[eNextCharRect]=%s, "
      "mAnchorCharRects[ePrevCharRect]=%s, mFocusCharRects[eNextCharRect]=%s, "
      "mFocusCharRects[ePrevCharRect]=%s }, mFirstCharRect=%s",
      this, aOffset, GetBoolName(aRoundToExistingOffset),
      mCaret.mOffset, GetRectText(mCaret.mRect).get(),
      GetBoolName(mCaret.IsValid()), mTextRectArray.mStart,
      mTextRectArray.mRects.Length(), mSelection.mAnchor, mSelection.mFocus,
      GetWritingModeName(mSelection.mWritingMode).get(),
@@ -1073,17 +1075,17 @@ ContentCacheInParent::GetCaretRect(uint3
   return true;
 }
 
 bool
 ContentCacheInParent::OnCompositionEvent(const WidgetCompositionEvent& aEvent)
 {
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("0x%p OnCompositionEvent(aEvent={ "
-     "mMessage=%s, mData=\"%s\" (Length()=%u), mRanges->Length()=%u }), "
+     "mMessage=%s, mData=\"%s\" (Length()=%u), mRanges->Length()=%" PRIuSIZE " }), "
      "mPendingEventsNeedingAck=%u, mWidgetHasComposition=%s, "
      "mPendingCompositionCount=%u, mCommitStringByRequest=0x%p",
      this, ToChar(aEvent.mMessage),
      GetEscapedUTF8String(aEvent.mData).get(), aEvent.mData.Length(),
      aEvent.mRanges ? aEvent.mRanges->Length() : 0, mPendingEventsNeedingAck,
      GetBoolName(mWidgetHasComposition), mPendingCompositionCount,
      mCommitStringByRequest));
 
@@ -1155,18 +1157,18 @@ void
 ContentCacheInParent::OnEventNeedingAckHandled(nsIWidget* aWidget,
                                                 EventMessage aMessage)
 {
   // This is called when the child process receives WidgetCompositionEvent or
   // WidgetSelectionEvent.
 
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("0x%p OnEventNeedingAckHandled(aWidget=0x%p, "
-     "aMessage=%s), mPendingEventsNeedingAck=%u, mPendingCompositionCount=%u",
-     this, aWidget, ToChar(aMessage), mPendingEventsNeedingAck));
+     "aMessage=%s), mPendingEventsNeedingAck=%u, mPendingCompositionCount=%" PRIu8,
+     this, aWidget, ToChar(aMessage), mPendingEventsNeedingAck, mPendingCompositionCount));
 
   if (WidgetCompositionEvent::IsFollowedByCompositionEnd(aMessage)) {
     MOZ_RELEASE_ASSERT(mPendingCompositionCount > 0);
     mPendingCompositionCount--;
   }
 
   MOZ_RELEASE_ASSERT(mPendingEventsNeedingAck > 0);
   if (--mPendingEventsNeedingAck) {
--- a/widget/cocoa/NativeKeyBindings.mm
+++ b/widget/cocoa/NativeKeyBindings.mm
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "NativeKeyBindings.h"
 
 #include "nsTArray.h"
 #include "nsCocoaUtils.h"
 #include "mozilla/Logging.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/TextEvents.h"
 
 namespace mozilla {
 namespace widget {
 
 PRLogModuleInfo* gNativeKeyBindingsLog = nullptr;
 
 NativeKeyBindings* NativeKeyBindings::sInstanceForSingleLineEditor = nullptr;
@@ -220,17 +221,17 @@ NativeKeyBindings::Execute(const WidgetK
 
   MOZ_LOG(gNativeKeyBindingsLog, LogLevel::Info,
     ("%p NativeKeyBindings::KeyPress, interpreting", this));
 
   AutoTArray<KeyBindingsCommand, 2> bindingCommands;
   nsCocoaUtils::GetCommandsFromKeyEvent(cocoaEvent, bindingCommands);
 
   MOZ_LOG(gNativeKeyBindingsLog, LogLevel::Info,
-    ("%p NativeKeyBindings::KeyPress, bindingCommands=%u",
+    ("%p NativeKeyBindings::KeyPress, bindingCommands=%" PRIuSIZE,
      this, bindingCommands.Length()));
 
   AutoTArray<Command, 4> geckoCommands;
 
   for (uint32_t i = 0; i < bindingCommands.Length(); i++) {
     SEL selector = bindingCommands[i].selector;
 
     if (MOZ_LOG_TEST(gNativeKeyBindingsLog, LogLevel::Info)) {
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -7,16 +7,17 @@
 #include "TextInputHandler.h"
 
 #include "mozilla/Logging.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
+#include "mozilla/SizePrintfMacros.h"
 #include "mozilla/TextEventDispatcher.h"
 #include "mozilla/TextEvents.h"
 
 #include "nsChildView.h"
 #include "nsObjCExceptions.h"
 #include "nsBidiUtils.h"
 #include "nsToolkit.h"
 #include "nsCocoaUtils.h"
@@ -345,35 +346,36 @@ TISInputSourceWrapper::TranslateToString
   aStr.Truncate();
 
   const UCKeyboardLayout* UCKey = GetUCKeyboardLayout();
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p TISInputSourceWrapper::TranslateToString, aKeyCode=0x%X, "
      "aModifiers=0x%X, aKbType=0x%X UCKey=%p\n    "
      "Shift: %s, Ctrl: %s, Opt: %s, Cmd: %s, CapsLock: %s, NumLock: %s",
-     this, aKeyCode, aModifiers, aKbType, UCKey,
+     this, static_cast<unsigned int>(aKeyCode), static_cast<unsigned int>(aModifiers),
+     static_cast<unsigned int>(aKbType), UCKey,
      OnOrOff(aModifiers & shiftKey), OnOrOff(aModifiers & controlKey),
      OnOrOff(aModifiers & optionKey), OnOrOff(aModifiers & cmdKey),
      OnOrOff(aModifiers & alphaLock),
      OnOrOff(aModifiers & kEventKeyModifierNumLockMask)));
 
   NS_ENSURE_TRUE(UCKey, false);
 
   UInt32 deadKeyState = 0;
   UniCharCount len;
   UniChar chars[5];
   OSStatus err = ::UCKeyTranslate(UCKey, aKeyCode,
                                   kUCKeyActionDown, aModifiers >> 8,
                                   aKbType, kUCKeyTranslateNoDeadKeysMask,
                                   &deadKeyState, 5, &len, chars);
 
   MOZ_LOG(gLog, LogLevel::Info,
-    ("%p TISInputSourceWrapper::TranslateToString, err=0x%X, len=%llu",
-     this, err, len));
+    ("%p TISInputSourceWrapper::TranslateToString, err=0x%X, len=%" PRIuSIZE,
+     this, static_cast<int>(err), len));
 
   NS_ENSURE_TRUE(err == noErr, false);
   if (len == 0) {
     return true;
   }
   NS_ENSURE_TRUE(EnsureStringLength(aStr, len), false);
   NS_ASSERTION(sizeof(char16_t) == sizeof(UniChar),
                "size of char16_t and size of UniChar are different");
@@ -1060,17 +1062,17 @@ TISInputSourceWrapper::WillDispatchKeybo
     MOZ_LOG(gLog, LogLevel::Info,
       ("%p TISInputSourceWrapper::WillDispatchKeyboardEvent, "
        "aNativeKeyEvent=%p, [aNativeKeyEvent characters]=\"%s\", "
        "aKeyEvent={ mMessage=%s, mCharCode=0x%X(%s) }, kbType=0x%X, "
        "IsOpenedIMEMode()=%s",
        this, aNativeKeyEvent, utf8Chars.get(),
        GetGeckoKeyEventType(aKeyEvent), aKeyEvent.mCharCode,
        uniChar ? NS_ConvertUTF16toUTF8(&uniChar, 1).get() : "",
-       kbType, TrueOrFalse(IsOpenedIMEMode())));
+       static_cast<unsigned int>(kbType), TrueOrFalse(IsOpenedIMEMode())));
   }
 
   nsAutoString insertStringForCharCode;
   ComputeInsertStringForCharCode(aNativeKeyEvent, aKeyEvent, aInsertString,
                                  insertStringForCharCode);
 
   // The mCharCode was set from mKeyValue. However, for example, when Ctrl key
   // is pressed, its value should indicate an ASCII character for backward
@@ -1098,18 +1100,19 @@ TISInputSourceWrapper::WillDispatchKeybo
     lockState |= alphaLock;
   }
   if ([aNativeKeyEvent modifierFlags] & NSNumericPadKeyMask) {
     lockState |= kEventKeyModifierNumLockMask;
   }
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p TISInputSourceWrapper::WillDispatchKeyboardEvent, "
-     "isRomanKeyboardLayout=%s, key=0x%X",
-     this, TrueOrFalse(isRomanKeyboardLayout), kbType, key));
+     "isRomanKeyboardLayout=%s, kbType=0x%X, key=0x%X",
+     this, TrueOrFalse(isRomanKeyboardLayout), static_cast<unsigned int>(kbType),
+     static_cast<unsigned int>(key)));
 
   nsString str;
 
   // normal chars
   uint32_t unshiftedChar = TranslateToChar(key, lockState, kbType);
   UInt32 shiftLockMod = shiftKey | lockState;
   uint32_t shiftedChar = TranslateToChar(key, shiftLockMod, kbType);
 
@@ -1229,17 +1232,18 @@ uint32_t
 TISInputSourceWrapper::ComputeGeckoKeyCode(UInt32 aNativeKeyCode,
                                            UInt32 aKbType,
                                            bool aCmdIsPressed)
 {
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p TISInputSourceWrapper::ComputeGeckoKeyCode, aNativeKeyCode=0x%X, "
      "aKbType=0x%X, aCmdIsPressed=%s, IsOpenedIMEMode()=%s, "
      "IsASCIICapable()=%s",
-     this, aNativeKeyCode, aKbType, TrueOrFalse(aCmdIsPressed),
+     this, static_cast<unsigned int>(aNativeKeyCode),
+     static_cast<unsigned int>(aKbType), TrueOrFalse(aCmdIsPressed),
      TrueOrFalse(IsOpenedIMEMode()), TrueOrFalse(IsASCIICapable())));
 
   switch (aNativeKeyCode) {
     case kVK_Space:             return NS_VK_SPACE;
     case kVK_Escape:            return NS_VK_ESCAPE;
 
     // modifiers
     case kVK_RightCommand:
@@ -1517,21 +1521,22 @@ TextInputHandler::HandleKeyDownEvent(NSE
        "widget has been already destroyed", this));
     return false;
   }
 
   // Insert empty line to the log for easier to read.
   MOZ_LOG(gLog, LogLevel::Info, (""));
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p TextInputHandler::HandleKeyDownEvent, aNativeEvent=%p, "
-     "type=%s, keyCode=%lld (0x%X), modifierFlags=0x%X, characters=\"%s\", "
+     "type=%s, keyCode=%u (0x%X), modifierFlags=0x%lX, characters=\"%s\", "
      "charactersIgnoringModifiers=\"%s\"",
      this, aNativeEvent, GetNativeKeyEventType(aNativeEvent),
      [aNativeEvent keyCode], [aNativeEvent keyCode],
-     [aNativeEvent modifierFlags], GetCharacters([aNativeEvent characters]),
+     static_cast<unsigned long>([aNativeEvent modifierFlags]),
+     GetCharacters([aNativeEvent characters]),
      GetCharacters([aNativeEvent charactersIgnoringModifiers])));
 
   // Except when Command key is pressed, we should hide mouse cursor until
   // next mousemove.  Handling here means that:
   // - Don't hide mouse cursor at pressing modifier key
   // - Hide mouse cursor even if the key event will be handled by IME (i.e.,
   //   even without dispatching eKeyPress events)
   // - Hide mouse cursor even when a plugin has focus
@@ -1699,22 +1704,23 @@ TextInputHandler::HandleKeyDownEvent(NSE
 
 void
 TextInputHandler::HandleKeyUpEvent(NSEvent* aNativeEvent)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p TextInputHandler::HandleKeyUpEvent, aNativeEvent=%p, "
-     "type=%s, keyCode=%lld (0x%X), modifierFlags=0x%X, characters=\"%s\", "
+     "type=%s, keyCode=%u (0x%X), modifierFlags=0x%lX, characters=\"%s\", "
      "charactersIgnoringModifiers=\"%s\", "
      "IsIMEComposing()=%s",
      this, aNativeEvent, GetNativeKeyEventType(aNativeEvent),
      [aNativeEvent keyCode], [aNativeEvent keyCode],
-     [aNativeEvent modifierFlags], GetCharacters([aNativeEvent characters]),
+     static_cast<unsigned long>([aNativeEvent modifierFlags]),
+     GetCharacters([aNativeEvent characters]),
      GetCharacters([aNativeEvent charactersIgnoringModifiers]),
      TrueOrFalse(IsIMEComposing())));
 
   if (Destroyed()) {
     MOZ_LOG(gLog, LogLevel::Info,
       ("%p TextInputHandler::HandleKeyUpEvent, "
        "widget has been already destroyed", this));
     return;
@@ -1751,21 +1757,22 @@ TextInputHandler::HandleFlagsChanged(NSE
     return;
   }
 
   RefPtr<nsChildView> kungFuDeathGrip(mWidget);
   mozilla::Unused << kungFuDeathGrip; // Not referenced within this function
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p TextInputHandler::HandleFlagsChanged, aNativeEvent=%p, "
-     "type=%s, keyCode=%s (0x%X), modifierFlags=0x%08X, "
-     "sLastModifierState=0x%08X, IsIMEComposing()=%s",
+     "type=%s, keyCode=%s (0x%X), modifierFlags=0x%08lX, "
+     "sLastModifierState=0x%08lX, IsIMEComposing()=%s",
      this, aNativeEvent, GetNativeKeyEventType(aNativeEvent),
      GetKeyNameForNativeKeyCode([aNativeEvent keyCode]), [aNativeEvent keyCode],
-     [aNativeEvent modifierFlags], sLastModifierState,
+     static_cast<unsigned long>([aNativeEvent modifierFlags]),
+     static_cast<unsigned long>(sLastModifierState),
      TrueOrFalse(IsIMEComposing())));
 
   MOZ_ASSERT([aNativeEvent type] == NSFlagsChanged);
 
   NSUInteger diff = [aNativeEvent modifierFlags] ^ sLastModifierState;
   // Device dependent flags for left-control key, both shift keys, both command
   // keys and both option keys have been defined in Next's SDK.  But we
   // shouldn't use it directly as far as possible since Cocoa SDK doesn't
@@ -2117,23 +2124,23 @@ TextInputHandler::InsertText(NSAttribute
   if (Destroyed()) {
     return;
   }
 
   KeyEventState* currentKeyEvent = GetCurrentKeyEvent();
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p TextInputHandler::InsertText, aAttrString=\"%s\", "
-     "aReplacementRange=%p { location=%llu, length=%llu }, "
+     "aReplacementRange=%p { location=%lu, length=%lu }, "
      "IsIMEComposing()=%s, IgnoreIMEComposition()=%s, "
      "keyevent=%p, keydownHandled=%s, keypressDispatched=%s, "
      "causedOtherKeyEvents=%s, compositionDispatched=%s",
      this, GetCharacters([aAttrString string]), aReplacementRange,
-     aReplacementRange ? aReplacementRange->location : 0,
-     aReplacementRange ? aReplacementRange->length : 0,
+     static_cast<unsigned long>(aReplacementRange ? aReplacementRange->location : 0),
+     static_cast<unsigned long>(aReplacementRange ? aReplacementRange->length : 0),
      TrueOrFalse(IsIMEComposing()), TrueOrFalse(IgnoreIMEComposition()),
      currentKeyEvent ? currentKeyEvent->mKeyEvent : nullptr,
      currentKeyEvent ?
        TrueOrFalse(currentKeyEvent->mKeyDownHandled) : "N/A",
      currentKeyEvent ?
        TrueOrFalse(currentKeyEvent->mKeyPressDispatched) : "N/A",
      currentKeyEvent ?
        TrueOrFalse(currentKeyEvent->mCausedOtherKeyEvents) : "N/A",
@@ -2757,18 +2764,18 @@ IMEInputHandler::ExecutePendingMethods()
  ******************************************************************************/
 
 TextRangeType
 IMEInputHandler::ConvertToTextRangeType(uint32_t aUnderlineStyle,
                                         NSRange& aSelectedRange)
 {
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::ConvertToTextRangeType, "
-     "aUnderlineStyle=%llu, aSelectedRange.length=%llu,",
-     this, aUnderlineStyle, aSelectedRange.length));
+     "aUnderlineStyle=%u, aSelectedRange.length=%lu,",
+     this, aUnderlineStyle, static_cast<unsigned long>(aSelectedRange.length)));
 
   // We assume that aUnderlineStyle is NSUnderlineStyleSingle or
   // NSUnderlineStyleThick.  NSUnderlineStyleThick should indicate a selected
   // clause.  Otherwise, should indicate non-selected clause.
 
   if (aSelectedRange.length == 0) {
     switch (aUnderlineStyle) {
       case NSUnderlineStyleSingle:
@@ -2809,17 +2816,17 @@ IMEInputHandler::GetRangeCount(NSAttribu
                     inRange:limitRange];
     limitRange =
       NSMakeRange(NSMaxRange(effectiveRange), 
                   NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
     count++;
   }
 
   MOZ_LOG(gLog, LogLevel::Info,
-    ("%p IMEInputHandler::GetRangeCount, aAttrString=\"%s\", count=%llu",
+    ("%p IMEInputHandler::GetRangeCount, aAttrString=\"%s\", count=%u",
      this, GetCharacters([aAttrString string]), count));
 
   return count;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
 }
 
 already_AddRefed<mozilla::TextRangeArray>
@@ -2854,17 +2861,17 @@ IMEInputHandler::CreateTextRangeArray(NS
     range.mStartOffset = effectiveRange.location;
     range.mEndOffset = NSMaxRange(effectiveRange);
     range.mRangeType =
       ConvertToTextRangeType([attributeValue intValue], aSelectedRange);
     textRangeArray->AppendElement(range);
 
     MOZ_LOG(gLog, LogLevel::Info,
       ("%p IMEInputHandler::CreateTextRangeArray, "
-       "range={ mStartOffset=%llu, mEndOffset=%llu, mRangeType=%s }",
+       "range={ mStartOffset=%u, mEndOffset=%u, mRangeType=%s }",
        this, range.mStartOffset, range.mEndOffset,
        ToChar(range.mRangeType)));
 
     limitRange =
       NSMakeRange(NSMaxRange(effectiveRange), 
                   NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
   }
 
@@ -2872,33 +2879,34 @@ IMEInputHandler::CreateTextRangeArray(NS
   TextRange range;
   range.mStartOffset = aSelectedRange.location + aSelectedRange.length;
   range.mEndOffset = range.mStartOffset;
   range.mRangeType = TextRangeType::eCaret;
   textRangeArray->AppendElement(range);
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::CreateTextRangeArray, "
-     "range={ mStartOffset=%llu, mEndOffset=%llu, mRangeType=%s }",
+     "range={ mStartOffset=%u, mEndOffset=%u, mRangeType=%s }",
      this, range.mStartOffset, range.mEndOffset,
      ToChar(range.mRangeType)));
 
   return textRangeArray.forget();
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL;
 }
 
 bool
 IMEInputHandler::DispatchCompositionStartEvent()
 {
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::DispatchCompositionStartEvent, "
-     "mSelectedRange={ location=%llu, length=%llu }, Destroyed()=%s, "
+     "mSelectedRange={ location=%lu, length=%lu }, Destroyed()=%s, "
      "mView=%p, mWidget=%p, inputContext=%p, mIsIMEComposing=%s",
-     this,  SelectedRange().location, mSelectedRange.length,
+     this,  static_cast<unsigned long>(SelectedRange().location),
+     static_cast<unsigned long>(mSelectedRange.length),
      TrueOrFalse(Destroyed()), mView, mWidget,
      mView ? [mView inputContext] : nullptr, TrueOrFalse(mIsIMEComposing)));
 
   RefPtr<IMEInputHandler> kungFuDeathGrip(this);
 
   nsresult rv = mDispatcher->BeginNativeInputTransaction();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     MOZ_LOG(gLog, LogLevel::Error,
@@ -2942,21 +2950,22 @@ IMEInputHandler::DispatchCompositionChan
                                                 NSAttributedString* aAttrString,
                                                 NSRange& aSelectedRange)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::DispatchCompositionChangeEvent, "
      "aText=\"%s\", aAttrString=\"%s\", "
-     "aSelectedRange={ location=%llu, length=%llu }, Destroyed()=%s, mView=%p, "
+     "aSelectedRange={ location=%lu, length=%lu }, Destroyed()=%s, mView=%p, "
      "mWidget=%p, inputContext=%p, mIsIMEComposing=%s",
      this, NS_ConvertUTF16toUTF8(aText).get(),
      GetCharacters([aAttrString string]),
-     aSelectedRange.location, aSelectedRange.length,
+     static_cast<unsigned long>(aSelectedRange.location),
+     static_cast<unsigned long>(aSelectedRange.length),
      TrueOrFalse(Destroyed()), mView, mWidget,
      mView ? [mView inputContext] : nullptr, TrueOrFalse(mIsIMEComposing)));
 
   NS_ENSURE_TRUE(!Destroyed(), false);
 
   NS_ASSERTION(mIsIMEComposing, "We're not in composition");
 
   RefPtr<IMEInputHandler> kungFuDeathGrip(this);
@@ -3081,24 +3090,25 @@ void
 IMEInputHandler::InsertTextAsCommittingComposition(
                    NSAttributedString* aAttrString,
                    NSRange* aReplacementRange)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::InsertTextAsCommittingComposition, "
-     "aAttrString=\"%s\", aReplacementRange=%p { location=%llu, length=%llu }, "
+     "aAttrString=\"%s\", aReplacementRange=%p { location=%lu, length=%lu }, "
      "Destroyed()=%s, IsIMEComposing()=%s, "
-     "mMarkedRange={ location=%llu, length=%llu }",
+     "mMarkedRange={ location=%lu, length=%lu }",
      this, GetCharacters([aAttrString string]), aReplacementRange,
-     aReplacementRange ? aReplacementRange->location : 0,
-     aReplacementRange ? aReplacementRange->length : 0,
+     static_cast<unsigned long>(aReplacementRange ? aReplacementRange->location : 0),
+     static_cast<unsigned long>(aReplacementRange ? aReplacementRange->length : 0),
      TrueOrFalse(Destroyed()), TrueOrFalse(IsIMEComposing()),
-     mMarkedRange.location, mMarkedRange.length));
+     static_cast<unsigned long>(mMarkedRange.location),
+     static_cast<unsigned long>(mMarkedRange.length)));
 
   if (IgnoreIMECommit()) {
     MOZ_CRASH("IMEInputHandler::InsertTextAsCommittingComposition() must not"
               "be called while canceling the composition");
   }
 
   if (Destroyed()) {
     return;
@@ -3157,29 +3167,31 @@ IMEInputHandler::SetMarkedText(NSAttribu
                                NSRange* aReplacementRange)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   KeyEventState* currentKeyEvent = GetCurrentKeyEvent();
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::SetMarkedText, "
-     "aAttrString=\"%s\", aSelectedRange={ location=%llu, length=%llu }, "
-     "aReplacementRange=%p { location=%llu, length=%llu }, "
+     "aAttrString=\"%s\", aSelectedRange={ location=%lu, length=%lu }, "
+     "aReplacementRange=%p { location=%lu, length=%lu }, "
      "Destroyed()=%s, IgnoreIMEComposition()=%s, IsIMEComposing()=%s, "
-     "mMarkedRange={ location=%llu, length=%llu }, keyevent=%p, "
+     "mMarkedRange={ location=%lu, length=%lu }, keyevent=%p, "
      "keydownHandled=%s, keypressDispatched=%s, causedOtherKeyEvents=%s, "
      "compositionDispatched=%s",
      this, GetCharacters([aAttrString string]),
-     aSelectedRange.location, aSelectedRange.length, aReplacementRange,
-     aReplacementRange ? aReplacementRange->location : 0,
-     aReplacementRange ? aReplacementRange->length : 0,
+     static_cast<unsigned long>(aSelectedRange.location),
+     static_cast<unsigned long>(aSelectedRange.length), aReplacementRange,
+     static_cast<unsigned long>(aReplacementRange ? aReplacementRange->location : 0),
+     static_cast<unsigned long>(aReplacementRange ? aReplacementRange->length : 0),
      TrueOrFalse(Destroyed()), TrueOrFalse(IgnoreIMEComposition()),
      TrueOrFalse(IsIMEComposing()),
-     mMarkedRange.location, mMarkedRange.length,
+     static_cast<unsigned long>(mMarkedRange.location),
+     static_cast<unsigned long>(mMarkedRange.length),
      currentKeyEvent ? currentKeyEvent->mKeyEvent : nullptr,
      currentKeyEvent ?
        TrueOrFalse(currentKeyEvent->mKeyDownHandled) : "N/A",
      currentKeyEvent ?
        TrueOrFalse(currentKeyEvent->mKeyPressDispatched) : "N/A",
      currentKeyEvent ?
        TrueOrFalse(currentKeyEvent->mCausedOtherKeyEvents) : "N/A",
      currentKeyEvent ?
@@ -3260,18 +3272,19 @@ IMEInputHandler::SetMarkedText(NSAttribu
 NSAttributedString*
 IMEInputHandler::GetAttributedSubstringFromRange(NSRange& aRange,
                                                  NSRange* aActualRange)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::GetAttributedSubstringFromRange, "
-     "aRange={ location=%llu, length=%llu }, aActualRange=%p, Destroyed()=%s",
-     this, aRange.location, aRange.length, aActualRange,
+     "aRange={ location=%lu, length=%lu }, aActualRange=%p, Destroyed()=%s",
+     this, static_cast<unsigned long>(aRange.location),
+     static_cast<unsigned long>(aRange.length), aActualRange,
      TrueOrFalse(Destroyed())));
 
   if (aActualRange) {
     *aActualRange = NSMakeRange(NSNotFound, 0);
   }
 
   if (Destroyed() || aRange.location == NSNotFound || aRange.length == 0) {
     return nil;
@@ -3361,46 +3374,48 @@ IMEInputHandler::GetAttributedSubstringF
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 bool
 IMEInputHandler::HasMarkedText()
 {
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::HasMarkedText, "
-     "mMarkedRange={ location=%llu, length=%llu }",
-     this, mMarkedRange.location, mMarkedRange.length));
+     "mMarkedRange={ location=%lu, length=%lu }",
+     this, static_cast<unsigned long>(mMarkedRange.location),
+     static_cast<unsigned long>(mMarkedRange.length)));
 
   return (mMarkedRange.location != NSNotFound) && (mMarkedRange.length != 0);
 }
 
 NSRange
 IMEInputHandler::MarkedRange()
 {
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::MarkedRange, "
-     "mMarkedRange={ location=%llu, length=%llu }",
-     this, mMarkedRange.location, mMarkedRange.length));
+     "mMarkedRange={ location=%lu, length=%lu }",
+     this, static_cast<unsigned long>(mMarkedRange.location),
+     static_cast<unsigned long>(mMarkedRange.length)));
 
   if (!HasMarkedText()) {
     return NSMakeRange(NSNotFound, 0);
   }
   return mMarkedRange;
 }
 
 NSRange
 IMEInputHandler::SelectedRange()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::SelectedRange, Destroyed()=%s, mSelectedRange={ "
-     "location=%llu, length=%llu }",
-     this, TrueOrFalse(Destroyed()), mSelectedRange.location,
-     mSelectedRange.length));
+     "location=%lu, length=%lu }",
+     this, TrueOrFalse(Destroyed()), static_cast<unsigned long>(mSelectedRange.location),
+     static_cast<unsigned long>(mSelectedRange.length)));
 
   if (Destroyed()) {
     return mSelectedRange;
   }
 
   if (mSelectedRange.location != NSNotFound) {
     MOZ_ASSERT(mIMEHasFocus);
     return mSelectedRange;
@@ -3470,19 +3485,19 @@ IMEInputHandler::DrawsVerticallyForChara
 NSRect
 IMEInputHandler::FirstRectForCharacterRange(NSRange& aRange,
                                             NSRange* aActualRange)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::FirstRectForCharacterRange, Destroyed()=%s, "
-     "aRange={ location=%llu, length=%llu }, aActualRange=%p }",
-     this, TrueOrFalse(Destroyed()), aRange.location, aRange.length,
-     aActualRange));
+     "aRange={ location=%lu, length=%lu }, aActualRange=%p }",
+     this, TrueOrFalse(Destroyed()), static_cast<unsigned long>(aRange.location),
+     static_cast<unsigned long>(aRange.length), aActualRange));
 
   // XXX this returns first character rect or caret rect, it is limitation of
   // now. We need more work for returns first line rect. But current
   // implementation is enough for IMEs.
 
   NSRect rect = NSMakeRect(0.0, 0.0, 0.0, 0.0);
   NSRange actualRange = NSMakeRange(NSNotFound, 0);
   if (aActualRange) {
@@ -3560,20 +3575,20 @@ IMEInputHandler::FirstRectForCharacterRa
 
   if (aActualRange) {
     *aActualRange = actualRange;
   }
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::FirstRectForCharacterRange, "
      "useCaretRect=%s rect={ x=%f, y=%f, width=%f, height=%f }, "
-     "actualRange={ location=%llu, length=%llu }",
+     "actualRange={ location=%lu, length=%lu }",
      this, TrueOrFalse(useCaretRect), rect.origin.x, rect.origin.y,
-     rect.size.width, rect.size.height, actualRange.location,
-     actualRange.length));
+     rect.size.width, rect.size.height, static_cast<unsigned long>(actualRange.location),
+     static_cast<unsigned long>(actualRange.length)));
 
   return rect;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NSMakeRect(0.0, 0.0, 0.0, 0.0));
 }
 
 NSUInteger
 IMEInputHandler::CharacterIndexForPoint(NSPoint& aPoint)
@@ -3742,17 +3757,17 @@ void
 IMEInputHandler::SendCommittedText(NSString *aString)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p IMEInputHandler::SendCommittedText, mView=%p, mWidget=%p, "
      "inputContext=%p, mIsIMEComposing=%s",
      this, mView, mWidget, mView ? [mView inputContext] : nullptr,
-     TrueOrFalse(mIsIMEComposing), mWidget));
+     TrueOrFalse(mIsIMEComposing)));
 
   NS_ENSURE_TRUE(mWidget, );
   // XXX We should send the string without mView.
   if (!mView) {
     return;
   }
 
   NSAttributedString* attrStr =
@@ -4186,18 +4201,18 @@ TextInputHandlerBase::GetWindowLevel()
   // When an <input> element on a XUL <panel> is focused, the actual focused view
   // is the panel's parent view (mView). But the editor is displayed on the
   // popped-up widget's view (editorView).  We want the latter's window level.
   NSView<mozView>* editorView = mWidget->GetEditorView();
   NS_ENSURE_TRUE(editorView, NSNormalWindowLevel);
   NSInteger windowLevel = [[editorView window] level];
 
   MOZ_LOG(gLog, LogLevel::Info,
-    ("%p TextInputHandlerBase::GetWindowLevel, windowLevel=%s (%X)",
-     this, GetWindowLevelName(windowLevel), windowLevel));
+    ("%p TextInputHandlerBase::GetWindowLevel, windowLevel=%s (%lX)",
+     this, GetWindowLevelName(windowLevel), static_cast<unsigned long>(windowLevel)));
 
   return windowLevel;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NSNormalWindowLevel);
 }
 
 NS_IMETHODIMP
 TextInputHandlerBase::AttachNativeKeyEvent(WidgetKeyboardEvent& aKeyEvent)
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -1637,17 +1637,17 @@ IMContextWrapper::CreateTextRangeArray(G
             gunichar2* utf16StrBeforeCaret =
                 g_utf8_to_utf16(preedit_string, charAfterCaret - preedit_string,
                                 nullptr, &caretOffset, nullptr);
             if (NS_WARN_IF(!utf16StrBeforeCaret) ||
                 NS_WARN_IF(caretOffset < 0)) {
                 MOZ_LOG(gGtkIMLog, LogLevel::Warning,
                     ("0x%p   CreateTextRangeArray(), WARNING, failed to "
                      "convert to UTF-16 string before the caret "
-                     "(cursor_pos_in_chars=%d, caretOffset=%d)",
+                     "(cursor_pos_in_chars=%d, caretOffset=%ld)",
                      this, cursor_pos_in_chars, caretOffset));
             } else {
                 caretOffsetInUTF16 = static_cast<uint32_t>(caretOffset);
                 uint32_t compositionStringLength = aCompositionString.Length();
                 if (NS_WARN_IF(caretOffsetInUTF16 > compositionStringLength)) {
                     MOZ_LOG(gGtkIMLog, LogLevel::Warning,
                         ("0x%p   CreateTextRangeArray(), WARNING, "
                          "caretOffsetInUTF16=%u is larger than "
@@ -2170,32 +2170,32 @@ IMContextWrapper::DeleteText(GtkIMContex
     NS_ConvertUTF16toUTF8 utf8Str(
         nsDependentSubstring(queryTextContentEvent.mReply.mString,
                              0, selOffset));
     glong offsetInUTF8Characters =
         g_utf8_strlen(utf8Str.get(), utf8Str.Length()) + aOffset;
     if (offsetInUTF8Characters < 0) {
         MOZ_LOG(gGtkIMLog, LogLevel::Error,
             ("0x%p   DeleteText(), FAILED, aOffset is too small for "
-             "current cursor pos (computed offset: %d)",
+             "current cursor pos (computed offset: %ld)",
              this, offsetInUTF8Characters));
         return NS_ERROR_FAILURE;
     }
 
     AppendUTF16toUTF8(
         nsDependentSubstring(queryTextContentEvent.mReply.mString, selOffset),
         utf8Str);
     glong countOfCharactersInUTF8 =
         g_utf8_strlen(utf8Str.get(), utf8Str.Length());
     glong endInUTF8Characters =
         offsetInUTF8Characters + aNChars;
     if (countOfCharactersInUTF8 < endInUTF8Characters) {
         MOZ_LOG(gGtkIMLog, LogLevel::Error,
             ("0x%p   DeleteText(), FAILED, aNChars is too large for "
-             "current contents (content length: %d, computed end offset: %d)",
+             "current contents (content length: %ld, computed end offset: %ld)",
              this, countOfCharactersInUTF8, endInUTF8Characters));
         return NS_ERROR_FAILURE;
     }
 
     gchar* charAtOffset =
         g_utf8_offset_to_pointer(utf8Str.get(), offsetInUTF8Characters);
     gchar* charAtEnd =
         g_utf8_offset_to_pointer(utf8Str.get(), endInUTF8Characters);
--- a/widget/gtk/nsDragService.cpp
+++ b/widget/gtk/nsDragService.cpp
@@ -773,17 +773,17 @@ nsDragService::GetData(nsITransferable *
         nsCOMPtr<nsISupportsCString> currentFlavor;
         currentFlavor = do_QueryElementAt(flavorList, i);
         if (currentFlavor) {
             // find our gtk flavor
             nsXPIDLCString flavorStr;
             currentFlavor->ToString(getter_Copies(flavorStr));
             GdkAtom gdkFlavor = gdk_atom_intern(flavorStr, FALSE);
             MOZ_LOG(sDragLm, LogLevel::Debug,
-                   ("looking for data in type %s, gdk flavor %ld\n",
+                   ("looking for data in type %s, gdk flavor %p\n",
                    static_cast<const char*>(flavorStr), gdkFlavor));
             bool dataFound = false;
             if (gdkFlavor) {
                 GetTargetDragData(gdkFlavor);
             }
             if (mTargetDragData) {
                 MOZ_LOG(sDragLm, LogLevel::Debug, ("dataFound = true\n"));
                 dataFound = true;
@@ -1194,17 +1194,17 @@ nsDragService::IsTargetContextList(void)
 }
 
 // Maximum time to wait for a "drag_received" arrived, in microseconds
 #define NS_DND_TIMEOUT 500000
 
 void
 nsDragService::GetTargetDragData(GdkAtom aFlavor)
 {
-    MOZ_LOG(sDragLm, LogLevel::Debug, ("getting data flavor %d\n", aFlavor));
+    MOZ_LOG(sDragLm, LogLevel::Debug, ("getting data flavor %p\n", aFlavor));
     MOZ_LOG(sDragLm, LogLevel::Debug, ("mLastWidget is %p and mLastContext is %p\n",
                                    mTargetWidget.get(),
                                    mTargetDragContext.get()));
     // reset our target data areas
     TargetResetData();
     gtk_drag_get_data(mTargetWidget, mTargetDragContext, aFlavor, mTargetTime);
     
     MOZ_LOG(sDragLm, LogLevel::Debug, ("about to start inner iteration."));
--- a/widget/gtk/nsGtkKeyUtils.cpp
+++ b/widget/gtk/nsGtkKeyUtils.cpp
@@ -358,17 +358,17 @@ KeymapWrapper::InitBySystemSettings()
             continue;
         }
 
         const int32_t modIndex = bit - 3;
         for (int32_t j = 0; j < keysyms_per_keycode; j++) {
             Modifier modifier = GetModifierForGDKKeyval(syms[j]);
             MOZ_LOG(gKeymapWrapperLog, LogLevel::Info,
                 ("%p InitBySystemSettings, "
-                 "    Mod%d, j=%d, syms[j]=%s(0x%X), modifier=%s",
+                 "    Mod%d, j=%d, syms[j]=%s(0x%lX), modifier=%s",
                  this, modIndex + 1, j, gdk_keyval_name(syms[j]), syms[j],
                  GetModifierName(modifier)));
 
             switch (modifier) {
                 case NOT_MODIFIER:
                     // Don't overwrite the stored information with
                     // NOT_MODIFIER.
                     break;
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2083,17 +2083,17 @@ ExtractExposeRegion(LayoutDeviceIntRegio
   if (rects->status != CAIRO_STATUS_SUCCESS) {
       NS_WARNING("Failed to obtain cairo rectangle list.");
       return false;
   }
 
   for (int i = 0; i < rects->num_rectangles; i++)  {
       const cairo_rectangle_t& r = rects->rectangles[i];
       aRegion.Or(aRegion, LayoutDeviceIntRect::Truncate(r.x, r.y, r.width, r.height));
-      LOGDRAW(("\t%d %d %d %d\n", r.x, r.y, r.width, r.height));
+      LOGDRAW(("\t%f %f %f %f\n", r.x, r.y, r.width, r.height));
   }
 
   cairo_rectangle_list_destroy(rects);
   return true;
 }
 #endif
 
 #if (MOZ_WIDGET_GTK == 2)
@@ -4830,17 +4830,17 @@ nsWindow::SetNonXEmbedPluginFocus()
     Window curFocusWindow;
     int focusState;
 
     GdkDisplay *gdkDisplay = gdk_window_get_display(mGdkWindow);
     XGetInputFocus(gdk_x11_display_get_xdisplay(gdkDisplay),
                    &curFocusWindow,
                    &focusState);
 
-    LOGFOCUS(("\t curFocusWindow=%p\n", curFocusWindow));
+    LOGFOCUS(("\t curFocusWindow=%ld\n", curFocusWindow));
 
     GdkWindow* toplevel = gdk_window_get_toplevel(mGdkWindow);
 #if (MOZ_WIDGET_GTK == 2)
     GdkWindow *gdkfocuswin = gdk_window_lookup(curFocusWindow);
 #else
     GdkWindow *gdkfocuswin = gdk_x11_window_lookup_for_display(gdkDisplay,
                                                                curFocusWindow);
 #endif
@@ -4865,17 +4865,17 @@ nsWindow::SetNonXEmbedPluginFocus()
 #if (MOZ_WIDGET_GTK == 3)
     gdk_error_trap_pop_ignored();
 #else
     gdk_error_trap_pop();
 #endif
     gPluginFocusWindow = this;
     gdk_window_add_filter(nullptr, plugin_client_message_filter, this);
 
-    LOGFOCUS(("nsWindow::SetNonXEmbedPluginFocus oldfocus=%p new=%p\n",
+    LOGFOCUS(("nsWindow::SetNonXEmbedPluginFocus oldfocus=%lu new=%lu\n",
               mOldFocusWindow, gdk_x11_window_get_xid(mGdkWindow)));
 }
 
 void
 nsWindow::LoseNonXEmbedPluginFocus()
 {
     LOGFOCUS(("nsWindow::LoseNonXEmbedPluginFocus\n"));
 
--- a/widget/nsIdleService.cpp
+++ b/widget/nsIdleService.cpp
@@ -279,21 +279,21 @@ nsIdleServiceDaily::DailyCallback(nsITim
   PRTime now = PR_Now();
   if (self->mExpectedTriggerTime && now < self->mExpectedTriggerTime) {
     // Timer returned early, reschedule to the appropriate time.
     PRTime delayTime = self->mExpectedTriggerTime - now;
 
     // Add 10 ms to ensure we don't undershoot, and never get a "0" timer.
     delayTime += 10 * PR_USEC_PER_MSEC;
 
-    MOZ_LOG(sLog, LogLevel::Debug, ("nsIdleServiceDaily: DailyCallback resetting timer to %lld msec",
+    MOZ_LOG(sLog, LogLevel::Debug, ("nsIdleServiceDaily: DailyCallback resetting timer to %" PRId64 " msec",
                         delayTime / PR_USEC_PER_MSEC));
 #ifdef MOZ_WIDGET_ANDROID
     __android_log_print(LOG_LEVEL, LOG_TAG,
-                        "DailyCallback resetting timer to %lld msec",
+                        "DailyCallback resetting timer to %" PRId64 " msec",
                         delayTime / PR_USEC_PER_MSEC);
 #endif
 
     (void)self->mTimer->InitWithFuncCallback(DailyCallback,
                                              self,
                                              delayTime / PR_USEC_PER_MSEC,
                                              nsITimer::TYPE_ONE_SHOT);
     return;
--- a/widget/xremoteclient/XRemoteClient.cpp
+++ b/widget/xremoteclient/XRemoteClient.cpp
@@ -2,16 +2,17 @@
 /* vim:expandtab:shiftwidth=2:tabstop=8:
  */
 /* vim:set ts=8 sw=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Sprintf.h"
 #include "XRemoteClient.h"
 #include "prmem.h"
 #include "plstr.h"
 #include "prsystem.h"
 #include "mozilla/Logging.h"
 #include "prenv.h"
 #include "prdtoa.h"
@@ -203,17 +204,18 @@ XRemoteClient::SendCommandLine (const ch
       if (!destroyed)
           FreeLock(w); // doesn't really matter what this returns
 
     }
   }
 
   XSetErrorHandler(sOldHandler);
 
-  MOZ_LOG(sRemoteLm, LogLevel::Debug, ("SendCommandInternal returning 0x%x\n", rv));
+  MOZ_LOG(sRemoteLm, LogLevel::Debug, ("SendCommandInternal returning 0x%" PRIx32 "\n",
+                                       static_cast<uint32_t>(rv)));
 
   return rv;
 }
 
 Window
 XRemoteClient::CheckWindow(Window aWindow)
 {
   Atom type = None;
--- a/xpcom/base/Logging.cpp
+++ b/xpcom/base/Logging.cpp
@@ -9,23 +9,23 @@
 #include <algorithm>
 
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Atomics.h"
+#include "mozilla/Sprintf.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "nsClassHashtable.h"
 #include "nsDebug.h"
 #include "NSPRLogModulesParser.h"
 
 #include "prenv.h"
-#include "prprf.h"
 #ifdef XP_WIN
 #include <process.h>
 #else
 #include <sys/types.h>
 #include <unistd.h>
 #endif
 
 // NB: Initial amount determined by auditing the codebase for the total amount
@@ -42,19 +42,19 @@ namespace mozilla {
 namespace detail {
 
 void log_print(const PRLogModuleInfo* aModule,
                LogLevel aLevel,
                const char* aFmt, ...)
 {
   va_list ap;
   va_start(ap, aFmt);
-  char* buff = PR_vsmprintf(aFmt, ap);
+  char* buff = mozilla::Vsmprintf(aFmt, ap);
   PR_LogPrint("%s", buff);
-  PR_smprintf_free(buff);
+  mozilla::SmprintfFree(buff);
   va_end(ap);
 }
 
 void log_print(const LogModule* aModule,
                LogLevel aLevel,
                const char* aFmt, ...)
 {
   va_list ap;
@@ -360,22 +360,22 @@ public:
     char buff[kBuffSize];
 
     char* buffToWrite = buff;
 
     // For backwards compat we need to use the NSPR format string versions
     // of sprintf and friends and then hand off to printf.
     va_list argsCopy;
     va_copy(argsCopy, aArgs);
-    size_t charsWritten = PR_vsnprintf(buff, kBuffSize, aFmt, argsCopy);
+    size_t charsWritten = VsprintfLiteral(buff, aFmt, argsCopy);
     va_end(argsCopy);
 
     if (charsWritten == kBuffSize - 1) {
       // We may have maxed out, allocate a buffer instead.
-      buffToWrite = PR_vsmprintf(aFmt, aArgs);
+      buffToWrite = mozilla::Vsmprintf(aFmt, aArgs);
       charsWritten = strlen(buffToWrite);
     }
 
     // Determine if a newline needs to be appended to the message.
     const char* newline = "";
     if (charsWritten == 0 || buffToWrite[charsWritten - 1] != '\n') {
       newline = "\n";
     }
@@ -426,17 +426,17 @@ public:
           aName, buffToWrite, newline);
     }
 
     if (mIsSync) {
       fflush(out);
     }
 
     if (buffToWrite != buff) {
-      PR_smprintf_free(buffToWrite);
+      mozilla::SmprintfFree(buffToWrite);
     }
 
     if (mRotate > 0 && outFile) {
       int32_t fileSize = ftell(out);
       if (fileSize > mRotate) {
         uint32_t fileNum = outFile->Num();
 
         uint32_t nextFileNum = fileNum + 1;
--- a/xpcom/base/Logging.h
+++ b/xpcom/base/Logging.h
@@ -9,16 +9,17 @@
 
 #include <string.h>
 #include <stdarg.h>
 
 #include "prlog.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Atomics.h"
+#include "mozilla/Attributes.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MacroForEach.h"
 
 // This file is a placeholder for a replacement to the NSPR logging framework
 // that is defined in prlog.h. Currently it is just a pass through, but as
 // work progresses more functionality will be swapped out in favor of
 // mozilla logging implementations.
 
@@ -198,26 +199,26 @@ inline bool log_test(const PRLogModuleIn
 
 /**
  * A rather inefficient wrapper for PR_LogPrint that always allocates.
  * PR_LogModuleInfo is deprecated so it's not worth the effort to do
  * any better.
  */
 void log_print(const PRLogModuleInfo* aModule,
                       LogLevel aLevel,
-                      const char* aFmt, ...);
+                      const char* aFmt, ...) MOZ_FORMAT_PRINTF(3, 4);
 
 inline bool log_test(const LogModule* module, LogLevel level) {
   MOZ_ASSERT(level != LogLevel::Disabled);
   return module && module->ShouldLog(level);
 }
 
 void log_print(const LogModule* aModule,
                LogLevel aLevel,
-               const char* aFmt, ...);
+               const char* aFmt, ...) MOZ_FORMAT_PRINTF(3, 4);
 } // namespace detail
 
 } // namespace mozilla
 
 
 // Helper macro used convert MOZ_LOG's third parameter, |_args|, from a
 // parenthesized form to a varargs form. For example:
 //   ("%s", "a message") => "%s", "a message"
--- a/xpcom/io/nsInputStreamTee.cpp
+++ b/xpcom/io/nsInputStreamTee.cpp
@@ -97,18 +97,18 @@ public:
          this, mCount, mSink.get()));
 
     uint32_t totalBytesWritten = 0;
     while (mCount) {
       nsresult rv;
       uint32_t bytesWritten = 0;
       rv = mSink->Write(mBuf + totalBytesWritten, mCount, &bytesWritten);
       if (NS_FAILED(rv)) {
-        LOG(("nsInputStreamTeeWriteEvent::Run[%p] error %x in writing",
-             this, rv));
+        LOG(("nsInputStreamTeeWriteEvent::Run[%p] error %" PRIx32 " in writing",
+             this, static_cast<uint32_t>(rv)));
         mTee->InvalidateSink();
         break;
       }
       totalBytesWritten += bytesWritten;
       NS_ASSERTION(bytesWritten <= mCount, "wrote too much");
       mCount -= bytesWritten;
     }
     return NS_OK;
--- a/xpcom/io/nsPipe3.cpp
+++ b/xpcom/io/nsPipe3.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <algorithm>
 #include "mozilla/Attributes.h"
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "nsIBufferedStreams.h"
 #include "nsICloneableInputStream.h"
 #include "nsIPipe.h"
 #include "nsIEventTarget.h"
 #include "nsISeekableStream.h"
 #include "mozilla/RefPtr.h"
 #include "nsSegmentedBuffer.h"
@@ -882,17 +883,18 @@ nsPipe::GetWriteSegment(char*& aSegment,
 
   // make sure read cursor is initialized
   SetAllNullReadCursors();
 
   // check to see if we can roll-back our read and write cursors to the
   // beginning of the current/first segment.  this is purely an optimization.
   if (mWriteSegment == 0 && AllReadCursorsMatchWriteCursor()) {
     char* head = mBuffer.GetSegment(0);
-    LOG(("OOO rolling back write cursor %u bytes\n", mWriteCursor - head));
+    LOG(("OOO rolling back write cursor %" PRId64 " bytes\n",
+         static_cast<int64_t>(mWriteCursor - head)));
     RollBackAllReadCursors(head);
     mWriteCursor = head;
   }
 
   aSegment    = mWriteCursor;
   aSegmentLen = mWriteLimit - mWriteCursor;
   return NS_OK;
 }
@@ -980,18 +982,18 @@ nsPipe::OnInputStreamException(nsPipeInp
       return;
     }
   }
 }
 
 void
 nsPipe::OnPipeException(nsresult aReason, bool aOutputOnly)
 {
-  LOG(("PPP nsPipe::OnPipeException [reason=%x output-only=%d]\n",
-       aReason, aOutputOnly));
+  LOG(("PPP nsPipe::OnPipeException [reason=%" PRIx32 " output-only=%d]\n",
+       static_cast<uint32_t>(aReason), aOutputOnly));
 
   nsPipeEvents events;
   {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
     // if we've already hit an exception, then ignore this one.
     if (NS_FAILED(mStatus)) {
       return;
@@ -1279,18 +1281,18 @@ nsPipeInputStream::Wait()
 
   while (NS_SUCCEEDED(Status(mon)) && (mReadState.mAvailable == 0)) {
     LOG(("III pipe input: waiting for data\n"));
 
     mBlocked = true;
     mon.Wait();
     mBlocked = false;
 
-    LOG(("III pipe input: woke up [status=%x available=%u]\n",
-         Status(mon), mReadState.mAvailable));
+    LOG(("III pipe input: woke up [status=%" PRIx32 " available=%u]\n",
+         static_cast<uint32_t>(Status(mon)), mReadState.mAvailable));
   }
 
   return Status(mon) == NS_BASE_STREAM_CLOSED ? NS_OK : Status(mon);
 }
 
 MonitorAction
 nsPipeInputStream::OnInputReadable(uint32_t aBytesWritten,
                                    nsPipeEvents& aEvents,
@@ -1311,18 +1313,18 @@ nsPipeInputStream::OnInputReadable(uint3
 
   return result;
 }
 
 MonitorAction
 nsPipeInputStream::OnInputException(nsresult aReason, nsPipeEvents& aEvents,
                                     const ReentrantMonitorAutoEnter& ev)
 {
-  LOG(("nsPipeInputStream::OnInputException [this=%x reason=%x]\n",
-       this, aReason));
+  LOG(("nsPipeInputStream::OnInputException [this=%p reason=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(aReason)));
 
   MonitorAction result = DoNotNotifyMonitor;
 
   NS_ASSERTION(NS_FAILED(aReason), "huh? successful exception");
 
   if (NS_SUCCEEDED(mInputStatus)) {
     mInputStatus = aReason;
   }
@@ -1339,17 +1341,18 @@ nsPipeInputStream::OnInputException(nsre
   }
 
   return result;
 }
 
 NS_IMETHODIMP
 nsPipeInputStream::CloseWithStatus(nsresult aReason)
 {
-  LOG(("III CloseWithStatus [this=%x reason=%x]\n", this, aReason));
+  LOG(("III CloseWithStatus [this=%p reason=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(aReason)));
 
   ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
 
   if (NS_FAILED(mInputStatus)) {
     return NS_OK;
   }
 
   if (NS_SUCCEEDED(aReason)) {
@@ -1382,17 +1385,17 @@ nsPipeInputStream::Available(uint64_t* a
 }
 
 NS_IMETHODIMP
 nsPipeInputStream::ReadSegments(nsWriteSegmentFun aWriter,
                                 void* aClosure,
                                 uint32_t aCount,
                                 uint32_t* aReadCount)
 {
-  LOG(("III ReadSegments [this=%x count=%u]\n", this, aCount));
+  LOG(("III ReadSegments [this=%p count=%u]\n", this, aCount));
 
   nsresult rv = NS_OK;
 
   *aReadCount = 0;
   while (aCount) {
     AutoReadSegment segment(mPipe, mReadState, aCount);
     rv = segment.Status();
     if (NS_FAILED(rv)) {
@@ -1461,17 +1464,17 @@ nsPipeInputStream::IsNonBlocking(bool* a
 }
 
 NS_IMETHODIMP
 nsPipeInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
                              uint32_t aFlags,
                              uint32_t aRequestedCount,
                              nsIEventTarget* aTarget)
 {
-  LOG(("III AsyncWait [this=%x]\n", this));
+  LOG(("III AsyncWait [this=%p]\n", this));
 
   nsPipeEvents pipeEvents;
   {
     ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
 
     // replace a pending callback
     mCallback = nullptr;
     mCallbackFlags = 0;
@@ -1676,18 +1679,18 @@ nsPipeOutputStream::Wait()
 
   ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
 
   if (NS_SUCCEEDED(mPipe->mStatus) && !mWritable) {
     LOG(("OOO pipe output: waiting for space\n"));
     mBlocked = true;
     mon.Wait();
     mBlocked = false;
-    LOG(("OOO pipe output: woke up [pipe-status=%x writable=%u]\n",
-         mPipe->mStatus, mWritable));
+    LOG(("OOO pipe output: woke up [pipe-status=%" PRIx32 " writable=%u]\n",
+         static_cast<uint32_t>(mPipe->mStatus), mWritable));
   }
 
   return mPipe->mStatus == NS_BASE_STREAM_CLOSED ? NS_OK : mPipe->mStatus;
 }
 
 MonitorAction
 nsPipeOutputStream::OnOutputWritable(nsPipeEvents& aEvents)
 {
@@ -1704,18 +1707,18 @@ nsPipeOutputStream::OnOutputWritable(nsP
   }
 
   return result;
 }
 
 MonitorAction
 nsPipeOutputStream::OnOutputException(nsresult aReason, nsPipeEvents& aEvents)
 {
-  LOG(("nsPipeOutputStream::OnOutputException [this=%x reason=%x]\n",
-       this, aReason));
+  LOG(("nsPipeOutputStream::OnOutputException [this=%p reason=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(aReason)));
 
   MonitorAction result = DoNotNotifyMonitor;
 
   NS_ASSERTION(NS_FAILED(aReason), "huh? successful exception");
   mWritable = false;
 
   if (mCallback) {
     aEvents.NotifyOutputReady(this, mCallback);
@@ -1743,17 +1746,18 @@ nsPipeOutputStream::Release()
     Close();
   }
   return mPipe->Release();
 }
 
 NS_IMETHODIMP
 nsPipeOutputStream::CloseWithStatus(nsresult aReason)
 {
-  LOG(("OOO CloseWithStatus [this=%x reason=%x]\n", this, aReason));
+  LOG(("OOO CloseWithStatus [this=%p reason=%" PRIx32 "]\n",
+       this, static_cast<uint32_t>(aReason)));
 
   if (NS_SUCCEEDED(aReason)) {
     aReason = NS_BASE_STREAM_CLOSED;
   }
 
   // input stream may remain open
   mPipe->OnPipeException(aReason, true);
   return NS_OK;
@@ -1766,17 +1770,17 @@ nsPipeOutputStream::Close()
 }
 
 NS_IMETHODIMP
 nsPipeOutputStream::WriteSegments(nsReadSegmentFun aReader,
                                   void* aClosure,
                                   uint32_t aCount,
                                   uint32_t* aWriteCount)
 {
-  LOG(("OOO WriteSegments [this=%x count=%u]\n", this, aCount));
+  LOG(("OOO WriteSegments [this=%p count=%u]\n", this, aCount));
 
   nsresult rv = NS_OK;
 
   char* segment;
   uint32_t segmentLen;
 
   *aWriteCount = 0;
   while (aCount) {
@@ -1893,17 +1897,17 @@ nsPipeOutputStream::IsNonBlocking(bool* 
 }
 
 NS_IMETHODIMP
 nsPipeOutputStream::AsyncWait(nsIOutputStreamCallback* aCallback,
                               uint32_t aFlags,
                               uint32_t aRequestedCount,
                               nsIEventTarget* aTarget)
 {
-  LOG(("OOO AsyncWait [this=%x]\n", this));
+  LOG(("OOO AsyncWait [this=%p]\n", this));
 
   nsPipeEvents pipeEvents;
   {
     ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
 
     // replace a pending callback
     mCallback = nullptr;
     mCallbackFlags = 0;
--- a/xpcom/io/nsStorageStream.cpp
+++ b/xpcom/io/nsStorageStream.cpp
@@ -133,17 +133,17 @@ nsStorageStream::Close()
   // needed to contain the data, so as to conserve memory.
   if (segmentOffset) {
     mSegmentedBuffer->ReallocLastSegment(segmentOffset);
   }
 
   mWriteCursor = 0;
   mSegmentEnd = 0;
 
-  LOG(("nsStorageStream [%p] Close mWriteCursor=%x mSegmentEnd=%x\n",
+  LOG(("nsStorageStream [%p] Close mWriteCursor=%p mSegmentEnd=%p\n",
        this, mWriteCursor, mSegmentEnd));
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsStorageStream::Flush()
 {
@@ -160,17 +160,17 @@ nsStorageStream::Write(const char* aBuff
   if (NS_WARN_IF(!mSegmentedBuffer)) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   const char* readCursor;
   uint32_t count, availableInSegment, remaining;
   nsresult rv = NS_OK;
 
-  LOG(("nsStorageStream [%p] Write mWriteCursor=%x mSegmentEnd=%x aCount=%d\n",
+  LOG(("nsStorageStream [%p] Write mWriteCursor=%p mSegmentEnd=%p aCount=%d\n",
        this, mWriteCursor, mSegmentEnd, aCount));
 
   remaining = aCount;
   readCursor = aBuffer;
   // If no segments have been created yet, create one even if we don't have
   // to write any data; this enables creating an input stream which reads from
   // the very end of the data for any amount of data in the stream (i.e.
   // this stream contains N bytes of data and newInputStream(N) is called),
@@ -185,34 +185,34 @@ nsStorageStream::Write(const char* aBuff
       if (!mWriteCursor) {
         mSegmentEnd = 0;
         rv = NS_ERROR_OUT_OF_MEMORY;
         goto out;
       }
       mLastSegmentNum++;
       mSegmentEnd = mWriteCursor + mSegmentSize;
       availableInSegment = mSegmentEnd - mWriteCursor;
-      LOG(("nsStorageStream [%p] Write (new seg) mWriteCursor=%x mSegmentEnd=%x\n",
+      LOG(("nsStorageStream [%p] Write (new seg) mWriteCursor=%p mSegmentEnd=%p\n",
            this, mWriteCursor, mSegmentEnd));
     }
 
     count = XPCOM_MIN(availableInSegment, remaining);
     memcpy(mWriteCursor, readCursor, count);
     remaining -= count;
     readCursor += count;
     mWriteCursor += count;
-    LOG(("nsStorageStream [%p] Writing mWriteCursor=%x mSegmentEnd=%x count=%d\n",
+    LOG(("nsStorageStream [%p] Writing mWriteCursor=%p mSegmentEnd=%p count=%d\n",
          this, mWriteCursor, mSegmentEnd, count));
   }
 
 out:
   *aNumWritten = aCount - remaining;
   mLogicalLength += *aNumWritten;
 
-  LOG(("nsStorageStream [%p] Wrote mWriteCursor=%x mSegmentEnd=%x numWritten=%d\n",
+  LOG(("nsStorageStream [%p] Wrote mWriteCursor=%p mSegmentEnd=%p numWritten=%d\n",
        this, mWriteCursor, mSegmentEnd, *aNumWritten));
   return rv;
 }
 
 NS_IMETHODIMP
 nsStorageStream::WriteFrom(nsIInputStream* aInStr, uint32_t aCount,
                            uint32_t* aResult)
 {
@@ -297,17 +297,17 @@ nsStorageStream::Seek(int32_t aPosition)
 
   // Seeking backwards in the write stream results in truncation
   SetLength(aPosition);
 
   // Special handling for seek to start-of-buffer
   if (aPosition == 0) {
     mWriteCursor = 0;
     mSegmentEnd = 0;
-    LOG(("nsStorageStream [%p] Seek mWriteCursor=%x mSegmentEnd=%x\n",
+    LOG(("nsStorageStream [%p] Seek mWriteCursor=%p mSegmentEnd=%p\n",
          this, mWriteCursor, mSegmentEnd));
     return NS_OK;
   }
 
   // Segment may have changed, so reset pointers
   mWriteCursor = mSegmentedBuffer->GetSegment(mLastSegmentNum);
   NS_ASSERTION(mWriteCursor, "null mWriteCursor");
   mSegmentEnd = mWriteCursor + mSegmentSize;
@@ -317,17 +317,17 @@ nsStorageStream::Seek(int32_t aPosition)
   // case we need to be pointing at the end of the last segment.
   int32_t segmentOffset = SegOffset(aPosition);
   if (segmentOffset == 0 && (SegNum(aPosition) > (uint32_t) mLastSegmentNum)) {
     mWriteCursor = mSegmentEnd;
   } else {
     mWriteCursor += segmentOffset;
   }
 
-  LOG(("nsStorageStream [%p] Seek mWriteCursor=%x mSegmentEnd=%x\n",
+  LOG(("nsStorageStream [%p] Seek mWriteCursor=%p mSegmentEnd=%p\n",
        this, mWriteCursor, mSegmentEnd));
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 // There can be many nsStorageInputStreams for a single nsStorageStream
 class nsStorageInputStream final