Bug 1714307 - Autofix static-analysis warnings in netwerk/ r=necko-reviewers,kershaw
☠☠ backed out by ffa25be65666 ☠ ☠
authorValentin Gosu <valentin.gosu@gmail.com>
Fri, 04 Jun 2021 10:00:55 +0000
changeset 581925 c4b44c4ef15b25c1c6e390642f1276ace17c6c09
parent 581924 b8f309a3591241763a7283dd7f057cbe6b3f4bb3
child 581926 ffa25be6566690525f7bc42a01ac9060fe78da30
push id38514
push userabutkovits@mozilla.com
push dateFri, 04 Jun 2021 15:42:19 +0000
treeherdermozilla-central@963df76dc655 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnecko-reviewers, kershaw
bugs1714307
milestone91.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1714307 - Autofix static-analysis warnings in netwerk/ r=necko-reviewers,kershaw Differential Revision: https://phabricator.services.mozilla.com/D116701
netwerk/base/Dashboard.cpp
netwerk/base/EventTokenBucket.cpp
netwerk/base/EventTokenBucket.h
netwerk/base/IOActivityMonitor.h
netwerk/base/LoadContextInfo.h
netwerk/base/LoadInfo.cpp
netwerk/base/LoadInfo.h
netwerk/base/MemoryDownloader.h
netwerk/base/NetworkConnectivityService.cpp
netwerk/base/NetworkDataCountLayer.cpp
netwerk/base/NetworkInfoServiceImpl.h
netwerk/base/NetworkInfoServiceLinux.cpp
netwerk/base/Predictor.cpp
netwerk/base/Predictor.h
netwerk/base/ProxyAutoConfig.cpp
netwerk/base/RequestContextService.cpp
netwerk/base/SSLTokensCache.h
netwerk/base/SimpleBuffer.h
netwerk/base/SimpleChannel.h
netwerk/base/ThrottleQueue.cpp
netwerk/base/ThrottleQueue.h
netwerk/base/nsBaseChannel.cpp
netwerk/base/nsBaseChannel.h
netwerk/base/nsDirectoryIndexStream.h
netwerk/base/nsFileStreams.cpp
netwerk/base/nsFileStreams.h
netwerk/base/nsIOService.cpp
netwerk/base/nsIOService.h
netwerk/base/nsIncrementalDownload.cpp
netwerk/base/nsInputStreamPump.cpp
netwerk/base/nsInputStreamPump.h
netwerk/base/nsLoadGroup.cpp
netwerk/base/nsMIMEInputStream.cpp
netwerk/base/nsMediaFragmentURIParser.cpp
netwerk/base/nsNetUtil.cpp
netwerk/base/nsNetUtil.h
netwerk/base/nsPACMan.cpp
netwerk/base/nsPACMan.h
netwerk/base/nsPreloadedStream.cpp
netwerk/base/nsProtocolProxyService.cpp
netwerk/base/nsProtocolProxyService.h
netwerk/base/nsServerSocket.cpp
netwerk/base/nsServerSocket.h
netwerk/base/nsSimpleURI.h
netwerk/base/nsSocketTransport2.cpp
netwerk/base/nsSocketTransport2.h
netwerk/base/nsSocketTransportService2.cpp
netwerk/base/nsSocketTransportService2.h
netwerk/base/nsStandardURL.h
netwerk/base/nsStreamListenerTee.cpp
netwerk/base/nsStreamTransportService.cpp
netwerk/base/nsUDPSocket.cpp
netwerk/base/nsURLHelper.cpp
netwerk/base/nsURLHelper.h
netwerk/base/nsURLHelperUnix.cpp
netwerk/base/nsURLParsers.cpp
netwerk/build/nsNetModule.cpp
netwerk/cache/nsDeleteDir.cpp
netwerk/cache/nsDeleteDir.h
netwerk/cache2/CacheEntry.cpp
netwerk/cache2/CacheEntry.h
netwerk/cache2/CacheFile.cpp
netwerk/cache2/CacheFileChunk.cpp
netwerk/cache2/CacheFileChunk.h
netwerk/cache2/CacheFileContextEvictor.cpp
netwerk/cache2/CacheFileContextEvictor.h
netwerk/cache2/CacheFileIOManager.cpp
netwerk/cache2/CacheFileIOManager.h
netwerk/cache2/CacheFileInputStream.cpp
netwerk/cache2/CacheFileMetadata.cpp
netwerk/cache2/CacheFileMetadata.h
netwerk/cache2/CacheFileOutputStream.cpp
netwerk/cache2/CacheFileUtils.cpp
netwerk/cache2/CacheFileUtils.h
netwerk/cache2/CacheHashUtils.cpp
netwerk/cache2/CacheHashUtils.h
netwerk/cache2/CacheIOThread.cpp
netwerk/cache2/CacheIOThread.h
netwerk/cache2/CacheIndex.cpp
netwerk/cache2/CacheIndex.h
netwerk/cache2/CacheIndexContextIterator.cpp
netwerk/cache2/CacheIndexIterator.cpp
netwerk/cache2/CacheLog.cpp
netwerk/cache2/CacheObserver.cpp
netwerk/cache2/CacheStorage.h
netwerk/cache2/CacheStorageService.cpp
netwerk/cache2/CacheStorageService.h
netwerk/cookie/CookieCommons.cpp
netwerk/cookie/CookiePersistentStorage.cpp
netwerk/cookie/CookieService.cpp
netwerk/cookie/CookieServiceParent.cpp
netwerk/cookie/CookieStorage.cpp
netwerk/cookie/CookieStorage.h
netwerk/ipc/DocumentLoadListener.h
netwerk/ipc/InputChannelThrottleQueueParent.cpp
netwerk/ipc/SocketProcessBridgeChild.h
netwerk/ipc/SocketProcessChild.cpp
netwerk/ipc/SocketProcessImpl.h
netwerk/ipc/SocketProcessParent.h
netwerk/mime/nsMIMEHeaderParamImpl.cpp
netwerk/protocol/about/nsAboutCache.h
netwerk/protocol/about/nsAboutCacheEntry.cpp
netwerk/protocol/about/nsAboutProtocolHandler.cpp
netwerk/protocol/about/nsAboutProtocolHandler.h
netwerk/protocol/file/nsFileChannel.cpp
netwerk/protocol/file/nsFileProtocolHandler.cpp
netwerk/protocol/http/ASpdySession.h
netwerk/protocol/http/AlternateServices.h
netwerk/protocol/http/BackgroundChannelRegistrar.h
netwerk/protocol/http/ConnectionDiagnostics.cpp
netwerk/protocol/http/ConnectionEntry.cpp
netwerk/protocol/http/DelayHttpChannelQueue.cpp
netwerk/protocol/http/DnsAndConnectSocket.cpp
netwerk/protocol/http/Http2Compression.cpp
netwerk/protocol/http/Http2Compression.h
netwerk/protocol/http/Http2Push.cpp
netwerk/protocol/http/Http2Push.h
netwerk/protocol/http/Http2Session.cpp
netwerk/protocol/http/Http2Session.h
netwerk/protocol/http/Http2Stream.cpp
netwerk/protocol/http/Http2Stream.h
netwerk/protocol/http/Http3Session.cpp
netwerk/protocol/http/Http3Session.h
netwerk/protocol/http/HttpBackgroundChannelChild.h
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/HttpChannelChild.h
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/HttpChannelParent.h
netwerk/protocol/http/HttpConnectionMgrChild.cpp
netwerk/protocol/http/HttpConnectionMgrChild.h
netwerk/protocol/http/HttpConnectionUDP.cpp
netwerk/protocol/http/HttpConnectionUDP.h
netwerk/protocol/http/HttpLog.h
netwerk/protocol/http/HttpTransactionChild.h
netwerk/protocol/http/HttpTransactionParent.cpp
netwerk/protocol/http/HttpTransactionParent.h
netwerk/protocol/http/SpeculativeTransaction.cpp
netwerk/protocol/http/SpeculativeTransaction.h
netwerk/protocol/http/TRRServiceChannel.cpp
netwerk/protocol/http/TunnelUtils.cpp
netwerk/protocol/http/TunnelUtils.h
netwerk/protocol/http/nsAHttpConnection.h
netwerk/protocol/http/nsCORSListenerProxy.cpp
netwerk/protocol/http/nsCORSListenerProxy.h
netwerk/protocol/http/nsHttp.h
netwerk/protocol/http/nsHttpActivityDistributor.cpp
netwerk/protocol/http/nsHttpActivityDistributor.h
netwerk/protocol/http/nsHttpChannel.h
netwerk/protocol/http/nsHttpChunkedDecoder.cpp
netwerk/protocol/http/nsHttpChunkedDecoder.h
netwerk/protocol/http/nsHttpConnection.cpp
netwerk/protocol/http/nsHttpConnection.h
netwerk/protocol/http/nsHttpConnectionInfo.h
netwerk/protocol/http/nsHttpConnectionMgr.cpp
netwerk/protocol/http/nsHttpConnectionMgr.h
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpHandler.h
netwerk/protocol/http/nsHttpTransaction.h
netwerk/protocol/http/nsServerTiming.h
netwerk/protocol/res/SubstitutingProtocolHandler.h
netwerk/protocol/viewsource/nsViewSourceChannel.cpp
netwerk/protocol/websocket/BaseWebSocketChannel.cpp
netwerk/protocol/websocket/WebSocketChannel.cpp
netwerk/protocol/websocket/WebSocketChannel.h
netwerk/protocol/websocket/WebSocketChannelChild.h
netwerk/protocol/websocket/WebSocketEventService.cpp
netwerk/protocol/websocket/WebSocketEventService.h
netwerk/protocol/websocket/WebSocketFrame.cpp
netwerk/protocol/websocket/WebSocketFrame.h
netwerk/socket/nsSOCKSIOLayer.cpp
netwerk/socket/nsSOCKSSocketProvider.cpp
netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
netwerk/streamconv/converters/mozTXTToHTMLConv.h
netwerk/streamconv/converters/nsDirIndexParser.cpp
netwerk/streamconv/converters/nsDirIndexParser.h
netwerk/streamconv/converters/nsHTTPCompressConv.cpp
netwerk/streamconv/converters/nsHTTPCompressConv.h
netwerk/streamconv/converters/nsIndexedToHTML.cpp
netwerk/streamconv/converters/nsMultiMixedConv.cpp
netwerk/streamconv/converters/nsMultiMixedConv.h
netwerk/streamconv/converters/nsUnknownDecoder.cpp
netwerk/streamconv/converters/nsUnknownDecoder.h
netwerk/streamconv/nsStreamConverterService.cpp
netwerk/system/linux/nsNetworkLinkService.cpp
netwerk/test/gtest/TestCookie.cpp
netwerk/test/gtest/TestMozURL.cpp
netwerk/test/gtest/TestPACMan.cpp
netwerk/test/gtest/TestServerTimingHeader.cpp
netwerk/test/gtest/TestSocketTransportService.cpp
netwerk/test/gtest/TestStandardURL.cpp
netwerk/test/gtest/TestUDPSocket.cpp
netwerk/url-classifier/AsyncUrlChannelClassifier.cpp
netwerk/url-classifier/UrlClassifierCommon.cpp
netwerk/url-classifier/UrlClassifierFeatureBase.cpp
netwerk/url-classifier/UrlClassifierFeatureFactory.h
netwerk/url-classifier/UrlClassifierFeatureFlash.h
netwerk/url-classifier/UrlClassifierFeaturePhishingProtection.h
netwerk/url-classifier/nsChannelClassifier.cpp
netwerk/wifi/nsWifiAccessPoint.h
netwerk/wifi/nsWifiMonitor.cpp
--- a/netwerk/base/Dashboard.cpp
+++ b/netwerk/base/Dashboard.cpp
@@ -1143,20 +1143,20 @@ nsresult Dashboard::TestNewConnection(Co
     return rv;
   }
 
   connectionData->StartTimer(connectionData->mTimeout);
 
   return rv;
 }
 
-typedef struct {
+using ErrorEntry = struct {
   nsresult key;
   const char* error;
-} ErrorEntry;
+};
 
 #undef ERROR
 #define ERROR(key, val) \
   { key, #key }
 
 ErrorEntry socketTransportStatuses[] = {
     ERROR(NS_NET_STATUS_RESOLVING_HOST, FAILURE(3)),
     ERROR(NS_NET_STATUS_RESOLVED_HOST, FAILURE(11)),
--- a/netwerk/base/EventTokenBucket.cpp
+++ b/netwerk/base/EventTokenBucket.cpp
@@ -85,18 +85,19 @@ EventTokenBucket::EventTokenBucket(uint3
 {
   mLastUpdate = TimeStamp::Now();
 
   MOZ_ASSERT(NS_IsMainThread());
 
   nsresult rv;
   nsCOMPtr<nsIEventTarget> sts;
   nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
-  if (NS_SUCCEEDED(rv))
+  if (NS_SUCCEEDED(rv)) {
     sts = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
+  }
   if (NS_SUCCEEDED(rv)) mTimer = NS_NewTimer(sts);
   SetRate(eventsPerSecond, burstSize);
 }
 
 EventTokenBucket::~EventTokenBucket() {
   SOCKET_LOG(
       ("EventTokenBucket::dtor %p events=%zu\n", this, mEvents.GetSize()));
 
@@ -256,32 +257,34 @@ void EventTokenBucket::DispatchEvents() 
 
 #ifdef XP_WIN
   if (!mEvents.GetSize()) WantNormalTimers();
 #endif
 }
 
 void EventTokenBucket::UpdateTimer() {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
-  if (mTimerArmed || mPaused || mStopped || !mEvents.GetSize() || !mTimer)
+  if (mTimerArmed || mPaused || mStopped || !mEvents.GetSize() || !mTimer) {
     return;
+  }
 
   if (mCredit >= mUnitCost) return;
 
   // determine the time needed to wait to accumulate enough credits to admit
   // one more event and set the timer for that point. Always round it
   // up because firing early doesn't help.
   //
   uint64_t deficit = mUnitCost - mCredit;
   uint64_t msecWait = (deficit + (kUsecPerMsec - 1)) / kUsecPerMsec;
 
-  if (msecWait < 4)  // minimum wait
+  if (msecWait < 4) {  // minimum wait
     msecWait = 4;
-  else if (msecWait > 60000)  // maximum wait
+  } else if (msecWait > 60000) {  // maximum wait
     msecWait = 60000;
+  }
 
 #ifdef XP_WIN
   FineGrainTimers();
 #endif
 
   SOCKET_LOG(
       ("EventTokenBucket::UpdateTimer %p for %" PRIu64 "ms\n", this, msecWait));
   nsresult rv = mTimer->InitWithCallback(this, static_cast<uint32_t>(msecWait),
--- a/netwerk/base/EventTokenBucket.h
+++ b/netwerk/base/EventTokenBucket.h
@@ -98,17 +98,17 @@ class EventTokenBucket : public nsITimer
 
  private:
   virtual ~EventTokenBucket();
   void CleanupTimers();
 
   friend class RunNotifyEvent;
   friend class SetTimerEvent;
 
-  bool TryImmediateDispatch(TokenBucketCancelable* event);
+  bool TryImmediateDispatch(TokenBucketCancelable* cancelable);
   void SetRate(uint32_t eventsPerSecond, uint32_t burstSize);
 
   void DispatchEvents();
   void UpdateTimer();
   void UpdateCredits();
 
   const static uint64_t kUsecPerSec = 1000000;
   const static uint64_t kUsecPerMsec = 1000;
--- a/netwerk/base/IOActivityMonitor.h
+++ b/netwerk/base/IOActivityMonitor.h
@@ -24,17 +24,17 @@ namespace mozilla {
 namespace dom {
 class Promise;
 }
 
 namespace net {
 
 #define IO_ACTIVITY_ENABLED_PREF "io.activity.enabled"
 
-typedef nsTHashMap<nsCStringHashKey, dom::IOActivityDataDictionary> Activities;
+using Activities = nsTHashMap<nsCStringHashKey, dom::IOActivityDataDictionary>;
 
 // IOActivityMonitor has several roles:
 // - maintains an IOActivity per resource and updates it
 // - sends a dump of the activities to a promise via RequestActivities
 class IOActivityMonitor final : public nsINamed {
  public:
   IOActivityMonitor();
 
--- a/netwerk/base/LoadContextInfo.h
+++ b/netwerk/base/LoadContextInfo.h
@@ -36,18 +36,17 @@ class LoadContextInfoFactory : public ns
       NS_DECL_NSILOADCONTEXTINFOFACTORY
 };
 
 LoadContextInfo* GetLoadContextInfo(nsIChannel* aChannel);
 
 LoadContextInfo* GetLoadContextInfo(nsILoadContext* aLoadContext,
                                     bool aIsAnonymous);
 
-LoadContextInfo* GetLoadContextInfo(nsIDOMWindow* aLoadContext,
-                                    bool aIsAnonymous);
+LoadContextInfo* GetLoadContextInfo(nsIDOMWindow* aWindow, bool aIsAnonymous);
 
 LoadContextInfo* GetLoadContextInfo(nsILoadContextInfo* aInfo);
 
 LoadContextInfo* GetLoadContextInfo(bool const aIsAnonymous,
                                     OriginAttributes const& aOriginAttributes);
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/base/LoadInfo.cpp
+++ b/netwerk/base/LoadInfo.cpp
@@ -827,17 +827,17 @@ nsIPrincipal* LoadInfo::FindPrincipalToI
     return mPrincipalToInherit;
   }
 
   nsCOMPtr<nsIURI> uri = mResultPrincipalURI;
   if (!uri) {
     Unused << aChannel->GetOriginalURI(getter_AddRefs(uri));
   }
 
-  auto prin = BasePrincipal::Cast(mTriggeringPrincipal);
+  auto* prin = BasePrincipal::Cast(mTriggeringPrincipal);
   return prin->PrincipalToInherit(uri);
 }
 
 nsIPrincipal* LoadInfo::GetSandboxedLoadingPrincipal() {
   if (!(mSandboxFlags & SANDBOXED_ORIGIN)) {
     return nullptr;
   }
 
--- a/netwerk/base/LoadInfo.h
+++ b/netwerk/base/LoadInfo.h
@@ -43,17 +43,17 @@ namespace ipc {
 // we have to forward declare that function so we can use it as a friend.
 nsresult LoadInfoArgsToLoadInfo(
     const Maybe<mozilla::net::LoadInfoArgs>& aLoadInfoArgs,
     nsINode* aCspToInheritLoadingContext, net::LoadInfo** outLoadInfo);
 }  // namespace ipc
 
 namespace net {
 
-typedef nsTArray<nsCOMPtr<nsIRedirectHistoryEntry>> RedirectHistoryArray;
+using RedirectHistoryArray = nsTArray<nsCOMPtr<nsIRedirectHistoryEntry>>;
 
 /**
  * Class that provides an nsILoadInfo implementation.
  */
 class LoadInfo final : public nsILoadInfo {
   template <typename T, typename... Args>
   friend already_AddRefed<T> mozilla::MakeAndAddRef(Args&&... aArgs);
 
@@ -275,17 +275,17 @@ class LoadInfo final : public nsILoadInf
   Maybe<mozilla::dom::ClientInfo> mInitialClientInfo;
   Maybe<mozilla::dom::ServiceWorkerDescriptor> mController;
   RefPtr<mozilla::dom::PerformanceStorage> mPerformanceStorage;
 
   nsWeakPtr mLoadingContext;
   nsWeakPtr mContextForTopLevelLoad;
   nsSecurityFlags mSecurityFlags;
   uint32_t mSandboxFlags;
-  uint32_t mTriggeringSandboxFlags;
+  uint32_t mTriggeringSandboxFlags = 0;
   nsContentPolicyType mInternalContentPolicyType;
   LoadTainting mTainting = LoadTainting::Basic;
   bool mBlockAllMixedContent = false;
   bool mUpgradeInsecureRequests = false;
   bool mBrowserUpgradeInsecureRequests = false;
   bool mBrowserDidUpgradeInsecureRequests = false;
   bool mBrowserWouldUpgradeInsecureRequests = false;
   bool mForceAllowDataURI = false;
--- a/netwerk/base/MemoryDownloader.h
+++ b/netwerk/base/MemoryDownloader.h
@@ -24,17 +24,17 @@ namespace mozilla {
 namespace net {
 
 class MemoryDownloader final : public nsIStreamListener {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
 
-  typedef mozilla::UniquePtr<FallibleTArray<uint8_t>> Data;
+  using Data = mozilla::UniquePtr<FallibleTArray<uint8_t>>;
 
   class IObserver : public nsISupports {
    public:
     // Note: aData may be null if (and only if) aStatus indicates failure.
     virtual void OnDownloadComplete(MemoryDownloader* aDownloader,
                                     nsIRequest* aRequest, nsISupports* aCtxt,
                                     nsresult aStatus, Data aData) = 0;
   };
--- a/netwerk/base/NetworkConnectivityService.cpp
+++ b/netwerk/base/NetworkConnectivityService.cpp
@@ -131,23 +131,19 @@ already_AddRefed<AddrInfo> NetworkConnec
 }
 
 // Returns true if a prefix was read and saved to the argument
 static inline bool NAT64PrefixFromPref(NetAddr* prefix) {
   nsAutoCString nat64PrefixPref;
 
   nsresult rv = Preferences::GetCString(
       "network.connectivity-service.nat64-prefix", nat64PrefixPref);
-  if (NS_FAILED(rv) || nat64PrefixPref.IsEmpty() ||
-      NS_FAILED(prefix->InitFromString(nat64PrefixPref)) ||
-      prefix->raw.family != PR_AF_INET6) {
-    return false;
-  }
-
-  return true;
+  return !(NS_FAILED(rv) || nat64PrefixPref.IsEmpty() ||
+           NS_FAILED(prefix->InitFromString(nat64PrefixPref)) ||
+           prefix->raw.family != PR_AF_INET6);
 }
 
 static inline bool NAT64PrefixCompare(const NetAddr& prefix1,
                                       const NetAddr& prefix2) {
   // Compare the first 96 bits as 64 + 32
   return prefix1.inet6.ip.u64[0] == prefix2.inet6.ip.u64[0] &&
          prefix1.inet6.ip.u32[2] == prefix2.inet6.ip.u32[2];
 }
--- a/netwerk/base/NetworkDataCountLayer.cpp
+++ b/netwerk/base/NetworkDataCountLayer.cpp
@@ -13,17 +13,17 @@ namespace mozilla {
 namespace net {
 
 static PRDescIdentity sNetworkDataCountLayerIdentity;
 static PRIOMethods sNetworkDataCountLayerMethods;
 static PRIOMethods* sNetworkDataCountLayerMethodsPtr = nullptr;
 
 class NetworkDataCountSecret {
  public:
-  NetworkDataCountSecret() {}
+  NetworkDataCountSecret() = default;
 
   uint64_t mSentBytes = 0;
   uint64_t mReceivedBytes = 0;
 };
 
 static PRInt32 NetworkDataCountSend(PRFileDesc* fd, const void* buf,
                                     PRInt32 amount, PRIntn flags,
                                     PRIntervalTime timeout) {
--- a/netwerk/base/NetworkInfoServiceImpl.h
+++ b/netwerk/base/NetworkInfoServiceImpl.h
@@ -5,14 +5,14 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsString.h"
 #include "nsTHashMap.h"
 
 namespace mozilla {
 namespace net {
 
-typedef nsTHashMap<nsCStringHashKey, nsCString> AddrMapType;
+using AddrMapType = nsTHashMap<nsCStringHashKey, nsCString>;
 
 nsresult DoListAddresses(AddrMapType& aAddrMap);
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/base/NetworkInfoServiceLinux.cpp
+++ b/netwerk/base/NetworkInfoServiceLinux.cpp
@@ -14,28 +14,28 @@
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/ScopeExit.h"
 
 #include "NetworkInfoServiceImpl.h"
 
 namespace mozilla::net {
 
-static nsresult ListInterfaceAddresses(int aFd, const char* aIface,
+static nsresult ListInterfaceAddresses(int aFd, const char* aInterface,
                                        AddrMapType& aAddrMap);
 
 nsresult DoListAddresses(AddrMapType& aAddrMap) {
   int fd = socket(AF_INET, SOCK_DGRAM, 0);
   if (fd < 0) {
     return NS_ERROR_FAILURE;
   }
 
   auto autoCloseSocket = MakeScopeExit([&] { close(fd); });
 
-  struct ifconf ifconf;
+  struct ifconf ifconf {};
   /* 16k of space should be enough to list all interfaces.  Worst case, if it's
    * not then we will error out and fail to list addresses.  This should only
    * happen on pathological machines with way too many interfaces.
    */
   char buf[16384];
 
   ifconf.ifc_len = sizeof(buf);
   ifconf.ifc_buf = buf;
@@ -56,17 +56,17 @@ nsresult DoListAddresses(AddrMapType& aA
     i += len;
   }
 
   return NS_OK;
 }
 
 static nsresult ListInterfaceAddresses(int aFd, const char* aInterface,
                                        AddrMapType& aAddrMap) {
-  struct ifreq ifreq;
+  struct ifreq ifreq {};
   memset(&ifreq, 0, sizeof(struct ifreq));
   strncpy(ifreq.ifr_name, aInterface, IFNAMSIZ - 1);
   if (ioctl(aFd, SIOCGIFADDR, &ifreq) != 0) {
     return NS_ERROR_FAILURE;
   }
 
   char host[128];
   switch (ifreq.ifr_addr.sa_family) {
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -566,17 +566,17 @@ Predictor::PredictNative(nsIURI* targetU
       uriKey = mStartupURI;
       originKey = mStartupURI;
       break;
     default:
       PREDICTOR_LOG(("    invalid reason"));
       return NS_ERROR_INVALID_ARG;
   }
 
-  Predictor::Reason argReason;
+  Predictor::Reason argReason{};
   argReason.mPredict = reason;
 
   // First we open the regular cache entry, to ensure we don't gum up the works
   // waiting on the less-important predictor-only cache entry
   RefPtr<Predictor::Action> uriAction = new Predictor::Action(
       Predictor::Action::IS_FULL_URI, Predictor::Action::DO_PREDICT, argReason,
       targetURI, nullptr, verifier, this);
   nsAutoCString uriKeyStr;
@@ -722,17 +722,17 @@ bool Predictor::PredictForPageload(nsICa
 
   rv = entry->GetLoadContextInfo(getter_AddRefs(lci));
   NS_ENSURE_SUCCESS(rv, false);
 
   nsCOMPtr<nsIURI> redirectURI;
   if (WouldRedirect(entry, loadCount, lastLoad, globalDegradation,
                     getter_AddRefs(redirectURI))) {
     mPreconnects.AppendElement(redirectURI);
-    Predictor::Reason reason;
+    Predictor::Reason reason{};
     reason.mPredict = nsINetworkPredictor::PREDICT_LOAD;
     RefPtr<Predictor::Action> redirectAction = new Predictor::Action(
         Predictor::Action::IS_FULL_URI, Predictor::Action::DO_PREDICT, reason,
         redirectURI, nullptr, verifier, this, stackCount + 1);
     nsAutoCString redirectUriString;
     redirectURI->GetAsciiSpec(redirectUriString);
 
     nsCOMPtr<nsICacheStorage> cacheDiskStorage;
@@ -1323,17 +1323,17 @@ Predictor::LearnNative(nsIURI* targetURI
     default:
       PREDICTOR_LOG(("    invalid reason"));
       return NS_ERROR_INVALID_ARG;
   }
 
   Telemetry::AutoCounter<Telemetry::PREDICTOR_LEARN_ATTEMPTS> learnAttempts;
   ++learnAttempts;
 
-  Predictor::Reason argReason;
+  Predictor::Reason argReason{};
   argReason.mLearn = reason;
 
   // We always open the full uri (general cache) entry first, so we don't gum up
   // the works waiting on predictor-only entries to open
   RefPtr<Predictor::Action> uriAction = new Predictor::Action(
       Predictor::Action::IS_FULL_URI, Predictor::Action::DO_LEARN, argReason,
       targetURI, sourceURI, nullptr, this);
   nsAutoCString uriKeyStr, targetUriStr, sourceUriStr;
--- a/netwerk/base/Predictor.h
+++ b/netwerk/base/Predictor.h
@@ -59,17 +59,17 @@ class Predictor final : public nsINetwor
   static nsresult Create(nsISupports* outer, const nsIID& iid, void** result);
 
   // Used to update whether a particular URI was cacheable or not.
   // sourceURI and targetURI are the same as the arguments to Learn
   // and httpStatus is the status code we got while loading targetURI.
   static void UpdateCacheability(nsIURI* sourceURI, nsIURI* targetURI,
                                  uint32_t httpStatus,
                                  nsHttpRequestHead& requestHead,
-                                 nsHttpResponseHead* reqponseHead,
+                                 nsHttpResponseHead* responseHead,
                                  nsILoadContextInfo* lci, bool isTracking);
 
  private:
   virtual ~Predictor();
 
   // Stores callbacks for a child process predictor (for test purposes)
   nsCOMPtr<nsINetworkPredictorVerifier> mChildVerifier;
 
--- a/netwerk/base/ProxyAutoConfig.cpp
+++ b/netwerk/base/ProxyAutoConfig.cpp
@@ -372,18 +372,19 @@ static void PACLogToConsole(nsString& aM
 }
 
 // Javascript errors and warnings are logged to the main error console
 static void PACLogErrorOrWarning(const nsAString& aKind,
                                  JSErrorReport* aReport) {
   nsString formattedMessage(u"PAC Execution "_ns);
   formattedMessage += aKind;
   formattedMessage += u": "_ns;
-  if (aReport->message())
+  if (aReport->message()) {
     formattedMessage.Append(NS_ConvertUTF8toUTF16(aReport->message().c_str()));
+  }
   formattedMessage += u" ["_ns;
   formattedMessage.Append(aReport->linebuf(), aReport->linebufLength());
   formattedMessage += u"]"_ns;
   PACLogToConsole(formattedMessage);
 }
 
 static void PACWarningReporter(JSContext* aCx, JSErrorReport* aReport) {
   MOZ_ASSERT(aReport);
@@ -483,32 +484,29 @@ bool ProxyAutoConfig::ResolveAddress(con
     return false;
   });
 
   if (NS_FAILED(helper->mStatus)) {
     return false;
   }
 
   nsCOMPtr<nsIDNSAddrRecord> rec = do_QueryInterface(helper->mResponse);
-  if (!rec || NS_FAILED(rec->GetNextAddr(0, aNetAddr))) {
-    return false;
-  }
-
-  return true;
+  return !(!rec || NS_FAILED(rec->GetNextAddr(0, aNetAddr)));
 }
 
 static bool PACResolveToString(const nsCString& aHostName,
                                nsCString& aDottedDecimal,
                                unsigned int aTimeout) {
   NetAddr netAddr;
   if (!PACResolve(aHostName, &netAddr, aTimeout)) return false;
 
   char dottedDecimal[128];
-  if (!netAddr.ToStringBuffer(dottedDecimal, sizeof(dottedDecimal)))
+  if (!netAddr.ToStringBuffer(dottedDecimal, sizeof(dottedDecimal))) {
     return false;
+  }
 
   aDottedDecimal.Assign(dottedDecimal);
   return true;
 }
 
 // dnsResolve(host) javascript implementation
 static bool PACDnsResolve(JSContext* cx, unsigned int argc, JS::Value* vp) {
   JS::CallArgs args = CallArgsFromVp(argc, vp);
@@ -927,18 +925,19 @@ bool ProxyAutoConfig::SrcAddress(const N
     PR_Close(fd);
     return false;
   }
 
   PR_Close(fd);
 
   char dottedDecimal[128];
   if (PR_NetAddrToString(&localName, dottedDecimal, sizeof(dottedDecimal)) !=
-      PR_SUCCESS)
+      PR_SUCCESS) {
     return false;
+  }
 
   localAddress.Assign(dottedDecimal);
 
   return true;
 }
 
 // hostName is run through a dns lookup and then a udp socket is connected
 // to the result. If that all works, the local IP address of the socket is
--- a/netwerk/base/RequestContextService.cpp
+++ b/netwerk/base/RequestContextService.cpp
@@ -56,17 +56,17 @@ class RequestContext final : public nsIR
   void ScheduleUnblock();
   // Hard-reschedules the timer
   void RescheduleUntailTimer(TimeStamp const& now);
 
   uint64_t mID;
   Atomic<uint32_t> mBlockingTransactionCount;
   UniquePtr<SpdyPushCache> mSpdyCache;
 
-  typedef nsCOMPtr<nsIRequestTailUnblockCallback> PendingTailRequest;
+  using PendingTailRequest = nsCOMPtr<nsIRequestTailUnblockCallback>;
   // Number of known opened non-tailed requets
   uint32_t mNonTailRequests;
   // Queue of requests that have been tailed, when conditions are met
   // we call each of them to unblock and drop the reference
   nsTArray<PendingTailRequest> mTailQueue;
   // Loosly scheduled timer, never scheduled further to the future than
   // mUntailAt time
   nsCOMPtr<nsITimer> mUntailTimer;
--- a/netwerk/base/SSLTokensCache.h
+++ b/netwerk/base/SSLTokensCache.h
@@ -68,17 +68,17 @@ class SSLTokensCache : public nsIMemoryR
   uint32_t mCacheSize;  // Actual cache size in bytes
 
   class TokenCacheRecord {
    public:
     uint32_t Size() const;
     void Reset();
 
     nsCString mKey;
-    PRUint32 mExpirationTime;
+    PRUint32 mExpirationTime = 0;
     nsTArray<uint8_t> mToken;
     SessionCacheInfo mSessionCacheInfo;
   };
 
   nsClassHashtable<nsCStringHashKey, TokenCacheRecord> mTokenCacheRecords;
   nsTArray<TokenCacheRecord*> mExpirationArray;
 };
 
--- a/netwerk/base/SimpleBuffer.h
+++ b/netwerk/base/SimpleBuffer.h
@@ -21,27 +21,27 @@ namespace net {
 
 class SimpleBufferPage : public LinkedListElement<SimpleBufferPage> {
  public:
   SimpleBufferPage() : mReadOffset(0), mWriteOffset(0) {}
   static const size_t kSimpleBufferPageSize = 32000;
 
  private:
   friend class SimpleBuffer;
-  char mBuffer[kSimpleBufferPageSize];
+  char mBuffer[kSimpleBufferPageSize]{};
   size_t mReadOffset;
   size_t mWriteOffset;
 };
 
 class SimpleBuffer {
  public:
   SimpleBuffer();
   ~SimpleBuffer() = default;
 
-  nsresult Write(char* stc, size_t len);   // return OK or OUT_OF_MEMORY
+  nsresult Write(char* src, size_t len);   // return OK or OUT_OF_MEMORY
   size_t Read(char* dest, size_t maxLen);  // return bytes read
   size_t Available();
   void Clear();
 
  private:
   NS_DECL_OWNINGTHREAD
 
   nsresult mStatus;
--- a/netwerk/base/SimpleChannel.h
+++ b/netwerk/base/SimpleChannel.h
@@ -117,17 +117,18 @@ already_AddRefed<nsIChannel> NS_NewSimpl
  */
 template <typename T, typename F1, typename F2>
 inline already_AddRefed<nsIChannel> NS_NewSimpleChannel(
     nsIURI* aURI, nsILoadInfo* aLoadInfo, T* context, F1&& aStartAsyncRead,
     F2&& aOpenContentStream) {
   using namespace mozilla;
 
   auto callbacks = MakeUnique<net::SimpleChannelCallbacksImpl<F1, F2, T>>(
-      std::move(aStartAsyncRead), std::move(aOpenContentStream), context);
+      std::forward<F1>(aStartAsyncRead), std::forward<F2>(aOpenContentStream),
+      context);
 
   return net::NS_NewSimpleChannelInternal(aURI, aLoadInfo,
                                           std::move(callbacks));
 }
 
 template <typename T, typename F1>
 inline already_AddRefed<nsIChannel> NS_NewSimpleChannel(nsIURI* aURI,
                                                         nsILoadInfo* aLoadInfo,
@@ -135,13 +136,13 @@ inline already_AddRefed<nsIChannel> NS_N
                                                         F1&& aStartAsyncRead) {
   using namespace mozilla;
 
   auto openContentStream = [](bool async, nsIChannel* channel, T* context) {
     return Err(NS_ERROR_NOT_IMPLEMENTED);
   };
 
   return NS_NewSimpleChannel(aURI, aLoadInfo, context,
-                             std::move(aStartAsyncRead),
+                             std::forward<F1>(aStartAsyncRead),
                              std::move(openContentStream));
 }
 
 #endif  // SimpleChannel_h
--- a/netwerk/base/ThrottleQueue.cpp
+++ b/netwerk/base/ThrottleQueue.cpp
@@ -236,18 +236,19 @@ NS_IMPL_ISUPPORTS(ThrottleQueue, nsIInpu
 ThrottleQueue::ThrottleQueue()
     : mMeanBytesPerSecond(0),
       mMaxBytesPerSecond(0),
       mBytesProcessed(0),
       mTimerArmed(false) {
   nsresult rv;
   nsCOMPtr<nsIEventTarget> sts;
   nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
-  if (NS_SUCCEEDED(rv))
+  if (NS_SUCCEEDED(rv)) {
     sts = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
+  }
   if (NS_SUCCEEDED(rv)) mTimer = NS_NewTimer(sts);
 }
 
 ThrottleQueue::~ThrottleQueue() {
   if (mTimer && mTimerArmed) {
     mTimer->Cancel();
   }
   mTimer = nullptr;
@@ -345,17 +346,18 @@ ThrottleQueue::Notify(nsITimer* aTimer) 
 NS_IMETHODIMP
 ThrottleQueue::GetName(nsACString& aName) {
   aName.AssignLiteral("net::ThrottleQueue");
   return NS_OK;
 }
 
 void ThrottleQueue::QueueStream(ThrottleInputStream* aStream) {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
-  if (mAsyncEvents.IndexOf(aStream) == mAsyncEvents.NoIndex) {
+  if (mAsyncEvents.IndexOf(aStream) ==
+      nsTArray<RefPtr<mozilla::net::ThrottleInputStream>>::NoIndex) {
     mAsyncEvents.AppendElement(aStream);
 
     if (!mTimerArmed) {
       uint32_t ms = 1000;
       if (mReadEvents.Length() > 0) {
         TimeStamp t = mReadEvents[0].mTime + TimeDuration::FromSeconds(1);
         TimeStamp now = TimeStamp::Now();
 
--- a/netwerk/base/ThrottleQueue.h
+++ b/netwerk/base/ThrottleQueue.h
@@ -41,17 +41,17 @@ class ThrottleQueue : public nsIInputCha
   void DequeueStream(ThrottleInputStream* aStream);
 
  protected:
   ThrottleQueue();
   virtual ~ThrottleQueue();
 
   struct ThrottleEntry {
     TimeStamp mTime;
-    uint32_t mBytesRead;
+    uint32_t mBytesRead = 0;
   };
 
   nsTArray<ThrottleEntry> mReadEvents;
   uint32_t mMeanBytesPerSecond;
   uint32_t mMaxBytesPerSecond;
   uint64_t mBytesProcessed;
 
   nsTArray<RefPtr<ThrottleInputStream>> mAsyncEvents;
--- a/netwerk/base/nsBaseChannel.cpp
+++ b/netwerk/base/nsBaseChannel.cpp
@@ -641,18 +641,19 @@ nsBaseChannel::Open(nsIInputStream** aSt
 
   nsCOMPtr<nsIChannel> chan;
   rv = OpenContentStream(false, aStream, getter_AddRefs(chan));
   NS_ASSERTION(!chan || !*aStream, "Got both a channel and a stream?");
   if (NS_SUCCEEDED(rv) && chan) {
     rv = Redirect(chan, nsIChannelEventSink::REDIRECT_INTERNAL, false);
     if (NS_FAILED(rv)) return rv;
     rv = chan->Open(aStream);
-  } else if (rv == NS_ERROR_NOT_IMPLEMENTED)
+  } else if (rv == NS_ERROR_NOT_IMPLEMENTED) {
     return NS_ImplementChannelOpen(this, aStream);
+  }
 
   if (NS_SUCCEEDED(rv)) {
     mWasOpened = true;
     ClassifyURI();
   }
 
   return rv;
 }
@@ -818,40 +819,43 @@ nsBaseChannel::OnStartRequest(nsIRequest
     // sniffer. If the sniffer is not available for some reason, then we just
     // keep going as-is.
     if (NS_SUCCEEDED(mStatus) &&
         mContentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
       mPump->PeekStream(CallUnknownTypeSniffer, static_cast<nsIChannel*>(this));
     }
 
     // Now, the general type sniffers. Skip this if we have none.
-    if (mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS)
+    if (mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) {
       mPump->PeekStream(CallTypeSniffers, static_cast<nsIChannel*>(this));
+    }
   }
 
   SUSPEND_PUMP_FOR_SCOPE();
 
-  if (mListener)  // null in case of redirect
+  if (mListener) {  // null in case of redirect
     return mListener->OnStartRequest(this);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBaseChannel::OnStopRequest(nsIRequest* request, nsresult status) {
   // If both mStatus and status are failure codes, we keep mStatus as-is since
   // that is consistent with our GetStatus and Cancel methods.
   if (NS_SUCCEEDED(mStatus)) mStatus = status;
 
   // Cause Pending to return false.
   mPump = nullptr;
   mRequest = nullptr;
   mPumpingData = false;
 
-  if (mListener)  // null in case of redirect
+  if (mListener) {  // null in case of redirect
     mListener->OnStopRequest(this, mStatus);
+  }
   ChannelDone();
 
   // No need to suspend pump in this scope since we will not be receiving
   // any more events from it.
 
   if (mLoadGroup) mLoadGroup->RemoveRequest(this, nullptr, mStatus);
 
   // Drop notification callbacks to prevent cycles.
--- a/netwerk/base/nsBaseChannel.h
+++ b/netwerk/base/nsBaseChannel.h
@@ -207,17 +207,17 @@ class nsBaseChannel
   // The fromType and toType values are passed to nsIStreamConverterService's
   // AsyncConvertData method.  If invalidatesContentLength is true, then the
   // channel's content-length property will be assigned a value of -1.  This is
   // necessary when the converter changes the length of the resulting data
   // stream, which is almost always the case for a "stream converter" ;-)
   // This function optionally returns a reference to the new converter.
   nsresult PushStreamConverter(const char* fromType, const char* toType,
                                bool invalidatesContentLength = true,
-                               nsIStreamListener** converter = nullptr);
+                               nsIStreamListener** result = nullptr);
 
  protected:
   void DisallowThreadRetargeting() { mAllowThreadRetargeting = false; }
 
   virtual void SetupNeckoTarget();
 
  private:
   NS_DECL_NSISTREAMLISTENER
--- a/netwerk/base/nsDirectoryIndexStream.h
+++ b/netwerk/base/nsDirectoryIndexStream.h
@@ -29,17 +29,17 @@ class nsDirectoryIndexStream final : pub
    */
   nsresult Init(nsIFile* aDir);
   ~nsDirectoryIndexStream();
 
  public:
   /**
    * aDir will only be used on the calling thread.
    */
-  static nsresult Create(nsIFile* aDir, nsIInputStream** aStreamResult);
+  static nsresult Create(nsIFile* aDir, nsIInputStream** aResult);
 
   // nsISupportsInterface
   NS_DECL_THREADSAFE_ISUPPORTS
 
   // nsIInputStream interface
   NS_DECL_NSIINPUTSTREAM
 };
 
--- a/netwerk/base/nsFileStreams.cpp
+++ b/netwerk/base/nsFileStreams.cpp
@@ -25,17 +25,17 @@
 #include "nsLiteralString.h"
 #include "nsSocketTransport2.h"  // for ErrorAccordingToNSPR()
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/Unused.h"
 #include "mozilla/FileUtils.h"
 #include "nsNetCID.h"
 #include "nsXULAppAPI.h"
 
-typedef mozilla::ipc::FileDescriptor::PlatformHandleType FileHandleType;
+using FileHandleType = mozilla::ipc::FileDescriptor::PlatformHandleType;
 
 using namespace mozilla::ipc;
 using namespace mozilla::net;
 
 using mozilla::DebugOnly;
 using mozilla::Maybe;
 using mozilla::Nothing;
 using mozilla::Some;
@@ -849,18 +849,19 @@ nsAtomicFileOutputStream::Finish() {
 
     if (!mTargetFileExists) {
       // If the target file did not exist when we were initialized, then the
       // temp file we gave out was actually a reference to the target file.
       // since we succeeded in writing to the temp file (and hence succeeded
       // in writing to the target file), there is nothing more to do.
 #ifdef DEBUG
       bool equal;
-      if (NS_FAILED(mTargetFile->Equals(mTempFile, &equal)) || !equal)
+      if (NS_FAILED(mTargetFile->Equals(mTempFile, &equal)) || !equal) {
         NS_WARNING("mTempFile not equal to mTargetFile");
+      }
 #endif
     } else {
       nsAutoString targetFilename;
       rv = mTargetFile->GetLeafName(targetFilename);
       if (NS_SUCCEEDED(rv)) {
         // This will replace target.
         rv = mTempFile->MoveTo(nullptr, targetFilename);
         if (NS_FAILED(rv)) mTempFile->Remove(false);
@@ -876,23 +877,25 @@ nsAtomicFileOutputStream::Finish() {
   return rv;
 }
 
 NS_IMETHODIMP
 nsAtomicFileOutputStream::Write(const char* buf, uint32_t count,
                                 uint32_t* result) {
   nsresult rv = nsFileOutputStream::Write(buf, count, result);
   if (NS_SUCCEEDED(mWriteResult)) {
-    if (NS_FAILED(rv))
+    if (NS_FAILED(rv)) {
       mWriteResult = rv;
-    else if (count != *result)
+    } else if (count != *result) {
       mWriteResult = NS_ERROR_LOSS_OF_SIGNIFICANT_DATA;
+    }
 
-    if (NS_FAILED(mWriteResult) && count > 0)
+    if (NS_FAILED(mWriteResult) && count > 0) {
       NS_WARNING("writing to output stream failed! data may be lost");
+    }
   }
   return rv;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsSafeFileOutputStream
 
 NS_IMETHODIMP
--- a/netwerk/base/nsFileStreams.h
+++ b/netwerk/base/nsFileStreams.h
@@ -36,23 +36,23 @@ class nsFileStreamBase : public nsISeeka
   NS_DECL_NSIFILEMETADATA
 
   nsFileStreamBase();
 
  protected:
   virtual ~nsFileStreamBase();
 
   nsresult Close();
-  nsresult Available(uint64_t* _retval);
-  nsresult Read(char* aBuf, uint32_t aCount, uint32_t* _retval);
+  nsresult Available(uint64_t* aResult);
+  nsresult Read(char* aBuf, uint32_t aCount, uint32_t* aResult);
   nsresult ReadSegments(nsWriteSegmentFun aWriter, void* aClosure,
                         uint32_t aCount, uint32_t* _retval);
-  nsresult IsNonBlocking(bool* _retval);
+  nsresult IsNonBlocking(bool* aNonBlocking);
   nsresult Flush();
-  nsresult Write(const char* aBuf, uint32_t aCount, uint32_t* _retval);
+  nsresult Write(const char* aBuf, uint32_t aCount, uint32_t* result);
   nsresult WriteFrom(nsIInputStream* aFromStream, uint32_t aCount,
                      uint32_t* _retval);
   nsresult WriteSegments(nsReadSegmentFun aReader, void* aClosure,
                          uint32_t aCount, uint32_t* _retval);
 
   PRFileDesc* mFD;
 
   /**
@@ -71,18 +71,18 @@ class nsFileStreamBase : public nsISeeka
     eClosed,
     // Something bad happen in the Open() or in Deserialize(). The actual
     // error value is stored in mErrorValue.
     eError
   } mState;
 
   struct OpenParams {
     nsCOMPtr<nsIFile> localFile;
-    int32_t ioFlags;
-    int32_t perm;
+    int32_t ioFlags = 0;
+    int32_t perm = 0;
   };
 
   /**
    * Data we need to do an open.
    */
   OpenParams mOpenParams;
 
   nsresult mErrorValue;
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -270,18 +270,19 @@ nsresult nsIOService::Init() {
   errorService->RegisterErrorStringBundle(NS_ERROR_MODULE_NETWORK,
                                           NECKO_MSGS_URL);
 
   SSLTokensCache::Init();
 
   InitializeCaptivePortalService();
 
   // setup our bad port list stuff
-  for (int i = 0; gBadPortList[i]; i++)
+  for (int i = 0; gBadPortList[i]; i++) {
     mRestrictedPortList.AppendElement(gBadPortList[i]);
+  }
 
   // Further modifications to the port list come from prefs
   Preferences::RegisterPrefixCallbacks(nsIOService::PrefsChanged,
                                        gCallbackPrefs, this);
   PrefsChanged();
 
   mSocketProcessTopicBlackList.Insert(
       nsLiteralCString(NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID));
@@ -1225,18 +1226,19 @@ nsIOService::GetOffline(bool* offline) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIOService::SetOffline(bool offline) {
   LOG(("nsIOService::SetOffline offline=%d\n", offline));
   // When someone wants to go online (!offline) after we got XPCOM shutdown
   // throw ERROR_NOT_AVAILABLE to prevent return to online state.
-  if ((mShutdown || mOfflineForProfileChange) && !offline)
+  if ((mShutdown || mOfflineForProfileChange) && !offline) {
     return NS_ERROR_NOT_AVAILABLE;
+  }
 
   // SetOffline() may re-enter while it's shutting down services.
   // If that happens, save the most recent value and it will be
   // processed when the first SetOffline() call is done bringing
   // down the service.
   mSetOfflineValue = offline;
   if (mSettingOffline) {
     return NS_OK;
@@ -1262,28 +1264,30 @@ nsIOService::SetOffline(bool offline) {
   nsIIOService* subject = static_cast<nsIIOService*>(this);
   while (mSetOfflineValue != mOffline) {
     offline = mSetOfflineValue;
 
     if (offline && !mOffline) {
       mOffline = true;  // indicate we're trying to shutdown
 
       // don't care if notifications fail
-      if (observerService)
+      if (observerService) {
         observerService->NotifyObservers(subject,
                                          NS_IOSERVICE_GOING_OFFLINE_TOPIC,
                                          u"" NS_IOSERVICE_OFFLINE);
+      }
 
       if (mSocketTransportService) mSocketTransportService->SetOffline(true);
 
       mLastOfflineStateChange = PR_IntervalNow();
-      if (observerService)
+      if (observerService) {
         observerService->NotifyObservers(subject,
                                          NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
                                          u"" NS_IOSERVICE_OFFLINE);
+      }
     } else if (!offline && mOffline) {
       // go online
       InitializeSocketTransportService();
       mOffline = false;  // indicate success only AFTER we've
                          // brought up the services
 
       mLastOfflineStateChange = PR_IntervalNow();
       // don't care if notification fails
@@ -1435,51 +1439,56 @@ nsIOService::AllowPort(int32_t inPort, c
 
 // static
 void nsIOService::PrefsChanged(const char* pref, void* self) {
   static_cast<nsIOService*>(self)->PrefsChanged(pref);
 }
 
 void nsIOService::PrefsChanged(const char* pref) {
   // Look for extra ports to block
-  if (!pref || strcmp(pref, PORT_PREF("banned")) == 0)
+  if (!pref || strcmp(pref, PORT_PREF("banned")) == 0) {
     ParsePortList(PORT_PREF("banned"), false);
+  }
 
   // ...as well as previous blocks to remove.
-  if (!pref || strcmp(pref, PORT_PREF("banned.override")) == 0)
+  if (!pref || strcmp(pref, PORT_PREF("banned.override")) == 0) {
     ParsePortList(PORT_PREF("banned.override"), true);
+  }
 
   if (!pref || strcmp(pref, MANAGE_OFFLINE_STATUS_PREF) == 0) {
     bool manage;
     if (mNetworkLinkServiceInitialized &&
         NS_SUCCEEDED(
             Preferences::GetBool(MANAGE_OFFLINE_STATUS_PREF, &manage))) {
       LOG(("nsIOService::PrefsChanged ManageOfflineStatus manage=%d\n",
            manage));
       SetManageOfflineStatus(manage);
     }
   }
 
   if (!pref || strcmp(pref, NECKO_BUFFER_CACHE_COUNT_PREF) == 0) {
     int32_t count;
     if (NS_SUCCEEDED(
-            Preferences::GetInt(NECKO_BUFFER_CACHE_COUNT_PREF, &count)))
+            Preferences::GetInt(NECKO_BUFFER_CACHE_COUNT_PREF, &count))) {
       /* check for bogus values and default if we find such a value */
       if (count > 0) gDefaultSegmentCount = count;
+    }
   }
 
   if (!pref || strcmp(pref, NECKO_BUFFER_CACHE_SIZE_PREF) == 0) {
     int32_t size;
-    if (NS_SUCCEEDED(Preferences::GetInt(NECKO_BUFFER_CACHE_SIZE_PREF, &size)))
+    if (NS_SUCCEEDED(
+            Preferences::GetInt(NECKO_BUFFER_CACHE_SIZE_PREF, &size))) {
       /* check for bogus values and default if we find such a value
        * the upper limit here is arbitrary. having a 1mb segment size
        * is pretty crazy.  if you remove this, consider adding some
        * integer rollover test.
        */
       if (size > 0 && size < 1024 * 1024) gDefaultSegmentSize = size;
+    }
     NS_WARNING_ASSERTION(!(size & (size - 1)),
                          "network segment size is not a power of 2!");
   }
 
   if (!pref || strcmp(pref, NETWORK_CAPTIVE_PORTAL_PREF) == 0) {
     nsresult rv = Preferences::GetBool(NETWORK_CAPTIVE_PORTAL_PREF,
                                        &gCaptivePortalEnabled);
     if (NS_SUCCEEDED(rv) && mCaptivePortalService) {
@@ -1510,31 +1519,34 @@ void nsIOService::ParsePortList(const ch
       portListArray[index].StripWhitespace();
       int32_t portBegin, portEnd;
 
       if (PR_sscanf(portListArray[index].get(), "%d-%d", &portBegin,
                     &portEnd) == 2) {
         if ((portBegin < 65536) && (portEnd < 65536)) {
           int32_t curPort;
           if (remove) {
-            for (curPort = portBegin; curPort <= portEnd; curPort++)
+            for (curPort = portBegin; curPort <= portEnd; curPort++) {
               restrictedPortList.RemoveElement(curPort);
+            }
           } else {
-            for (curPort = portBegin; curPort <= portEnd; curPort++)
+            for (curPort = portBegin; curPort <= portEnd; curPort++) {
               restrictedPortList.AppendElement(curPort);
+            }
           }
         }
       } else {
         nsresult aErrorCode;
         int32_t port = portListArray[index].ToInteger(&aErrorCode);
         if (NS_SUCCEEDED(aErrorCode) && port < 65536) {
-          if (remove)
+          if (remove) {
             restrictedPortList.RemoveElement(port);
-          else
+          } else {
             restrictedPortList.AppendElement(port);
+          }
         }
       }
     }
   }
 
   MutexAutoLock lock(mMutex);
   mRestrictedPortList.Assign(std::move(restrictedPortList));
 }
@@ -1814,18 +1826,19 @@ nsresult nsIOService::OnNetworkLinkEvent
 NS_IMETHODIMP
 nsIOService::EscapeString(const nsACString& aString, uint32_t aEscapeType,
                           nsACString& aResult) {
   NS_ENSURE_ARG_MAX(aEscapeType, 4);
 
   nsAutoCString stringCopy(aString);
   nsCString result;
 
-  if (!NS_Escape(stringCopy, result, (nsEscapeMask)aEscapeType))
+  if (!NS_Escape(stringCopy, result, (nsEscapeMask)aEscapeType)) {
     return NS_ERROR_OUT_OF_MEMORY;
+  }
 
   aResult.Assign(result);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIOService::EscapeURL(const nsACString& aStr, uint32_t aFlags,
--- a/netwerk/base/nsIOService.h
+++ b/netwerk/base/nsIOService.h
@@ -21,17 +21,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/Mutex.h"
 #include "prtime.h"
 #include "nsICaptivePortalService.h"
 #include "nsIObserverService.h"
 #include "nsTHashSet.h"
 #include "nsWeakReference.h"
 
-#define NS_N(x) (sizeof(x) / sizeof(*x))
+#define NS_N(x) (sizeof(x) / sizeof(*(x)))
 
 // We don't want to expose this observer topic.
 // Intended internal use only for remoting offline/inline events.
 // See Bug 552829
 #define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
 #define NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC "ipc:network:set-connectivity"
 
 static const char gScheme[][sizeof("moz-safe-about")] = {
@@ -153,17 +153,18 @@ class nsIOService final : public nsIIOSe
   ~nsIOService();
   nsresult SetConnectivityInternal(bool aConnectivity);
 
   nsresult OnNetworkLinkEvent(const char* data);
 
   nsresult GetCachedProtocolHandler(const char* scheme,
                                     nsIProtocolHandler** hdlrResult,
                                     uint32_t start = 0, uint32_t end = 0);
-  nsresult CacheProtocolHandler(const char* scheme, nsIProtocolHandler* hdlr);
+  nsresult CacheProtocolHandler(const char* scheme,
+                                nsIProtocolHandler* handler);
 
   nsresult InitializeCaptivePortalService();
   nsresult RecheckCaptivePortalIfLocalRedirect(nsIChannel* newChan);
 
   // Prefs wrangling
   static void PrefsChanged(const char* pref, void* self);
   void PrefsChanged(const char* pref = nullptr);
   void ParsePortList(const char* pref, bool remove);
--- a/netwerk/base/nsIncrementalDownload.cpp
+++ b/netwerk/base/nsIncrementalDownload.cpp
@@ -48,18 +48,19 @@ using namespace mozilla::net;
 static nsresult WriteToFile(nsIFile* lf, const char* data, uint32_t len,
                             int32_t flags) {
   PRFileDesc* fd;
   int32_t mode = 0600;
   nsresult rv;
   rv = lf->OpenNSPRFileDesc(flags, mode, &fd);
   if (NS_FAILED(rv)) return rv;
 
-  if (len)
+  if (len) {
     rv = PR_Write(fd, data, len) == int32_t(len) ? NS_OK : NS_ERROR_FAILURE;
+  }
 
   PR_Close(fd);
   return rv;
 }
 
 static nsresult AppendToFile(nsIFile* lf, const char* data, uint32_t len) {
   int32_t flags = PR_WRONLY | PR_CREATE_FILE | PR_APPEND;
   return WriteToFile(lf, data, len, flags);
@@ -168,18 +169,19 @@ nsresult nsIncrementalDownload::FlushChu
   mChunkLen = 0;
 
   return NS_OK;
 }
 
 void nsIncrementalDownload::UpdateProgress() {
   mLastProgressUpdate = PR_Now();
 
-  if (mProgressSink)
+  if (mProgressSink) {
     mProgressSink->OnProgress(this, mCurrentSize + mChunkLen, mTotalSize);
+  }
 }
 
 nsresult nsIncrementalDownload::CallOnStartRequest() {
   if (!mObserver || mDidOnStartRequest) return NS_OK;
 
   mDidOnStartRequest = true;
   return mObserver->OnStartRequest(this);
 }
@@ -522,19 +524,20 @@ nsIncrementalDownload::OnStartRequest(ns
     // expectations on each 206. If it is not then drop this response and
     // retry with no-cache set.
     if (!mCacheBust) {
       nsAutoCString buf;
       int64_t startByte = 0;
       bool confirmedOK = false;
 
       rv = http->GetResponseHeader("Content-Range"_ns, buf);
-      if (NS_FAILED(rv))
+      if (NS_FAILED(rv)) {
         return rv;  // it isn't a useful 206 without a CONTENT-RANGE of some
-                    // sort
+      }
+      // sort
 
       // Content-Range: bytes 0-299999/25604694
       int32_t p = buf.Find("bytes ");
 
       // first look for the starting point of the content-range
       // to make sure it is what we expect
       if (p != -1) {
         char* endptr = nullptr;
@@ -578,18 +581,19 @@ nsIncrementalDownload::OnStartRequest(ns
   }
 
   // Do special processing after the first response.
   if (mTotalSize == int64_t(-1)) {
     // Update knowledge of mFinalURI
     rv = http->GetURI(getter_AddRefs(mFinalURI));
     if (NS_FAILED(rv)) return rv;
     Unused << http->GetResponseHeader("Etag"_ns, mPartialValidator);
-    if (StringBeginsWith(mPartialValidator, "W/"_ns))
+    if (StringBeginsWith(mPartialValidator, "W/"_ns)) {
       mPartialValidator.Truncate();  // don't use weak validators
+    }
     if (mPartialValidator.IsEmpty()) {
       rv = http->GetResponseHeader("Last-Modified"_ns, mPartialValidator);
       if (NS_FAILED(rv)) {
         LOG(
             ("nsIncrementalDownload::OnStartRequest\n"
              "    empty validator\n"));
       }
     }
@@ -600,18 +604,20 @@ nsIncrementalDownload::OnStartRequest(ns
       nsAutoCString buf;
       rv = http->GetResponseHeader("Content-Range"_ns, buf);
       if (NS_FAILED(rv)) return rv;
       int32_t slash = buf.FindChar('/');
       if (slash == kNotFound) {
         NS_WARNING("server returned invalid Content-Range header!");
         return NS_ERROR_UNEXPECTED;
       }
-      if (PR_sscanf(buf.get() + slash + 1, "%lld", (int64_t*)&mTotalSize) != 1)
+      if (PR_sscanf(buf.get() + slash + 1, "%lld", (int64_t*)&mTotalSize) !=
+          1) {
         return NS_ERROR_UNEXPECTED;
+      }
     } else {
       rv = http->GetContentLength(&mTotalSize);
       if (NS_FAILED(rv)) return rv;
       // We need to know the total size of the thing we're trying to download.
       if (mTotalSize == int64_t(-1)) {
         NS_WARNING("server returned no content-length header!");
         return NS_ERROR_UNEXPECTED;
       }
@@ -689,18 +695,19 @@ nsIncrementalDownload::OnDataAvailable(n
     mChunkLen += n;
 
     if (mChunkLen == mChunkSize) {
       rv = FlushChunk();
       if (NS_FAILED(rv)) return rv;
     }
   }
 
-  if (PR_Now() > mLastProgressUpdate + UPDATE_PROGRESS_INTERVAL)
+  if (PR_Now() > mLastProgressUpdate + UPDATE_PROGRESS_INTERVAL) {
     UpdateProgress();
+  }
 
   return NS_OK;
 }
 
 // nsIObserver
 
 NS_IMETHODIMP
 nsIncrementalDownload::Observe(nsISupports* subject, const char* topic,
--- a/netwerk/base/nsInputStreamPump.cpp
+++ b/netwerk/base/nsInputStreamPump.cpp
@@ -551,43 +551,45 @@ uint32_t nsInputStreamPump::OnStateTrans
 
     // don't enter this code if ODA failed or called Cancel
     if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(mStatus)) {
       // test to see if this ODA failed to consume data
       if (tellable) {
         // NOTE: if Tell fails, which can happen if the stream is
         // now closed, then we assume that everything was read.
         int64_t offsetAfter;
-        if (NS_FAILED(tellable->Tell(&offsetAfter)))
+        if (NS_FAILED(tellable->Tell(&offsetAfter))) {
           offsetAfter = offsetBefore + odaAvail;
-        if (offsetAfter > offsetBefore)
+        }
+        if (offsetAfter > offsetBefore) {
           mStreamOffset += (offsetAfter - offsetBefore);
-        else if (mSuspendCount == 0) {
+        } else if (mSuspendCount == 0) {
           //
           // possible infinite loop if we continue pumping data!
           //
           // NOTE: although not allowed by nsIStreamListener, we
           // will allow the ODA impl to Suspend the pump.  IMAP
           // does this :-(
           //
           NS_ERROR("OnDataAvailable implementation consumed no data");
           mStatus = NS_ERROR_UNEXPECTED;
         }
-      } else
+      } else {
         mStreamOffset += odaAvail;  // assume ODA behaved well
+      }
     }
   }
 
   // an error returned from Available or OnDataAvailable should cause us to
   // abort; however, we must not stop on mStatus if already canceled.
 
   if (NS_SUCCEEDED(mStatus)) {
-    if (NS_FAILED(rv))
+    if (NS_FAILED(rv)) {
       mStatus = rv;
-    else if (avail) {
+    } else if (avail) {
       // if stream is now closed, advance to STATE_STOP right away.
       // Available may return 0 bytes available at the moment; that
       // would not mean that we are done.
       // XXX async streams should have a GetStatus method!
       rv = mAsyncStream->Available(&avail);
       if (NS_SUCCEEDED(rv)) return STATE_TRANSFER;
       if (rv != NS_BASE_STREAM_CLOSED) mStatus = rv;
     }
@@ -628,20 +630,21 @@ uint32_t nsInputStreamPump::OnStateStop(
   // 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?");
     return STATE_IDLE;
   }
 
-  if (NS_FAILED(mStatus))
+  if (NS_FAILED(mStatus)) {
     mAsyncStream->CloseWithStatus(mStatus);
-  else if (mCloseWhenDone)
+  } else if (mCloseWhenDone) {
     mAsyncStream->Close();
+  }
 
   mAsyncStream = nullptr;
   mTargetThread = nullptr;
   mIsPending = false;
   {
     // Note: Must exit mutex for call to OnStartRequest to avoid
     // deadlocks when calls to RetargetDeliveryTo for multiple
     // nsInputStreamPumps are needed (e.g. nsHttpChannel).
--- a/netwerk/base/nsInputStreamPump.h
+++ b/netwerk/base/nsInputStreamPump.h
@@ -25,34 +25,33 @@ class nsIStreamListener;
   }
 
 class nsInputStreamPump final : public nsIInputStreamPump,
                                 public nsIInputStreamCallback,
                                 public nsIThreadRetargetableRequest {
   ~nsInputStreamPump() = default;
 
  public:
-  typedef mozilla::RecursiveMutexAutoLock RecursiveMutexAutoLock;
-  typedef mozilla::RecursiveMutexAutoUnlock RecursiveMutexAutoUnlock;
+  using RecursiveMutexAutoLock = mozilla::RecursiveMutexAutoLock;
+  using RecursiveMutexAutoUnlock = mozilla::RecursiveMutexAutoUnlock;
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIREQUEST
   NS_DECL_NSIINPUTSTREAMPUMP
   NS_DECL_NSIINPUTSTREAMCALLBACK
   NS_DECL_NSITHREADRETARGETABLEREQUEST
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_INPUT_STREAM_PUMP_IID)
 
   nsInputStreamPump();
 
   static nsresult Create(nsInputStreamPump** result, nsIInputStream* stream,
                          uint32_t segsize = 0, uint32_t segcount = 0,
                          bool closeWhenDone = false,
                          nsIEventTarget* mainThreadTarget = nullptr);
 
-  typedef void (*PeekSegmentFun)(void* closure, const uint8_t* buf,
-                                 uint32_t bufLen);
+  using PeekSegmentFun = void (*)(void*, const uint8_t*, uint32_t);
   /**
    * Peek into the first chunk of data that's in the stream. Note that this
    * method will not call the callback when there is no data in the stream.
    * The callback will be called at most once.
    *
    * The data from the stream will not be consumed, i.e. the pump's listener
    * can still read all the data.
    *
--- a/netwerk/base/nsLoadGroup.cpp
+++ b/netwerk/base/nsLoadGroup.cpp
@@ -141,33 +141,34 @@ nsLoadGroup::GetName(nsACString& result)
     return NS_OK;
   }
 
   return mDefaultLoadRequest->GetName(result);
 }
 
 NS_IMETHODIMP
 nsLoadGroup::IsPending(bool* aResult) {
-  *aResult = (mForegroundCount > 0) ? true : false;
+  *aResult = mForegroundCount > 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLoadGroup::GetStatus(nsresult* status) {
-  if (NS_SUCCEEDED(mStatus) && mDefaultLoadRequest)
+  if (NS_SUCCEEDED(mStatus) && mDefaultLoadRequest) {
     return mDefaultLoadRequest->GetStatus(status);
+  }
 
   *status = mStatus;
   return NS_OK;
 }
 
 static bool AppendRequestsToArray(PLDHashTable* aTable,
                                   nsTArray<nsIRequest*>* aArray) {
   for (auto iter = aTable->Iter(); !iter.Done(); iter.Next()) {
-    auto e = static_cast<RequestMapEntry*>(iter.Get());
+    auto* e = static_cast<RequestMapEntry*>(iter.Get());
     nsIRequest* request = e->mKey;
     NS_ASSERTION(request, "What? Null key in PLDHashTable entry?");
 
     // XXX(Bug 1631371) Check if this should use a fallible operation as it
     // pretended earlier.
     aArray->AppendElement(request);
     NS_ADDREF(request);
   }
@@ -451,17 +452,17 @@ nsLoadGroup::AddRequest(nsIRequest* requ
     rv = MergeLoadFlags(request, flags);
   }
   if (NS_FAILED(rv)) return rv;
 
   //
   // Add the request to the list of active requests...
   //
 
-  auto entry = static_cast<RequestMapEntry*>(mRequests.Add(request, fallible));
+  auto* entry = static_cast<RequestMapEntry*>(mRequests.Add(request, fallible));
   if (!entry) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   if (mPriority != 0) RescheduleRequest(request, mPriority);
 
   nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(request);
   if (timedChannel) timedChannel->SetTimingEnabled(true);
@@ -543,17 +544,17 @@ nsresult nsLoadGroup::RemoveRequestFromH
          mRequests.EntryCount() - 1));
   }
 
   //
   // 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));
+  auto* entry = static_cast<RequestMapEntry*>(mRequests.Search(request));
 
   if (!entry) {
     LOG(("LOADGROUP [%p]: Unable to remove request %p. Not in group!\n", this,
          request));
 
     return NS_ERROR_FAILURE;
   }
 
@@ -640,17 +641,17 @@ nsresult nsLoadGroup::NotifyRemovalObser
 }
 
 NS_IMETHODIMP
 nsLoadGroup::GetRequests(nsISimpleEnumerator** aRequests) {
   nsCOMArray<nsIRequest> requests;
   requests.SetCapacity(mRequests.EntryCount());
 
   for (auto iter = mRequests.Iter(); !iter.Done(); iter.Next()) {
-    auto e = static_cast<RequestMapEntry*>(iter.Get());
+    auto* e = static_cast<RequestMapEntry*>(iter.Get());
     requests.AppendObject(e->mKey);
   }
 
   return NS_NewArrayEnumerator(aRequests, requests, NS_GET_IID(nsIRequest));
 }
 
 NS_IMETHODIMP
 nsLoadGroup::SetGroupObserver(nsIRequestObserver* aObserver) {
@@ -754,17 +755,17 @@ nsLoadGroup::SetPriority(int32_t aValue)
 }
 
 NS_IMETHODIMP
 nsLoadGroup::AdjustPriority(int32_t aDelta) {
   // Update the priority for each request that supports nsISupportsPriority
   if (aDelta != 0) {
     mPriority += aDelta;
     for (auto iter = mRequests.Iter(); !iter.Done(); iter.Next()) {
-      auto e = static_cast<RequestMapEntry*>(iter.Get());
+      auto* e = static_cast<RequestMapEntry*>(iter.Get());
       RescheduleRequest(e->mKey, aDelta);
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLoadGroup::GetDefaultLoadFlags(uint32_t* aFlags) {
--- a/netwerk/base/nsMIMEInputStream.cpp
+++ b/netwerk/base/nsMIMEInputStream.cpp
@@ -63,18 +63,18 @@ class nsMIMEInputStream : public nsIMIME
   template <typename M>
   void SerializeInternal(InputStreamParams& aParams,
                          FileDescriptorArray& aFileDescriptors,
                          bool aDelayedStart, uint32_t aMaxSize,
                          uint32_t* aSizeUsed, M* aManager);
 
   struct MOZ_STACK_CLASS ReadSegmentsState {
     nsCOMPtr<nsIInputStream> mThisStream;
-    nsWriteSegmentFun mWriter;
-    void* mClosure;
+    nsWriteSegmentFun mWriter{nullptr};
+    void* mClosure{nullptr};
   };
   static nsresult ReadSegCb(nsIInputStream* aIn, void* aClosure,
                             const char* aFromRawSegment, uint32_t aToOffset,
                             uint32_t aCount, uint32_t* aWriteCount);
 
   bool IsSeekableInputStream() const;
   bool IsAsyncInputStream() const;
   bool IsInputStreamLength() const;
--- a/netwerk/base/nsMediaFragmentURIParser.cpp
+++ b/netwerk/base/nsMediaFragmentURIParser.cpp
@@ -334,17 +334,18 @@ void nsMediaFragmentURIParser::Parse(nsA
   }
 
   // Parse the media fragment values.
   bool gotTemporal = false, gotSpatial = false;
   for (int i = fragments.Length() - 1; i >= 0; --i) {
     if (gotTemporal && gotSpatial) {
       // We've got one of each possible type. No need to look at the rest.
       break;
-    } else if (!gotTemporal && fragments[i].first.EqualsLiteral("t")) {
+    }
+    if (!gotTemporal && fragments[i].first.EqualsLiteral("t")) {
       nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
       gotTemporal = ParseNPT(nsDependentSubstring(value, 0));
     } else if (!gotSpatial && fragments[i].first.EqualsLiteral("xywh")) {
       nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
       gotSpatial = ParseXYWH(nsDependentSubstring(value, 0));
     }
   }
 }
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -597,20 +597,21 @@ nsresult NS_GetIsDocumentChannel(nsIChan
 
 nsresult NS_MakeAbsoluteURI(nsACString& result, const nsACString& spec,
                             nsIURI* baseURI) {
   nsresult rv;
   if (!baseURI) {
     NS_WARNING("It doesn't make sense to not supply a base URI");
     result = spec;
     rv = NS_OK;
-  } else if (spec.IsEmpty())
+  } else if (spec.IsEmpty()) {
     rv = baseURI->GetSpec(result);
-  else
+  } else {
     rv = baseURI->Resolve(spec, result);
+  }
   return rv;
 }
 
 nsresult NS_MakeAbsoluteURI(char** result, const char* spec, nsIURI* baseURI) {
   nsresult rv;
   nsAutoCString resultBuf;
   rv = NS_MakeAbsoluteURI(resultBuf, nsDependentCString(spec), baseURI);
   if (NS_SUCCEEDED(rv)) {
@@ -624,20 +625,21 @@ nsresult NS_MakeAbsoluteURI(nsAString& r
                             nsIURI* baseURI) {
   nsresult rv;
   if (!baseURI) {
     NS_WARNING("It doesn't make sense to not supply a base URI");
     result = spec;
     rv = NS_OK;
   } else {
     nsAutoCString resultBuf;
-    if (spec.IsEmpty())
+    if (spec.IsEmpty()) {
       rv = baseURI->GetSpec(resultBuf);
-    else
+    } else {
       rv = baseURI->Resolve(NS_ConvertUTF16toUTF8(spec), resultBuf);
+    }
     if (NS_SUCCEEDED(rv)) CopyUTF8toUTF16(resultBuf, result);
   }
   return rv;
 }
 
 int32_t NS_GetDefaultPort(const char* scheme,
                           nsIIOService* ioService /* = nullptr */) {
   nsresult rv;
@@ -669,19 +671,17 @@ int32_t NS_GetDefaultPort(const char* sc
 /**
  * This function is a helper function to apply the ToAscii conversion
  * to a string
  */
 bool NS_StringToACE(const nsACString& idn, nsACString& result) {
   nsCOMPtr<nsIIDNService> idnSrv = do_GetService(NS_IDNSERVICE_CONTRACTID);
   if (!idnSrv) return false;
   nsresult rv = idnSrv->ConvertUTF8toACE(idn, result);
-  if (NS_FAILED(rv)) return false;
-
-  return true;
+  return NS_SUCCEEDED(rv);
 }
 
 int32_t NS_GetRealPort(nsIURI* aURI) {
   int32_t port;
   nsresult rv = aURI->GetPort(&port);
   if (NS_FAILED(rv)) return -1;
 
   if (port != -1) return port;  // explicitly specified
@@ -1091,31 +1091,33 @@ nsresult NS_CheckPortSafety(int32_t port
     }
   }
   return rv;
 }
 
 nsresult NS_CheckPortSafety(nsIURI* uri) {
   int32_t port;
   nsresult rv = uri->GetPort(&port);
-  if (NS_FAILED(rv) || port == -1)  // port undefined or default-valued
+  if (NS_FAILED(rv) || port == -1) {  // port undefined or default-valued
     return NS_OK;
+  }
   nsAutoCString scheme;
   uri->GetScheme(scheme);
   return NS_CheckPortSafety(port, scheme.get());
 }
 
 nsresult NS_NewProxyInfo(const nsACString& type, const nsACString& host,
                          int32_t port, uint32_t flags, nsIProxyInfo** result) {
   nsresult rv;
   nsCOMPtr<nsIProtocolProxyService> pps =
       do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv))
+  if (NS_SUCCEEDED(rv)) {
     rv = pps->NewProxyInfo(type, host, port, ""_ns, ""_ns, flags, UINT32_MAX,
                            nullptr, result);
+  }
   return rv;
 }
 
 nsresult NS_GetFileProtocolHandler(nsIFileProtocolHandler** result,
                                    nsIIOService* ioService /* = nullptr */) {
   nsresult rv;
   nsCOMPtr<nsIIOService> grip;
   rv = net_EnsureIOService(&ioService, grip);
@@ -2256,18 +2258,19 @@ nsresult NS_URIChainHasFlags(nsIURI* uri
   return util->URIChainHasFlags(uri, flags, result);
 }
 
 uint32_t NS_SecurityHashURI(nsIURI* aURI) {
   nsCOMPtr<nsIURI> baseURI = NS_GetInnermostURI(aURI);
 
   nsAutoCString scheme;
   uint32_t schemeHash = 0;
-  if (NS_SUCCEEDED(baseURI->GetScheme(scheme)))
+  if (NS_SUCCEEDED(baseURI->GetScheme(scheme))) {
     schemeHash = mozilla::HashString(scheme);
+  }
 
   // TODO figure out how to hash file:// URIs
   if (scheme.EqualsLiteral("file")) return schemeHash;  // sad face
 
 #if IS_ORIGIN_IS_FULL_SPEC_DEFINED
   bool hasFlag;
   if (NS_FAILED(NS_URIChainHasFlags(
           baseURI, nsIProtocolHandler::ORIGIN_IS_FULL_SPEC, &hasFlag)) ||
@@ -2280,18 +2283,19 @@ uint32_t NS_SecurityHashURI(nsIURI* aURI
     else
       specHash = static_cast<uint32_t>(res);
     return specHash;
   }
 #endif
 
   nsAutoCString host;
   uint32_t hostHash = 0;
-  if (NS_SUCCEEDED(baseURI->GetAsciiHost(host)))
+  if (NS_SUCCEEDED(baseURI->GetAsciiHost(host))) {
     hostHash = mozilla::HashString(host);
+  }
 
   return mozilla::AddToHash(schemeHash, hostHash, NS_GetRealPort(baseURI));
 }
 
 bool NS_SecurityCompareURIs(nsIURI* aSourceURI, nsIURI* aTargetURI,
                             bool aStrictFileOriginPolicy) {
   nsresult rv;
 
@@ -2623,18 +2627,19 @@ uint32_t NS_GetContentDispositionFromTok
   // RFC 2183, section 2.8 says that an unknown disposition
   // value should be treated as "attachment"
   // If all of these tests eval to false, then we have a content-disposition of
   // "attachment" or unknown
   if (aDispToken.IsEmpty() || aDispToken.LowerCaseEqualsLiteral("inline") ||
       // Broken sites just send
       // Content-Disposition: filename="file"
       // without a disposition token... screen those out.
-      StringHead(aDispToken, 8).LowerCaseEqualsLiteral("filename"))
+      StringHead(aDispToken, 8).LowerCaseEqualsLiteral("filename")) {
     return nsIChannel::DISPOSITION_INLINE;
+  }
 
   return nsIChannel::DISPOSITION_ATTACHMENT;
 }
 
 uint32_t NS_GetContentDispositionFromHeader(const nsACString& aHeader,
                                             nsIChannel* aChan /* = nullptr */) {
   nsresult rv;
   nsCOMPtr<nsIMIMEHeaderParam> mimehdrpar =
@@ -2642,18 +2647,19 @@ uint32_t NS_GetContentDispositionFromHea
   if (NS_FAILED(rv)) return nsIChannel::DISPOSITION_ATTACHMENT;
 
   nsAutoString dispToken;
   rv = mimehdrpar->GetParameterHTTP(aHeader, "", ""_ns, true, nullptr,
                                     dispToken);
 
   if (NS_FAILED(rv)) {
     // special case (see bug 272541): empty disposition type handled as "inline"
-    if (rv == NS_ERROR_FIRST_HEADER_FIELD_COMPONENT_EMPTY)
+    if (rv == NS_ERROR_FIRST_HEADER_FIELD_COMPONENT_EMPTY) {
       return nsIChannel::DISPOSITION_INLINE;
+    }
     return nsIChannel::DISPOSITION_ATTACHMENT;
   }
 
   return NS_GetContentDispositionFromToken(dispToken);
 }
 
 nsresult NS_GetFilenameFromDisposition(nsAString& aFilename,
                                        const nsACString& aDisposition) {
@@ -2714,36 +2720,38 @@ bool NS_IsAboutBlank(nsIURI* uri) {
 
 nsresult NS_GenerateHostPort(const nsCString& host, int32_t port,
                              nsACString& hostLine) {
   if (strchr(host.get(), ':')) {
     // host is an IPv6 address literal and must be encapsulated in []'s
     hostLine.Assign('[');
     // scope id is not needed for Host header.
     int scopeIdPos = host.FindChar('%');
-    if (scopeIdPos == -1)
+    if (scopeIdPos == -1) {
       hostLine.Append(host);
-    else if (scopeIdPos > 0)
+    } else if (scopeIdPos > 0) {
       hostLine.Append(Substring(host, 0, scopeIdPos));
-    else
+    } else {
       return NS_ERROR_MALFORMED_URI;
+    }
     hostLine.Append(']');
-  } else
+  } else {
     hostLine.Assign(host);
+  }
   if (port != -1) {
     hostLine.Append(':');
     hostLine.AppendInt(port);
   }
   return NS_OK;
 }
 
 void NS_SniffContent(const char* aSnifferType, nsIRequest* aRequest,
                      const uint8_t* aData, uint32_t aLength,
                      nsACString& aSniffedType) {
-  typedef nsCategoryCache<nsIContentSniffer> ContentSnifferCache;
+  using ContentSnifferCache = nsCategoryCache<nsIContentSniffer>;
   extern ContentSnifferCache* gNetSniffers;
   extern ContentSnifferCache* gDataSniffers;
   extern ContentSnifferCache* gORBSniffers;
   extern ContentSnifferCache* gNetAndORBSniffers;
   ContentSnifferCache* cache = nullptr;
   if (!strcmp(aSnifferType, NS_CONTENT_SNIFFER_CATEGORY)) {
     if (!gNetSniffers) {
       gNetSniffers = new ContentSnifferCache(NS_CONTENT_SNIFFER_CATEGORY);
@@ -3175,22 +3183,18 @@ bool NS_ShouldClassifyChannel(nsIChannel
       return false;
     }
   }
 
   nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
   ExtContentPolicyType type = loadInfo->GetExternalContentPolicyType();
   // Skip classifying channel triggered by system unless it is a top-level
   // load.
-  if (loadInfo->TriggeringPrincipal()->IsSystemPrincipal() &&
-      ExtContentPolicy::TYPE_DOCUMENT != type) {
-    return false;
-  }
-
-  return true;
+  return !(loadInfo->TriggeringPrincipal()->IsSystemPrincipal() &&
+           ExtContentPolicy::TYPE_DOCUMENT != type);
 }
 
 namespace mozilla {
 namespace net {
 
 bool InScriptableRange(int64_t val) {
   return (val <= kJS_MAX_SAFE_INTEGER) && (val >= kJS_MIN_SAFE_INTEGER);
 }
--- a/netwerk/base/nsNetUtil.h
+++ b/netwerk/base/nsNetUtil.h
@@ -76,17 +76,17 @@ struct already_AddRefed;
 
 already_AddRefed<nsIIOService> do_GetIOService(nsresult* error = nullptr);
 
 already_AddRefed<nsINetUtil> do_GetNetUtil(nsresult* error = nullptr);
 
 // private little helper function... don't call this directly!
 nsresult net_EnsureIOService(nsIIOService** ios, nsCOMPtr<nsIIOService>& grip);
 
-nsresult NS_NewURI(nsIURI** result, const nsACString& spec,
+nsresult NS_NewURI(nsIURI** aURI, const nsACString& spec,
                    const char* charset = nullptr, nsIURI* baseURI = nullptr);
 
 nsresult NS_NewURI(nsIURI** result, const nsACString& spec,
                    mozilla::NotNull<const mozilla::Encoding*> encoding,
                    nsIURI* baseURI = nullptr);
 
 nsresult NS_NewURI(nsIURI** result, const nsAString& spec,
                    const char* charset = nullptr, nsIURI* baseURI = nullptr);
--- a/netwerk/base/nsPACMan.cpp
+++ b/netwerk/base/nsPACMan.cpp
@@ -322,31 +322,33 @@ PendingPACQuery::PendingPACQuery(nsPACMa
   uri->GetScheme(mScheme);
   uri->GetPort(&mPort);
 }
 
 void PendingPACQuery::Complete(nsresult status, const nsACString& pacString) {
   if (!mCallback) return;
   RefPtr<ExecuteCallback> runnable = new ExecuteCallback(mCallback, status);
   runnable->SetPACString(pacString);
-  if (mOnMainThreadOnly)
+  if (mOnMainThreadOnly) {
     mPACMan->Dispatch(runnable.forget());
-  else
+  } else {
     runnable->Run();
+  }
 }
 
 void PendingPACQuery::UseAlternatePACFile(const nsACString& pacURL) {
   if (!mCallback) return;
 
   RefPtr<ExecuteCallback> runnable = new ExecuteCallback(mCallback, NS_OK);
   runnable->SetPACURL(pacURL);
-  if (mOnMainThreadOnly)
+  if (mOnMainThreadOnly) {
     mPACMan->Dispatch(runnable.forget());
-  else
+  } else {
     runnable->Run();
+  }
 }
 
 NS_IMETHODIMP
 PendingPACQuery::Run() {
   MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
   mPACMan->PostQuery(this);
   return NS_OK;
 }
@@ -757,18 +759,19 @@ void nsPACMan::CancelPendingQ(nsresult s
     query->Complete(status, ""_ns);
   }
 
   if (aShutdown) mPAC.Shutdown();
 }
 
 void nsPACMan::ProcessPendingQ() {
   MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
-  while (ProcessPending())
+  while (ProcessPending()) {
     ;
+  }
 
   if (mShutdown) {
     mPAC.Shutdown();
   } else {
     // do GC while the thread has nothing pending
     mPAC.GC();
   }
 }
@@ -890,20 +893,21 @@ nsPACMan::OnStreamComplete(nsIStreamLoad
     mLoadFailureCount = 0;
   } else {
     // We were unable to load the PAC file (presumably because of a network
     // failure).  Try again a little later.
     LOG(("OnStreamComplete: unable to load PAC, retry later\n"));
     OnLoadFailure();
   }
 
-  if (NS_SUCCEEDED(status))
+  if (NS_SUCCEEDED(status)) {
     PostProcessPendingQ();
-  else
+  } else {
     PostCancelPendingQ(status);
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPACMan::GetInterface(const nsIID& iid, void** result) {
   // In case loading the PAC file requires authentication.
   if (iid.Equals(NS_GET_IID(nsIAuthPrompt))) {
--- a/netwerk/base/nsPACMan.h
+++ b/netwerk/base/nsPACMan.h
@@ -114,17 +114,17 @@ class nsPACMan final : public nsIStreamL
    *        The callback to run once the PAC result is available.
    * @param flags
    *        A bit-wise combination of the RESOLVE_ flags defined above.  Pass
    *        0 to specify the default behavior.
    * @param mustCallbackOnMainThread
    *        If set to false the callback can be made from the PAC thread
    */
   nsresult AsyncGetProxyForURI(nsIURI* uri, nsPACManCallback* callback,
-                               uint32_t flags, bool mustCallbackOnMainThread);
+                               uint32_t flags, bool mainThreadResponse);
 
   /**
    * This method may be called to reload the PAC file.  While we are loading
    * the PAC file, any asynchronous PAC queries will be queued up to be
    * processed once the PAC file finishes loading.
    *
    * @param aSpec
    *        The non normalized uri spec of this URI used for comparison with
--- a/netwerk/base/nsPreloadedStream.cpp
+++ b/netwerk/base/nsPreloadedStream.cpp
@@ -102,18 +102,19 @@ class RunOnThread : public Runnable {
   nsCOMPtr<nsIAsyncInputStream> mStream;
   nsCOMPtr<nsIInputStreamCallback> mCallback;
 };
 
 NS_IMETHODIMP
 nsPreloadedStream::AsyncWait(nsIInputStreamCallback* aCallback, uint32_t aFlags,
                              uint32_t aRequestedCount,
                              nsIEventTarget* aEventTarget) {
-  if (!mLen)
+  if (!mLen) {
     return mStream->AsyncWait(aCallback, aFlags, aRequestedCount, aEventTarget);
+  }
 
   if (!aCallback) return NS_OK;
 
   if (!aEventTarget) return aCallback->OnInputStreamReady(this);
 
   nsCOMPtr<nsIRunnable> event = new RunOnThread(this, aCallback);
   return aEventTarget->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
 }
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -65,18 +65,18 @@ extern const char kProxyType_DIRECT[];
 #define PROXY_PREF_BRANCH "network.proxy"
 #define PROXY_PREF(x) PROXY_PREF_BRANCH "." x
 
 //----------------------------------------------------------------------------
 
 // This structure is intended to be allocated on the stack
 struct nsProtocolInfo {
   nsAutoCString scheme;
-  uint32_t flags;
-  int32_t defaultPort;
+  uint32_t flags = 0;
+  int32_t defaultPort = 0;
 };
 
 //----------------------------------------------------------------------------
 
 // Return the channel's proxy URI, or if it doesn't exist, the
 // channel's main URI.
 static nsresult GetProxyURI(nsIChannel* channel, nsIURI** aOut) {
   nsresult rv = NS_OK;
@@ -176,33 +176,33 @@ class nsAsyncResolveRequest final : publ
     // The reference counter is thread-safe, but the processing logic is
     // considered single thread only.  We want the counter be thread safe,
     // since this class can be released on a background thread.
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIPROXYPROTOCOLFILTERRESULT
     NS_DECL_NSIRUNNABLE
     NS_DECL_NSICANCELABLE
 
-    typedef std::function<nsresult(nsAsyncResolveRequest*, nsIProxyInfo*, bool)>
-        Callback;
+    using Callback =
+        std::function<nsresult(nsAsyncResolveRequest*, nsIProxyInfo*, bool)>;
 
     explicit AsyncApplyFilters(nsProtocolInfo& aInfo,
                                Callback const& aCallback);
     // This method starts the processing or filters.  If all of them
     // answer synchronously (call back from within applyFilters) this method
     // will return immediately and the returning result will carry return
     // result of the callback given in constructor.
     // This method is looping the registered filters (that have been copied
     // locally) as long as an answer from a filter is obtained synchronously.
     // Note that filters are processed serially to let them build a list
     // of proxy info.
     nsresult AsyncProcess(nsAsyncResolveRequest* aRequest);
 
    private:
-    typedef nsProtocolProxyService::FilterLink FilterLink;
+    using FilterLink = nsProtocolProxyService::FilterLink;
 
     virtual ~AsyncApplyFilters();
     // Processes the next filter and loops until a filter is successfully
     // called on or it has called back to us.
     nsresult ProcessNextFilter();
     // Called after the last filter has been processed (=called back or failed
     // to be called on)
     nsresult Finish();
@@ -283,23 +283,24 @@ class nsAsyncResolveRequest final : publ
     // If we've already called DoCallback then, nothing more to do.
     if (!mCallback) return NS_OK;
 
     SetResult(reason, nullptr);
     return DispatchCallback();
   }
 
   nsresult DispatchCallback() {
-    if (mDispatched)  // Only need to dispatch once
+    if (mDispatched) {  // Only need to dispatch once
       return NS_OK;
+    }
 
     nsresult rv = NS_DispatchToCurrentThread(this);
-    if (NS_FAILED(rv))
+    if (NS_FAILED(rv)) {
       NS_WARNING("unable to dispatch callback event");
-    else {
+    } else {
       mDispatched = true;
       return NS_OK;
     }
 
     mCallback = nullptr;  // break possible reference cycle
     return rv;
   }
 
@@ -391,18 +392,19 @@ class nsAsyncResolveRequest final : publ
       if (NS_SUCCEEDED(rv)) {
         // now that the load is triggered, we can resubmit the query
         RefPtr<nsAsyncResolveRequest> newRequest =
             new nsAsyncResolveRequest(mPPS, mChannel, mResolveFlags, mCallback);
         rv = mPPS->mPACMan->AsyncGetProxyForURI(proxyURI, newRequest,
                                                 mResolveFlags, true);
       }
 
-      if (NS_FAILED(rv))
+      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 %" PRIX32 "\n",
            static_cast<uint32_t>(mStatus)));
       if (NS_SUCCEEDED(mStatus)) mPPS->MaybeDisableDNSPrefetch(mProxyInfo);
       EnsureResolveFlagsMatch();
@@ -707,44 +709,46 @@ static void proxy_MaskIPv6Addr(PRIPv6Add
         PR_htonl(PR_ntohl(addr.pr_s6_addr32[0]) & (~0uL << (32 - mask_len)));
   }
 }
 
 static void proxy_GetStringPref(nsIPrefBranch* aPrefBranch, const char* aPref,
                                 nsCString& aResult) {
   nsAutoCString temp;
   nsresult rv = aPrefBranch->GetCharPref(aPref, temp);
-  if (NS_FAILED(rv))
+  if (NS_FAILED(rv)) {
     aResult.Truncate();
-  else {
+  } else {
     aResult.Assign(temp);
     // all of our string prefs are hostnames, so we should remove any
     // whitespace characters that the user might have unknowingly entered.
     aResult.StripWhitespace();
   }
 }
 
 static void proxy_GetIntPref(nsIPrefBranch* aPrefBranch, const char* aPref,
                              int32_t& aResult) {
   int32_t temp;
   nsresult rv = aPrefBranch->GetIntPref(aPref, &temp);
-  if (NS_FAILED(rv))
+  if (NS_FAILED(rv)) {
     aResult = -1;
-  else
+  } else {
     aResult = temp;
+  }
 }
 
 static void proxy_GetBoolPref(nsIPrefBranch* aPrefBranch, const char* aPref,
                               bool& aResult) {
   bool temp;
   nsresult rv = aPrefBranch->GetBoolPref(aPref, &temp);
-  if (NS_FAILED(rv))
+  if (NS_FAILED(rv)) {
     aResult = false;
-  else
+  } else {
     aResult = temp;
+  }
 }
 
 //----------------------------------------------------------------------------
 
 static const int32_t PROXYCONFIG_DIRECT4X = 3;
 static const int32_t PROXYCONFIG_COUNT = 6;
 
 NS_IMPL_ADDREF(nsProtocolProxyService)
@@ -987,72 +991,82 @@ void nsProtocolProxyService::PrefsChange
     } else {
       if (mSystemProxySettings) {
         mSystemProxySettings = nullptr;
         ResetPACThread();
       }
     }
   }
 
-  if (!pref || !strcmp(pref, PROXY_PREF("http")))
+  if (!pref || !strcmp(pref, PROXY_PREF("http"))) {
     proxy_GetStringPref(prefBranch, PROXY_PREF("http"), mHTTPProxyHost);
+  }
 
-  if (!pref || !strcmp(pref, PROXY_PREF("http_port")))
+  if (!pref || !strcmp(pref, PROXY_PREF("http_port"))) {
     proxy_GetIntPref(prefBranch, PROXY_PREF("http_port"), mHTTPProxyPort);
+  }
 
-  if (!pref || !strcmp(pref, PROXY_PREF("ssl")))
+  if (!pref || !strcmp(pref, PROXY_PREF("ssl"))) {
     proxy_GetStringPref(prefBranch, PROXY_PREF("ssl"), mHTTPSProxyHost);
+  }
 
-  if (!pref || !strcmp(pref, PROXY_PREF("ssl_port")))
+  if (!pref || !strcmp(pref, PROXY_PREF("ssl_port"))) {
     proxy_GetIntPref(prefBranch, PROXY_PREF("ssl_port"), mHTTPSProxyPort);
+  }
 
-  if (!pref || !strcmp(pref, PROXY_PREF("socks")))
+  if (!pref || !strcmp(pref, PROXY_PREF("socks"))) {
     proxy_GetStringPref(prefBranch, PROXY_PREF("socks"), mSOCKSProxyTarget);
+  }
 
-  if (!pref || !strcmp(pref, PROXY_PREF("socks_port")))
+  if (!pref || !strcmp(pref, PROXY_PREF("socks_port"))) {
     proxy_GetIntPref(prefBranch, PROXY_PREF("socks_port"), mSOCKSProxyPort);
+  }
 
   if (!pref || !strcmp(pref, PROXY_PREF("socks_version"))) {
     int32_t version;
     proxy_GetIntPref(prefBranch, PROXY_PREF("socks_version"), version);
     // make sure this preference value remains sane
-    if (version == 5)
+    if (version == 5) {
       mSOCKSProxyVersion = 5;
-    else
+    } else {
       mSOCKSProxyVersion = 4;
+    }
   }
 
-  if (!pref || !strcmp(pref, PROXY_PREF("socks_remote_dns")))
+  if (!pref || !strcmp(pref, PROXY_PREF("socks_remote_dns"))) {
     proxy_GetBoolPref(prefBranch, PROXY_PREF("socks_remote_dns"),
                       mSOCKSProxyRemoteDNS);
+  }
 
   if (!pref || !strcmp(pref, PROXY_PREF("proxy_over_tls"))) {
     proxy_GetBoolPref(prefBranch, PROXY_PREF("proxy_over_tls"), mProxyOverTLS);
   }
 
   if (!pref || !strcmp(pref, PROXY_PREF("enable_wpad_over_dhcp"))) {
     proxy_GetBoolPref(prefBranch, PROXY_PREF("enable_wpad_over_dhcp"),
                       mWPADOverDHCPEnabled);
     reloadPAC = reloadPAC || mProxyConfig == PROXYCONFIG_WPAD;
   }
 
-  if (!pref || !strcmp(pref, PROXY_PREF("failover_timeout")))
+  if (!pref || !strcmp(pref, PROXY_PREF("failover_timeout"))) {
     proxy_GetIntPref(prefBranch, PROXY_PREF("failover_timeout"),
                      mFailedProxyTimeout);
+  }
 
   if (!pref || !strcmp(pref, PROXY_PREF("no_proxies_on"))) {
     rv = prefBranch->GetCharPref(PROXY_PREF("no_proxies_on"), tempString);
     if (NS_SUCCEEDED(rv)) LoadHostFilters(tempString);
   }
 
   // We're done if not using something that could give us a PAC URL
   // (PAC, WPAD or System)
   if (mProxyConfig != PROXYCONFIG_PAC && mProxyConfig != PROXYCONFIG_WPAD &&
-      mProxyConfig != PROXYCONFIG_SYSTEM)
+      mProxyConfig != PROXYCONFIG_SYSTEM) {
     return;
+  }
 
   // OK, we need to reload the PAC file if:
   //  1) network.proxy.type changed, or
   //  2) network.proxy.autoconfig_url changed and PAC is configured
 
   if (!pref || !strcmp(pref, PROXY_PREF("autoconfig_url"))) reloadPAC = true;
 
   if (reloadPAC) {
@@ -1126,18 +1140,19 @@ bool nsProtocolProxyService::CanUseProxy
 
     if (is_ipaddr) {
       // generate masked version of target IPv6 address
       PRIPv6Addr masked;
       memcpy(&masked, &ipv6, sizeof(PRIPv6Addr));
       proxy_MaskIPv6Addr(masked, hinfo->ip.mask_len);
 
       // check for a match
-      if (memcmp(&masked, &hinfo->ip.addr, sizeof(PRIPv6Addr)) == 0)
+      if (memcmp(&masked, &hinfo->ip.addr, sizeof(PRIPv6Addr)) == 0) {
         return false;  // proxy disallowed
+      }
     } else {
       uint32_t host_len = host.Length();
       uint32_t filter_host_len = hinfo->name.host_len;
 
       if (host_len >= filter_host_len) {
         //
         // compare last |filter_host_len| bytes of target hostname.
         //
@@ -1220,34 +1235,36 @@ const char* nsProtocolProxyService::Extr
             5) {
           type = kProxyType_SOCKS;
         }
       } else if (nsCRT::strncasecmp(start, kProxyType_HTTPS, 5) == 0) {
         type = kProxyType_HTTPS;
       }
       break;
     case 6:
-      if (nsCRT::strncasecmp(start, kProxyType_DIRECT, 6) == 0)
+      if (nsCRT::strncasecmp(start, kProxyType_DIRECT, 6) == 0) {
         type = kProxyType_DIRECT;
-      else if (nsCRT::strncasecmp(start, kProxyType_SOCKS4, 6) == 0)
+      } else if (nsCRT::strncasecmp(start, kProxyType_SOCKS4, 6) == 0) {
         type = kProxyType_SOCKS4;
-      else if (nsCRT::strncasecmp(start, kProxyType_SOCKS5, 6) == 0)
+      } else if (nsCRT::strncasecmp(start, kProxyType_SOCKS5, 6) == 0) {
         // map "SOCKS5" to "socks" to match contract-id of registered
         // SOCKS-v5 socket provider.
         type = kProxyType_SOCKS;
+      }
       break;
   }
   if (type) {
     int32_t port = -1;
 
     // If it's a SOCKS5 proxy, do name resolution on the server side.
     // We could use this with SOCKS4a servers too, but they might not
     // support it.
-    if (type == kProxyType_SOCKS || mSOCKSProxyRemoteDNS)
+    if (type == kProxyType_SOCKS || mSOCKSProxyRemoteDNS) {
       flags |= nsIProxyInfo::TRANSPARENT_PROXY_RESOLVES_HOST;
+    }
 
     // extract host:port
     start = sp;
     while ((*start == ' ' || *start == '\t') && start < end) start++;
 
     // port defaults
     if (type == kProxyType_HTTP) {
       port = 80;
@@ -1436,18 +1453,19 @@ void nsProtocolProxyService::ProcessPACS
       delete pi;
       pi = nullptr;
     }
 
     if (pi) {
       if (last) {
         NS_ASSERTION(last->mNext == nullptr, "leaking nsProxyInfo");
         last->mNext = pi;
-      } else
+      } else {
         first = pi;
+      }
       last = pi;
     }
   }
   *result = first;
 }
 
 // nsIProtocolProxyService2
 NS_IMETHODIMP
@@ -1455,28 +1473,29 @@ nsProtocolProxyService::ReloadPAC() {
   nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
   if (!prefs) return NS_OK;
 
   int32_t type;
   nsresult rv = prefs->GetIntPref(PROXY_PREF("type"), &type);
   if (NS_FAILED(rv)) return NS_OK;
 
   nsAutoCString pacSpec;
-  if (type == PROXYCONFIG_PAC)
+  if (type == PROXYCONFIG_PAC) {
     prefs->GetCharPref(PROXY_PREF("autoconfig_url"), pacSpec);
-  else if (type == PROXYCONFIG_SYSTEM) {
+  } else if (type == PROXYCONFIG_SYSTEM) {
     if (mSystemProxySettings) {
       AsyncConfigureFromPAC(true, true);
     } else {
       ResetPACThread();
     }
   }
 
-  if (!pacSpec.IsEmpty() || type == PROXYCONFIG_WPAD)
+  if (!pacSpec.IsEmpty() || type == PROXYCONFIG_WPAD) {
     ConfigureFromPAC(pacSpec, true);
+  }
   return NS_OK;
 }
 
 // When sync interface is removed this can go away too
 // The nsPACManCallback portion of this implementation should be run
 // off the main thread, because it uses a condvar for signaling and
 // the main thread is blocking on that condvar -
 //  so call nsPACMan::AsyncGetProxyForURI() with
@@ -1667,18 +1686,19 @@ nsProtocolProxyService::NewProxyInfoWith
 
 NS_IMETHODIMP
 nsProtocolProxyService::GetFailoverForProxy(nsIProxyInfo* aProxy, nsIURI* aURI,
                                             nsresult aStatus,
                                             nsIProxyInfo** aResult) {
   // We only support failover when a PAC file is configured, either
   // directly or via system settings
   if (mProxyConfig != PROXYCONFIG_PAC && mProxyConfig != PROXYCONFIG_WPAD &&
-      mProxyConfig != PROXYCONFIG_SYSTEM)
+      mProxyConfig != PROXYCONFIG_SYSTEM) {
     return NS_ERROR_NOT_AVAILABLE;
+  }
 
   // Verify that |aProxy| is one of our nsProxyInfo objects.
   nsCOMPtr<nsProxyInfo> pi = do_QueryInterface(aProxy);
   NS_ENSURE_ARG(pi);
   // OK, the QI checked out.  We can proceed.
 
   // Remember that this proxy is down.
   DisableProxy(pi);
@@ -1694,29 +1714,29 @@ nsProtocolProxyService::GetFailoverForPr
 
   *aResult = do_AddRef(pi->mNext).take();
   return NS_OK;
 }
 
 namespace {  // anon
 
 class ProxyFilterPositionComparator {
-  typedef RefPtr<nsProtocolProxyService::FilterLink> FilterLinkRef;
+  using FilterLinkRef = RefPtr<nsProtocolProxyService::FilterLink>;
 
  public:
   bool Equals(const FilterLinkRef& a, const FilterLinkRef& b) const {
     return a->position == b->position;
   }
   bool LessThan(const FilterLinkRef& a, const FilterLinkRef& b) const {
     return a->position < b->position;
   }
 };
 
 class ProxyFilterObjectComparator {
-  typedef RefPtr<nsProtocolProxyService::FilterLink> FilterLinkRef;
+  using FilterLinkRef = RefPtr<nsProtocolProxyService::FilterLink>;
 
  public:
   bool Equals(const FilterLinkRef& link, const nsISupports* obj) const {
     return obj == nsCOMPtr<nsISupports>(do_QueryInterface(link->filter)) ||
            obj == nsCOMPtr<nsISupports>(do_QueryInterface(link->channelFilter));
   }
 };
 
@@ -2049,33 +2069,35 @@ nsresult nsProtocolProxyService::Resolve
                                                   uint32_t flags,
                                                   bool* usePACThread,
                                                   nsIProxyInfo** result) {
   NS_ENSURE_ARG_POINTER(channel);
 
   *usePACThread = false;
   *result = nullptr;
 
-  if (!(info.flags & nsIProtocolHandler::ALLOWS_PROXY))
+  if (!(info.flags & nsIProtocolHandler::ALLOWS_PROXY)) {
     return NS_OK;  // Can't proxy this (filters may not override)
+  }
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetProxyURI(channel, getter_AddRefs(uri));
   if (NS_FAILED(rv)) return rv;
 
   // See bug #586908.
   // Avoid endless loop if |uri| is the current PAC-URI. Returning OK
   // here means that we will not use a proxy for this connection.
   if (mPACMan && mPACMan->IsPACURI(uri)) return NS_OK;
 
   // if proxies are enabled and this host:port combo is supposed to use a
   // proxy, check for a proxy.
   if ((mProxyConfig == PROXYCONFIG_DIRECT) ||
-      !CanUseProxy(uri, info.defaultPort))
+      !CanUseProxy(uri, info.defaultPort)) {
     return NS_OK;
+  }
 
   bool mainThreadOnly;
   if (mSystemProxySettings && mProxyConfig == PROXYCONFIG_SYSTEM &&
       NS_SUCCEEDED(mSystemProxySettings->GetMainThreadOnly(&mainThreadOnly)) &&
       !mainThreadOnly) {
     *usePACThread = true;
     return NS_OK;
   }
@@ -2151,18 +2173,19 @@ nsresult nsProtocolProxyService::Resolve
       return NS_OK;
     }
   }
 
   // if proxies are enabled and this host:port combo is supposed to use a
   // proxy, check for a proxy.
   if (mProxyConfig == PROXYCONFIG_DIRECT ||
       (mProxyConfig == PROXYCONFIG_MANUAL &&
-       !CanUseProxy(uri, info.defaultPort)))
+       !CanUseProxy(uri, info.defaultPort))) {
     return NS_OK;
+  }
 
   // Proxy auto config magic...
   if (mProxyConfig == PROXYCONFIG_PAC || mProxyConfig == PROXYCONFIG_WPAD) {
     // Do not query PAC now.
     *usePACThread = true;
     return NS_OK;
   }
 
@@ -2175,23 +2198,25 @@ nsresult nsProtocolProxyService::Resolve
   const nsACString* host = nullptr;
   int32_t port = -1;
 
   uint32_t proxyFlags = 0;
 
   if ((flags & RESOLVE_PREFER_SOCKS_PROXY) && !mSOCKSProxyTarget.IsEmpty() &&
       (IsHostLocalTarget(mSOCKSProxyTarget) || mSOCKSProxyPort > 0)) {
     host = &mSOCKSProxyTarget;
-    if (mSOCKSProxyVersion == 4)
+    if (mSOCKSProxyVersion == 4) {
       type = kProxyType_SOCKS4;
-    else
+    } else {
       type = kProxyType_SOCKS;
+    }
     port = mSOCKSProxyPort;
-    if (mSOCKSProxyRemoteDNS)
+    if (mSOCKSProxyRemoteDNS) {
       proxyFlags |= nsIProxyInfo::TRANSPARENT_PROXY_RESOLVES_HOST;
+    }
   } else if ((flags & RESOLVE_PREFER_HTTPS_PROXY) &&
              !mHTTPSProxyHost.IsEmpty() && mHTTPSProxyPort > 0) {
     host = &mHTTPSProxyHost;
     type = kProxyType_HTTP;
     port = mHTTPSProxyPort;
   } else if (!mHTTPProxyHost.IsEmpty() && mHTTPProxyPort > 0 &&
              ((flags & RESOLVE_IGNORE_URI_SCHEME) ||
               info.scheme.EqualsLiteral("http"))) {
@@ -2202,23 +2227,25 @@ nsresult nsProtocolProxyService::Resolve
              !(flags & RESOLVE_IGNORE_URI_SCHEME) &&
              info.scheme.EqualsLiteral("https")) {
     host = &mHTTPSProxyHost;
     type = kProxyType_HTTP;
     port = mHTTPSProxyPort;
   } else if (!mSOCKSProxyTarget.IsEmpty() &&
              (IsHostLocalTarget(mSOCKSProxyTarget) || mSOCKSProxyPort > 0)) {
     host = &mSOCKSProxyTarget;
-    if (mSOCKSProxyVersion == 4)
+    if (mSOCKSProxyVersion == 4) {
       type = kProxyType_SOCKS4;
-    else
+    } else {
       type = kProxyType_SOCKS;
+    }
     port = mSOCKSProxyPort;
-    if (mSOCKSProxyRemoteDNS)
+    if (mSOCKSProxyRemoteDNS) {
       proxyFlags |= nsIProxyInfo::TRANSPARENT_PROXY_RESOLVES_HOST;
+    }
   }
 
   if (type) {
     rv = NewProxyInfo_Internal(type, *host, port, ""_ns, ""_ns, ""_ns, ""_ns,
                                proxyFlags, UINT32_MAX, nullptr, flags, result);
     if (NS_FAILED(rv)) return rv;
   }
 
@@ -2299,20 +2326,21 @@ void nsProtocolProxyService::PruneProxyI
 
   // Start by removing all disallowed proxies if required:
   if (!(info.flags & nsIProtocolHandler::ALLOWS_PROXY_HTTP)) {
     nsProxyInfo *last = nullptr, *iter = head;
     while (iter) {
       if ((iter->Type() == kProxyType_HTTP) ||
           (iter->Type() == kProxyType_HTTPS)) {
         // reject!
-        if (last)
+        if (last) {
           last->mNext = iter->mNext;
-        else
+        } else {
           head = iter->mNext;
+        }
         nsProxyInfo* next = iter->mNext;
         iter->mNext = nullptr;
         iter->Release();
         iter = next;
       } else {
         last = iter;
         iter = iter->mNext;
       }
@@ -2342,20 +2370,21 @@ void nsProtocolProxyService::PruneProxyI
     // remove any disabled proxies.
     nsProxyInfo* last = nullptr;
     for (iter = head; iter;) {
       if (IsProxyDisabled(iter)) {
         // reject!
         nsProxyInfo* reject = iter;
 
         iter = iter->mNext;
-        if (last)
+        if (last) {
           last->mNext = iter;
-        else
+        } else {
           head = iter;
+        }
 
         reject->mNext = nullptr;
         NS_RELEASE(reject);
         continue;
       }
 
       // since we are about to use this proxy, make sure it is not on
       // the disabled proxy list.  we'll add it back to that list if
@@ -2366,18 +2395,19 @@ void nsProtocolProxyService::PruneProxyI
       EnableProxy(iter);
 
       last = iter;
       iter = iter->mNext;
     }
   }
 
   // if only DIRECT was specified then return no proxy info, and we're done.
-  if (head && !head->mNext && head->mType == kProxyType_DIRECT)
+  if (head && !head->mNext && head->mType == kProxyType_DIRECT) {
     NS_RELEASE(head);
+  }
 
   *list = head;  // Transfer ownership
 
   LOG(("nsProtocolProxyService::PruneProxyInfo LEAVE list=%p", *list));
 }
 
 bool nsProtocolProxyService::GetIsPACLoading() {
   return mPACMan && mPACMan->IsLoading();
--- a/netwerk/base/nsProtocolProxyService.h
+++ b/netwerk/base/nsProtocolProxyService.h
@@ -20,17 +20,17 @@
 #include "mozilla/Attributes.h"
 
 class nsIPrefBranch;
 class nsISystemProxySettings;
 
 namespace mozilla {
 namespace net {
 
-typedef nsTHashMap<nsCStringHashKey, uint32_t> nsFailedProxyTable;
+using nsFailedProxyTable = nsTHashMap<nsCStringHashKey, uint32_t>;
 
 class nsPACMan;
 class nsProxyInfo;
 struct nsProtocolInfo;
 
 // CID for the nsProtocolProxyService class
 // 091eedd8-8bae-4fe3-ad62-0c87351e640d
 #define NS_PROTOCOL_PROXY_SERVICE_IMPL_CID           \
@@ -85,17 +85,17 @@ class nsProtocolProxyService final : pub
    * to initialize all preferences.
    *
    * @param prefs
    *        This must be a pointer to the root pref branch.
    * @param name
    *        This can be the name of a fully-qualified preference, or it can
    *        be null, in which case all preferences will be initialized.
    */
-  void PrefsChanged(nsIPrefBranch* prefs, const char* name);
+  void PrefsChanged(nsIPrefBranch* prefBranch, const char* pref);
 
   /**
    * This method is called to create a nsProxyInfo instance from the given
    * PAC-style proxy string.  It parses up to the end of the string, or to
    * the next ';' character.
    *
    * @param proxy
    *        The PAC-style proxy string to parse.  This must not be null.
@@ -103,26 +103,26 @@ class nsProtocolProxyService final : pub
    *        The flags passed to Resolve or AsyncResolve that are stored in
    *        proxyInfo.
    * @param result
    *        Upon return this points to a newly allocated nsProxyInfo or null
    *        if the proxy string was invalid.
    *
    * @return A pointer beyond the parsed proxy string (never null).
    */
-  const char* ExtractProxyInfo(const char* proxy, uint32_t aResolveFlags,
+  const char* ExtractProxyInfo(const char* start, uint32_t aResolveFlags,
                                nsProxyInfo** result);
 
   /**
    * Load the specified PAC file.
    *
    * @param pacURI
    *        The URI spec of the PAC file to load.
    */
-  nsresult ConfigureFromPAC(const nsCString& pacURI, bool forceReload);
+  nsresult ConfigureFromPAC(const nsCString& spec, bool forceReload);
 
   /**
    * This method builds a list of nsProxyInfo objects from the given PAC-
    * style string.
    *
    * @param pacString
    *        The PAC-style proxy string to parse.  This may be empty.
    * @param aResolveFlags
@@ -138,17 +138,17 @@ class nsProtocolProxyService final : pub
    * This method generates a string valued identifier for the given
    * nsProxyInfo object.
    *
    * @param pi
    *        The nsProxyInfo object from which to generate the key.
    * @param result
    *        Upon return, this parameter holds the generated key.
    */
-  void GetProxyKey(nsProxyInfo* pi, nsCString& result);
+  void GetProxyKey(nsProxyInfo* pi, nsCString& key);
 
   /**
    * @return Seconds since start of session.
    */
   uint32_t SecondsSinceSessionStart();
 
   /**
    * This method removes the specified proxy from the disabled list.
@@ -182,17 +182,17 @@ class nsProtocolProxyService final : pub
    *
    * @param uri
    *        The URI to query.
    * @param info
    *        Holds information about the protocol upon return.  Pass address
    *        of structure when you call this method.  This parameter must not
    *        be null.
    */
-  nsresult GetProtocolInfo(nsIURI* uri, nsProtocolInfo* result);
+  nsresult GetProtocolInfo(nsIURI* uri, nsProtocolInfo* info);
 
   /**
    * This method is an internal version nsIProtocolProxyService::newProxyInfo
    * that expects a string literal for the type.
    *
    * @param type
    *        The proxy type.
    * @param host
@@ -215,18 +215,18 @@ class nsProtocolProxyService final : pub
    *        The resulting nsIProxyInfo object.
    */
   nsresult NewProxyInfo_Internal(const char* type, const nsACString& host,
                                  int32_t port, const nsACString& username,
                                  const nsACString& password,
                                  const nsACString& aProxyAuthorizationHeader,
                                  const nsACString& aConnectionIsolationKey,
                                  uint32_t flags, uint32_t timeout,
-                                 nsIProxyInfo* next, uint32_t aResolveFlags,
-                                 nsIProxyInfo** result);
+                                 nsIProxyInfo* aFailoverProxy,
+                                 uint32_t aResolveFlags, nsIProxyInfo** result);
 
   /**
    * This method is an internal version of Resolve that does not query PAC.
    * It performs all of the built-in processing, and reports back to the
    * caller with either the proxy info result or a flag to instruct the
    * caller to use PAC instead.
    *
    * @param channel
@@ -253,29 +253,29 @@ class nsProtocolProxyService final : pub
   void CopyFilters(nsTArray<RefPtr<FilterLink>>& aCopy);
 
   /**
    * This method applies the provided filter to the given proxy info
    * list, and expects |callback| be called on (synchronously or
    * asynchronously) to provide the updated proxyinfo list.
    */
   bool ApplyFilter(FilterLink const* filterLink, nsIChannel* channel,
-                   const nsProtocolInfo& info, nsCOMPtr<nsIProxyInfo> proxyInfo,
+                   const nsProtocolInfo& info, nsCOMPtr<nsIProxyInfo> list,
                    nsIProxyProtocolFilterResult* callback);
 
   /**
    * This method prunes out disabled and disallowed proxies from a given
    * proxy info list.
    *
    * @param info
    *        Information about the URI's protocol.
    * @param proxyInfo
    *        The proxy info list to be modified.  This is an inout param.
    */
-  void PruneProxyInfo(const nsProtocolInfo& info, nsIProxyInfo** proxyInfo);
+  void PruneProxyInfo(const nsProtocolInfo& info, nsIProxyInfo** list);
 
   /**
    * This method is a simple wrapper around PruneProxyInfo that takes the
    * proxy info list inout param as a nsCOMPtr.
    */
   void PruneProxyInfo(const nsProtocolInfo& info,
                       nsCOMPtr<nsIProxyInfo>& proxyInfo) {
     nsIProxyInfo* pi = nullptr;
@@ -285,17 +285,17 @@ class nsProtocolProxyService final : pub
   }
 
   /**
    * This method populates mHostFiltersArray from the given string.
    *
    * @param hostFilters
    *        A "no-proxy-for" exclusion list.
    */
-  void LoadHostFilters(const nsACString& hostFilters);
+  void LoadHostFilters(const nsACString& aFilters);
 
   /**
    * This method checks the given URI against mHostFiltersArray.
    *
    * @param uri
    *        The URI to test.
    * @param defaultPort
    *        The default port for the given URI.
@@ -339,17 +339,17 @@ class nsProtocolProxyService final : pub
   };
 
  protected:
   // simplified array of filters defined by this struct
   struct HostInfo {
     bool is_ipaddr;
     int32_t port;
     union {
-      HostInfoIP ip;
+      HostInfoIP ip{};
       HostInfoName name;
     };
 
     HostInfo()
         : is_ipaddr(false),
           port(0) { /* other members intentionally uninitialized */
     }
     ~HostInfo() {
--- a/netwerk/base/nsServerSocket.cpp
+++ b/netwerk/base/nsServerSocket.cpp
@@ -17,17 +17,17 @@
 #include "nsServiceManagerUtils.h"
 #include "nsIFile.h"
 
 namespace mozilla {
 namespace net {
 
 //-----------------------------------------------------------------------------
 
-typedef void (nsServerSocket::*nsServerSocketFunc)(void);
+using nsServerSocketFunc = void (nsServerSocket::*)();
 
 static nsresult PostEvent(nsServerSocket* s, nsServerSocketFunc func) {
   nsCOMPtr<nsIRunnable> ev = NewRunnableMethod("net::PostEvent", s, func);
   if (!gSocketTransportService) return NS_ERROR_FAILURE;
 
   return gSocketTransportService->Dispatch(ev, NS_DISPATCH_NORMAL);
 }
 
@@ -279,18 +279,19 @@ nsServerSocket::InitWithFilename(nsIFile
   nsresult rv;
 
   nsAutoCString path;
   rv = aPath->GetNativePath(path);
   if (NS_FAILED(rv)) return rv;
 
   // Create a Unix domain PRNetAddr referring to the given path.
   PRNetAddr addr;
-  if (path.Length() > sizeof(addr.local.path) - 1)
+  if (path.Length() > sizeof(addr.local.path) - 1) {
     return NS_ERROR_FILE_NAME_TOO_LONG;
+  }
   addr.local.family = PR_AF_LOCAL;
   memcpy(addr.local.path, path.get(), path.Length());
   addr.local.path[path.Length()] = '\0';
 
   rv = InitWithAddress(&addr, aBacklog);
   if (NS_FAILED(rv)) return rv;
 
   return aPath->SetPermissions(aPermissions);
@@ -323,20 +324,21 @@ nsServerSocket::InitWithAbstractAddress(
 
 NS_IMETHODIMP
 nsServerSocket::InitSpecialConnection(int32_t aPort, nsServerSocketFlag aFlags,
                                       int32_t aBackLog) {
   PRNetAddrValue val;
   PRNetAddr addr;
 
   if (aPort < 0) aPort = 0;
-  if (aFlags & nsIServerSocket::LoopbackOnly)
+  if (aFlags & nsIServerSocket::LoopbackOnly) {
     val = PR_IpAddrLoopback;
-  else
+  } else {
     val = PR_IpAddrAny;
+  }
   PR_SetNetAddr(val, PR_AF_INET, aPort, &addr);
 
   mKeepWhenOffline = ((aFlags & nsIServerSocket::KeepWhenOffline) != 0);
   return InitWithAddress(&addr, aBackLog);
 }
 
 NS_IMETHODIMP
 nsServerSocket::InitWithAddress(const PRNetAddr* aAddr, int32_t aBackLog) {
@@ -523,22 +525,23 @@ nsServerSocket::AsyncListen(nsIServerSoc
 
   return PostEvent(this, &nsServerSocket::OnMsgAttach);
 }
 
 NS_IMETHODIMP
 nsServerSocket::GetPort(int32_t* aResult) {
   // no need to enter the lock here
   uint16_t port;
-  if (mAddr.raw.family == PR_AF_INET)
+  if (mAddr.raw.family == PR_AF_INET) {
     port = mAddr.inet.port;
-  else if (mAddr.raw.family == PR_AF_INET6)
+  } else if (mAddr.raw.family == PR_AF_INET6) {
     port = mAddr.ipv6.port;
-  else
+  } else {
     return NS_ERROR_FAILURE;
+  }
 
   *aResult = static_cast<int32_t>(NetworkEndian::readUint16(&port));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsServerSocket::GetAddress(PRNetAddr* aResult) {
   // no need to enter the lock here
--- a/netwerk/base/nsServerSocket.h
+++ b/netwerk/base/nsServerSocket.h
@@ -47,17 +47,17 @@ class nsServerSocket : public nsASocketH
   void OnMsgClose();
   void OnMsgAttach();
 
   // try attaching our socket (mFD) to the STS's poll list.
   nsresult TryAttach();
 
   // lock protects access to mListener; so it is not cleared while being used.
   mozilla::Mutex mLock;
-  PRNetAddr mAddr;
+  PRNetAddr mAddr = {.raw = {0, {0}}};
   nsCOMPtr<nsIEventTarget> mListenerTarget;
   bool mAttached;
   bool mKeepWhenOffline;
 };
 
 }  // namespace net
 }  // namespace mozilla
 
--- a/netwerk/base/nsSimpleURI.h
+++ b/netwerk/base/nsSimpleURI.h
@@ -50,31 +50,31 @@ class nsSimpleURI : public nsIURI, publi
   // - nsBlobURI: mPrincipal
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
 
  protected:
   // enum used in a few places to specify how .ref attribute should be handled
   enum RefHandlingEnum { eIgnoreRef, eHonorRef, eReplaceRef };
 
-  virtual nsresult Clone(nsIURI** aURI);
+  virtual nsresult Clone(nsIURI** result);
   virtual nsresult SetSpecInternal(const nsACString& aSpec,
                                    bool aStripWhitespace = false);
-  virtual nsresult SetScheme(const nsACString& input);
+  virtual nsresult SetScheme(const nsACString& scheme);
   virtual nsresult SetUserPass(const nsACString& input);
   nsresult SetUsername(const nsACString& input);
   virtual nsresult SetPassword(const nsACString& input);
   virtual nsresult SetHostPort(const nsACString& aValue);
   virtual nsresult SetHost(const nsACString& input);
   virtual nsresult SetPort(int32_t port);
-  virtual nsresult SetPathQueryRef(const nsACString& input);
-  virtual nsresult SetRef(const nsACString& input);
-  virtual nsresult SetFilePath(const nsACString& input);
-  virtual nsresult SetQuery(const nsACString& input);
-  virtual nsresult SetQueryWithEncoding(const nsACString& input,
+  virtual nsresult SetPathQueryRef(const nsACString& aPath);
+  virtual nsresult SetRef(const nsACString& aRef);
+  virtual nsresult SetFilePath(const nsACString& aFilePath);
+  virtual nsresult SetQuery(const nsACString& aQuery);
+  virtual nsresult SetQueryWithEncoding(const nsACString& aQuery,
                                         const Encoding* encoding);
   nsresult ReadPrivate(nsIObjectInputStream* stream);
 
   // Helper to share code between Equals methods.
   virtual nsresult EqualsInternal(nsIURI* other,
                                   RefHandlingEnum refHandlingMode,
                                   bool* result);
 
@@ -91,29 +91,28 @@ class nsSimpleURI : public nsIURI, publi
   // NOTE: This takes the refHandlingMode as an argument because
   // nsSimpleNestedURI's specialized version needs to know how to clone
   // its inner URI.
   virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode,
                                   const nsACString& newRef);
 
   // Helper to share code between Clone methods.
   virtual nsresult CloneInternal(RefHandlingEnum refHandlingMode,
-                                 const nsACString& newRef, nsIURI** clone);
+                                 const nsACString& newRef, nsIURI** result);
 
   nsresult EscapeAndSetPathQueryRef(const nsACString& aPath);
   nsresult SetPathQueryRefInternal(const nsACString& aPath);
 
   bool Deserialize(const mozilla::ipc::URIParams&);
 
   nsCString mScheme;
   nsCString mPath;  // NOTE: mPath does not include ref, as an optimization
   nsCString mRef;   // so that URIs with different refs can share string data.
   nsCString
       mQuery;  // so that URLs with different querys can share string data.
-  bool mMutable;
   bool mIsRefValid;    // To distinguish between empty-ref and no-ref.
   bool mIsQueryValid;  // To distinguish between empty-query and no-query.
 
  public:
   class Mutator final : public nsIURIMutator,
                         public BaseURIMutator<nsSimpleURI>,
                         public nsISimpleURIMutator,
                         public nsISerializable {
--- a/netwerk/base/nsSocketTransport2.cpp
+++ b/netwerk/base/nsSocketTransport2.cpp
@@ -339,19 +339,19 @@ nsSocketInputStream::Available(uint64_t*
   }
 
   nsresult rv;
   {
     MutexAutoLock lock(mTransport->mLock);
 
     mTransport->ReleaseFD_Locked(fd);
 
-    if (n >= 0)
+    if (n >= 0) {
       *avail = n;
-    else {
+    } else {
       PRErrorCode code = PR_GetError();
       if (code == PR_WOULD_BLOCK_ERROR) return NS_OK;
       mCondition = ErrorAccordingToNSPR(code);
     }
     rv = mCondition;
   }
   if (NS_FAILED(rv)) mTransport->OnInputClosed(rv);
   return rv;
@@ -362,18 +362,19 @@ nsSocketInputStream::Read(char* buf, uin
   SOCKET_LOG(("nsSocketInputStream::Read [this=%p count=%u]\n", this, count));
 
   *countRead = 0;
 
   PRFileDesc* fd = nullptr;
   {
     MutexAutoLock lock(mTransport->mLock);
 
-    if (NS_FAILED(mCondition))
+    if (NS_FAILED(mCondition)) {
       return (mCondition == NS_BASE_STREAM_CLOSED) ? NS_OK : mCondition;
+    }
 
     fd = mTransport->GetFD_Locked();
     if (!fd) return NS_BASE_STREAM_WOULD_BLOCK;
   }
 
   SOCKET_LOG(("  calling PR_Read [count=%u]\n", count));
 
   // cannot hold lock while calling NSPR.  (worried about the fact that PSM
@@ -388,19 +389,19 @@ nsSocketInputStream::Read(char* buf, uin
     MutexAutoLock lock(mTransport->mLock);
 
 #ifdef ENABLE_SOCKET_TRACING
     if (n > 0) mTransport->TraceInBuf(buf, n);
 #endif
 
     mTransport->ReleaseFD_Locked(fd);
 
-    if (n > 0)
+    if (n > 0) {
       mByteCount += (*countRead = n);
-    else if (n < 0) {
+    } else if (n < 0) {
       PRErrorCode code = PR_GetError();
       if (code == PR_WOULD_BLOCK_ERROR) return NS_BASE_STREAM_WOULD_BLOCK;
       mCondition = ErrorAccordingToNSPR(code);
     }
     rv = mCondition;
   }
   if (NS_FAILED(rv)) mTransport->OnInputClosed(rv);
 
@@ -430,20 +431,21 @@ nsSocketInputStream::CloseWithStatus(nsr
               this, static_cast<uint32_t>(reason)));
 
   // may be called from any thread
 
   nsresult rv;
   {
     MutexAutoLock lock(mTransport->mLock);
 
-    if (NS_SUCCEEDED(mCondition))
+    if (NS_SUCCEEDED(mCondition)) {
       rv = mCondition = reason;
-    else
+    } else {
       rv = NS_OK;
+    }
   }
   if (NS_FAILED(rv)) mTransport->OnInputClosed(rv);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSocketInputStream::AsyncWait(nsIInputStreamCallback* callback, uint32_t flags,
                                uint32_t amount, nsIEventTarget* target) {
@@ -454,18 +456,19 @@ nsSocketInputStream::AsyncWait(nsIInputS
     MutexAutoLock lock(mTransport->mLock);
 
     if (callback && target) {
       //
       // build event proxy
       //
       mCallback = NS_NewInputStreamReadyEvent("nsSocketInputStream::AsyncWait",
                                               callback, target);
-    } else
+    } else {
       mCallback = callback;
+    }
     mCallbackFlags = flags;
 
     hasError = NS_FAILED(mCondition);
   }  // unlock mTransport->mLock
 
   if (hasError) {
     // OnSocketEvent will call OnInputStreamReady with an error code after
     // going through the event loop. We do this because most socket callers
@@ -574,19 +577,19 @@ nsSocketOutputStream::Write(const char* 
     MutexAutoLock lock(mTransport->mLock);
 
 #ifdef ENABLE_SOCKET_TRACING
     if (n > 0) mTransport->TraceOutBuf(buf, n);
 #endif
 
     mTransport->ReleaseFD_Locked(fd);
 
-    if (n > 0)
+    if (n > 0) {
       mByteCount += (*countWritten = n);
-    else if (n < 0) {
+    } else if (n < 0) {
       PRErrorCode code = PR_GetError();
       if (code == PR_WOULD_BLOCK_ERROR) return NS_BASE_STREAM_WOULD_BLOCK;
       mCondition = ErrorAccordingToNSPR(code);
     }
     rv = mCondition;
   }
   if (NS_FAILED(rv)) mTransport->OnOutputClosed(rv);
 
@@ -632,20 +635,21 @@ nsSocketOutputStream::CloseWithStatus(ns
               this, static_cast<uint32_t>(reason)));
 
   // may be called from any thread
 
   nsresult rv;
   {
     MutexAutoLock lock(mTransport->mLock);
 
-    if (NS_SUCCEEDED(mCondition))
+    if (NS_SUCCEEDED(mCondition)) {
       rv = mCondition = reason;
-    else
+    } else {
       rv = NS_OK;
+    }
   }
   if (NS_FAILED(rv)) mTransport->OnOutputClosed(rv);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSocketOutputStream::AsyncWait(nsIOutputStreamCallback* callback,
                                 uint32_t flags, uint32_t amount,
@@ -655,18 +659,19 @@ nsSocketOutputStream::AsyncWait(nsIOutpu
   {
     MutexAutoLock lock(mTransport->mLock);
 
     if (callback && target) {
       //
       // build event proxy
       //
       mCallback = NS_NewOutputStreamReadyEvent(callback, target);
-    } else
+    } else {
       mCallback = callback;
+    }
 
     mCallbackFlags = flags;
   }
   mTransport->OnOutputPending();
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
@@ -793,20 +798,21 @@ nsresult nsSocketTransport::Init(const n
 
   if (!mTypes.SetCapacity(typeCount, fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   // now verify that each socket type has a registered socket provider.
   for (uint32_t i = 0, type = 0; i < typeCount; ++i) {
     // store socket types
-    if (i == 0 && proxyType)
+    if (i == 0 && proxyType) {
       mTypes.AppendElement(proxyType);
-    else
+    } else {
       mTypes.AppendElement(types[type++]);
+    }
 
     nsCOMPtr<nsISocketProvider> provider;
     rv = spserv->GetSocketProvider(mTypes[i].get(), getter_AddRefs(provider));
     if (NS_FAILED(rv)) {
       NS_WARNING("no registered socket provider");
       return rv;
     }
 
@@ -864,22 +870,23 @@ nsresult nsSocketTransport::InitWithConn
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
   NS_ASSERTION(!mFD.IsInitialized(), "already initialized");
 
   char buf[kNetAddrMaxCStrBufSize];
   addr->ToStringBuffer(buf, sizeof(buf));
   mHost.Assign(buf);
 
   uint16_t port;
-  if (addr->raw.family == AF_INET)
+  if (addr->raw.family == AF_INET) {
     port = addr->inet.port;
-  else if (addr->raw.family == AF_INET6)
+  } else if (addr->raw.family == AF_INET6) {
     port = addr->inet6.port;
-  else
+  } else {
     port = 0;
+  }
   mPort = ntohs(port);
 
   memcpy(&mNetAddr, addr, sizeof(NetAddr));
 
   mPollFlags = (PR_POLL_READ | PR_POLL_WRITE | PR_POLL_EXCEPT);
   mState = STATE_TRANSFERRING;
   SetSocketName(fd);
   mNetAddrIsSet = true;
@@ -1016,26 +1023,31 @@ nsresult nsSocketTransport::ResolveHost(
   }
   if (!dns) {
     return NS_ERROR_FAILURE;
   }
 
   mResolving = true;
 
   uint32_t dnsFlags = 0;
-  if (mConnectionFlags & nsSocketTransport::BYPASS_CACHE)
+  if (mConnectionFlags & nsSocketTransport::BYPASS_CACHE) {
     dnsFlags = nsIDNSService::RESOLVE_BYPASS_CACHE;
-  if (mConnectionFlags & nsSocketTransport::REFRESH_CACHE)
+  }
+  if (mConnectionFlags & nsSocketTransport::REFRESH_CACHE) {
     dnsFlags = nsIDNSService::RESOLVE_REFRESH_CACHE;
-  if (mConnectionFlags & nsSocketTransport::DISABLE_IPV6)
+  }
+  if (mConnectionFlags & nsSocketTransport::DISABLE_IPV6) {
     dnsFlags |= nsIDNSService::RESOLVE_DISABLE_IPV6;
-  if (mConnectionFlags & nsSocketTransport::DISABLE_IPV4)
+  }
+  if (mConnectionFlags & nsSocketTransport::DISABLE_IPV4) {
     dnsFlags |= nsIDNSService::RESOLVE_DISABLE_IPV4;
-  if (mConnectionFlags & nsSocketTransport::DISABLE_TRR)
+  }
+  if (mConnectionFlags & nsSocketTransport::DISABLE_TRR) {
     dnsFlags |= nsIDNSService::RESOLVE_DISABLE_TRR;
+  }
 
   if (mConnectionFlags & nsSocketTransport::USE_IP_HINT_ADDRESS) {
     dnsFlags |= nsIDNSService::RESOLVE_IP_HINT;
   }
 
   dnsFlags |= nsIDNSService::GetFlagsFromTRRMode(
       nsISocketTransport::GetTRRModeFromFlags(mConnectionFlags));
 
@@ -1089,27 +1101,31 @@ nsresult nsSocketTransport::BuildSocket(
 #if defined(XP_UNIX)
   MOZ_ASSERT(!mNetAddrIsSet || mNetAddr.raw.family != AF_LOCAL,
              "Unix domain sockets can't be used with socket types");
 #endif
 
   fd = nullptr;
 
   uint32_t controlFlags = 0;
-  if (mProxyTransparentResolvesHost)
+  if (mProxyTransparentResolvesHost) {
     controlFlags |= nsISocketProvider::PROXY_RESOLVES_HOST;
-
-  if (mConnectionFlags & nsISocketTransport::ANONYMOUS_CONNECT)
+  }
+
+  if (mConnectionFlags & nsISocketTransport::ANONYMOUS_CONNECT) {
     controlFlags |= nsISocketProvider::ANONYMOUS_CONNECT;
-
-  if (mConnectionFlags & nsISocketTransport::NO_PERMANENT_STORAGE)
+  }
+
+  if (mConnectionFlags & nsISocketTransport::NO_PERMANENT_STORAGE) {
     controlFlags |= nsISocketProvider::NO_PERMANENT_STORAGE;
-
-  if (mConnectionFlags & nsISocketTransport::BE_CONSERVATIVE)
+  }
+
+  if (mConnectionFlags & nsISocketTransport::BE_CONSERVATIVE) {
     controlFlags |= nsISocketProvider::BE_CONSERVATIVE;
+  }
 
   if (mConnectionFlags &
       nsISocketTransport::ANONYMOUS_CONNECT_ALLOW_CLIENT_CERT) {
     controlFlags |= nsISocketProvider::ANONYMOUS_CONNECT_ALLOW_CLIENT_CERT;
   }
 
   // by setting host to mOriginHost, instead of mHost we send the
   // SocketProvider (e.g. PSM) the origin hostname but can still do DNS
@@ -1264,18 +1280,19 @@ nsresult nsSocketTransport::InitiateSock
   // Hosts/Proxy Hosts that are Local IP Literals should not be speculatively
   // connected - Bug 853423.
   if (mConnectionFlags & nsISocketTransport::DISABLE_RFC1918 &&
       mNetAddr.IsIPAddrLocal()) {
     if (SOCKET_LOG_ENABLED()) {
       nsAutoCString netAddrCString;
       netAddrCString.SetLength(kIPv6CStrBufSize);
       if (!mNetAddr.ToStringBuffer(netAddrCString.BeginWriting(),
-                                   kIPv6CStrBufSize))
+                                   kIPv6CStrBufSize)) {
         netAddrCString = "<IP-to-string failed>"_ns;
+      }
       SOCKET_LOG(
           ("nsSocketTransport::InitiateSocket skipping "
            "speculative connection for host [%s:%d] proxy "
            "[%s:%d] with Local IP address [%s]",
            mHost.get(), mPort, mProxyHost.get(), mProxyPort,
            netAddrCString.get()));
     }
     mCondition = NS_ERROR_CONNECTION_REFUSED;
@@ -1533,22 +1550,22 @@ nsresult nsSocketTransport::InitiateSock
     OnSocketConnected();
   } else {
 #if defined(TEST_CONNECT_ERRORS)
     code = RandomizeConnectError(code);
 #endif
     //
     // If the PR_Connect(...) would block, then poll for a connection.
     //
-    if ((PR_WOULD_BLOCK_ERROR == code) || (PR_IN_PROGRESS_ERROR == code))
+    if ((PR_WOULD_BLOCK_ERROR == code) || (PR_IN_PROGRESS_ERROR == code)) {
       mPollFlags = (PR_POLL_EXCEPT | PR_POLL_WRITE);
-    //
-    // If the socket is already connected, then return success...
-    //
-    else if (PR_IS_CONNECTED_ERROR == code) {
+      //
+      // If the socket is already connected, then return success...
+      //
+    } else if (PR_IS_CONNECTED_ERROR == code) {
       //
       // we are connected!
       //
       OnSocketConnected();
 
       if (mSecInfo && !mProxyHost.IsEmpty() && proxyTransparent && usingSSL) {
         // if the connection phase is finished, and the ssl layer has
         // been pushed, and we were proxying (transparently; ie. nothing
@@ -1586,18 +1603,19 @@ nsresult nsSocketTransport::InitiateSock
             connectStarted, Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_NORMAL,
             Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_SHUTDOWN,
             Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_CONNECTIVITY_CHANGE,
             Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_LINK_CHANGE,
             Telemetry::PRCONNECT_FAIL_BLOCKING_TIME_OFFLINE);
       }
 
       rv = ErrorAccordingToNSPR(code);
-      if ((rv == NS_ERROR_CONNECTION_REFUSED) && !mProxyHost.IsEmpty())
+      if ((rv == NS_ERROR_CONNECTION_REFUSED) && !mProxyHost.IsEmpty()) {
         rv = NS_ERROR_PROXY_CONNECTION_REFUSED;
+      }
     }
   }
   return rv;
 }
 
 bool nsSocketTransport::RecoverFromError() {
   NS_ASSERTION(NS_FAILED(mCondition), "there should be something wrong");
 
@@ -1767,43 +1785,43 @@ void nsSocketTransport::OnMsgInputClosed
   SOCKET_LOG(("nsSocketTransport::OnMsgInputClosed [this=%p reason=%" PRIx32
               "]\n",
               this, static_cast<uint32_t>(reason)));
 
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
 
   mInputClosed = true;
   // check if event should affect entire transport
-  if (NS_FAILED(reason) && (reason != NS_BASE_STREAM_CLOSED))
+  if (NS_FAILED(reason) && (reason != NS_BASE_STREAM_CLOSED)) {
     mCondition = reason;  // XXX except if NS_FAILED(mCondition), right??
-  else if (mOutputClosed)
+  } else if (mOutputClosed) {
     mCondition =
         NS_BASE_STREAM_CLOSED;  // XXX except if NS_FAILED(mCondition), right??
-  else {
+  } else {
     if (mState == STATE_TRANSFERRING) mPollFlags &= ~PR_POLL_READ;
     mInput.OnSocketReady(reason);
   }
 }
 
 // called on the socket thread only
 void nsSocketTransport::OnMsgOutputClosed(nsresult reason) {
   SOCKET_LOG(("nsSocketTransport::OnMsgOutputClosed [this=%p reason=%" PRIx32
               "]\n",
               this, static_cast<uint32_t>(reason)));
 
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
 
   mOutputClosed = true;
   // check if event should affect entire transport
-  if (NS_FAILED(reason) && (reason != NS_BASE_STREAM_CLOSED))
+  if (NS_FAILED(reason) && (reason != NS_BASE_STREAM_CLOSED)) {
     mCondition = reason;  // XXX except if NS_FAILED(mCondition), right??
-  else if (mInputClosed)
+  } else if (mInputClosed) {
     mCondition =
         NS_BASE_STREAM_CLOSED;  // XXX except if NS_FAILED(mCondition), right??
-  else {
+  } else {
     if (mState == STATE_TRANSFERRING) mPollFlags &= ~PR_POLL_WRITE;
     mOutput.OnSocketReady(reason);
   }
 }
 
 void nsSocketTransport::OnSocketConnected() {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
   SOCKET_LOG(("  advancing to STATE_TRANSFERRING\n"));
@@ -1961,19 +1979,19 @@ void nsSocketTransport::OnSocketEvent(ui
       // ensure that we have created a socket, attached it, and have a
       // connection.
       //
       if (mState == STATE_CLOSED) {
         // Unix domain sockets are ready to connect; mNetAddr is all we
         // need. Internet address families require a DNS lookup (or possibly
         // several) before we can connect.
 #if defined(XP_UNIX)
-        if (mNetAddrIsSet && mNetAddr.raw.family == AF_LOCAL)
+        if (mNetAddrIsSet && mNetAddr.raw.family == AF_LOCAL) {
           mCondition = InitiateSocket();
-        else
+        } else
 #endif
           mCondition = ResolveHost();
 
       } else {
         SOCKET_LOG(("  ignoring redundant event\n"));
       }
       break;
 
@@ -1992,20 +2010,21 @@ void nsSocketTransport::OnSocketEvent(ui
       // status contains DNS lookup status
       if (NS_FAILED(status)) {
         // When using a HTTP proxy, NS_ERROR_UNKNOWN_HOST means the HTTP
         // proxy host is not found, so we fixup the error code.
         // For SOCKS proxies (mProxyTransparent == true), the socket
         // transport resolves the real host here, so there's no fixup
         // (see bug 226943).
         if ((status == NS_ERROR_UNKNOWN_HOST) && !mProxyTransparent &&
-            !mProxyHost.IsEmpty())
+            !mProxyHost.IsEmpty()) {
           mCondition = NS_ERROR_UNKNOWN_PROXY_HOST;
-        else
+        } else {
           mCondition = status;
+        }
       } else if (mState == STATE_RESOLVING) {
         mCondition = InitiateSocket();
       }
       break;
 
     case MSG_RETRY_INIT_SOCKET:
       mCondition = InitiateSocket();
       break;
@@ -2040,20 +2059,22 @@ void nsSocketTransport::OnSocketEvent(ui
       break;
     default:
       SOCKET_LOG(("  unhandled event!\n"));
   }
 
   if (NS_FAILED(mCondition)) {
     SOCKET_LOG(("  after event [this=%p cond=%" PRIx32 "]\n", this,
                 static_cast<uint32_t>(mCondition)));
-    if (!mAttached)  // need to process this error ourselves...
+    if (!mAttached) {  // need to process this error ourselves...
       OnSocketDetached(nullptr);
-  } else if (mPollFlags == PR_POLL_EXCEPT)
+    }
+  } else if (mPollFlags == PR_POLL_EXCEPT) {
     mPollFlags = 0;  // make idle
+  }
 }
 
 //-----------------------------------------------------------------------------
 // socket handler impl
 
 void nsSocketTransport::OnSocketReady(PRFileDesc* fd, int16_t outFlags) {
   SOCKET_LOG1(("nsSocketTransport::OnSocketReady [this=%p outFlags=%hd]\n",
                this, outFlags));
@@ -2150,18 +2171,19 @@ void nsSocketTransport::OnSocketReady(PR
         code = PR_GetOSError();
         mCondition = ErrorAccordingToNSPR(code);
       } else {
         //
         // else, the connection failed...
         //
         mCondition = ErrorAccordingToNSPR(code);
         if ((mCondition == NS_ERROR_CONNECTION_REFUSED) &&
-            !mProxyHost.IsEmpty())
+            !mProxyHost.IsEmpty()) {
           mCondition = NS_ERROR_PROXY_CONNECTION_REFUSED;
+        }
         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(
@@ -2192,19 +2214,19 @@ void nsSocketTransport::OnSocketDetached
     if (gIOService->IsOffline()) {
       mCondition = NS_ERROR_OFFLINE;
     } else {
       mCondition = NS_ERROR_ABORT;
     }
   }
 
   // If we are not shutting down try again.
-  if (!gIOService->IsNetTearingDown() && RecoverFromError())
+  if (!gIOService->IsNetTearingDown() && RecoverFromError()) {
     mCondition = NS_OK;
-  else {
+  } else {
     mState = STATE_CLOSED;
 
     // make sure there isn't any pending DNS request
     if (mDNSRequest) {
       mDNSRequest->Cancel(NS_ERROR_ABORT);
       mDNSRequest = nullptr;
     }
 
@@ -2301,18 +2323,19 @@ nsSocketTransport::OpenInputStream(uint3
     if (NS_FAILED(rv)) return rv;
 
     // async copy from socket to pipe
     rv = NS_AsyncCopy(&mInput, pipeOut, mSocketTransportService,
                       NS_ASYNCCOPY_VIA_WRITESEGMENTS, segsize);
     if (NS_FAILED(rv)) return rv;
 
     *result = pipeIn;
-  } else
+  } else {
     *result = &mInput;
+  }
 
   // flag input stream as open
   mInputClosed = false;
 
   rv = PostEvent(MSG_ENSURE_CONNECT);
   if (NS_FAILED(rv)) return rv;
 
   NS_ADDREF(*result);
@@ -2344,18 +2367,19 @@ nsSocketTransport::OpenOutputStream(uint
     if (NS_FAILED(rv)) return rv;
 
     // async copy from socket to pipe
     rv = NS_AsyncCopy(pipeIn, &mOutput, mSocketTransportService,
                       NS_ASYNCCOPY_VIA_READSEGMENTS, segsize);
     if (NS_FAILED(rv)) return rv;
 
     *result = pipeOut;
-  } else
+  } else {
     *result = &mOutput;
+  }
 
   // flag output stream as open
   mOutputClosed = false;
 
   rv = PostEvent(MSG_ENSURE_CONNECT);
   if (NS_FAILED(rv)) return rv;
 
   NS_ADDREF(*result);
@@ -2440,18 +2464,19 @@ nsSocketTransport::IsAlive(bool* result)
     return NS_OK;
   }
 
   // XXX do some idle-time based checks??
 
   char c;
   int32_t rval = PR_Recv(fd, &c, 1, PR_MSG_PEEK, 0);
 
-  if ((rval > 0) || (rval < 0 && PR_GetError() == PR_WOULD_BLOCK_ERROR))
+  if ((rval > 0) || (rval < 0 && PR_GetError() == PR_WOULD_BLOCK_ERROR)) {
     *result = true;
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSocketTransport::GetHost(nsACString& host) {
   host = SocketHost();
   return NS_OK;
@@ -2644,36 +2669,38 @@ nsSocketTransport::GetQoSBits(uint8_t* a
 NS_IMETHODIMP
 nsSocketTransport::GetRecvBufferSize(uint32_t* aSize) {
   PRFileDescAutoLock fd(this);
   if (!fd.IsInitialized()) return NS_ERROR_NOT_CONNECTED;
 
   nsresult rv = NS_OK;
   PRSocketOptionData opt;
   opt.option = PR_SockOpt_RecvBufferSize;
-  if (PR_GetSocketOption(fd, &opt) == PR_SUCCESS)
+  if (PR_GetSocketOption(fd, &opt) == PR_SUCCESS) {
     *aSize = opt.value.recv_buffer_size;
-  else
+  } else {
     rv = NS_ERROR_FAILURE;
+  }
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsSocketTransport::GetSendBufferSize(uint32_t* aSize) {
   PRFileDescAutoLock fd(this);
   if (!fd.IsInitialized()) return NS_ERROR_NOT_CONNECTED;
 
   nsresult rv = NS_OK;
   PRSocketOptionData opt;
   opt.option = PR_SockOpt_SendBufferSize;
-  if (PR_GetSocketOption(fd, &opt) == PR_SUCCESS)
+  if (PR_GetSocketOption(fd, &opt) == PR_SUCCESS) {
     *aSize = opt.value.send_buffer_size;
-  else
+  } else {
     rv = NS_ERROR_FAILURE;
+  }
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsSocketTransport::SetRecvBufferSize(uint32_t aSize) {
   PRFileDescAutoLock fd(this);
   if (!fd.IsInitialized()) return NS_ERROR_NOT_CONNECTED;
--- a/netwerk/base/nsSocketTransport2.h
+++ b/netwerk/base/nsSocketTransport2.h
@@ -130,17 +130,17 @@ class nsSocketTransport final : public n
                 nsIProxyInfo* proxyInfo, nsIDNSRecord* dnsRecord);
 
   // this method instructs the socket transport to use an already connected
   // socket with the given address.
   nsresult InitWithConnectedSocket(PRFileDesc* socketFD, const NetAddr* addr);
 
   // this method instructs the socket transport to use an already connected
   // socket with the given address, and additionally supplies security info.
-  nsresult InitWithConnectedSocket(PRFileDesc* aSocketFD, const NetAddr* aAddr,
+  nsresult InitWithConnectedSocket(PRFileDesc* aFD, const NetAddr* aAddr,
                                    nsISupports* aSecInfo);
 
 #ifdef XP_UNIX
   // This method instructs the socket transport to open a socket
   // connected to the given Unix domain address. We can only create
   // unlayered, simple, stream sockets.
   nsresult InitWithFilename(const char* filename);
 
@@ -339,22 +339,24 @@ class nsSocketTransport final : public n
 
   void SendStatus(nsresult status);
   nsresult ResolveHost();
   nsresult BuildSocket(PRFileDesc*&, bool&, bool&);
   nsresult InitiateSocket();
   bool RecoverFromError();
 
   void OnMsgInputPending() {
-    if (mState == STATE_TRANSFERRING)
+    if (mState == STATE_TRANSFERRING) {
       mPollFlags |= (PR_POLL_READ | PR_POLL_EXCEPT);
+    }
   }
   void OnMsgOutputPending() {
-    if (mState == STATE_TRANSFERRING)
+    if (mState == STATE_TRANSFERRING) {
       mPollFlags |= (PR_POLL_WRITE | PR_POLL_EXCEPT);
+    }
   }
   void OnMsgInputClosed(nsresult reason);
   void OnMsgOutputClosed(nsresult reason);
 
   // called when the socket is connected
   void OnSocketConnected();
 
   //-------------------------------------------------------------------------
@@ -377,17 +379,17 @@ class nsSocketTransport final : public n
 
   nsSocketInputStream mInput;
   nsSocketOutputStream mOutput;
 
   friend class nsSocketInputStream;
   friend class nsSocketOutputStream;
 
   // socket timeouts are protected by mLock.
-  uint16_t mTimeouts[2];
+  uint16_t mTimeouts[2]{};
 
   // linger options to use when closing
   bool mLingerPolarity;
   int16_t mLingerTimeout;
 
   // QoS setting for socket
   uint8_t mQoSBits;
 
@@ -397,41 +399,45 @@ class nsSocketTransport final : public n
   PRFileDesc* GetFD_Locked();
   void ReleaseFD_Locked(PRFileDesc* fd);
 
   //
   // stream state changes (called outside mLock):
   //
   void OnInputClosed(nsresult reason) {
     // no need to post an event if called on the socket thread
-    if (OnSocketThread())
+    if (OnSocketThread()) {
       OnMsgInputClosed(reason);
-    else
+    } else {
       PostEvent(MSG_INPUT_CLOSED, reason);
+    }
   }
   void OnInputPending() {
     // no need to post an event if called on the socket thread
-    if (OnSocketThread())
+    if (OnSocketThread()) {
       OnMsgInputPending();
-    else
+    } else {
       PostEvent(MSG_INPUT_PENDING);
+    }
   }
   void OnOutputClosed(nsresult reason) {
     // no need to post an event if called on the socket thread
-    if (OnSocketThread())
+    if (OnSocketThread()) {
       OnMsgOutputClosed(reason);  // XXX need to not be inside lock!
-    else
+    } else {
       PostEvent(MSG_OUTPUT_CLOSED, reason);
+    }
   }
   void OnOutputPending() {
     // no need to post an event if called on the socket thread
-    if (OnSocketThread())
+    if (OnSocketThread()) {
       OnMsgOutputPending();
-    else
+    } else {
       PostEvent(MSG_OUTPUT_PENDING);
+    }
   }
 
 #ifdef ENABLE_SOCKET_TRACING
   void TraceInBuf(const char* buf, int32_t n);
   void TraceOutBuf(const char* buf, int32_t n);
 #endif
 
   // Reads prefs to get default keepalive config.
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -405,17 +405,17 @@ nsSocketTransportService::AttachSocket(P
       ("nsSocketTransportService::AttachSocket [handler=%p]\n", handler));
 
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
 
   if (!CanAttachSocket()) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  SocketContext sock;
+  SocketContext sock{};
   sock.mFD = fd;
   sock.mHandler = handler;
   sock.mPollStartEpoch = 0;
 
   nsresult rv = AddToIdleList(&sock);
   if (NS_SUCCEEDED(rv)) NS_ADDREF(handler);
   return rv;
 }
@@ -458,20 +458,21 @@ nsresult nsSocketTransportService::Detac
   }
   mSentBytesCount += sock->mHandler->ByteCountSent();
   mReceivedBytesCount += sock->mHandler->ByteCountReceived();
 
   // cleanup
   sock->mFD = nullptr;
   NS_RELEASE(sock->mHandler);
 
-  if (listHead == mActiveList)
+  if (listHead == mActiveList) {
     RemoveFromPollList(sock);
-  else
+  } else {
     RemoveFromIdleList(sock);
+  }
 
   // NOTE: sock is now an invalid pointer
 
   //
   // notify the first element on the pending socket queue...
   //
   nsCOMPtr<nsIRunnable> event;
   LinkedRunnableEvent* runnable = mPendingSocketQueue.getFirst();
@@ -571,28 +572,30 @@ void nsSocketTransportService::RemoveFro
   if (index != mIdleCount - 1) mIdleList[index] = mIdleList[mIdleCount - 1];
   mIdleCount--;
 
   SOCKET_LOG(("  active=%u idle=%u\n", mActiveCount, mIdleCount));
 }
 
 void nsSocketTransportService::MoveToIdleList(SocketContext* sock) {
   nsresult rv = AddToIdleList(sock);
-  if (NS_FAILED(rv))
+  if (NS_FAILED(rv)) {
     DetachSocket(mActiveList, sock);
-  else
+  } else {
     RemoveFromPollList(sock);
+  }
 }
 
 void nsSocketTransportService::MoveToPollList(SocketContext* sock) {
   nsresult rv = AddToPollList(sock);
-  if (NS_FAILED(rv))
+  if (NS_FAILED(rv)) {
     DetachSocket(mIdleList, sock);
-  else
+  } else {
     RemoveFromIdleList(sock);
+  }
 }
 
 bool nsSocketTransportService::GrowActiveList() {
   int32_t toAdd = gMaxCount - mActiveListSize;
   if (toAdd > 100) {
     toAdd = 100;
   } else if (toAdd < 1) {
     MOZ_ASSERT(false, "CanAttachSocket() should prevent this");
@@ -670,20 +673,21 @@ int32_t nsSocketTransportService::Poll(T
   if (mPollList[0].fd) {
     mPollList[0].out_flags = 0;
     pollList = mPollList;
     pollCount = mActiveCount + 1;
     pollTimeout = pendingEvents ? PR_INTERVAL_NO_WAIT : PollTimeout(ts);
   } else {
     // no pollable event, so busy wait...
     pollCount = mActiveCount;
-    if (pollCount)
+    if (pollCount) {
       pollList = &mPollList[1];
-    else
+    } else {
       pollList = nullptr;
+    }
     pollTimeout =
         pendingEvents ? PR_INTERVAL_NO_WAIT : PR_MillisecondsToInterval(25);
   }
 
   if ((ts - mLastNetworkLinkChangeTime) < mNetworkLinkChangeBusyWaitPeriod) {
     // Being here means we are few seconds after a network change has
     // been detected.
     PRIntervalTime to = mNetworkLinkChangeBusyWaitTimeout;
@@ -1318,20 +1322,21 @@ nsresult nsSocketTransportService::DoPol
   for (i = count - 1; i >= 0; --i) {
     //---
     SOCKET_LOG(("  idle [%u] { handler=%p condition=%" PRIx32
                 " pollflags=%hu }\n",
                 i, mIdleList[i].mHandler,
                 static_cast<uint32_t>(mIdleList[i].mHandler->mCondition),
                 mIdleList[i].mHandler->mPollFlags));
     //---
-    if (NS_FAILED(mIdleList[i].mHandler->mCondition))
+    if (NS_FAILED(mIdleList[i].mHandler->mCondition)) {
       DetachSocket(mIdleList, &mIdleList[i]);
-    else if (mIdleList[i].mHandler->mPollFlags != 0)
+    } else if (mIdleList[i].mHandler->mPollFlags != 0) {
       MoveToPollList(&mIdleList[i]);
+    }
   }
 
   {
     MutexAutoLock lock(mLock);
     if (mPollableEvent) {
       // we want to make sure the timeout is measured from the time
       // we enter poll().  This method resets the timestamp to 'now',
       // if we were first signalled between leaving poll() and here.
@@ -1399,18 +1404,19 @@ nsresult nsSocketTransportService::DoPol
         s.MaybeResetEpoch();
       }
     }
     //
     // check for "dead" sockets and remove them (need to do this in
     // reverse order obviously).
     //
     for (i = mActiveCount - 1; i >= 0; --i) {
-      if (NS_FAILED(mActiveList[i].mHandler->mCondition))
+      if (NS_FAILED(mActiveList[i].mHandler->mCondition)) {
         DetachSocket(mActiveList, &mActiveList[i]);
+      }
     }
 
     {
       MutexAutoLock lock(mLock);
       // acknowledge pollable event (should not block)
       if (n != 0 &&
           (mPollList[0].out_flags & (PR_POLL_READ | PR_POLL_EXCEPT)) &&
           mPollableEvent &&
@@ -1455,30 +1461,33 @@ nsresult nsSocketTransportService::Updat
   mSendBufferSize = 0;
 
   UpdateSendBufferPref();
 
   // Default TCP Keepalive Values.
   int32_t keepaliveIdleTimeS;
   nsresult rv =
       Preferences::GetInt(KEEPALIVE_IDLE_TIME_PREF, &keepaliveIdleTimeS);
-  if (NS_SUCCEEDED(rv))
+  if (NS_SUCCEEDED(rv)) {
     mKeepaliveIdleTimeS = clamped(keepaliveIdleTimeS, 1, kMaxTCPKeepIdle);
+  }
 
   int32_t keepaliveRetryIntervalS;
   rv = Preferences::GetInt(KEEPALIVE_RETRY_INTERVAL_PREF,
                            &keepaliveRetryIntervalS);
-  if (NS_SUCCEEDED(rv))
+  if (NS_SUCCEEDED(rv)) {
     mKeepaliveRetryIntervalS =
         clamped(keepaliveRetryIntervalS, 1, kMaxTCPKeepIntvl);
+  }
 
   int32_t keepaliveProbeCount;
   rv = Preferences::GetInt(KEEPALIVE_PROBE_COUNT_PREF, &keepaliveProbeCount);
-  if (NS_SUCCEEDED(rv))
+  if (NS_SUCCEEDED(rv)) {
     mKeepaliveProbeCount = clamped(keepaliveProbeCount, 1, kMaxTCPKeepCount);
+  }
   bool keepaliveEnabled = false;
   rv = Preferences::GetBool(KEEPALIVE_ENABLED_PREF, &keepaliveEnabled);
   if (NS_SUCCEEDED(rv) && keepaliveEnabled != mKeepaliveEnabledPref) {
     mKeepaliveEnabledPref = keepaliveEnabled;
     OnKeepaliveEnabledPrefChange();
   }
 
   int32_t maxTimePref;
@@ -1719,19 +1728,20 @@ PRStatus nsSocketTransportService::Disco
   gMaxCount = SOCKET_LIMIT_MIN;
 
 #if defined(XP_UNIX) && !defined(AIX) && !defined(NEXTSTEP) && !defined(QNX)
   // On unix and os x network sockets and file
   // descriptors are the same. OS X comes defaulted at 256,
   // most linux at 1000. We can reliably use [sg]rlimit to
   // query that and raise it if needed.
 
-  struct rlimit rlimitData;
-  if (getrlimit(RLIMIT_NOFILE, &rlimitData) == -1)  // rlimit broken - use min
+  struct rlimit rlimitData {};
+  if (getrlimit(RLIMIT_NOFILE, &rlimitData) == -1) {  // rlimit broken - use min
     return PR_SUCCESS;
+  }
 
   if (rlimitData.rlim_cur >= SOCKET_LIMIT_TARGET) {  // larger than target!
     gMaxCount = SOCKET_LIMIT_TARGET;
     return PR_SUCCESS;
   }
 
   int32_t maxallowed = rlimitData.rlim_max;
   if ((uint32_t)maxallowed <= SOCKET_LIMIT_MIN) {
@@ -1786,35 +1796,38 @@ void nsSocketTransportService::AnalyzeCo
 
   char host[64] = {0};
   rv = PR_NetAddrToString(&peer_addr, host, sizeof(host));
   if (rv != PR_SUCCESS) {
     return;
   }
 
   uint16_t port;
-  if (peer_addr.raw.family == PR_AF_INET)
+  if (peer_addr.raw.family == PR_AF_INET) {
     port = peer_addr.inet.port;
-  else
+  } else {
     port = peer_addr.ipv6.port;
+  }
   port = PR_ntohs(port);
   uint64_t sent = context->mHandler->ByteCountSent();
   uint64_t received = context->mHandler->ByteCountReceived();
   SocketInfo info = {nsCString(host), sent, received, port, aActive, tcp};
 
   data->AppendElement(info);
 }
 
 void nsSocketTransportService::GetSocketConnections(
     nsTArray<SocketInfo>* data) {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
-  for (uint32_t i = 0; i < mActiveCount; i++)
+  for (uint32_t i = 0; i < mActiveCount; i++) {
     AnalyzeConnection(data, &mActiveList[i], true);
-  for (uint32_t i = 0; i < mIdleCount; i++)
+  }
+  for (uint32_t i = 0; i < mIdleCount; i++) {
     AnalyzeConnection(data, &mIdleList[i], false);
+  }
 }
 
 bool nsSocketTransportService::IsTelemetryEnabledAndNotSleepPhase() {
   return Telemetry::CanRecordPrereleaseData() && !mSleepPhase;
 }
 
 #if defined(XP_WIN)
 void nsSocketTransportService::StartPollWatchdog() {
--- a/netwerk/base/nsSocketTransportService2.h
+++ b/netwerk/base/nsSocketTransportService2.h
@@ -246,17 +246,17 @@ class nsSocketTransportService final : p
   //-------------------------------------------------------------------------
 
   PRPollDesc* mPollList; /* mListSize + 1 entries */
 
   PRIntervalTime PollTimeout(
       PRIntervalTime now);  // computes ideal poll timeout
   nsresult DoPollIteration(TimeDuration* pollDuration);
   // perfoms a single poll iteration
-  int32_t Poll(TimeDuration* pollDuration, PRIntervalTime now);
+  int32_t Poll(TimeDuration* pollDuration, PRIntervalTime ts);
   // calls PR_Poll.  the out param
   // interval indicates the poll
   // duration in seconds.
   // pollDuration is used only for
   // telemetry
 
   //-------------------------------------------------------------------------
   // pending socket queue - see NotifyWhenCanAttachSocket
@@ -298,17 +298,17 @@ class nsSocketTransportService final : p
   nsCOMPtr<nsITimer> mAfterWakeUpTimer;
 
   // Lazily created array of forced port remappings.  The tuple members meaning
   // is exactly:
   // <0> the greater-or-equal port number of the range to remap
   // <1> the less-or-equal port number of the range to remap
   // <2> the port number to remap to, when the given port number falls to the
   // range
-  typedef CopyableTArray<Tuple<uint16_t, uint16_t, uint16_t>> TPortRemapping;
+  using TPortRemapping = CopyableTArray<Tuple<uint16_t, uint16_t, uint16_t>>;
   Maybe<TPortRemapping> mPortRemapping;
 
   // Called on the socket thread to apply the mapping build on the main thread
   // from the preference.
   void ApplyPortRemapPreference(TPortRemapping const& portRemapping);
 
   void OnKeepaliveEnabledPrefChange();
   void NotifyKeepaliveEnabledPrefChange(SocketContext* sock);
--- a/netwerk/base/nsStandardURL.h
+++ b/netwerk/base/nsStandardURL.h
@@ -210,37 +210,37 @@ class nsStandardURL : public nsIFileURL,
   int32_t ReplaceSegment(uint32_t pos, uint32_t len, const nsACString& val);
 
   nsresult ParseURL(const char* spec, int32_t specLen);
   nsresult ParsePath(const char* spec, uint32_t pathPos, int32_t pathLen = -1);
 
   char* AppendToSubstring(uint32_t pos, int32_t len, const char* tail);
 
   // dependent substring helpers
-  const nsDependentCSubstring Segment(uint32_t pos, int32_t len);  // see below
-  const nsDependentCSubstring Segment(const URLSegment& s) {
+  nsDependentCSubstring Segment(uint32_t pos, int32_t len);  // see below
+  nsDependentCSubstring Segment(const URLSegment& s) {
     return Segment(s.mPos, s.mLen);
   }
 
   // dependent substring getters
-  const nsDependentCSubstring Prepath();  // see below
-  const nsDependentCSubstring Scheme() { return Segment(mScheme); }
-  const nsDependentCSubstring Userpass(bool includeDelim = false);  // see below
-  const nsDependentCSubstring Username() { return Segment(mUsername); }
-  const nsDependentCSubstring Password() { return Segment(mPassword); }
-  const nsDependentCSubstring Hostport();  // see below
-  const nsDependentCSubstring Host();      // see below
-  const nsDependentCSubstring Path() { return Segment(mPath); }
-  const nsDependentCSubstring Filepath() { return Segment(mFilepath); }
-  const nsDependentCSubstring Directory() { return Segment(mDirectory); }
-  const nsDependentCSubstring Filename();  // see below
-  const nsDependentCSubstring Basename() { return Segment(mBasename); }
-  const nsDependentCSubstring Extension() { return Segment(mExtension); }
-  const nsDependentCSubstring Query() { return Segment(mQuery); }
-  const nsDependentCSubstring Ref() { return Segment(mRef); }
+  nsDependentCSubstring Prepath();  // see below
+  nsDependentCSubstring Scheme() { return Segment(mScheme); }
+  nsDependentCSubstring Userpass(bool includeDelim = false);  // see below
+  nsDependentCSubstring Username() { return Segment(mUsername); }
+  nsDependentCSubstring Password() { return Segment(mPassword); }
+  nsDependentCSubstring Hostport();  // see below
+  nsDependentCSubstring Host();      // see below
+  nsDependentCSubstring Path() { return Segment(mPath); }
+  nsDependentCSubstring Filepath() { return Segment(mFilepath); }
+  nsDependentCSubstring Directory() { return Segment(mDirectory); }
+  nsDependentCSubstring Filename();  // see below
+  nsDependentCSubstring Basename() { return Segment(mBasename); }
+  nsDependentCSubstring Extension() { return Segment(mExtension); }
+  nsDependentCSubstring Query() { return Segment(mQuery); }
+  nsDependentCSubstring Ref() { return Segment(mRef); }
 
   // shift the URLSegments to the right by diff
   void ShiftFromAuthority(int32_t diff);
   void ShiftFromUsername(int32_t diff);
   void ShiftFromPassword(int32_t diff);
   void ShiftFromHost(int32_t diff);
   void ShiftFromPath(int32_t diff);
   void ShiftFromFilepath(int32_t diff);
@@ -471,32 +471,31 @@ class nsStandardURL : public nsIFileURL,
       0xaf, 0x5a, 0x79, 0x59, 0x67, 0x70, 0xf5, 0xd7 \
     }                                                \
   }
 
 //-----------------------------------------------------------------------------
 // Dependent substring getters
 //-----------------------------------------------------------------------------
 
-inline const nsDependentCSubstring nsStandardURL::Segment(uint32_t pos,
-                                                          int32_t len) {
+inline nsDependentCSubstring nsStandardURL::Segment(uint32_t pos, int32_t len) {
   if (len < 0) {
     pos = 0;
     len = 0;
   }
   return Substring(mSpec, pos, uint32_t(len));
 }
 
-inline const nsDependentCSubstring nsStandardURL::Prepath() {
+inline nsDependentCSubstring nsStandardURL::Prepath() {
   uint32_t len = 0;
   if (mAuthority.mLen >= 0) len = mAuthority.mPos + mAuthority.mLen;
   return Substring(mSpec, 0, len);
 }
 
-inline const nsDependentCSubstring nsStandardURL::Userpass(bool includeDelim) {
+inline nsDependentCSubstring nsStandardURL::Userpass(bool includeDelim) {
   uint32_t pos = 0, len = 0;
   if (mUsername.mLen > 0 || mPassword.mLen > 0) {
     if (mUsername.mLen > 0) {
       pos = mUsername.mPos;
       len = mUsername.mLen;
       if (mPassword.mLen >= 0) {
         len += (mPassword.mLen + 1);
       }
@@ -505,39 +504,39 @@ inline const nsDependentCSubstring nsSta
       len = mPassword.mLen + 1;
     }
 
     if (includeDelim) len++;
   }
   return Substring(mSpec, pos, len);
 }
 
-inline const nsDependentCSubstring nsStandardURL::Hostport() {
+inline nsDependentCSubstring nsStandardURL::Hostport() {
   uint32_t pos = 0, len = 0;
   if (mAuthority.mLen > 0) {
     pos = mHost.mPos;
     len = mAuthority.mPos + mAuthority.mLen - pos;
   }
   return Substring(mSpec, pos, len);
 }
 
-inline const nsDependentCSubstring nsStandardURL::Host() {
+inline nsDependentCSubstring nsStandardURL::Host() {
   uint32_t pos = 0, len = 0;
   if (mHost.mLen > 0) {
     pos = mHost.mPos;
     len = mHost.mLen;
     if (mSpec.CharAt(pos) == '[' && mSpec.CharAt(pos + len - 1) == ']') {
       pos++;
       len -= 2;
     }
   }
   return Substring(mSpec, pos, len);
 }
 
-inline const nsDependentCSubstring nsStandardURL::Filename() {
+inline nsDependentCSubstring nsStandardURL::Filename() {
   uint32_t pos = 0, len = 0;
   // if there is no basename, then there can be no extension
   if (mBasename.mLen > 0) {
     pos = mBasename.mPos;
     len = mBasename.mLen;
     if (mExtension.mLen >= 0) len += (mExtension.mLen + 1);
   }
   return Substring(mSpec, pos, len);
--- a/netwerk/base/nsStreamListenerTee.cpp
+++ b/netwerk/base/nsStreamListenerTee.cpp
@@ -61,21 +61,22 @@ nsStreamListenerTee::OnDataAvailable(nsI
                                      uint64_t offset, uint32_t count) {
   NS_ENSURE_TRUE(mListener, NS_ERROR_NOT_INITIALIZED);
   NS_ENSURE_TRUE(mSink, NS_ERROR_NOT_INITIALIZED);
 
   nsCOMPtr<nsIInputStream> tee;
   nsresult rv;
 
   if (!mInputTee) {
-    if (mEventTarget)
+    if (mEventTarget) {
       rv = NS_NewInputStreamTeeAsync(getter_AddRefs(tee), input, mSink,
                                      mEventTarget);
-    else
+    } else {
       rv = NS_NewInputStreamTee(getter_AddRefs(tee), input, mSink);
+    }
     if (NS_FAILED(rv)) return rv;
 
     mInputTee = do_QueryInterface(tee, &rv);
     if (NS_FAILED(rv)) return rv;
   } else {
     // re-initialize the input tee since the input stream may have changed.
     rv = mInputTee->SetSource(input);
     if (NS_FAILED(rv)) return rv;
--- a/netwerk/base/nsStreamTransportService.cpp
+++ b/netwerk/base/nsStreamTransportService.cpp
@@ -140,19 +140,20 @@ nsInputStreamTransport::Close(nsresult r
   return mPipeIn->CloseWithStatus(reason);
 }
 
 NS_IMETHODIMP
 nsInputStreamTransport::SetEventSink(nsITransportEventSink* sink,
                                      nsIEventTarget* target) {
   NS_ENSURE_TRUE(!mInProgress, NS_ERROR_IN_PROGRESS);
 
-  if (target)
+  if (target) {
     return net_NewTransportEventSinkProxy(getter_AddRefs(mEventSink), sink,
                                           target);
+  }
 
   mEventSink = sink;
   return NS_OK;
 }
 
 /** nsIInputStream **/
 
 NS_IMETHODIMP
@@ -170,18 +171,19 @@ nsInputStreamTransport::Available(uint64
 }
 
 NS_IMETHODIMP
 nsInputStreamTransport::Read(char* buf, uint32_t count, uint32_t* result) {
   nsresult rv = mSource->Read(buf, count, result);
 
   if (NS_SUCCEEDED(rv)) {
     mOffset += *result;
-    if (mEventSink)
+    if (mEventSink) {
       mEventSink->OnTransportStatus(this, NS_NET_STATUS_READING, mOffset, -1);
+    }
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsInputStreamTransport::ReadSegments(nsWriteSegmentFun writer, void* closure,
                                      uint32_t count, uint32_t* result) {
   return NS_ERROR_NOT_IMPLEMENTED;
--- a/netwerk/base/nsUDPSocket.cpp
+++ b/netwerk/base/nsUDPSocket.cpp
@@ -32,17 +32,17 @@
 
 namespace mozilla {
 namespace net {
 
 static const uint32_t UDP_PACKET_CHUNK_SIZE = 1400;
 
 //-----------------------------------------------------------------------------
 
-typedef void (nsUDPSocket::*nsUDPSocketFunc)(void);
+using nsUDPSocketFunc = void (nsUDPSocket::*)();
 
 static nsresult PostEvent(nsUDPSocket* s, nsUDPSocketFunc func) {
   if (!gSocketTransportService) return NS_ERROR_FAILURE;
 
   return gSocketTransportService->Dispatch(
       NewRunnableMethod("net::PostEvent", s, func), NS_DISPATCH_NORMAL);
 }
 
@@ -498,20 +498,21 @@ nsUDPSocket::Init(int32_t aPort, bool aL
                   bool aAddressReuse, uint8_t aOptionalArgc) {
   NetAddr addr;
 
   if (aPort < 0) aPort = 0;
 
   addr.raw.family = AF_INET;
   addr.inet.port = htons(aPort);
 
-  if (aLoopbackOnly)
+  if (aLoopbackOnly) {
     addr.inet.ip = htonl(INADDR_LOOPBACK);
-  else
+  } else {
     addr.inet.ip = htonl(INADDR_ANY);
+  }
 
   return InitWithAddress(&addr, aPrincipal, aAddressReuse, aOptionalArgc);
 }
 
 NS_IMETHODIMP
 nsUDPSocket::Init2(const nsACString& aAddr, int32_t aPort,
                    nsIPrincipal* aPrincipal, bool aAddressReuse,
                    uint8_t aOptionalArgc) {
--- a/netwerk/base/nsURLHelper.cpp
+++ b/netwerk/base/nsURLHelper.cpp
@@ -182,23 +182,26 @@ nsresult net_ParseFileURL(const nsACStri
   filepathPos += pathPos;
 
   // invoke the parser to extract the directory and filename from filepath
   rv = parser->ParseFilePath(url + filepathPos, filepathLen, &directoryPos,
                              &directoryLen, &basenamePos, &basenameLen,
                              &extensionPos, &extensionLen);
   if (NS_FAILED(rv)) return rv;
 
-  if (directoryLen > 0)
+  if (directoryLen > 0) {
     outDirectory = Substring(inURL, filepathPos + directoryPos, directoryLen);
-  if (basenameLen > 0)
+  }
+  if (basenameLen > 0) {
     outFileBaseName = Substring(inURL, filepathPos + basenamePos, basenameLen);
-  if (extensionLen > 0)
+  }
+  if (extensionLen > 0) {
     outFileExtension =
         Substring(inURL, filepathPos + extensionPos, extensionLen);
+  }
   // since we are using a no-auth url parser, there will never be a host
   // XXX not strictly true... file://localhost/foo/bar.html is a valid URL
 
   return NS_OK;
 }
 
 //----------------------------------------------------------------------------
 // path manipulation functions
@@ -220,20 +223,21 @@ void net_CoalesceDirs(netCoalesceFlags f
   uint32_t special_ftp_len = 0;
 
   /* Remember if this url is a special ftp one: */
   if (flags & NET_COALESCE_DOUBLE_SLASH_IS_ROOT) {
     /* some schemes (for example ftp) have the speciality that
        the path can begin // or /%2F to mark the root of the
        servers filesystem, a simple / only marks the root relative
        to the user loging in. We remember the length of the marker */
-    if (nsCRT::strncasecmp(path, "/%2F", 4) == 0)
+    if (nsCRT::strncasecmp(path, "/%2F", 4) == 0) {
       special_ftp_len = 4;
-    else if (strncmp(path, "//", 2) == 0)
+    } else if (strncmp(path, "//", 2) == 0) {
       special_ftp_len = 2;
+    }
   }
 
   /* find the last slash before # or ? */
   for (; (*fwdPtr != '\0') && (*fwdPtr != '?') && (*fwdPtr != '#'); ++fwdPtr) {
   }
 
   /* found nothing, but go back one only */
   /* if there is something to go back to */
@@ -281,18 +285,19 @@ void net_CoalesceDirs(netCoalesceFlags f
                 *(fwdPtr + 3) == '?' ||   // something like foo/bar/..#sometag
                 *(fwdPtr + 3) == '#')) {
       // remove foo/..
       // reverse the urlPtr to the previous slash if possible
       // if url does not allow relative root then drop .. above root
       // otherwise retain them in the path
       if (traversal > 0 || !(flags & NET_COALESCE_ALLOW_RELATIVE_ROOT)) {
         if (urlPtr != path) urlPtr--;  // we must be going back at least by one
-        for (; *urlPtr != '/' && urlPtr != path; urlPtr--)
-          ;           // null body
+        for (; *urlPtr != '/' && urlPtr != path; urlPtr--) {
+          ;  // null body
+        }
         --traversal;  // count back
         // forward the fwdPtr past the ../
         fwdPtr += 2;
         // if we have reached the beginning of the path
         // while searching for the previous / and we remember
         // that it is an url that begins with /%2F then
         // advance urlPtr again by 3 chars because /%2F already
         // marks the root of the path
@@ -307,43 +312,47 @@ void net_CoalesceDirs(netCoalesceFlags f
       } else {
         // there are to much /.. in this path, just copy them instead.
         // forward the urlPtr past the /.. and copying it
 
         // However if we remember it is an url that starts with
         // /%2F and urlPtr just points at the "F" of "/%2F" then do
         // not overwrite it with the /, just copy .. and move forward
         // urlPtr.
-        if (special_ftp_len > 3 && urlPtr == path + special_ftp_len - 1)
+        if (special_ftp_len > 3 && urlPtr == path + special_ftp_len - 1) {
           ++urlPtr;
-        else
+        } else {
           *urlPtr++ = *fwdPtr;
+        }
         ++fwdPtr;
         *urlPtr++ = *fwdPtr;
         ++fwdPtr;
         *urlPtr++ = *fwdPtr;
       }
     } else {
       // count the hierachie, but only if we do not have reached
       // the root of some special urls with a special root marker
       if (*fwdPtr == '/' && *(fwdPtr + 1) != '.' &&
-          (special_ftp_len != 2 || *(fwdPtr + 1) != '/'))
+          (special_ftp_len != 2 || *(fwdPtr + 1) != '/')) {
         traversal++;
+      }
       // copy the url incrementaly
       *urlPtr++ = *fwdPtr;
     }
   }
 
   /*
    *  Now lets remove trailing . case
    *     /foo/foo1/.   ->  /foo/foo1/
    */
 
-  if ((urlPtr > (path + 1)) && (*(urlPtr - 1) == '.') && (*(urlPtr - 2) == '/'))
+  if ((urlPtr > (path + 1)) && (*(urlPtr - 1) == '.') &&
+      (*(urlPtr - 2) == '/')) {
     urlPtr--;
+  }
 
   // Copy remaining stuff past the #?;
   for (; *fwdPtr != '\0'; ++fwdPtr) {
     *urlPtr++ = *fwdPtr;
   }
   *urlPtr = '\0';  // terminate the url
 }
 
@@ -432,32 +441,32 @@ bool net_IsAbsoluteURL(const nsACString&
     return true;
   }
   return false;
 }
 
 void net_FilterURIString(const nsACString& input, nsACString& result) {
   result.Truncate();
 
-  auto start = input.BeginReading();
-  auto end = input.EndReading();
+  const auto* start = input.BeginReading();
+  const auto* end = input.EndReading();
 
   // Trim off leading and trailing invalid chars.
   auto charFilter = [](char c) { return static_cast<uint8_t>(c) > 0x20; };
-  auto newStart = std::find_if(start, end, charFilter);
-  auto newEnd =
+  const auto* newStart = std::find_if(start, end, charFilter);
+  const auto* newEnd =
       std::find_if(std::reverse_iterator<decltype(end)>(end),
                    std::reverse_iterator<decltype(newStart)>(newStart),
                    charFilter)
           .base();
 
   // Check if chars need to be stripped.
   bool needsStrip = false;
   const ASCIIMaskArray& mask = ASCIIMask::MaskCRLFTab();
-  for (auto itr = start; itr != end; ++itr) {
+  for (const auto* itr = start; itr != end; ++itr) {
     if (ASCIIMask::IsMasked(mask, *itr)) {
       needsStrip = true;
       break;
     }
   }
 
   // Just use the passed in string rather than creating new copies if no
   // changes are necessary.
@@ -472,23 +481,23 @@ void net_FilterURIString(const nsACStrin
   }
 }
 
 nsresult net_FilterAndEscapeURI(const nsACString& aInput, uint32_t aFlags,
                                 const ASCIIMaskArray& aFilterMask,
                                 nsACString& aResult) {
   aResult.Truncate();
 
-  auto start = aInput.BeginReading();
-  auto end = aInput.EndReading();
+  const auto* start = aInput.BeginReading();
+  const auto* end = aInput.EndReading();
 
   // Trim off leading and trailing invalid chars.
   auto charFilter = [](char c) { return static_cast<uint8_t>(c) > 0x20; };
-  auto newStart = std::find_if(start, end, charFilter);
-  auto newEnd =
+  const auto* newStart = std::find_if(start, end, charFilter);
+  const auto* newEnd =
       std::find_if(std::reverse_iterator<decltype(end)>(end),
                    std::reverse_iterator<decltype(newStart)>(newStart),
                    charFilter)
           .base();
 
   return NS_EscapeAndFilterURL(Substring(newStart, newEnd), aFlags,
                                &aFilterMask, aResult, fallible);
 }
@@ -881,18 +890,19 @@ bool net_IsValidHostName(const nsACStrin
   // the list.
 
   // Whitelist for DNS names (RFC 1035) with extra characters added
   // for pragmatic reasons "$+_"
   // see https://bugzilla.mozilla.org/show_bug.cgi?id=355181#c2
   if (net_FindCharNotInSet(host.BeginReading(), end,
                            "abcdefghijklmnopqrstuvwxyz"
                            ".-0123456789"
-                           "ABCDEFGHIJKLMNOPQRSTUVWXYZ$+_") == end)
+                           "ABCDEFGHIJKLMNOPQRSTUVWXYZ$+_") == end) {
     return true;
+  }
 
   // Might be a valid IPv6 link-local address containing a percent sign
   return mozilla::net::HostIsIPLiteral(host);
 }
 
 bool net_IsValidIPv4Addr(const nsACString& aAddr) {
   return mozilla::net::rust_net_is_valid_ipv4_addr(&aAddr);
 }
--- a/netwerk/base/nsURLHelper.h
+++ b/netwerk/base/nsURLHelper.h
@@ -63,17 +63,17 @@ nsresult net_ParseFileURL(const nsACStri
 void net_CoalesceDirs(netCoalesceFlags flags, char* path);
 
 /**
  * Check if a URL is absolute
  *
  * @param inURL     URL spec
  * @return true if the given spec represents an absolute URL
  */
-bool net_IsAbsoluteURL(const nsACString& inURL);
+bool net_IsAbsoluteURL(const nsACString& uri);
 
 /**
  * Extract URI-Scheme if possible
  *
  * @param inURI     URI spec
  * @param scheme    scheme copied to this buffer on return. Is lowercase.
  */
 nsresult net_ExtractURLScheme(const nsACString& inURI, nsACString& scheme);
@@ -132,31 +132,32 @@ bool net_NormalizeFileURL(const nsACStri
 void net_ToLowerCase(char* str, uint32_t length);
 void net_ToLowerCase(char* str);
 
 /**
  * returns pointer to first character of |str| in the given set.  if not found,
  * then |end| is returned.  stops prematurely if a null byte is encountered,
  * and returns the address of the null byte.
  */
-char* net_FindCharInSet(const char* str, const char* end, const char* set);
+char* net_FindCharInSet(const char* iter, const char* stop, const char* set);
 
 /**
  * returns pointer to first character of |str| NOT in the given set.  if all
  * characters are in the given set, then |end| is returned.  if '\0' is not
  * included in |set|, then stops prematurely if a null byte is encountered,
  * and returns the address of the null byte.
  */
-char* net_FindCharNotInSet(const char* str, const char* end, const char* set);
+char* net_FindCharNotInSet(const char* iter, const char* stop, const char* set);
 
 /**
  * returns pointer to last character of |str| NOT in the given set.  if all
  * characters are in the given set, then |str - 1| is returned.
  */
-char* net_RFindCharNotInSet(const char* str, const char* end, const char* set);
+char* net_RFindCharNotInSet(const char* stop, const char* iter,
+                            const char* set);
 
 /**
  * Parses a content-type header and returns the content type and
  * charset (if any).  aCharset is not modified if no charset is
  * specified in anywhere in aHeaderStr.  In that case (no charset
  * specified), aHadCharset is set to false.  Otherwise, it's set to
  * true.  Note that aContentCharset can be empty even if aHadCharset
  * is true.
--- a/netwerk/base/nsURLHelperUnix.cpp
+++ b/netwerk/base/nsURLHelperUnix.cpp
@@ -21,29 +21,31 @@ nsresult net_GetURLSpecFromActualFile(ns
   rv = aFile->GetNativePath(nativePath);
   if (NS_FAILED(rv)) return rv;
 
   // Convert to unicode and back to check correct conversion to native charset
   NS_CopyNativeToUnicode(nativePath, path);
   NS_CopyUnicodeToNative(path, ePath);
 
   // Use UTF8 version if conversion was successful
-  if (nativePath == ePath)
+  if (nativePath == ePath) {
     CopyUTF16toUTF8(path, ePath);
-  else
+  } else {
     ePath = nativePath;
+  }
 
   nsAutoCString escPath;
   constexpr auto prefix = "file://"_ns;
 
   // Escape the path with the directory mask
-  if (NS_EscapeURL(ePath.get(), -1, esc_Directory + esc_Forced, escPath))
+  if (NS_EscapeURL(ePath.get(), -1, esc_Directory + esc_Forced, escPath)) {
     escPath.Insert(prefix, 0);
-  else
+  } else {
     escPath.Assign(prefix + ePath);
+  }
 
   // esc_Directory does not escape the semicolons, so if a filename
   // contains semicolons we need to manually escape them.
   // This replacement should be removed in bug #473280
   escPath.ReplaceSubstring(";", "%3b");
   result = escPath;
   return NS_OK;
 }
@@ -81,25 +83,27 @@ nsresult net_GetFileFromURLSpec(const ns
   }
 
   NS_UnescapeURL(path);
   if (path.Length() != strlen(path.get())) return NS_ERROR_FILE_INVALID_PATH;
 
   if (IsUtf8(path)) {
     // speed up the start-up where UTF-8 is the native charset
     // (e.g. on recent Linux distributions)
-    if (NS_IsNativeUTF8())
+    if (NS_IsNativeUTF8()) {
       rv = localFile->InitWithNativePath(path);
-    else
+    } else {
       rv = localFile->InitWithPath(NS_ConvertUTF8toUTF16(path));
+    }
     // XXX In rare cases, a valid UTF-8 string can be valid as a native
     // encoding (e.g. 0xC5 0x83 is valid both as UTF-8 and Windows-125x).
     // However, the chance is very low that a meaningful word in a legacy
     // encoding is valid as UTF-8.
-  } else
+  } else {
     // if path is not in UTF-8, assume it is encoded in the native charset
     rv = localFile->InitWithNativePath(path);
+  }
 
   if (NS_FAILED(rv)) return rv;
 
   localFile.forget(result);
   return NS_OK;
 }
--- a/netwerk/base/nsURLParsers.cpp
+++ b/netwerk/base/nsURLParsers.cpp
@@ -32,19 +32,19 @@ NS_IMPL_ISUPPORTS(nsAuthURLParser, nsIUR
 NS_IMPL_ISUPPORTS(nsNoAuthURLParser, nsIURLParser)
 
 #define SET_RESULT(component, pos, len)                \
   PR_BEGIN_MACRO                                       \
   if (component##Pos) *component##Pos = uint32_t(pos); \
   if (component##Len) *component##Len = int32_t(len);  \
   PR_END_MACRO
 
-#define OFFSET_RESULT(component, offset)         \
-  PR_BEGIN_MACRO                                 \
-  if (component##Pos) *component##Pos += offset; \
+#define OFFSET_RESULT(component, offset)           \
+  PR_BEGIN_MACRO                                   \
+  if (component##Pos) *component##Pos += (offset); \
   PR_END_MACRO
 
 NS_IMETHODIMP
 nsBaseURLParser::ParseURL(const char* spec, int32_t specLen,
                           uint32_t* schemePos, int32_t* schemeLen,
                           uint32_t* authorityPos, int32_t* authorityLen,
                           uint32_t* pathPos, int32_t* pathLen) {
   if (NS_WARN_IF(!spec)) {
@@ -93,18 +93,19 @@ nsBaseURLParser::ParseURL(const char* sp
   if (specLen == 0) {
     SET_RESULT(scheme, 0, -1);
     SET_RESULT(authority, 0, 0);
     SET_RESULT(path, 0, 0);
     return NS_OK;
   }
 
   // ignore trailing whitespace and control characters
-  for (p = spec + specLen - 1; ((unsigned char)*p <= ' ') && (p != spec); --p)
+  for (p = spec + specLen - 1; ((unsigned char)*p <= ' ') && (p != spec); --p) {
     ;
+  }
 
   specLen = p - spec + 1;
 
   if (colon && (colon < slash || !slash)) {
     //
     // spec = <scheme>:/<the-rest>
     //
     // or
@@ -204,51 +205,56 @@ nsBaseURLParser::ParsePath(const char* p
   // XXX PL_strnpbrk would be nice, but it's buggy
 
   // search for first occurrence of either ? or #
   const char *query_beg = nullptr, *query_end = nullptr;
   const char* ref_beg = nullptr;
   const char* p = nullptr;
   for (p = path; p < path + pathLen; ++p) {
     // only match the query string if it precedes the reference fragment
-    if (!ref_beg && !query_beg && *p == '?')
+    if (!ref_beg && !query_beg && *p == '?') {
       query_beg = p + 1;
-    else if (*p == '#') {
+    } else if (*p == '#') {
       ref_beg = p + 1;
       if (query_beg) query_end = p;
       break;
     }
   }
 
   if (query_beg) {
-    if (query_end)
+    if (query_end) {
       SET_RESULT(query, query_beg - path, query_end - query_beg);
-    else
+    } else {
       SET_RESULT(query, query_beg - path, pathLen - (query_beg - path));
-  } else
+    }
+  } else {
     SET_RESULT(query, 0, -1);
+  }
 
-  if (ref_beg)
+  if (ref_beg) {
     SET_RESULT(ref, ref_beg - path, pathLen - (ref_beg - path));
-  else
+  } else {
     SET_RESULT(ref, 0, -1);
+  }
 
   const char* end;
-  if (query_beg)
+  if (query_beg) {
     end = query_beg - 1;
-  else if (ref_beg)
+  } else if (ref_beg) {
     end = ref_beg - 1;
-  else
+  } else {
     end = path + pathLen;
+  }
 
   // an empty file path is no file path
-  if (end != path)
+  if (end != path) {
     SET_RESULT(filepath, 0, end - path);
-  else
+  } else {
     SET_RESULT(filepath, 0, -1);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBaseURLParser::ParseFilePath(const char* filepath, int32_t filepathLen,
                                uint32_t* directoryPos, int32_t* directoryLen,
                                uint32_t* basenamePos, int32_t* basenameLen,
                                uint32_t* extensionPos, int32_t* extensionLen) {
@@ -264,23 +270,25 @@ nsBaseURLParser::ParseFilePath(const cha
     SET_RESULT(extension, 0, -1);
     return NS_OK;
   }
 
   const char* p;
   const char* end = filepath + filepathLen;
 
   // search backwards for filename
-  for (p = end - 1; *p != '/' && p > filepath; --p)
+  for (p = end - 1; *p != '/' && p > filepath; --p) {
     ;
+  }
   if (*p == '/') {
     // catch /.. and /.
     if ((p + 1 < end && *(p + 1) == '.') &&
-        (p + 2 == end || (*(p + 2) == '.' && p + 3 == end)))
+        (p + 2 == end || (*(p + 2) == '.' && p + 3 == end))) {
       p = end - 1;
+    }
     // filepath = <directory><filename>.<extension>
     SET_RESULT(directory, 0, p - filepath + 1);
     ParseFileName(p + 1, end - (p + 1), basenamePos, basenameLen, extensionPos,
                   extensionLen);
     OFFSET_RESULT(basename, p + 1 - filepath);
     OFFSET_RESULT(extension, p + 1 - filepath);
   } else {
     // filepath = <filename>.<extension>
@@ -360,20 +368,21 @@ void nsNoAuthURLParser::ParseAfterScheme
           break;
         }
         // Ignore apparent authority; path is everything after it
         for (p = spec + 2; p < spec + specLen; ++p) {
           if (*p == '/' || *p == '?' || *p == '#') break;
         }
       }
       SET_RESULT(auth, 0, -1);
-      if (p && p != spec + specLen)
+      if (p && p != spec + specLen) {
         SET_RESULT(path, p - spec, specLen - (p - spec));
-      else
+      } else {
         SET_RESULT(path, 0, -1);
+      }
       return;
     }
     default:
       pos = 2;
       break;
   }
   SET_RESULT(auth, pos, 0);
   SET_RESULT(path, pos, specLen - pos);
@@ -542,32 +551,34 @@ nsAuthURLParser::ParseServerInfo(const c
         *port = -1;
       } else {
         const char* nondigit = NS_strspnp("0123456789", buf.get());
         if (nondigit && *nondigit) return NS_ERROR_MALFORMED_URI;
 
         nsresult err;
         *port = buf.ToInteger(&err);
         if (NS_FAILED(err) || *port < 0 ||
-            *port > std::numeric_limits<uint16_t>::max())
+            *port > std::numeric_limits<uint16_t>::max()) {
           return NS_ERROR_MALFORMED_URI;
+        }
       }
     }
   } else {
     // serverinfo = <hostname>
     SET_RESULT(hostname, 0, serverinfoLen);
     if (port) *port = -1;
   }
 
   // In case of IPv6 address check its validity
   if (*hostnameLen > 1 && *(serverinfo + *hostnamePos) == '[' &&
       *(serverinfo + *hostnamePos + *hostnameLen - 1) == ']' &&
       !net_IsValidIPv6Addr(
-          Substring(serverinfo + *hostnamePos + 1, *hostnameLen - 2)))
+          Substring(serverinfo + *hostnamePos + 1, *hostnameLen - 2))) {
     return NS_ERROR_MALFORMED_URI;
+  }
 
   return NS_OK;
 }
 
 void nsAuthURLParser::ParseAfterScheme(const char* spec, int32_t specLen,
                                        uint32_t* authPos, int32_t* authLen,
                                        uint32_t* pathPos, int32_t* pathLen) {
   MOZ_ASSERT(specLen >= 0, "unexpected");
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -28,24 +28,24 @@
 #include "nsNetCID.h"
 
 #if defined(XP_MACOSX) || defined(XP_WIN) || defined(XP_LINUX)
 #  define BUILD_NETWORK_INFO_SERVICE 1
 #endif
 
 using namespace mozilla;
 
-typedef nsCategoryCache<nsIContentSniffer> ContentSnifferCache;
+using ContentSnifferCache = nsCategoryCache<nsIContentSniffer>;
 ContentSnifferCache* gNetSniffers = nullptr;
 ContentSnifferCache* gDataSniffers = nullptr;
 ContentSnifferCache* gORBSniffers = nullptr;
 ContentSnifferCache* gNetAndORBSniffers = nullptr;
 
 #define static
-typedef mozilla::net::nsLoadGroup nsLoadGroup;
+using nsLoadGroup = mozilla::net::nsLoadGroup;
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsLoadGroup, Init)
 #undef static
 
 ///////////////////////////////////////////////////////////////////////////////
 // protocols
 ///////////////////////////////////////////////////////////////////////////////
 
 // http/https
--- a/netwerk/cache/nsDeleteDir.cpp
+++ b/netwerk/cache/nsDeleteDir.cpp
@@ -92,18 +92,19 @@ nsresult nsDeleteDir::Shutdown(bool fini
       while (!gInstance->mNotified) {
         gInstance->mCondVar.Wait();
       }
     }
   }
 
   delete gInstance;
 
-  for (int32_t i = 0; i < dirsToRemove.Count(); i++)
+  for (int32_t i = 0; i < dirsToRemove.Count(); i++) {
     dirsToRemove[i]->Remove(true);
+  }
 
   return NS_OK;
 }
 
 nsresult nsDeleteDir::InitThread() {
   if (mBackgroundET) return NS_OK;
 
   nsresult rv = NS_CreateBackgroundTaskQueue("Cache Deleter",
@@ -114,19 +115,20 @@ nsresult nsDeleteDir::InitThread() {
   }
 
   return NS_OK;
 }
 
 void nsDeleteDir::DestroyThread() {
   if (!mBackgroundET) return;
 
-  if (mTimers.Count())
+  if (mTimers.Count()) {
     // more work to do, so don't delete thread.
     return;
+  }
 
   mBackgroundET = nullptr;
 }
 
 void nsDeleteDir::TimerCallback(nsITimer* aTimer, void* arg) {
   Telemetry::AutoTimer<Telemetry::NETWORK_DISK_CACHE_DELETEDIR> timer;
   {
     MutexAutoLock lock(gInstance->mLock);
--- a/netwerk/cache/nsDeleteDir.h
+++ b/netwerk/cache/nsDeleteDir.h
@@ -42,17 +42,17 @@ class nsDeleteDir {
    * renamed immediately if 'moveToTrash' is passed, so upon return it is safe
    * to create a directory with the same name).
    */
   static nsresult DeleteDir(nsIFile* dir, bool moveToTrash, uint32_t delay = 0);
 
   /**
    * Returns the trash directory corresponding to the given directory.
    */
-  static nsresult GetTrashDir(nsIFile* dir, nsCOMPtr<nsIFile>* result);
+  static nsresult GetTrashDir(nsIFile* target, nsCOMPtr<nsIFile>* result);
 
   /**
    * Remove all trashes left from previous run. This function does nothing when
    * called second and more times.
    */
   static nsresult RemoveOldTrashes(nsIFile* cacheDir);
 
   static void TimerCallback(nsITimer* aTimer, void* arg);
--- a/netwerk/cache2/CacheEntry.cpp
+++ b/netwerk/cache2/CacheEntry.cpp
@@ -25,18 +25,17 @@
 #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 {
+namespace mozilla::net {
 
 static uint32_t const ENTRY_WANTED = nsICacheEntryOpenCallback::ENTRY_WANTED;
 static uint32_t const RECHECK_AFTER_WRITE_FINISHED =
     nsICacheEntryOpenCallback::RECHECK_AFTER_WRITE_FINISHED;
 static uint32_t const ENTRY_NEEDS_REVALIDATION =
     nsICacheEntryOpenCallback::ENTRY_NEEDS_REVALIDATION;
 static uint32_t const ENTRY_NOT_WANTED =
     nsICacheEntryOpenCallback::ENTRY_NOT_WANTED;
@@ -109,18 +108,18 @@ CacheEntry::Callback::Callback(CacheEntr
                                bool aDoomWhenFoundInPinStatus)
     : mEntry(aEntry),
       mReadOnly(false),
       mRevalidating(false),
       mCheckOnAnyThread(true),
       mRecheckAfterWrite(false),
       mNotWanted(false),
       mSecret(false),
-      mDoomWhenFoundPinned(aDoomWhenFoundInPinStatus == true),
-      mDoomWhenFoundNonPinned(aDoomWhenFoundInPinStatus == false) {
+      mDoomWhenFoundPinned(aDoomWhenFoundInPinStatus),
+      mDoomWhenFoundNonPinned(!aDoomWhenFoundInPinStatus) {
   MOZ_COUNT_CTOR(CacheEntry::Callback);
   MOZ_ASSERT(mEntry->HandlesCount());
   mEntry->AddHandleRef();
 }
 
 CacheEntry::Callback::Callback(CacheEntry::Callback const& aThat)
     : mEntry(aThat.mEntry),
       mCallback(aThat.mCallback),
@@ -567,26 +566,28 @@ already_AddRefed<CacheEntryHandle> Cache
   return writeHandle.forget();
 }
 
 void CacheEntry::TransferCallbacks(CacheEntry& aFromEntry) {
   mozilla::MutexAutoLock lock(mLock);
 
   LOG(("CacheEntry::TransferCallbacks [entry=%p, from=%p]", this, &aFromEntry));
 
-  if (!mCallbacks.Length())
+  if (!mCallbacks.Length()) {
     mCallbacks.SwapElements(aFromEntry.mCallbacks);
-  else
+  } else {
     mCallbacks.AppendElements(aFromEntry.mCallbacks);
+  }
 
   uint32_t callbacksLength = mCallbacks.Length();
   if (callbacksLength) {
     // Carry the entry reference (unfortunately, needs to be done manually...)
-    for (uint32_t i = 0; i < callbacksLength; ++i)
+    for (uint32_t i = 0; i < callbacksLength; ++i) {
       mCallbacks[i].ExchangeEntry(this);
+    }
 
     BackgroundOp(Ops::CALLBACKS, true);
   }
 }
 
 void CacheEntry::RememberCallback(Callback& aCallback) {
   mLock.AssertCurrentThreadOwns();
 
@@ -1391,18 +1392,19 @@ nsresult CacheEntry::GetStorageDataSize(
 }
 
 nsresult CacheEntry::AsyncDoom(nsICacheEntryDoomCallback* aCallback) {
   LOG(("CacheEntry::AsyncDoom [this=%p]", this));
 
   {
     mozilla::MutexAutoLock lock(mLock);
 
-    if (mIsDoomed || mDoomCallback)
+    if (mIsDoomed || mDoomCallback) {
       return NS_ERROR_IN_PROGRESS;  // to aggregate have DOOMING state
+    }
 
     RemoveForcedValidity();
 
     mIsDoomed = true;
     mDoomCallback = aCallback;
   }
 
   // This immediately removes the entry from the master hashtable and also
@@ -1785,18 +1787,19 @@ void CacheEntry::RemoveForcedValidity() 
 
   CacheStorageService::Self()->RemoveEntryForceValid(mStorageID, entryKey);
 }
 
 void CacheEntry::BackgroundOp(uint32_t aOperations, bool aForceAsync) {
   mLock.AssertCurrentThreadOwns();
 
   if (!CacheStorageService::IsOnManagementThread() || aForceAsync) {
-    if (mBackgroundOperations.Set(aOperations))
+    if (mBackgroundOperations.Set(aOperations)) {
       CacheStorageService::Self()->Dispatch(this);
+    }
 
     LOG(("CacheEntry::BackgroundOp this=%p dipatch of %x", this, aOperations));
     return;
   }
 
   {
     mozilla::MutexAutoUnlock unlock(mLock);
 
@@ -1905,10 +1908,9 @@ size_t CacheEntry::SizeOfExcludingThis(
   return n;
 }
 
 size_t CacheEntry::SizeOfIncludingThis(
     mozilla::MallocSizeOf mallocSizeOf) const {
   return mallocSizeOf(this) + SizeOfExcludingThis(mallocSizeOf);
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheEntry.h
+++ b/netwerk/cache2/CacheEntry.h
@@ -57,55 +57,55 @@ class CacheEntry final : public nsIRunna
   CacheEntryHandle* NewHandle();
   // For a new and recreated entry w/o a callback, we need to wrap it
   // with a handle to detect writing consumer is gone.
   CacheEntryHandle* NewWriteHandle();
 
   // Forwarded to from CacheEntryHandle : nsICacheEntry
   nsresult GetKey(nsACString& aKey);
   nsresult GetCacheEntryId(uint64_t* aCacheEntryId);
-  nsresult GetPersistent(bool* aPersistent);
+  nsresult GetPersistent(bool* aPersistToDisk);
   nsresult GetFetchCount(int32_t* aFetchCount);
   nsresult GetLastFetched(uint32_t* aLastFetched);
   nsresult GetLastModified(uint32_t* aLastModified);
   nsresult GetExpirationTime(uint32_t* aExpirationTime);
   nsresult SetExpirationTime(uint32_t expirationTime);
-  nsresult GetOnStartTime(uint64_t* aOnStartTime);
-  nsresult GetOnStopTime(uint64_t* aOnStopTime);
+  nsresult GetOnStartTime(uint64_t* aTime);
+  nsresult GetOnStopTime(uint64_t* aTime);
   nsresult SetNetworkTimes(uint64_t onStartTime, uint64_t onStopTime);
   nsresult SetContentType(uint8_t aContentType);
   nsresult ForceValidFor(uint32_t aSecondsToTheFuture);
   nsresult GetIsForcedValid(bool* aIsForcedValid);
   nsresult OpenInputStream(int64_t offset, nsIInputStream** _retval);
   nsresult OpenOutputStream(int64_t offset, int64_t predictedSize,
                             nsIOutputStream** _retval);
   nsresult GetSecurityInfo(nsISupports** aSecurityInfo);
   nsresult SetSecurityInfo(nsISupports* aSecurityInfo);
   nsresult GetStorageDataSize(uint32_t* aStorageDataSize);
-  nsresult AsyncDoom(nsICacheEntryDoomCallback* listener);
-  nsresult GetMetaDataElement(const char* key, char** _retval);
+  nsresult AsyncDoom(nsICacheEntryDoomCallback* aCallback);
+  nsresult GetMetaDataElement(const char* key, char** aRetval);
   nsresult SetMetaDataElement(const char* key, const char* value);
   nsresult VisitMetaData(nsICacheEntryMetaDataVisitor* visitor);
   nsresult MetaDataReady(void);
   nsresult SetValid(void);
   nsresult GetDiskStorageSizeInKB(uint32_t* aDiskStorageSizeInKB);
   nsresult Recreate(bool aMemoryOnly, nsICacheEntry** _retval);
   nsresult GetDataSize(int64_t* aDataSize);
-  nsresult GetAltDataSize(int64_t* aAltDataSize);
+  nsresult GetAltDataSize(int64_t* aDataSize);
   nsresult GetAltDataType(nsACString& aAltDataType);
   nsresult OpenAlternativeOutputStream(const nsACString& type,
                                        int64_t predictedSize,
                                        nsIAsyncOutputStream** _retval);
   nsresult OpenAlternativeInputStream(const nsACString& type,
                                       nsIInputStream** _retval);
-  nsresult GetLoadContextInfo(nsILoadContextInfo** aLoadContextInfo);
+  nsresult GetLoadContextInfo(nsILoadContextInfo** aInfo);
   nsresult Close(void);
   nsresult MarkValid(void);
   nsresult MaybeMarkValid(void);
-  nsresult HasWriteAccess(bool aWriteAllowed, bool* _retval);
+  nsresult HasWriteAccess(bool aWriteAllowed, bool* aWriteAccess);
 
  public:
   uint32_t GetMetadataMemoryConsumption();
   nsCString const& GetStorageID() const { return mStorageID; }
   nsCString const& GetEnhanceID() const { return mEnhanceID; }
   nsCString const& GetURI() const { return mURI; }
   // Accessible at any time
   bool IsUsingDisk() const { return mUseDisk; }
--- a/netwerk/cache2/CacheFile.cpp
+++ b/netwerk/cache2/CacheFile.cpp
@@ -25,18 +25,17 @@
 // When it is not defined, we always release the chunks ASAP, i.e. we cache
 // unused chunks only when:
 //  - CacheFile is memory-only
 //  - CacheFile is still waiting for the handle
 //  - the chunk is preloaded
 
 //#define CACHE_CHUNKS
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 class NotifyCacheFileListenerEvent : public Runnable {
  public:
   NotifyCacheFileListenerEvent(CacheFileListener* aCallback, nsresult aResult,
                                bool aIsNew)
       : Runnable("net::NotifyCacheFileListenerEvent"),
         mCallback(aCallback),
         mRV(aResult),
@@ -1166,19 +1165,20 @@ nsresult CacheFile::SetFrecency(uint32_t
 
   LOG(("CacheFile::SetFrecency() this=%p, frecency=%u", this, aFrecency));
 
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   PostWriteTimer();
 
-  if (mHandle && !mHandle->IsDoomed())
+  if (mHandle && !mHandle->IsDoomed()) {
     CacheFileIOManager::UpdateIndexEntry(mHandle, &aFrecency, nullptr, nullptr,
                                          nullptr, nullptr);
+  }
 
   mMetadata->SetFrecency(aFrecency);
   return NS_OK;
 }
 
 nsresult CacheFile::GetFrecency(uint32_t* _retval) {
   CacheFileAutoLock lock(this);
   MOZ_ASSERT(mMetadata);
@@ -1499,17 +1499,18 @@ nsresult CacheFile::GetChunkLocked(uint3
       QueueChunkListener(aIndex, aCallback);
     }
 
     if (preload) {
       PreloadChunks(aIndex + 1);
     }
 
     return NS_OK;
-  } else if (off == mDataSize) {
+  }
+  if (off == mDataSize) {
     if (aCaller == WRITER) {
       // this listener is going to write to the chunk
       chunk = new CacheFileChunk(this, aIndex, true);
       mChunks.InsertOrUpdate(aIndex, RefPtr{chunk});
       chunk->mActiveChunk = true;
 
       LOG(("CacheFile::GetChunkLocked() - Created new empty chunk %p [this=%p]",
            chunk.get(), this));
@@ -2069,17 +2070,17 @@ static uint32_t StatusToTelemetryEnum(ns
 }
 
 void CacheFile::RemoveInput(CacheFileInputStream* aInput, nsresult aStatus) {
   AssertOwnsLock();
 
   LOG(("CacheFile::RemoveInput() [this=%p, input=%p, status=0x%08" PRIx32 "]",
        this, aInput, static_cast<uint32_t>(aStatus)));
 
-  DebugOnly<bool> found;
+  DebugOnly<bool> found{};
   found = mInputs.RemoveElement(aInput);
   MOZ_ASSERT(found);
 
   ReleaseOutsideLock(
       already_AddRefed<nsIInputStream>(static_cast<nsIInputStream*>(aInput)));
 
   if (!mMemoryOnly) WriteMetadataIfNeededLocked();
 
@@ -2236,17 +2237,17 @@ bool CacheFile::HaveChunkListeners(uint3
 void CacheFile::NotifyListenersAboutOutputRemoval() {
   LOG(("CacheFile::NotifyListenersAboutOutputRemoval() [this=%p]", this));
 
   AssertOwnsLock();
 
   // First fail all chunk listeners that wait for non-existent chunk
   for (auto iter = mChunkListeners.Iter(); !iter.Done(); iter.Next()) {
     uint32_t idx = iter.Key();
-    auto listeners = iter.UserData();
+    auto* listeners = iter.UserData();
 
     LOG(
         ("CacheFile::NotifyListenersAboutOutputRemoval() - fail "
          "[this=%p, idx=%u]",
          this, idx));
 
     RefPtr<CacheFileChunk> chunk;
     mChunks.Get(idx, getter_AddRefs(chunk));
@@ -2355,21 +2356,17 @@ bool CacheFile::EntryWouldExceedLimit(in
     return false;
   }
 
   int64_t totalSize = aOffset + aSize;
   if (aIsAltData) {
     totalSize += (mAltDataOffset == -1) ? mDataSize : mAltDataOffset;
   }
 
-  if (CacheObserver::EntryIsTooBig(totalSize, !mMemoryOnly)) {
-    return true;
-  }
-
-  return false;
+  return CacheObserver::EntryIsTooBig(totalSize, !mMemoryOnly);
 }
 
 bool CacheFile::IsDirty() { return mDataIsDirty || mMetadata->IsDirty(); }
 
 void CacheFile::WriteMetadataIfNeeded() {
   LOG(("CacheFile::WriteMetadataIfNeeded() [this=%p]", this));
 
   CacheFileAutoLock lock(this);
@@ -2391,18 +2388,19 @@ void CacheFile::WriteMetadataIfNeededLoc
   if (!mMetadata) {
     MOZ_CRASH("Must have metadata here");
     return;
   }
 
   if (NS_FAILED(mStatus)) return;
 
   if (!IsDirty() || mOutput || mInputs.Length() || mChunks.Count() ||
-      mWritingMetadata || mOpeningFile || mKill)
+      mWritingMetadata || mOpeningFile || mKill) {
     return;
+  }
 
   if (!aFireAndForget) {
     // if aFireAndForget is set, we are called from dtor. Write
     // scheduler hard-refers CacheFile otherwise, so we cannot be here.
     CacheFileIOManager::UnscheduleMetadataWrite(this);
   }
 
   LOG(("CacheFile::WriteMetadataIfNeededLocked() - Writing metadata [this=%p]",
@@ -2502,17 +2500,17 @@ nsresult CacheFile::InitIndexEntry() {
   rv = CacheFileIOManager::InitIndexEntry(
       mHandle, GetOriginAttrsHash(mMetadata->OriginAttributes()),
       mMetadata->IsAnonymous(), mPinned);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t frecency = mMetadata->GetFrecency();
 
   bool hasAltData =
-      mMetadata->GetElement(CacheFileUtils::kAltDataKey) ? true : false;
+      mMetadata->GetElement(CacheFileUtils::kAltDataKey) != nullptr;
 
   static auto toUint16 = [](const char* s) -> uint16_t {
     if (s) {
       nsresult rv;
       uint64_t n64 = nsDependentCString(s).ToInteger64(&rv);
       MOZ_ASSERT(NS_SUCCEEDED(rv));
       return n64 <= kIndexTimeOutOfBound ? n64 : kIndexTimeOutOfBound;
     }
@@ -2585,10 +2583,9 @@ size_t CacheFile::SizeOfExcludingThis(
   return n;
 }
 
 size_t CacheFile::SizeOfIncludingThis(
     mozilla::MallocSizeOf mallocSizeOf) const {
   return mallocSizeOf(this) + SizeOfExcludingThis(mallocSizeOf);
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheFileChunk.cpp
+++ b/netwerk/cache2/CacheFileChunk.cpp
@@ -5,18 +5,17 @@
 #include "CacheLog.h"
 #include "CacheFileChunk.h"
 
 #include "CacheFile.h"
 #include "nsThreadUtils.h"
 
 #include "mozilla/IntegerPrintfMacros.h"
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 #define kMinBufSize 512
 
 CacheFileChunkBuffer::CacheFileChunkBuffer(CacheFileChunk* aChunk)
     : mChunk(aChunk),
       mBuf(nullptr),
       mBufSize(0),
       mDataSize(0),
@@ -831,10 +830,9 @@ void CacheFileChunk::BuffersAllocationCh
 
 mozilla::Atomic<uint32_t, ReleaseAcquire>& CacheFileChunk::ChunksMemoryUsage()
     const {
   static mozilla::Atomic<uint32_t, ReleaseAcquire> chunksMemoryUsage(0);
   static mozilla::Atomic<uint32_t, ReleaseAcquire> prioChunksMemoryUsage(0);
   return mIsPriority ? prioChunksMemoryUsage : chunksMemoryUsage;
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheFileChunk.h
+++ b/netwerk/cache2/CacheFileChunk.h
@@ -22,17 +22,17 @@ class CacheFileChunk;
 class CacheFile;
 
 class CacheFileChunkBuffer {
  public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CacheFileChunkBuffer)
 
   explicit CacheFileChunkBuffer(CacheFileChunk* aChunk);
 
-  nsresult EnsureBufSize(uint32_t aSize);
+  nsresult EnsureBufSize(uint32_t aBufSize);
   void CopyFrom(CacheFileChunkBuffer* aOther);
   nsresult FillInvalidRanges(CacheFileChunkBuffer* aOther,
                              CacheFileUtils::ValidityMap* aMap);
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
 
   char* Buf() const { return mBuf; }
   void SetDataSize(uint32_t aDataSize);
   uint32_t DataSize() const { return mDataSize; }
--- a/netwerk/cache2/CacheFileContextEvictor.cpp
+++ b/netwerk/cache2/CacheFileContextEvictor.cpp
@@ -15,18 +15,17 @@
 #include "nsThreadUtils.h"
 #include "nsString.h"
 #include "nsIDirectoryEnumerator.h"
 #include "mozilla/Base64.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 #define CONTEXT_EVICTION_PREFIX "ce_"
 const uint32_t kContextEvictionPrefixLength =
     sizeof(CONTEXT_EVICTION_PREFIX) - 1;
 
 bool CacheFileContextEvictor::sDiskAlreadySearched = false;
 
 CacheFileContextEvictor::CacheFileContextEvictor()
@@ -604,17 +603,18 @@ void CacheFileContextEvictor::EvictEntri
       LOG(
           ("CacheFileContextEvictor::EvictEntries() - No more entries left in "
            "iterator. [iterator=%p, info=%p]",
            mEntries[0]->mIterator.get(), mEntries[0]->mInfo.get()));
       RemoveEvictInfoFromDisk(mEntries[0]->mInfo, mEntries[0]->mPinned,
                               mEntries[0]->mOrigin);
       mEntries.RemoveElementAt(0);
       continue;
-    } else if (NS_FAILED(rv)) {
+    }
+    if (NS_FAILED(rv)) {
       LOG(
           ("CacheFileContextEvictor::EvictEntries() - Iterator failed to "
            "provide next hash (shutdown?), keeping eviction info on disk."
            " [iterator=%p, info=%p]",
            mEntries[0]->mIterator.get(), mEntries[0]->mInfo.get()));
       mEntries.RemoveElementAt(0);
       continue;
     }
@@ -734,10 +734,9 @@ void CacheFileContextEvictor::EvictEntri
     LOG(("CacheFileContextEvictor::EvictEntries - Removing entry."));
     file->Remove(false);
     CacheIndex::RemoveEntry(&hash);
   }
 
   MOZ_ASSERT_UNREACHABLE("We should never get here");
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheFileContextEvictor.h
+++ b/netwerk/cache2/CacheFileContextEvictor.h
@@ -15,19 +15,19 @@ class nsILoadContextInfo;
 
 namespace mozilla {
 namespace net {
 
 class CacheIndexIterator;
 
 struct CacheFileContextEvictorEntry {
   nsCOMPtr<nsILoadContextInfo> mInfo;
-  bool mPinned;
-  nsString mOrigin;   // it can be empty
-  PRTime mTimeStamp;  // in milliseconds
+  bool mPinned = false;
+  nsString mOrigin;       // it can be empty
+  PRTime mTimeStamp = 0;  // in milliseconds
   RefPtr<CacheIndexIterator> mIterator;
 };
 
 class CacheFileContextEvictor {
  public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CacheFileContextEvictor)
 
   CacheFileContextEvictor();
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -36,18 +36,17 @@
 #elif defined(XP_WIN)
 #  include <windows.h>
 #  undef CreateFile
 #  undef CREATE_NEW
 #else
 // XXX add necessary include file for ftruncate (or equivalent)
 #endif
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 #define kOpenHandlesLimit 128
 #define kMetadataWriteDelay 5000
 #define kRemoveTrashStartDelay 60000    // in milliseconds
 #define kSmartSizeUpdateInterval 60000  // in milliseconds
 
 #ifdef ANDROID
 const uint32_t kMaxCacheSizeKB = 512 * 1024;  // 512 MB
@@ -65,21 +64,17 @@ bool CacheFileHandle::DispatchRelease() 
   if (!ioTarget) {
     return false;
   }
 
   nsresult rv = ioTarget->Dispatch(
       NewNonOwningRunnableMethod("net::CacheFileHandle::Release", this,
                                  &CacheFileHandle::Release),
       nsIEventTarget::DISPATCH_NORMAL);
-  if (NS_FAILED(rv)) {
-    return false;
-  }
-
-  return true;
+  return NS_SUCCEEDED(rv);
 }
 
 NS_IMPL_ADDREF(CacheFileHandle)
 NS_IMETHODIMP_(MozExternalRefCountType)
 CacheFileHandle::Release() {
   nsrefcnt count = mRefCnt - 1;
   if (DispatchRelease()) {
     // Redispatched to the IO thread.
@@ -264,17 +259,17 @@ void CacheFileHandles::HandleHashKey::Ad
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
 
   mHandles.InsertElementAt(0, aHandle);
 }
 
 void CacheFileHandles::HandleHashKey::RemoveHandle(CacheFileHandle* aHandle) {
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
 
-  DebugOnly<bool> found;
+  DebugOnly<bool> found{};
   found = mHandles.RemoveElement(aHandle);
   MOZ_ASSERT(found);
 }
 
 already_AddRefed<CacheFileHandle>
 CacheFileHandles::HandleHashKey::GetNewestHandle() {
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
 
@@ -282,17 +277,17 @@ CacheFileHandles::HandleHashKey::GetNewe
   if (mHandles.Length()) {
     handle = mHandles[0];
   }
 
   return handle.forget();
 }
 
 void CacheFileHandles::HandleHashKey::GetHandles(
-    nsTArray<RefPtr<CacheFileHandle> >& aResult) {
+    nsTArray<RefPtr<CacheFileHandle>>& aResult) {
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
 
   for (uint32_t i = 0; i < mHandles.Length(); ++i) {
     CacheFileHandle* handle = mHandles[i];
     aResult.AppendElement(handle);
   }
 }
 
@@ -460,25 +455,25 @@ void CacheFileHandles::RemoveHandle(Cach
         ("CacheFileHandles::RemoveHandle() hash=%08x%08x%08x%08x%08x "
          "list is empty, removing entry %p",
          LOGSHA1(entry->Hash()), entry));
     mTable.RemoveEntry(entry);
   }
 }
 
 void CacheFileHandles::GetAllHandles(
-    nsTArray<RefPtr<CacheFileHandle> >* _retval) {
+    nsTArray<RefPtr<CacheFileHandle>>* _retval) {
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
   for (auto iter = mTable.Iter(); !iter.Done(); iter.Next()) {
     iter.Get()->GetHandles(*_retval);
   }
 }
 
 void CacheFileHandles::GetActiveHandles(
-    nsTArray<RefPtr<CacheFileHandle> >* _retval) {
+    nsTArray<RefPtr<CacheFileHandle>>* _retval) {
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
   for (auto iter = mTable.Iter(); !iter.Done(); iter.Next()) {
     RefPtr<CacheFileHandle> handle = iter.Get()->GetNewestHandle();
     MOZ_ASSERT(handle);
 
     if (!handle->IsDoomed()) {
       _retval->AppendElement(handle);
     }
@@ -491,17 +486,17 @@ void CacheFileHandles::ClearAll() {
 }
 
 uint32_t CacheFileHandles::HandleCount() { return mTable.Count(); }
 
 #ifdef DEBUG_HANDLES
 void CacheFileHandles::Log(CacheFileHandlesEntry* entry) {
   LOG(("CacheFileHandles::Log() BEGIN [entry=%p]", entry));
 
-  nsTArray<RefPtr<CacheFileHandle> > array;
+  nsTArray<RefPtr<CacheFileHandle>> array;
   aEntry->GetHandles(array);
 
   for (uint32_t i = 0; i < array.Length(); ++i) {
     CacheFileHandle* handle = array[i];
     handle->Log();
   }
 
   LOG(("CacheFileHandles::Log() END [entry=%p]", entry));
@@ -592,17 +587,17 @@ class IOPerfReportEvent {
     // Single IO operations can take less than 1ms. So we use microseconds to
     // keep a good resolution of data.
     uint32_t duration = (TimeStamp::Now() - mStartTime).ToMicroseconds();
 
     // This is a simple prefiltering of values that might differ a lot from the
     // average value. Do not add the value to the filtered stats when the event
     // had to wait in a long queue.
     uint32_t eventCounter = aIOThread->EventCounter();
-    bool shortOnly = eventCounter - mEventCounter < 5 ? false : true;
+    bool shortOnly = eventCounter - mEventCounter >= 5;
 
     CacheFileUtils::CachePerfStats::AddValue(mType, duration, shortOnly);
   }
 
  protected:
   CacheFileUtils::CachePerfStats::EDataType mType;
   TimeStamp mStartTime;
   uint32_t mEventCounter;
@@ -657,17 +652,17 @@ class OpenFileEvent : public Runnable, p
       }
     }
 
     mCallback->OnFileOpened(mHandle, rv);
     return NS_OK;
   }
 
  protected:
-  SHA1Sum::Hash mHash;
+  SHA1Sum::Hash mHash{};
   uint32_t mFlags;
   nsCOMPtr<CacheFileIOListener> mCallback;
   RefPtr<CacheFileIOManager> mIOMan;
   RefPtr<CacheFileHandle> mHandle;
   nsCString mKey;
 };
 
 class ReadEvent : public Runnable, public IOPerfReportEvent {
@@ -845,17 +840,17 @@ class DoomFileByKeyEvent : public Runnab
     if (mCallback) {
       mCallback->OnFileDoomed(nullptr, rv);
     }
 
     return NS_OK;
   }
 
  protected:
-  SHA1Sum::Hash mHash;
+  SHA1Sum::Hash mHash{};
   nsCOMPtr<CacheFileIOListener> mCallback;
   RefPtr<CacheFileIOManager> mIOMan;
 };
 
 class ReleaseNSPRHandleEvent : public Runnable {
  public:
   explicit ReleaseNSPRHandleEvent(CacheFileHandle* aHandle)
       : Runnable("net::ReleaseNSPRHandleEvent"), mHandle(aHandle) {}
@@ -1204,17 +1199,17 @@ void CacheFileIOManager::ShutdownInterna
   mShuttingDown = true;
 
   if (mTrashTimer) {
     mTrashTimer->Cancel();
     mTrashTimer = nullptr;
   }
 
   // close all handles and delete all associated files
-  nsTArray<RefPtr<CacheFileHandle> > handles;
+  nsTArray<RefPtr<CacheFileHandle>> handles;
   mHandles.GetAllHandles(&handles);
   handles.AppendElements(mSpecialHandles);
 
   for (uint32_t i = 0; i < handles.Length(); i++) {
     CacheFileHandle* h = handles[i];
     h->mClosed = true;
 
     h->Log();
@@ -1417,17 +1412,17 @@ nsresult CacheFileIOManager::ScheduleMet
 
   if (!mMetadataWritesTimer) {
     rv = NS_NewTimerWithCallback(getter_AddRefs(mMetadataWritesTimer), this,
                                  kMetadataWriteDelay, nsITimer::TYPE_ONE_SHOT);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   if (mScheduledMetadataWrites.IndexOf(aFile) !=
-      mScheduledMetadataWrites.NoIndex) {
+      nsTArray<RefPtr<mozilla::net::CacheFile>>::NoIndex) {
     return NS_OK;
   }
 
   mScheduledMetadataWrites.AppendElement(aFile);
 
   return NS_OK;
 }
 
@@ -1466,17 +1461,17 @@ nsresult CacheFileIOManager::ShutdownMet
   nsCOMPtr<nsIEventTarget> target = ioMan->IOTarget();
   NS_ENSURE_TRUE(target, NS_ERROR_UNEXPECTED);
   return target->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
 }
 
 void CacheFileIOManager::ShutdownMetadataWriteSchedulingInternal() {
   MOZ_ASSERT(IsOnIOThreadOrCeased());
 
-  nsTArray<RefPtr<CacheFile> > files = std::move(mScheduledMetadataWrites);
+  nsTArray<RefPtr<CacheFile>> files = std::move(mScheduledMetadataWrites);
   for (uint32_t i = 0; i < files.Length(); ++i) {
     CacheFile* file = files[i];
     file->WriteMetadataIfNeeded();
   }
 
   if (mMetadataWritesTimer) {
     mMetadataWritesTimer->Cancel();
     mMetadataWritesTimer = nullptr;
@@ -1485,17 +1480,17 @@ void CacheFileIOManager::ShutdownMetadat
 
 NS_IMETHODIMP
 CacheFileIOManager::Notify(nsITimer* aTimer) {
   MOZ_ASSERT(IsOnIOThreadOrCeased());
   MOZ_ASSERT(mMetadataWritesTimer == aTimer);
 
   mMetadataWritesTimer = nullptr;
 
-  nsTArray<RefPtr<CacheFile> > files = std::move(mScheduledMetadataWrites);
+  nsTArray<RefPtr<CacheFile>> files = std::move(mScheduledMetadataWrites);
   for (uint32_t i = 0; i < files.Length(); ++i) {
     CacheFile* file = files[i];
     file->WriteMetadataIfNeeded();
   }
 
   return NS_OK;
 }
 
@@ -2290,17 +2285,17 @@ nsresult CacheFileIOManager::MaybeReleas
   LOG(
       ("CacheFileIOManager::MaybeReleaseNSPRHandleInternal() [handle=%p, "
        "ignore shutdown=%d]",
        aHandle, aIgnoreShutdownLag));
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
 
   if (aHandle->mFD) {
-    DebugOnly<bool> found;
+    DebugOnly<bool> found{};
     found = mHandlesByLastUsed.RemoveElement(aHandle);
     MOZ_ASSERT(found);
   }
 
   PRFileDesc* fd = aHandle->mFD;
   aHandle->mFD = nullptr;
 
   // Leak invalid (w/o metadata) and doomed handles immediately after shutdown.
@@ -2960,17 +2955,17 @@ nsresult CacheFileIOManager::EvictAllInt
   if (!mTreeCreated) {
     rv = CreateCacheTree();
     if (NS_FAILED(rv)) {
       return rv;
     }
   }
 
   // Doom all active handles
-  nsTArray<RefPtr<CacheFileHandle> > handles;
+  nsTArray<RefPtr<CacheFileHandle>> handles;
   mHandles.GetActiveHandles(&handles);
 
   for (uint32_t i = 0; i < handles.Length(); ++i) {
     rv = DoomFileInternal(handles[i]);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       LOG(
           ("CacheFileIOManager::EvictAllInternal() - Cannot doom handle "
            "[handle=%p]",
@@ -3082,17 +3077,17 @@ nsresult CacheFileIOManager::EvictByCont
     if (NS_FAILED(rv)) {
       return rv;
     }
   }
 
   NS_ConvertUTF16toUTF8 origin(aOrigin);
 
   // Doom all active handles that matches the load context
-  nsTArray<RefPtr<CacheFileHandle> > handles;
+  nsTArray<RefPtr<CacheFileHandle>> handles;
   mHandles.GetActiveHandles(&handles);
 
   for (uint32_t i = 0; i < handles.Length(); ++i) {
     CacheFileHandle* handle = handles[i];
 
     nsAutoCString uriSpec;
     RefPtr<nsILoadContextInfo> info =
         CacheFileUtils::ParseKey(handle->Key(), nullptr, &uriSpec);
@@ -3923,17 +3918,17 @@ nsresult CacheFileIOManager::OpenNSPRHan
 
   return NS_OK;
 }
 
 void CacheFileIOManager::NSPRHandleUsed(CacheFileHandle* aHandle) {
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
   MOZ_ASSERT(aHandle->mFD);
 
-  DebugOnly<bool> found;
+  DebugOnly<bool> found{};
   found = mHandlesByLastUsed.RemoveElement(aHandle);
   MOZ_ASSERT(found);
 
   mHandlesByLastUsed.AppendElement(aHandle);
 }
 
 nsresult CacheFileIOManager::SyncRemoveDir(nsIFile* aFile, const char* aDir) {
   nsresult rv;
@@ -4216,10 +4211,9 @@ size_t CacheFileIOManager::SizeOfExcludi
 }
 
 // static
 size_t CacheFileIOManager::SizeOfIncludingThis(
     mozilla::MallocSizeOf mallocSizeOf) {
   return mallocSizeOf(gInstance) + SizeOfExcludingThis(mallocSizeOf);
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheFileIOManager.h
+++ b/netwerk/cache2/CacheFileIOManager.h
@@ -134,34 +134,34 @@ class CacheFileHandles {
  public:
   CacheFileHandles();
   ~CacheFileHandles();
 
   nsresult GetHandle(const SHA1Sum::Hash* aHash, CacheFileHandle** _retval);
   already_AddRefed<CacheFileHandle> NewHandle(const SHA1Sum::Hash*,
                                               bool aPriority,
                                               CacheFileHandle::PinningStatus);
-  void RemoveHandle(CacheFileHandle* aHandlle);
+  void RemoveHandle(CacheFileHandle* aHandle);
   void GetAllHandles(nsTArray<RefPtr<CacheFileHandle> >* _retval);
   void GetActiveHandles(nsTArray<RefPtr<CacheFileHandle> >* _retval);
   void ClearAll();
   uint32_t HandleCount();
 
 #ifdef DEBUG_HANDLES
   void Log(CacheFileHandlesEntry* entry);
 #endif
 
   // Memory reporting
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
 
   class HandleHashKey : public PLDHashEntryHdr {
    public:
-    typedef const SHA1Sum::Hash& KeyType;
-    typedef const SHA1Sum::Hash* KeyTypePointer;
+    using KeyType = const SHA1Sum::Hash&;
+    using KeyTypePointer = const SHA1Sum::Hash*;
 
     explicit HandleHashKey(KeyTypePointer aKey) {
       MOZ_COUNT_CTOR(HandleHashKey);
       mHash = MakeUnique<uint8_t[]>(SHA1Sum::kHashSize);
       memcpy(mHash.get(), aKey, sizeof(SHA1Sum::Hash));
     }
     HandleHashKey(const HandleHashKey& aOther) {
       MOZ_ASSERT_UNREACHABLE("HandleHashKey copy constructor is forbidden!");
@@ -311,17 +311,17 @@ class CacheFileIOManager final : public 
                                      int64_t aTruncatePos, int64_t aEOFPos,
                                      CacheFileIOListener* aCallback);
   static nsresult RenameFile(CacheFileHandle* aHandle,
                              const nsACString& aNewName,
                              CacheFileIOListener* aCallback);
   static nsresult EvictIfOverLimit();
   static nsresult EvictAll();
   static nsresult EvictByContext(nsILoadContextInfo* aLoadContextInfo,
-                                 bool aPinning, const nsAString& aOrigin);
+                                 bool aPinned, const nsAString& aOrigin);
 
   static nsresult InitIndexEntry(CacheFileHandle* aHandle,
                                  OriginAttrsHash aOriginAttrsHash,
                                  bool aAnonymous, bool aPinning);
   static nsresult UpdateIndexEntry(CacheFileHandle* aHandle,
                                    const uint32_t* aFrecency,
                                    const bool* aHasAltData,
                                    const uint16_t* aOnStartTime,
@@ -379,29 +379,29 @@ class CacheFileIOManager final : public 
   void CloseHandleInternal(CacheFileHandle* aHandle);
   nsresult ReadInternal(CacheFileHandle* aHandle, int64_t aOffset, char* aBuf,
                         int32_t aCount);
   nsresult WriteInternal(CacheFileHandle* aHandle, int64_t aOffset,
                          const char* aBuf, int32_t aCount, bool aValidate,
                          bool aTruncate);
   nsresult DoomFileInternal(
       CacheFileHandle* aHandle,
-      PinningDoomRestriction aPinningStatusRestriction = NO_RESTRICTION);
+      PinningDoomRestriction aPinningDoomRestriction = NO_RESTRICTION);
   nsresult DoomFileByKeyInternal(const SHA1Sum::Hash* aHash);
   nsresult MaybeReleaseNSPRHandleInternal(CacheFileHandle* aHandle,
                                           bool aIgnoreShutdownLag = false);
   nsresult TruncateSeekSetEOFInternal(CacheFileHandle* aHandle,
                                       int64_t aTruncatePos, int64_t aEOFPos);
   nsresult RenameFileInternal(CacheFileHandle* aHandle,
                               const nsACString& aNewName);
   nsresult EvictIfOverLimitInternal();
   nsresult OverLimitEvictionInternal();
   nsresult EvictAllInternal();
   nsresult EvictByContextInternal(nsILoadContextInfo* aLoadContextInfo,
-                                  bool aPinning, const nsAString& aOrigin);
+                                  bool aPinned, const nsAString& aOrigin);
 
   nsresult TrashDirectory(nsIFile* aFile);
   static void OnTrashTimer(nsITimer* aTimer, void* aClosure);
   nsresult StartRemovingTrash();
   nsresult RemoveTrashInternal();
   nsresult FindTrashDirToRemove();
 
   nsresult CreateFile(CacheFileHandle* aHandle);
--- a/netwerk/cache2/CacheFileInputStream.cpp
+++ b/netwerk/cache2/CacheFileInputStream.cpp
@@ -5,18 +5,17 @@
 #include "CacheLog.h"
 #include "CacheFileInputStream.h"
 
 #include "CacheFile.h"
 #include "nsStreamUtils.h"
 #include "nsThreadUtils.h"
 #include <algorithm>
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 NS_IMPL_ADDREF(CacheFileInputStream)
 NS_IMETHODIMP_(MozExternalRefCountType)
 CacheFileInputStream::Release() {
   MOZ_ASSERT(0 != mRefCnt, "dup release");
   nsrefcnt count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "CacheFileInputStream");
 
@@ -710,10 +709,9 @@ void CacheFileInputStream::MaybeNotifyLi
 size_t CacheFileInputStream::SizeOfIncludingThis(
     mozilla::MallocSizeOf mallocSizeOf) const {
   // Everything the stream keeps a reference to is already reported somewhere
   // else. mFile reports itself. mChunk reported as part of CacheFile. mCallback
   // is usually CacheFile or a class that is reported elsewhere.
   return mallocSizeOf(this);
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheFileMetadata.cpp
+++ b/netwerk/cache2/CacheFileMetadata.cpp
@@ -14,31 +14,30 @@
 #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 {
+namespace mozilla::net {
 
 #define kMinMetadataRead 1024  // TODO find optimal value from telemetry
 #define kAlignSize 4096
 
 // Most of the cache entries fit into one chunk due to current chunk size. Make
 // sure to tweak this value if kChunkSize is going to change.
 #define kInitialHashArraySize 1
 
 // Initial elements buffer size.
 #define kInitialBufSize 64
 
 // Max size of elements in bytes.
-#define kMaxElementsSize 64 * 1024
+#define kMaxElementsSize (64 * 1024)
 
 #define NOW_SECONDS() (uint32_t(PR_Now() / PR_USEC_PER_SEC))
 
 NS_IMPL_ISUPPORTS(CacheFileMetadata, CacheFileIOListener)
 
 CacheFileMetadata::CacheFileMetadata(CacheFileHandle* aHandle,
                                      const nsACString& aKey)
     : CacheMemoryConsumer(NORMAL),
@@ -58,17 +57,17 @@ CacheFileMetadata::CacheFileMetadata(Cac
   LOG(("CacheFileMetadata::CacheFileMetadata() [this=%p, handle=%p, key=%s]",
        this, aHandle, PromiseFlatCString(aKey).get()));
 
   memset(&mMetaHdr, 0, sizeof(CacheFileMetadataHeader));
   mMetaHdr.mVersion = kCacheEntryVersion;
   mMetaHdr.mExpirationTime = nsICacheEntry::NO_EXPIRATION_TIME;
   mKey = aKey;
 
-  DebugOnly<nsresult> rv;
+  DebugOnly<nsresult> rv{};
   rv = ParseKey(aKey);
   MOZ_ASSERT(NS_SUCCEEDED(rv));
 }
 
 CacheFileMetadata::CacheFileMetadata(bool aMemoryOnly, bool aPinned,
                                      const nsACString& aKey)
     : CacheMemoryConsumer(aMemoryOnly ? MEMORY_ONLY : NORMAL),
       mHandle(nullptr),
@@ -91,17 +90,17 @@ CacheFileMetadata::CacheFileMetadata(boo
   mMetaHdr.mVersion = kCacheEntryVersion;
   if (aPinned) {
     AddFlags(kCacheEntryIsPinned);
   }
   mMetaHdr.mExpirationTime = nsICacheEntry::NO_EXPIRATION_TIME;
   mKey = aKey;
   mMetaHdr.mKeySize = mKey.Length();
 
-  DebugOnly<nsresult> rv;
+  DebugOnly<nsresult> rv{};
   rv = ParseKey(aKey);
   MOZ_ASSERT(NS_SUCCEEDED(rv));
 }
 
 CacheFileMetadata::CacheFileMetadata()
     : CacheMemoryConsumer(DONT_REPORT /* This is a helper class */),
       mHandle(nullptr),
       mHashArray(nullptr),
@@ -499,17 +498,18 @@ nsresult CacheFileMetadata::SetHash(uint
        aHash));
 
   MarkDirty();
 
   MOZ_ASSERT(aIndex <= mHashCount);
 
   if (aIndex > mHashCount) {
     return NS_ERROR_INVALID_ARG;
-  } else if (aIndex == mHashCount) {
+  }
+  if (aIndex == mHashCount) {
     if ((aIndex + 1) * sizeof(CacheHash::Hash16_t) > mHashArraySize) {
       // reallocate hash array buffer
       if (mHashArraySize == 0) {
         mHashArraySize = kInitialHashArraySize * sizeof(CacheHash::Hash16_t);
       } else {
         mHashArraySize *= 2;
       }
       mHashArray = static_cast<CacheHash::Hash16_t*>(
@@ -1040,10 +1040,9 @@ size_t CacheFileMetadata::SizeOfExcludin
   return n;
 }
 
 size_t CacheFileMetadata::SizeOfIncludingThis(
     mozilla::MallocSizeOf mallocSizeOf) const {
   return mallocSizeOf(this) + SizeOfExcludingThis(mallocSizeOf);
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheFileMetadata.h
+++ b/netwerk/cache2/CacheFileMetadata.h
@@ -215,17 +215,17 @@ class CacheFileMetadata final : public C
   CacheHash::Hash16_t* mHashArray;
   uint32_t mHashArraySize;
   uint32_t mHashCount;
   int64_t mOffset;
   char* mBuf;  // used for parsing, then points
                // to elements
   uint32_t mBufSize;
   char* mWriteBuf;
-  CacheFileMetadataHeader mMetaHdr;
+  CacheFileMetadataHeader mMetaHdr{0};
   uint32_t mElementsSize;
   bool mIsDirty : 1;
   bool mAnonymous : 1;
   bool mAllocExactSize : 1;
   bool mFirstRead : 1;
   mozilla::OriginAttributes mOriginAttributes;
   mozilla::TimeStamp mReadStart;
   nsCOMPtr<CacheFileMetadataListener> mListener;
--- a/netwerk/cache2/CacheFileOutputStream.cpp
+++ b/netwerk/cache2/CacheFileOutputStream.cpp
@@ -7,18 +7,17 @@
 
 #include "CacheFile.h"
 #include "CacheEntry.h"
 #include "nsStreamUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/DebugOnly.h"
 #include <algorithm>
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 NS_IMPL_ADDREF(CacheFileOutputStream)
 NS_IMETHODIMP_(MozExternalRefCountType)
 CacheFileOutputStream::Release() {
   MOZ_ASSERT(0 != mRefCnt, "dup release");
   nsrefcnt count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "CacheFileOutputStream");
 
@@ -457,10 +456,9 @@ size_t CacheFileOutputStream::SizeOfIncl
   // else.
   // mFile reports itself.
   // mChunk reported as part of CacheFile.
   // mCloseListener is CacheEntry, already reported.
   // mCallback is usually CacheFile or a class that is reported elsewhere.
   return mallocSizeOf(this);
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheFileUtils.cpp
+++ b/netwerk/cache2/CacheFileUtils.cpp
@@ -9,19 +9,17 @@
 #include "LoadContextInfo.h"
 #include "mozilla/Tokenizer.h"
 #include "mozilla/Telemetry.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include <algorithm>
 #include "mozilla/Unused.h"
 
-namespace mozilla {
-namespace net {
-namespace CacheFileUtils {
+namespace mozilla::net::CacheFileUtils {
 
 // This designates the format for the "alt-data" metadata.
 // When the format changes we need to update the version.
 static uint32_t const kAltDataVersion = 1;
 const char* kAltDataKey = "alt-data";
 
 namespace {
 
@@ -660,11 +658,9 @@ void BuildAlternativeDataInfo(const char
   _retval.Truncate();
   _retval.AppendInt(kAltDataVersion);
   _retval.Append(';');
   _retval.AppendInt(aOffset);
   _retval.Append(',');
   _retval.Append(aInfo);
 }
 
-}  // namespace CacheFileUtils
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net::CacheFileUtils
--- a/netwerk/cache2/CacheFileUtils.h
+++ b/netwerk/cache2/CacheFileUtils.h
@@ -99,18 +99,18 @@ class DetailedCacheHitTelemetry {
     void AddRecord(ERecType aType);
     // Returns the bucket index that the current hit rate falls into according
     // to the given aNumOfBuckets.
     uint32_t GetHitRateBucket(uint32_t aNumOfBuckets) const;
     uint32_t Count();
     void Reset();
 
    private:
-    uint32_t mHitCnt;
-    uint32_t mMissCnt;
+    uint32_t mHitCnt = 0;
+    uint32_t mMissCnt = 0;
   };
 
   // Group the hits and misses statistics by cache files count ranges (0-5000,
   // 5001-10000, ... , 95001- )
   static const uint32_t kRangeSize = 5000;
   static const uint32_t kNumOfRanges = 20;
 
   // Use the same ranges to report an average hit rate. Report the hit rates
--- a/netwerk/cache2/CacheHashUtils.cpp
+++ b/netwerk/cache2/CacheHashUtils.cpp
@@ -4,18 +4,17 @@
 
 #include "CacheHashUtils.h"
 
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/EndianUtils.h"
 #include "mozilla/SHA1.h"
 #include "plstr.h"
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 /**
  *  CacheHash::Hash(const char * key, uint32_t initval)
  *
  *  See http://burtleburtle.net/bob/hash/evahash.html for more information
  *  about this hash function.
  *
  *  This algorithm is used to check the data integrity.
@@ -228,10 +227,9 @@ OriginAttrsHash GetOriginAttrsHash(const
   SHA1Sum sum;
   SHA1Sum::Hash hash;
   sum.update(suffix.BeginReading(), suffix.Length());
   sum.finish(hash);
 
   return BigEndian::readUint64(&hash);
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheHashUtils.h
+++ b/netwerk/cache2/CacheHashUtils.h
@@ -25,18 +25,18 @@ namespace mozilla {
 class OriginAttributes;
 
 namespace net {
 
 class CacheHash : public nsISupports {
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
-  typedef uint16_t Hash16_t;
-  typedef uint32_t Hash32_t;
+  using Hash16_t = uint16_t;
+  using Hash32_t = uint32_t;
 
   static Hash32_t Hash(const char* aData, uint32_t aSize,
                        uint32_t aInitval = 0);
   static Hash16_t Hash16(const char* aData, uint32_t aSize,
                          uint32_t aInitval = 0);
 
   explicit CacheHash(uint32_t aInitval = 0);
 
@@ -52,16 +52,16 @@ class CacheHash : public nsISupports {
   uint32_t mA, mB, mC;
   uint8_t mPos;
   uint32_t mBuf;
   uint8_t mBufPos;
   uint32_t mLength;
   bool mFinalized;
 };
 
-typedef uint64_t OriginAttrsHash;
+using OriginAttrsHash = uint64_t;
 
 OriginAttrsHash GetOriginAttrsHash(const mozilla::OriginAttributes& aOA);
 
 }  // namespace net
 }  // namespace mozilla
 
 #endif
--- a/netwerk/cache2/CacheIOThread.cpp
+++ b/netwerk/cache2/CacheIOThread.cpp
@@ -24,24 +24,23 @@
 #  include <windows.h>
 #endif
 
 #ifdef MOZ_TASK_TRACER
 #  include "GeckoTaskTracer.h"
 #  include "TracedTaskCommon.h"
 #endif
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 namespace {  // anon
 
 class CacheIOTelemetry {
  public:
-  typedef CacheIOThread::EventQueue::size_type size_type;
+  using size_type = CacheIOThread::EventQueue::size_type;
   static size_type mMinLengthToReport[CacheIOThread::LAST_LEVEL];
   static void Report(uint32_t aLevel, size_type aLength);
 };
 
 static CacheIOTelemetry::size_type const kGranularity = 30;
 
 CacheIOTelemetry::size_type
     CacheIOTelemetry::mMinLengthToReport[CacheIOThread::LAST_LEVEL] = {
@@ -272,30 +271,32 @@ nsresult CacheIOThread::Dispatch(already
 
   nsCOMPtr<nsIRunnable> runnable(aRunnable);
 
   // Runnable is always expected to be non-null, hard null-check bellow.
   MOZ_ASSERT(runnable);
 
   MonitorAutoLock lock(mMonitor);
 
-  if (mShutdown && (PR_GetCurrentThread() != mThread))
+  if (mShutdown && (PR_GetCurrentThread() != mThread)) {
     return NS_ERROR_UNEXPECTED;
+  }
 
   return DispatchInternal(runnable.forget(), aLevel);
 }
 
 nsresult CacheIOThread::DispatchAfterPendingOpens(nsIRunnable* aRunnable) {
   // Runnable is always expected to be non-null, hard null-check bellow.
   MOZ_ASSERT(aRunnable);
 
   MonitorAutoLock lock(mMonitor);
 
-  if (mShutdown && (PR_GetCurrentThread() != mThread))
+  if (mShutdown && (PR_GetCurrentThread() != mThread)) {
     return NS_ERROR_UNEXPECTED;
+  }
 
   // Move everything from later executed OPEN level to the OPEN_PRIORITY level
   // where we post the (eviction) runnable.
   mQueueLength[OPEN_PRIORITY] += mEventQueue[OPEN].Length();
   mQueueLength[OPEN] -= mEventQueue[OPEN].Length();
   mEventQueue[OPEN_PRIORITY].AppendElements(mEventQueue[OPEN]);
   mEventQueue[OPEN].Clear();
 
@@ -636,10 +637,9 @@ CacheIOThread::Cancelable::Cancelable(bo
 CacheIOThread::Cancelable::~Cancelable() {
   MOZ_ASSERT(CacheIOThread::sSelf);
 
   if (mCancelable) {
     --CacheIOThread::sSelf->mIOCancelableEvents;
   }
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheIOThread.h
+++ b/netwerk/cache2/CacheIOThread.h
@@ -31,17 +31,17 @@ class CacheIOThread final : public nsITh
   virtual ~CacheIOThread();
 
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSITHREADOBSERVER
 
   CacheIOThread();
 
-  typedef nsTArray<nsCOMPtr<nsIRunnable>> EventQueue;
+  using EventQueue = nsTArray<nsCOMPtr<nsIRunnable>>;
 
   enum ELevel : uint32_t {
     OPEN_PRIORITY,
     READ_PRIORITY,
     MANAGEMENT,  // Doesn't do any actual I/O
     OPEN,
     READ,
     WRITE_PRIORITY,
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -29,18 +29,17 @@
 #define kIndexVersion 0x0000000A
 #define kUpdateIndexStartDelay 50000  // in milliseconds
 #define kTelemetryReportBytesLimit (2U * 1024U * 1024U * 1024U)  // 2GB
 
 #define INDEX_NAME "index"
 #define TEMP_INDEX_NAME "index.tmp"
 #define JOURNAL_NAME "index.log"
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 namespace {
 
 class FrecencyComparator {
  public:
   bool Equals(const RefPtr<CacheIndexRecordWrapper>& a,
               const RefPtr<CacheIndexRecordWrapper>& b) const {
     if (!a || !b) {
@@ -1391,18 +1390,19 @@ nsresult CacheIndex::GetCacheStats(nsILo
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   *aSize = 0;
   *aCount = 0;
 
   for (auto iter = index->mFrecencyArray.Iter(); !iter.Done(); iter.Next()) {
     if (aInfo &&
-        !CacheIndexEntry::RecordMatchesLoadContextInfo(iter.Get(), aInfo))
+        !CacheIndexEntry::RecordMatchesLoadContextInfo(iter.Get(), aInfo)) {
       continue;
+    }
 
     *aSize += CacheIndexEntry::GetFileSize(*(iter.Get()->Get()));
     ++*aCount;
   }
 
   return NS_OK;
 }
 
@@ -2658,17 +2658,17 @@ nsresult CacheIndex::InitEntryFromDiskDa
   aEntry->MarkFresh();
 
   aEntry->Init(GetOriginAttrsHash(aMetaData->OriginAttributes()),
                aMetaData->IsAnonymous(), aMetaData->Pinned());
 
   aEntry->SetFrecency(aMetaData->GetFrecency());
 
   const char* altData = aMetaData->GetElement(CacheFileUtils::kAltDataKey);
-  bool hasAltData = altData ? true : false;
+  bool hasAltData = altData != nullptr;
   if (hasAltData && NS_FAILED(CacheFileUtils::ParseAlternativeDataInfo(
                         altData, nullptr, nullptr))) {
     return NS_ERROR_FAILURE;
   }
   aEntry->SetHasAltData(hasAltData);
 
   static auto toUint16 = [](const char* aUint16String) -> uint16_t {
     if (!aUint16String) {
@@ -2700,21 +2700,17 @@ nsresult CacheIndex::InitEntryFromDiskDa
   aEntry->SetFileSize(static_cast<uint32_t>(std::min(
       static_cast<int64_t>(PR_UINT32_MAX), (aFileSize + 0x3FF) >> 10)));
   return NS_OK;
 }
 
 bool CacheIndex::IsUpdatePending() {
   sLock.AssertCurrentThreadOwns();
 
-  if (mUpdateTimer || mUpdateEventPending) {
-    return true;
-  }
-
-  return false;
+  return mUpdateTimer || mUpdateEventPending;
 }
 
 void CacheIndex::BuildIndex() {
   LOG(("CacheIndex::BuildIndex()"));
 
   sLock.AssertCurrentThreadOwns();
 
   MOZ_ASSERT(mPendingUpdates.Count() == 0);
@@ -3869,10 +3865,9 @@ void CacheIndex::OnAsyncEviction(bool aE
   }
 
   index->mAsyncGetDiskConsumptionBlocked = aEvicting;
   if (!aEvicting) {
     index->NotifyAsyncGetDiskConsumptionCallbacks();
   }
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheIndex.h
+++ b/netwerk/cache2/CacheIndex.h
@@ -36,17 +36,17 @@ namespace net {
 
 class CacheFileMetadata;
 class FileOpenHelper;
 class CacheIndexIterator;
 
 const uint16_t kIndexTimeNotAvailable = 0xFFFFU;
 const uint16_t kIndexTimeOutOfBound = 0xFFFEU;
 
-typedef struct {
+using CacheIndexHeader = struct {
   // Version of the index. The index must be ignored and deleted when the file
   // on disk was written with a newer version.
   uint32_t mVersion;
 
   // Timestamp of time when the last successful write of the index started.
   // During update process we use this timestamp for a quick validation of entry
   // files. If last modified time of the file is lower than this timestamp, we
   // skip parsing of such file since the information in index should be up to
@@ -58,28 +58,28 @@ typedef struct {
   // journal and start update process whenever this flag is set during index
   // parsing.
   uint32_t mIsDirty;
 
   // The amount of data written to the cache. When it reaches
   // kTelemetryReportBytesLimit a telemetry report is sent and the counter is
   // reset.
   uint32_t mKBWritten;
-} CacheIndexHeader;
+};
 
 static_assert(sizeof(CacheIndexHeader::mVersion) +
                       sizeof(CacheIndexHeader::mTimeStamp) +
                       sizeof(CacheIndexHeader::mIsDirty) +
                       sizeof(CacheIndexHeader::mKBWritten) ==
                   sizeof(CacheIndexHeader),
               "Unexpected sizeof(CacheIndexHeader)!");
 
 #pragma pack(push, 1)
 struct CacheIndexRecord {
-  SHA1Sum::Hash mHash;
+  SHA1Sum::Hash mHash{};
   uint32_t mFrecency;
   OriginAttrsHash mOriginAttrsHash;
   uint16_t mOnStartTime;
   uint16_t mOnStopTime;
   uint8_t mContentType;
 
   /*
    *    1000 0000 0000 0000 0000 0000 0000 0000 : initialized
@@ -123,18 +123,18 @@ class CacheIndexRecordWrapper final {
 
  private:
   ~CacheIndexRecordWrapper() = default;
   UniquePtr<CacheIndexRecord> mRec;
 };
 
 class CacheIndexEntry : public PLDHashEntryHdr {
  public:
-  typedef const SHA1Sum::Hash& KeyType;
-  typedef const SHA1Sum::Hash* KeyTypePointer;
+  using KeyType = const SHA1Sum::Hash&;
+  using KeyTypePointer = const SHA1Sum::Hash*;
 
   explicit CacheIndexEntry(KeyTypePointer aKey) {
     MOZ_COUNT_CTOR(CacheIndexEntry);
     mRec = new CacheIndexRecordWrapper();
     LOG(("CacheIndexEntry::CacheIndexEntry() - Created record [rec=%p]",
          mRec->Get()));
     memcpy(&mRec->Get()->mHash, aKey, sizeof(SHA1Sum::Hash));
   }
@@ -333,24 +333,20 @@ class CacheIndexEntry : public PLDHashEn
          GetHasAltData(), GetOnStartTime(), GetOnStopTime(), GetContentType(),
          GetFileSize()));
   }
 
   static bool RecordMatchesLoadContextInfo(CacheIndexRecordWrapper* aRec,
                                            nsILoadContextInfo* aInfo) {
     MOZ_ASSERT(aInfo);
 
-    if (!aInfo->IsPrivate() &&
-        GetOriginAttrsHash(*aInfo->OriginAttributesPtr()) ==
-            aRec->Get()->mOriginAttrsHash &&
-        aInfo->IsAnonymous() == !!(aRec->Get()->mFlags & kAnonymousMask)) {
-      return true;
-    }
-
-    return false;
+    return !aInfo->IsPrivate() &&
+           GetOriginAttrsHash(*aInfo->OriginAttributesPtr()) ==
+               aRec->Get()->mOriginAttrsHash &&
+           aInfo->IsAnonymous() == !!(aRec->Get()->mFlags & kAnonymousMask);
   }
 
   // Memory reporting
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
     return mallocSizeOf(mRec->Get());
   }
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
@@ -689,24 +685,24 @@ class CacheIndexStats {
       LOG(("CacheIndexStats::AfterChange()"));
       Log();
     }
 #endif
   }
 
  private:
   uint32_t mCount;
-  uint32_t mCountByType[nsICacheEntry::CONTENT_TYPE_LAST];
+  uint32_t mCountByType[nsICacheEntry::CONTENT_TYPE_LAST]{};
   uint32_t mNotInitialized;
   uint32_t mRemoved;
   uint32_t mDirty;
   uint32_t mFresh;
   uint32_t mEmpty;
   uint32_t mSize;
-  uint32_t mSizeByType[nsICacheEntry::CONTENT_TYPE_LAST];
+  uint32_t mSizeByType[nsICacheEntry::CONTENT_TYPE_LAST]{};
 #ifdef DEBUG
   // We completely remove the data about an entry from the stats in
   // BeforeChange() and set this flag to true. The entry is then modified,
   // deleted or created and the data is again put into the stats and this flag
   // set to false. Statistics must not be read during this time since the
   // information is not correct.
   bool mStateLogged;
 
--- a/netwerk/cache2/CacheIndexContextIterator.cpp
+++ b/netwerk/cache2/CacheIndexContextIterator.cpp
@@ -2,18 +2,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 "CacheLog.h"
 #include "CacheIndexContextIterator.h"
 #include "CacheIndex.h"
 #include "nsString.h"
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 CacheIndexContextIterator::CacheIndexContextIterator(CacheIndex* aIndex,
                                                      bool aAddNew,
                                                      nsILoadContextInfo* aInfo)
     : CacheIndexIterator(aIndex, aAddNew), mInfo(aInfo) {}
 
 void CacheIndexContextIterator::AddRecord(CacheIndexRecordWrapper* aRecord) {
   if (CacheIndexEntry::RecordMatchesLoadContextInfo(aRecord, mInfo)) {
@@ -24,10 +23,9 @@ void CacheIndexContextIterator::AddRecor
 void CacheIndexContextIterator::AddRecords(
     const nsTArray<RefPtr<CacheIndexRecordWrapper>>& aRecords) {
   // We need to add one by one so that those with wrong context are ignored.
   for (uint32_t i = 0; i < aRecords.Length(); ++i) {
     AddRecord(aRecords[i]);
   }
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheIndexIterator.cpp
+++ b/netwerk/cache2/CacheIndexIterator.cpp
@@ -3,18 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CacheLog.h"
 #include "CacheIndexIterator.h"
 #include "CacheIndex.h"
 #include "nsString.h"
 #include "mozilla/DebugOnly.h"
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 CacheIndexIterator::CacheIndexIterator(CacheIndex* aIndex, bool aAddNew)
     : mStatus(NS_OK), mIndex(aIndex), mAddNew(aAddNew) {
   LOG(("CacheIndexIterator::CacheIndexIterator() [this=%p]", this));
 }
 
 CacheIndexIterator::~CacheIndexIterator() {
   LOG(("CacheIndexIterator::~CacheIndexIterator() [this=%p]", this));
@@ -93,10 +92,9 @@ bool CacheIndexIterator::ReplaceRecord(C
   if (RemoveRecord(aOldRecord)) {
     AddRecord(aNewRecord);
     return true;
   }
 
   return false;
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheLog.cpp
+++ b/netwerk/cache2/CacheLog.cpp
@@ -1,22 +1,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 "CacheLog.h"
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 // Log module for cache2 (2013) cache implementation logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set MOZ_LOG=cache2:5
 //    set MOZ_LOG_FILE=network.log
 //
 // This enables LogLevel::Debug level information and places all output in
 // the file network.log.
 LazyLogModule gCache2Log("cache2");
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheObserver.cpp
+++ b/netwerk/cache2/CacheObserver.cpp
@@ -13,18 +13,17 @@
 #include "mozilla/Preferences.h"
 #include "mozilla/TimeStamp.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/net/NeckoCommon.h"
 #include "prsystem.h"
 #include <time.h>
 #include <math.h>
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 StaticRefPtr<CacheObserver> CacheObserver::sSelf;
 
 static float const kDefaultHalfLifeHours = 24.0F;  // 24 hours
 float CacheObserver::sHalfLifeHours = kDefaultHalfLifeHours;
 
 // The default value will be overwritten as soon as the correct smart size is
 // calculated by CacheFileIOManager::UpdateSmartCacheSize(). It's limited to 1GB
@@ -165,19 +164,17 @@ bool CacheObserver::EntryIsTooBig(int64_
   if (preferredLimit != -1 && aSize > preferredLimit) return true;
 
   // Otherwise (or when in the custom limit), check limit based on the global
   // limit. It's 1/8 of the respective capacity.
   int64_t derivedLimit =
       aUsingDisk ? DiskCacheCapacity() : MemoryCacheCapacity();
   derivedLimit <<= (10 - 3);
 
-  if (aSize > derivedLimit) return true;
-
-  return false;
+  return aSize > derivedLimit;
 }
 
 // static
 bool CacheObserver::IsPastShutdownIOLag() {
 #ifdef DEBUG
   return false;
 #else
   if (sShutdownDemandedTime == PR_INTERVAL_NO_TIMEOUT ||
@@ -238,20 +235,20 @@ CacheObserver::Observe(nsISupports* aSub
       service->DropPrivateBrowsingEntries();
     }
 
     return NS_OK;
   }
 
   if (!strcmp(aTopic, "memory-pressure")) {
     RefPtr<CacheStorageService> service = CacheStorageService::Self();
-    if (service)
+    if (service) {
       service->PurgeFromMemory(nsICacheStorageService::PURGE_EVERYTHING);
+    }
 
     return NS_OK;
   }
 
   MOZ_ASSERT(false, "Missing observer handler");
   return NS_OK;
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheStorage.h
+++ b/netwerk/cache2/CacheStorage.h
@@ -16,17 +16,17 @@
 
 class nsIURI;
 
 namespace mozilla {
 namespace net {
 
 // This dance is needed to make CacheEntryTable declarable-only in headers
 // w/o exporting CacheEntry.h file to make nsNetModule.cpp compilable.
-typedef nsRefPtrHashtable<nsCStringHashKey, CacheEntry> TCacheEntryTable;
+using TCacheEntryTable = nsRefPtrHashtable<nsCStringHashKey, CacheEntry>;
 class CacheEntryTable : public TCacheEntryTable {
  public:
   enum EType { MEMORY_ONLY, ALL_ENTRIES };
 
   explicit CacheEntryTable(EType aType) : mType(aType) {}
   EType Type() const { return mType; }
 
  private:
--- a/netwerk/cache2/CacheStorageService.cpp
+++ b/netwerk/cache2/CacheStorageService.cpp
@@ -28,34 +28,33 @@
 #include "nsXULAppAPI.h"
 #include "mozilla/AtomicBitfields.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Services.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Telemetry.h"
 
-namespace mozilla {
-namespace net {
+namespace mozilla::net {
 
 namespace {
 
 void AppendMemoryStorageTag(nsAutoCString& key) {
   // Using DEL as the very last ascii-7 character we can use in the list of
   // attributes
   key.Append('\x7f');
   key.Append(',');
 }
 
 }  // namespace
 
 // Not defining as static or class member of CacheStorageService since
 // it would otherwise need to include CacheEntry.h and that then would
 // need to be exported to make nsNetModule.cpp compilable.
-typedef nsClassHashtable<nsCStringHashKey, CacheEntryTable> GlobalEntryTables;
+using GlobalEntryTables = nsClassHashtable<nsCStringHashKey, CacheEntryTable>;
 
 /**
  * Keeps tables of entries.  There is one entries table for each distinct load
  * context type.  The distinction is based on following load context info
  * states: <isPrivate|isAnon|inIsolatedMozBrowser> which builds a mapping
  * key.
  *
  * Thread-safe to access, protected by the service mutex.
@@ -311,18 +310,19 @@ class WalkMemoryCacheRunnable : public W
       return NS_ERROR_FAILURE;
     }
 
     NS_DispatchToMainThread(this);
     return NS_OK;
   }
 
   virtual ~WalkMemoryCacheRunnable() {
-    if (mCallback)
+    if (mCallback) {
       ProxyReleaseMainThread("WalkMemoryCacheRunnable::mCallback", mCallback);
+    }
   }
 
   virtual void OnEntryInfo(const nsACString& aURISpec,
                            const nsACString& aIdEnhance, int64_t aDataSize,
                            int32_t aFetchCount, uint32_t aLastModifiedTime,
                            uint32_t aExpirationTime, bool aPinned,
                            nsILoadContextInfo* aInfo) override {
     nsresult rv;
@@ -1092,24 +1092,26 @@ bool CacheStorageService::RemoveEntry(Ca
     if (!aEntry->IsUsingDisk() &&
         IsForcedValidEntry(aEntry->GetStorageID(), entryKey)) {
       LOG(("  forced valid, not removing"));
       return false;
     }
   }
 
   CacheEntryTable* entries;
-  if (sGlobalEntryTables->Get(aEntry->GetStorageID(), &entries))
+  if (sGlobalEntryTables->Get(aEntry->GetStorageID(), &entries)) {
     RemoveExactEntry(entries, entryKey, aEntry, false /* don't overwrite */);
+  }
 
   nsAutoCString memoryStorageID(aEntry->GetStorageID());
   AppendMemoryStorageTag(memoryStorageID);
 
-  if (sGlobalEntryTables->Get(memoryStorageID, &entries))
+  if (sGlobalEntryTables->Get(memoryStorageID, &entries)) {
     RemoveExactEntry(entries, entryKey, aEntry, false /* don't overwrite */);
+  }
 
   return true;
 }
 
 void CacheStorageService::RecordMemoryOnlyEntry(CacheEntry* aEntry,
                                                 bool aOnlyInMemory,
                                                 bool aOverwrite) {
   LOG(
@@ -1714,18 +1716,19 @@ class CacheEntryDoomByKeyCallback : publ
     return NS_OK;
   }
 
   nsCOMPtr<nsICacheEntryDoomCallback> mCallback;
   nsresult mResult;
 };
 
 CacheEntryDoomByKeyCallback::~CacheEntryDoomByKeyCallback() {
-  if (mCallback)
+  if (mCallback) {
     ProxyReleaseMainThread("CacheEntryDoomByKeyCallback::mCallback", mCallback);
+  }
 }
 
 NS_IMETHODIMP CacheEntryDoomByKeyCallback::OnFileDoomed(
     CacheFileHandle* aHandle, nsresult aResult) {
   if (!mCallback) return NS_OK;
 
   mResult = aResult;
   if (NS_IsMainThread()) {
@@ -1903,17 +1906,17 @@ nsresult CacheStorageService::DoomStorag
     // we need to remove the memory entries from the disk table one
     // by one manually.
     mozilla::UniquePtr<CacheEntryTable> memoryEntries;
     sGlobalEntryTables->Remove(memoryStorageID, &memoryEntries);
 
     CacheEntryTable* diskEntries;
     if (memoryEntries && sGlobalEntryTables->Get(aContextKey, &diskEntries)) {
       for (const auto& memoryEntry : *memoryEntries) {
-        auto entry = memoryEntry.GetData();
+        const auto& entry = memoryEntry.GetData();
         RemoveExactEntry(diskEntries, memoryEntry.GetKey(), entry, false);
       }
     }
   }
 
   {
     mozilla::MutexAutoLock lock(mForcedValidEntriesLock);
 
@@ -2330,10 +2333,9 @@ CacheStorageService::Flush(nsIObserver* 
   // up to this time will be done before this purging happens.
   RefPtr<CacheStorageService::PurgeFromMemoryRunnable> r =
       new CacheStorageService::PurgeFromMemoryRunnable(this,
                                                        CacheEntry::PURGE_WHOLE);
 
   return thread->Dispatch(r, CacheIOThread::WRITE);
 }
 
-}  // namespace net
-}  // namespace mozilla
+}  // namespace mozilla::net
--- a/netwerk/cache2/CacheStorageService.h
+++ b/netwerk/cache2/CacheStorageService.h
@@ -117,17 +117,17 @@ class CacheStorageService final : public
                              const nsACString& aIdEnhance, int64_t aDataSize,
                              int32_t aFetchCount, uint32_t aLastModifiedTime,
                              uint32_t aExpirationTime, bool aPinned,
                              nsILoadContextInfo* aInfo) = 0;
   };
 
   // Invokes OnEntryInfo for the given aEntry, synchronously.
   static void GetCacheEntryInfo(CacheEntry* aEntry,
-                                EntryInfoCallback* aVisitor);
+                                EntryInfoCallback* aCallback);
 
   nsresult GetCacheIndexEntryAttrs(CacheStorage const* aStorage,
                                    const nsACString& aURI,
                                    const nsACString& aIdExtension,
                                    bool* aHasAltData, uint32_t* aFileSizeKb);
 
   static uint32_t CacheQueueSize(bool highPriority);
 
@@ -197,17 +197,17 @@ class CacheStorageService final : public
  private:
   friend class CacheIndex;
 
   /**
    * CacheIndex uses this to prevent a cache entry from being prememptively
    * thrown away when forced valid
    * See nsICacheEntry.idl for more details
    */
-  bool IsForcedValidEntry(nsACString const& aEntryKeyWithContext);
+  bool IsForcedValidEntry(nsACString const& aContextEntryKey);
 
  private:
   // These are helpers for telemetry monitoring of the memory pools.
   void TelemetryPrune(TimeStamp& now);
   void TelemetryRecordEntryCreation(CacheEntry const* entry);
   void TelemetryRecordEntryRemoval(CacheEntry const* entry);
 
  private:
--- a/netwerk/cookie/CookieCommons.cpp
+++ b/netwerk/cookie/CookieCommons.cpp
@@ -63,21 +63,17 @@ bool CookieCommons::PathMatches(Cookie* 
   if (isPrefix && cookiePath.Last() == '/') {
     return true;
   }
 
   // if the cookie path is a prefix of the request path, and the first character
   // of the request path that is not included in the cookie path is a %x2F ("/")
   // character, they match.
   uint32_t cookiePathLen = cookiePath.Length();
-  if (isPrefix && aPath[cookiePathLen] == '/') {
-    return true;
-  }
-
-  return false;
+  return isPrefix && aPath[cookiePathLen] == '/';
 }
 
 // Get the base domain for aHostURI; e.g. for "www.bbc.co.uk", this would be
 // "bbc.co.uk". Only properly-formed URI's are tolerated, though a trailing
 // dot may be present. If aHostURI is an IP address, an alias such as
 // 'localhost', an eTLD such as 'co.uk', or the empty string, aBaseDomain will
 // be the exact host, and aRequireHostMatch will be true to indicate that
 // substring matches should not be performed.
--- a/netwerk/cookie/CookiePersistentStorage.cpp
+++ b/netwerk/cookie/CookiePersistentStorage.cpp
@@ -126,17 +126,17 @@ ConvertAppIdToOriginAttrsSQLFunction::On
   nsresult rv;
   int32_t inIsolatedMozBrowser;
 
   rv = aFunctionArguments->GetInt32(1, &inIsolatedMozBrowser);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Create an originAttributes object by inIsolatedMozBrowser.
   // Then create the originSuffix string from this object.
-  OriginAttributes attrs(inIsolatedMozBrowser ? true : false);
+  OriginAttributes attrs(inIsolatedMozBrowser != 0);
   nsAutoCString suffix;
   attrs.CreateSuffix(suffix);
 
   RefPtr<nsVariant> outVar(new nsVariant());
   rv = outVar->SetAsAUTF8String(suffix);
   NS_ENSURE_SUCCESS(rv, rv);
 
   outVar.forget(aResult);
@@ -377,17 +377,17 @@ void CookiePersistentStorage::NotifyChan
   // Notify for topic "session-cookie-changed" to update the copy of session
   // cookies in session restore component.
 
   // Filter out notifications for individual non-session cookies.
   if (u"changed"_ns.Equals(aData) || u"deleted"_ns.Equals(aData) ||
       u"added"_ns.Equals(aData)) {
     nsCOMPtr<nsICookie> xpcCookie = do_QueryInterface(aSubject);
     MOZ_ASSERT(xpcCookie);
-    auto cookie = static_cast<Cookie*>(xpcCookie.get());
+    auto* cookie = static_cast<Cookie*>(xpcCookie.get());
     if (!cookie->IsSession() && !aOldCookieIsSession) {
       return;
     }
   }
 
   nsCOMPtr<nsIObserverService> os = services::GetObserverService();
   if (os) {
     os->NotifyObservers(aSubject, "session-cookie-changed", aData);
--- a/netwerk/cookie/CookieService.cpp
+++ b/netwerk/cookie/CookieService.cpp
@@ -1316,42 +1316,39 @@ bool CookieService::GetTokenValue(nsACSt
   while (aIter != aEndIter && !isnull(*aIter) && !istokenseparator(*aIter)) {
     ++aIter;
   }
 
   // remove trailing <LWS>; first check we're not at the beginning
   lastSpace = aIter;
   if (lastSpace != start) {
     while (--lastSpace != start && iswhitespace(*lastSpace)) {
-      continue;
     }
     ++lastSpace;
   }
   aTokenString.Rebind(start, lastSpace);
 
   aEqualsFound = (*aIter == '=');
   if (aEqualsFound) {
     // find <value>
     while (++aIter != aEndIter && iswhitespace(*aIter)) {
-      continue;
     }
 
     start = aIter;
 
     // process <token>
     // just look for ';' to terminate ('=' allowed)
     while (aIter != aEndIter && !isnull(*aIter) && !isvalueseparator(*aIter)) {
       ++aIter;
     }
 
     // remove trailing <LWS>; first check we're not at the beginning
     if (aIter != start) {
       lastSpace = aIter;
       while (--lastSpace != start && iswhitespace(*lastSpace)) {
-        continue;
       }
 
       aTokenValue.Rebind(start, ++lastSpace);
     }
   }
 
   // aIter is on ';', or terminator, or EOS
   if (aIter != aEndIter) {
@@ -1581,41 +1578,38 @@ CookieStatus CookieService::CheckPrefs(
 
   MOZ_ASSERT(aRejectedReason);
 
   *aRejectedReason = 0;
 
   // don't let unsupported scheme sites get/set cookies (could be a security
   // issue)
   if (!CookieCommons::IsSchemeSupported(aHostURI)) {
-    COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
-                      aHostURI, aCookieHeader,
+    COOKIE_LOGFAILURE(!aCookieHeader.IsVoid(), aHostURI, aCookieHeader,
                       "non http/https sites cannot read cookies");
     return STATUS_REJECTED_WITH_ERROR;
   }
 
   nsCOMPtr<nsIPrincipal> principal =
       BasePrincipal::CreateContentPrincipal(aHostURI, aOriginAttrs);
 
   if (!principal) {
-    COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
-                      aHostURI, aCookieHeader,
+    COOKIE_LOGFAILURE(!aCookieHeader.IsVoid(), aHostURI, aCookieHeader,
                       "non-content principals cannot get/set cookies");
     return STATUS_REJECTED_WITH_ERROR;
   }
 
   // check the permission list first; if we find an entry, it overrides
   // default prefs. see bug 184059.
   uint32_t cookiePermission = nsICookiePermission::ACCESS_DEFAULT;
   rv = aCookieJarSettings->CookiePermission(principal, &cookiePermission);
   if (NS_SUCCEEDED(rv)) {
     switch (cookiePermission) {
       case nsICookiePermission::ACCESS_DENY:
-        COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
-                          aHostURI, aCookieHeader,
+        COOKIE_LOGFAILURE(!aCookieHeader.IsVoid(), aHostURI, aCookieHeader,
                           "cookies are blocked for this site");
         CookieLogging::LogMessageToConsole(
             aCRC, aHostURI, nsIScriptError::warningFlag,
             CONSOLE_REJECTION_CATEGORY, "CookieRejectedByPermissionManager"_ns,
             AutoTArray<nsString, 1>{
                 NS_ConvertUTF8toUTF16(aCookieHeader),
             });
 
@@ -1645,18 +1639,17 @@ CookieStatus CookieService::CheckPrefs(
             ? nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
             : nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER;
     if (StoragePartitioningEnabled(rejectReason, aCookieJarSettings)) {
       MOZ_ASSERT(!aOriginAttrs.mPartitionKey.IsEmpty(),
                  "We must have a StoragePrincipal here!");
       return STATUS_ACCEPTED;
     }
 
-    COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
-                      aHostURI, aCookieHeader,
+    COOKIE_LOGFAILURE(!aCookieHeader.IsVoid(), aHostURI, aCookieHeader,
                       "cookies are disabled in trackers");
     if (aIsThirdPartySocialTrackingResource) {
       *aRejectedReason =
           nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER;
     } else if (rejectThirdPartyWithExceptions) {
       *aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN;
     } else {
       *aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER;
@@ -1666,43 +1659,43 @@ CookieStatus CookieService::CheckPrefs(
 
   // check default prefs.
   // Check aStorageAccessPermissionGranted when checking aCookieBehavior
   // so that we take things such as the content blocking allow list into
   // account.
   if (aCookieJarSettings->GetCookieBehavior() ==
           nsICookieService::BEHAVIOR_REJECT &&
       !aStorageAccessPermissionGranted) {
-    COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
-                      aHostURI, aCookieHeader, "cookies are disabled");
+    COOKIE_LOGFAILURE(!aCookieHeader.IsVoid(), aHostURI, aCookieHeader,
+                      "cookies are disabled");
     *aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL;
     return STATUS_REJECTED;
   }
 
   // check if cookie is foreign
   if (aIsForeign) {
     if (aCookieJarSettings->GetCookieBehavior() ==
             nsICookieService::BEHAVIOR_REJECT_FOREIGN &&
         !aStorageAccessPermissionGranted) {
-      COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
-                        aHostURI, aCookieHeader, "context is third party");
+      COOKIE_LOGFAILURE(!aCookieHeader.IsVoid(), aHostURI, aCookieHeader,
+                        "context is third party");
       CookieLogging::LogMessageToConsole(
           aCRC, aHostURI, nsIScriptError::warningFlag,
           CONSOLE_REJECTION_CATEGORY, "CookieRejectedThirdParty"_ns,
           AutoTArray<nsString, 1>{
               NS_ConvertUTF8toUTF16(aCookieHeader),
           });
       *aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN;
       return STATUS_REJECTED;
     }
 
     if (aCookieJarSettings->GetLimitForeignContexts() &&
         !aStorageAccessPermissionGranted && aNumOfCookies == 0) {
-      COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
-                        aHostURI, aCookieHeader, "context is third party");
+      COOKIE_LOGFAILURE(!aCookieHeader.IsVoid(), aHostURI, aCookieHeader,
+                        "context is third party");
       CookieLogging::LogMessageToConsole(
           aCRC, aHostURI, nsIScriptError::warningFlag,
           CONSOLE_REJECTION_CATEGORY, "CookieRejectedThirdParty"_ns,
           AutoTArray<nsString, 1>{
               NS_ConvertUTF8toUTF16(aCookieHeader),
           });
       *aRejectedReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN;
       return STATUS_REJECTED;
@@ -1845,21 +1838,17 @@ bool CookieService::CheckPath(CookieStru
     params.AppendElement(size);
 
     CookieLogging::LogMessageToConsole(
         aCRC, aHostURI, nsIScriptError::warningFlag, CONSOLE_OVERSIZE_CATEGORY,
         "CookiePathOversize"_ns, params);
     return false;
   }
 
-  if (aCookieData.path().Contains('\t')) {
-    return false;
-  }
-
-  return true;
+  return !aCookieData.path().Contains('\t');
 }
 
 // CheckPrefixes
 //
 // Reject cookies whose name starts with the magic prefixes from
 // https://tools.ietf.org/html/draft-ietf-httpbis-cookie-prefixes-00
 // if they do not meet the criteria required by the prefix.
 //
@@ -2005,17 +1994,17 @@ CookieService::CookieExistsNative(const 
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsAutoCString baseDomain;
   nsresult rv =
       CookieCommons::GetBaseDomainFromHost(mTLDService, aHost, baseDomain);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  CookieListIter iter;
+  CookieListIter iter{};
   CookieStorage* storage = PickStorage(*aOriginAttributes);
   *aFoundCookie = storage->FindCookie(baseDomain, *aOriginAttributes, aHost,
                                       aName, aPath, iter);
   return NS_OK;
 }
 
 // count the number of cookies stored by a particular host. this is provided by
 // the nsICookieManager interface.
--- a/netwerk/cookie/CookieServiceParent.cpp
+++ b/netwerk/cookie/CookieServiceParent.cpp
@@ -35,43 +35,43 @@ void CookieServiceParent::RemoveBatchDel
   uint32_t len = 0;
   aCookieList->GetLength(&len);
   OriginAttributes attrs;
   CookieStruct cookieStruct;
   nsTArray<CookieStruct> cookieStructList;
   nsTArray<OriginAttributes> attrsList;
   for (uint32_t i = 0; i < len; i++) {
     nsCOMPtr<nsICookie> xpcCookie = do_QueryElementAt(aCookieList, i);
-    auto cookie = static_cast<Cookie*>(xpcCookie.get());
+    auto* cookie = static_cast<Cookie*>(xpcCookie.get());
     attrs = cookie->OriginAttributesRef();
     cookieStruct = cookie->ToIPC();
     if (cookie->IsHttpOnly()) {
       // Child only needs to exist if an HttpOnly cookie exists, not its value
       cookieStruct.value() = "";
     }
     cookieStructList.AppendElement(cookieStruct);
     attrsList.AppendElement(attrs);
   }
   Unused << SendRemoveBatchDeletedCookies(cookieStructList, attrsList);
 }
 
 void CookieServiceParent::RemoveAll() { Unused << SendRemoveAll(); }
 
 void CookieServiceParent::RemoveCookie(nsICookie* aCookie) {
-  auto cookie = static_cast<Cookie*>(aCookie);
+  auto* cookie = static_cast<Cookie*>(aCookie);
   const OriginAttributes& attrs = cookie->OriginAttributesRef();
   CookieStruct cookieStruct = cookie->ToIPC();
   if (cookie->IsHttpOnly()) {
     cookieStruct.value() = "";
   }
   Unused << SendRemoveCookie(cookieStruct, attrs);
 }
 
 void CookieServiceParent::AddCookie(nsICookie* aCookie) {
-  auto cookie = static_cast<Cookie*>(aCookie);
+  auto* cookie = static_cast<Cookie*>(aCookie);
   const OriginAttributes& attrs = cookie->OriginAttributesRef();
   CookieStruct cookieStruct = cookie->ToIPC();
   if (cookie->IsHttpOnly()) {
     cookieStruct.value() = "";
   }
   Unused << SendAddCookie(cookieStruct, attrs);
 }
 
--- a/netwerk/cookie/CookieStorage.cpp
+++ b/netwerk/cookie/CookieStorage.cpp
@@ -43,34 +43,33 @@ class CompareCookiesByAge {
   }
 };
 
 // Cookie comparator for the priority queue used in FindStaleCookies.
 // Note that the expired cookie has the highest priority.
 // Other non-expired cookies are sorted by their age.
 class CookieIterComparator {
  private:
-  CompareCookiesByAge mAgeComparator;
   int64_t mCurrentTime;
 
  public:
   explicit CookieIterComparator(int64_t aTime) : mCurrentTime(aTime) {}
 
   bool LessThan(const CookieListIter& lhs, const CookieListIter& rhs) {
     bool lExpired = lhs.Cookie()->Expiry() <= mCurrentTime;
     bool rExpired = rhs.Cookie()->Expiry() <= mCurrentTime;
     if (lExpired && !rExpired) {
       return true;
     }
 
     if (!lExpired && rExpired) {
       return false;
     }
 
-    return mAgeComparator.LessThan(lhs, rhs);
+    return mozilla::net::CompareCookiesByAge::LessThan(lhs, rhs);
   }
 };
 
 // comparator class for sorting cookies by entry and index.
 class CompareCookiesByIndex {
  public:
   static bool Equals(const CookieListIter& a, const CookieListIter& b) {
     NS_ASSERTION(a.entry != b.entry || a.index != b.index,
@@ -273,17 +272,17 @@ void CookieStorage::GetCookiesWithOrigin
   }
 }
 
 void CookieStorage::RemoveCookie(const nsACString& aBaseDomain,
                                  const OriginAttributes& aOriginAttributes,
                                  const nsACString& aHost,
                                  const nsACString& aName,
                                  const nsACString& aPath) {
-  CookieListIter matchIter;
+  CookieListIter matchIter{};
   RefPtr<Cookie> cookie;
   if (FindCookie(aBaseDomain, aOriginAttributes, aHost, aName, aPath,
                  matchIter)) {
     cookie = matchIter.Cookie();
     RemoveCookieFromList(matchIter);
   }
 
   if (cookie) {
@@ -398,17 +397,17 @@ void CookieStorage::NotifyChanged(nsISup
 void CookieStorage::AddCookie(nsIConsoleReportCollector* aCRC,
                               const nsACString& aBaseDomain,
                               const OriginAttributes& aOriginAttributes,
                               Cookie* aCookie, int64_t aCurrentTimeInUsec,
                               nsIURI* aHostURI, const nsACString& aCookieHeader,
                               bool aFromHttp) {
   int64_t currentTime = aCurrentTimeInUsec / PR_USEC_PER_SEC;
 
-  CookieListIter exactIter;
+  CookieListIter exactIter{};
   bool foundCookie = false;
   foundCookie = FindCookie(aBaseDomain, aOriginAttributes, aCookie->Host(),
                            aCookie->Name(), aCookie->Path(), exactIter);
   bool foundSecureExact = foundCookie && exactIter.Cookie()->IsSecure();
   bool potentiallyTrustworthy = true;
   if (aHostURI) {
     potentiallyTrustworthy =
         nsMixedContentBlocker::IsPotentiallyTrustworthyOrigin(aHostURI);
--- a/netwerk/cookie/CookieStorage.h
+++ b/netwerk/cookie/CookieStorage.h
@@ -22,18 +22,18 @@ namespace net {
 
 class Cookie;
 
 // Inherit from CookieKey so this can be stored in nsTHashTable
 // TODO: why aren't we using nsClassHashTable<CookieKey, ArrayType>?
 class CookieEntry : public CookieKey {
  public:
   // Hash methods
-  typedef nsTArray<RefPtr<Cookie>> ArrayType;
-  typedef ArrayType::index_type IndexType;
+  using ArrayType = nsTArray<RefPtr<Cookie>>;
+  using IndexType = ArrayType::index_type;
 
   explicit CookieEntry(KeyTypePointer aKey) : CookieKey(aKey) {}
 
   CookieEntry(const CookieEntry& toCopy) {
     // if we end up here, things will break. nsTHashtable shouldn't
     // allow this, since we set ALLOW_MEMMOVE to true.
     MOZ_ASSERT_UNREACHABLE("CookieEntry copy constructor is forbidden!");
   }
--- a/netwerk/ipc/DocumentLoadListener.h
+++ b/netwerk/ipc/DocumentLoadListener.h
@@ -54,17 +54,17 @@ struct StreamFilterRequest {
   StreamFilterRequest() = default;
   StreamFilterRequest(StreamFilterRequest&&) = default;
   ~StreamFilterRequest() {
     if (mPromise) {
       mPromise->Reject(false, __func__);
     }
   }
   RefPtr<ChildEndpointPromise::Private> mPromise;
-  base::ProcessId mChildProcessId;
+  base::ProcessId mChildProcessId = 0;
   mozilla::ipc::Endpoint<extensions::PStreamFilterChild> mChildEndpoint;
 };
 }  // namespace net
 }  // namespace mozilla
 MOZ_DECLARE_RELOCATE_USING_MOVE_CONSTRUCTOR(mozilla::net::StreamFilterRequest)
 
 namespace mozilla {
 namespace net {
@@ -114,19 +114,18 @@ class DocumentLoadListener : public nsII
   struct OpenPromiseFailedType {
     nsresult mStatus;
     nsresult mLoadGroupStatus;
     // This is set to true if we're rejecting the promise because we
     // switched to load away to a new process.
     bool mSwitchedProcess = false;
   };
 
-  typedef MozPromise<OpenPromiseSucceededType, OpenPromiseFailedType,
-                     true /* isExclusive */>
-      OpenPromise;
+  using OpenPromise =
+      MozPromise<OpenPromiseSucceededType, OpenPromiseFailedType, true>;
 
   // Interface which may be provided when performing an <object> or <embed> load
   // with `DocumentLoadListener`, to allow upgrading the Object load to a proper
   // Document load.
   struct ObjectUpgradeHandler : public SupportsWeakPtr {
     using ObjectUpgradePromise =
         MozPromise<RefPtr<dom::CanonicalBrowsingContext>, nsresult,
                    true /* isExclusive */>;
@@ -164,17 +163,17 @@ class DocumentLoadListener : public nsII
       nsresult* aRv);
 
   RefPtr<OpenPromise> OpenObject(
       nsDocShellLoadState* aLoadState, uint32_t aCacheKey,
       const Maybe<uint64_t>& aChannelId, const TimeStamp& aAsyncOpenTime,
       nsDOMNavigationTiming* aTiming, Maybe<dom::ClientInfo>&& aInfo,
       uint64_t aInnerWindowId, nsLoadFlags aLoadFlags,
       nsContentPolicyType aContentPolicyType, bool aUrgentStart,
-      base::ProcessId aPid, ObjectUpgradeHandler* aUpgradeHandler,
+      base::ProcessId aPid, ObjectUpgradeHandler* aObjectUpgradeHandler,
       nsresult* aRv);
 
   // Creates a DocumentLoadListener entirely in the parent process and opens it,
   // and never needs a DocumentChannel to connect to an existing docshell.
   // Once we get a response it takes the 'process switch' path to find the right
   // process and docshell, and delivers the response there directly.
   static bool LoadInParent(dom::CanonicalBrowsingContext* aBrowsingContext,
                            nsDocShellLoadState* aLoadState,
@@ -396,20 +395,19 @@ class DocumentLoadListener : public nsII
     nsCString mFullHashes;
   };
 
   struct ClassificationFlagsParams {
     uint32_t mClassificationFlags;
     bool mIsThirdParty;
   };
 
-  typedef mozilla::Variant<
+  using IParentChannelFunction = mozilla::Variant<
       nsIHttpChannel::FlashPluginState, ClassifierMatchedInfoParams,
-      ClassifierMatchedTrackingInfoParams, ClassificationFlagsParams>
-      IParentChannelFunction;
+      ClassifierMatchedTrackingInfoParams, ClassificationFlagsParams>;
 
   // Store a list of all the attribute setters that have been called on this
   // channel, so that we can repeat them on the real channel that we redirect
   // to.
   nsTArray<IParentChannelFunction> mIParentChannelFunctions;
 
   // This defines a variant this describes all the functions
   // from HttpChannelSecurityWarningReporter so that we can forward
@@ -422,25 +420,24 @@ class DocumentLoadListener : public nsII
 
   struct LogBlockedCORSRequestParams {
     nsString mMessage;
     nsCString mCategory;
   };
 
   struct LogMimeTypeMismatchParams {
     nsCString mMessageName;
-    bool mWarning;
+    bool mWarning = false;
     nsString mURL;
     nsString mContentType;
   };
 
-  typedef mozilla::Variant<ReportSecurityMessageParams,
-                           LogBlockedCORSRequestParams,
-                           LogMimeTypeMismatchParams>
-      SecurityWarningFunction;
+  using SecurityWarningFunction =
+      mozilla::Variant<ReportSecurityMessageParams, LogBlockedCORSRequestParams,
+                       LogMimeTypeMismatchParams>;
   nsTArray<SecurityWarningFunction> mSecurityWarningFunctions;
 
   struct OnStartRequestParams {
     nsCOMPtr<nsIRequest> request;
   };
   struct OnDataAvailableParams {
     nsCOMPtr<nsIRequest> request;
     nsCString data;
@@ -449,19 +446,19 @@ class DocumentLoadListener : public nsII
   };
   struct OnStopRequestParams {
     nsCOMPtr<nsIRequest> request;
     nsresult status;
   };
   struct OnAfterLastPartParams {
     nsresult status;
   };
-  typedef mozilla::Variant<OnStartRequestParams, OnDataAvailableParams,
-                           OnStopRequestParams, OnAfterLastPartParams>
-      StreamListenerFunction;
+  using StreamListenerFunction =
+      mozilla::Variant<OnStartRequestParams, OnDataAvailableParams,
+                       OnStopRequestParams, OnAfterLastPartParams>;
   // TODO Backtrack this.
   // The set of nsIStreamListener functions that got called on this
   // listener, so that we can replay them onto the replacement channel's
   // listener. This should generally only be OnStartRequest, since we
   // Suspend() the channel at that point, but it can fail sometimes
   // so we have to support holding a list.
   nsTArray<StreamListenerFunction> mStreamListenerFunctions;
 
--- a/netwerk/ipc/InputChannelThrottleQueueParent.cpp
+++ b/netwerk/ipc/InputChannelThrottleQueueParent.cpp
@@ -18,25 +18,25 @@ NS_INTERFACE_MAP_BEGIN(InputChannelThrot
   NS_INTERFACE_MAP_ENTRY_CONCRETE(InputChannelThrottleQueueParent)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP_(MozExternalRefCountType)
 InputChannelThrottleQueueParent::Release(void) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release");
 
-  if (!mRefCnt.isThreadSafe) {
+  if (!nsAutoRefCnt::isThreadSafe) {
     NS_ASSERT_OWNINGTHREAD(InputChannelThrottleQueueParent);
   }
 
   nsrefcnt count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "InputChannelThrottleQueueParent");
 
   if (count == 0) {
-    if (!mRefCnt.isThreadSafe) {
+    if (!nsAutoRefCnt::isThreadSafe) {
       NS_ASSERT_OWNINGTHREAD(InputChannelThrottleQueueParent);
     }
 
     mRefCnt = 1; /* stabilize */
     delete (this);
     return 0;
   }
 
--- a/netwerk/ipc/SocketProcessBridgeChild.h
+++ b/netwerk/ipc/SocketProcessBridgeChild.h
@@ -18,18 +18,18 @@ namespace net {
 // topic is observed, this actor will be destroyed.
 class SocketProcessBridgeChild final : public PSocketProcessBridgeChild,
                                        public nsIObserver {
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
   static already_AddRefed<SocketProcessBridgeChild> GetSingleton();
-  typedef MozPromise<RefPtr<SocketProcessBridgeChild>, nsCString, false>
-      GetPromise;
+  using GetPromise =
+      MozPromise<RefPtr<SocketProcessBridgeChild>, nsCString, false>;
   static RefPtr<GetPromise> GetSocketProcessBridge();
 
   mozilla::ipc::IPCResult RecvTest();
   void ActorDestroy(ActorDestroyReason aWhy) override;
   void DeferredDestroy();
   bool IsShuttingDown() const { return mShuttingDown; };
   bool Inited() const { return mInited; };
   ProcessId SocketProcessPid() const { return mSocketProcessPid; };
--- a/netwerk/ipc/SocketProcessChild.cpp
+++ b/netwerk/ipc/SocketProcessChild.cpp
@@ -143,21 +143,17 @@ bool SocketProcessChild::Init(base::Proc
   rv = ios->GetProtocolHandler("http", getter_AddRefs(handler));
   if (NS_FAILED(rv)) {
     return false;
   }
 
   // Initialize DNS Service here, since it needs to be done in main thread.
   nsCOMPtr<nsIDNSService> dns =
       do_GetService("@mozilla.org/network/dns-service;1", &rv);
-  if (NS_FAILED(rv)) {
-    return false;
-  }
-
-  return true;
+  return NS_SUCCEEDED(rv);
 }
 
 void SocketProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
   LOG(("SocketProcessChild::ActorDestroy\n"));
 
   mShuttingDown = true;
 
   if (AbnormalShutdown == aWhy) {
--- a/netwerk/ipc/SocketProcessImpl.h
+++ b/netwerk/ipc/SocketProcessImpl.h
@@ -11,17 +11,17 @@
 
 namespace mozilla {
 namespace net {
 
 // This class owns the subprocess instance of socket child process.
 // It is instantiated as a singleton in XRE_InitChildProcess.
 class SocketProcessImpl final : public mozilla::ipc::ProcessChild {
  protected:
-  typedef mozilla::ipc::ProcessChild ProcessChild;
+  using ProcessChild = mozilla::ipc::ProcessChild;
 
  public:
   explicit SocketProcessImpl(ProcessId aParentPid);
   ~SocketProcessImpl();
 
   bool Init(int aArgc, char* aArgv[]) override;
   void CleanUp() override;
 
--- a/netwerk/ipc/SocketProcessParent.h
+++ b/netwerk/ipc/SocketProcessParent.h
@@ -54,17 +54,17 @@ class SocketProcessParent final
   PWebrtcTCPSocketParent* AllocPWebrtcTCPSocketParent(
       const Maybe<TabId>& aTabId);
   bool DeallocPWebrtcTCPSocketParent(PWebrtcTCPSocketParent* aActor);
   already_AddRefed<PDNSRequestParent> AllocPDNSRequestParent(
       const nsCString& aHost, const nsCString& aTrrServer,
       const uint16_t& aType, const OriginAttributes& aOriginAttributes,
       const uint32_t& aFlags);
   virtual mozilla::ipc::IPCResult RecvPDNSRequestConstructor(
-      PDNSRequestParent* actor, const nsCString& hostName,
+      PDNSRequestParent* actor, const nsCString& aHost,
       const nsCString& trrServer, const uint16_t& type,
       const OriginAttributes& aOriginAttributes,
       const uint32_t& flags) override;
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
   bool SendRequestMemoryReport(const uint32_t& aGeneration,
                                const bool& aAnonymize,
                                const bool& aMinimizeMemoryUsage,
--- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp
+++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp
@@ -39,17 +39,17 @@ static nsresult internalDecodeParameter(
                                         nsACString&);
 
 static nsresult ToUTF8(const nsACString& aString, const nsACString& aCharset,
                        bool aAllowSubstitution, nsACString& aResult) {
   if (aCharset.IsEmpty()) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  auto encoding = Encoding::ForLabelNoReplacement(aCharset);
+  const auto* encoding = Encoding::ForLabelNoReplacement(aCharset);
   if (!encoding) {
     return NS_ERROR_UCONV_NOCONV;
   }
   if (aAllowSubstitution) {
     nsresult rv = encoding->DecodeWithoutBOMHandling(aString, aResult);
     if (NS_SUCCEEDED(rv)) {
       return NS_OK;
     }
@@ -163,18 +163,19 @@ nsresult nsMIMEHeaderParamImpl::DoGetPar
     }
   }
 
   if (IsUtf8(str1)) {
     CopyUTF8toUTF16(str1, aResult);
     return NS_OK;
   }
 
-  if (aTryLocaleCharset && !NS_IsNativeUTF8())
+  if (aTryLocaleCharset && !NS_IsNativeUTF8()) {
     return NS_CopyNativeToUnicode(str1, aResult);
+  }
 
   CopyASCIItoUTF16(str1, aResult);
   return NS_OK;
 }
 
 // remove backslash-encoded sequences from quoted-strings
 // modifies string in place, potentially shortening it
 void RemoveQuotedStringEscapes(char* src) {
@@ -397,40 +398,44 @@ nsresult nsMIMEHeaderParamImpl::DoParame
 
   // change to (aDecoding != HTTP_FIELD_ENCODING) when we want to disable
   // them for HTTP header fields later on, see bug 776324
   bool acceptContinuations = true;
 
   const char* str = aHeaderValue;
 
   // skip leading white space.
-  for (; *str && nsCRT::IsAsciiSpace(*str); ++str)
+  for (; *str && nsCRT::IsAsciiSpace(*str); ++str) {
     ;
+  }
   const char* start = str;
 
   // aParamName is empty. return the first (possibly) _unnamed_ 'parameter'
   // For instance, return 'inline' in the following case:
   // Content-Disposition: inline; filename=.....
   if (!aParamName || !*aParamName) {
-    for (; *str && *str != ';' && !nsCRT::IsAsciiSpace(*str); ++str)
+    for (; *str && *str != ';' && !nsCRT::IsAsciiSpace(*str); ++str) {
       ;
+    }
     if (str == start) return NS_ERROR_FIRST_HEADER_FIELD_COMPONENT_EMPTY;
 
     *aResult = (char*)moz_xmemdup(start, (str - start) + 1);
     (*aResult)[str - start] = '\0';  // null-terminate
     return NS_OK;
   }
 
   /* Skip forward to first ';' */
-  for (; *str && *str != ';' && *str != ','; ++str)
+  for (; *str && *str != ';' && *str != ','; ++str) {
     ;
+  }
   if (*str) str++;
   /* Skip over following whitespace */
-  for (; *str && nsCRT::IsAsciiSpace(*str); ++str)
+  for (; *str && nsCRT::IsAsciiSpace(*str); ++str) {
     ;
+  }
 
   // Some broken http servers just specify parameters
   // like 'filename' without specifying disposition
   // method. Rewind to the first non-white-space
   // character.
 
   if (!*str) str = start;
 
@@ -470,18 +475,19 @@ nsresult nsMIMEHeaderParamImpl::DoParame
     const char* valueStart = nullptr;
     const char* valueEnd = nullptr;
     bool isQuotedString = false;
 
     NS_ASSERTION(!nsCRT::IsAsciiSpace(*str), "should be after whitespace.");
 
     // Skip forward to the end of this token.
     for (; *str && !nsCRT::IsAsciiSpace(*str) && *str != '=' && *str != ';';
-         str++)
+         str++) {
       ;
+    }
     nameEnd = str;
 
     int32_t nameLen = nameEnd - nameStart;
 
     // Skip over whitespace, '=', and whitespace
     while (nsCRT::IsAsciiSpace(*str)) ++str;
     if (!*str) {
       break;
@@ -506,20 +512,21 @@ nsresult nsMIMEHeaderParamImpl::DoParame
       }
       str = valueEnd;
     } else {
       isQuotedString = true;
 
       ++str;
       valueStart = str;
       for (valueEnd = str; *valueEnd; ++valueEnd) {
-        if (*valueEnd == '\\' && *(valueEnd + 1))
+        if (*valueEnd == '\\' && *(valueEnd + 1)) {
           ++valueEnd;
-        else if (*valueEnd == '"')
+        } else if (*valueEnd == '"') {
           break;
+        }
       }
       str = valueEnd;
       // *valueEnd != null means that *valueEnd is quote character.
       if (*valueEnd) str++;
     }
 
     // See if this is the simplest case (case A above),
     // a 'single' line value with no charset and lang.
@@ -679,25 +686,27 @@ nsresult nsMIMEHeaderParamImpl::DoParame
     while (nsCRT::IsAsciiSpace(*str)) ++str;
   }
 
   caseCDResult = combineContinuations(segments);
 
   if (caseBResult && !charsetB.IsEmpty()) {
     // check that the 2231/5987 result decodes properly given the
     // specified character set
-    if (!IsValidOctetSequenceForCharset(charsetB, caseBResult))
+    if (!IsValidOctetSequenceForCharset(charsetB, caseBResult)) {
       caseBResult = nullptr;
+    }
   }
 
   if (caseCDResult && !charsetCD.IsEmpty()) {
     // check that the 2231/5987 result decodes properly given the
     // specified character set
-    if (!IsValidOctetSequenceForCharset(charsetCD, caseCDResult))
+    if (!IsValidOctetSequenceForCharset(charsetCD, caseCDResult)) {
       caseCDResult = nullptr;
+    }
   }
 
   if (caseBResult) {
     // prefer simple 5987 format over 2231 with continuations
     *aResult = caseBResult;
     caseBResult = nullptr;
     charset.Assign(charsetB);
   } else if (caseCDResult) {
@@ -958,18 +967,19 @@ char* DecodeQ(const char* in, uint32_t l
 
   out = dest = (char*)calloc(length + 1, sizeof(char));
   if (dest == nullptr) return nullptr;
   while (length > 0) {
     unsigned c = 0;
     switch (*in) {
       case '=':
         // check if |in| in the form of '=hh'  where h is [0-9a-fA-F].
-        if (length < 3 || !ISHEXCHAR(in[1]) || !ISHEXCHAR(in[2]))
+        if (length < 3 || !ISHEXCHAR(in[1]) || !ISHEXCHAR(in[2])) {
           goto badsyntax;
+        }
         PR_sscanf(in + 1, "%2X", &c);
         *out++ = (char)c;
         in += 3;
         length -= 3;
         break;
 
       case '_':
         *out++ = ' ';
@@ -1083,32 +1093,33 @@ void CopyRawHeader(const char* aInput, u
   nsAutoCString utf8Text;
   if (NS_SUCCEEDED(ConvertStringToUTF8(Substring(aInput, aInput + aLen),
                                        PromiseFlatCString(aDefaultCharset),
                                        skipCheck, true, utf8Text))) {
     aOutput.Append(utf8Text);
   } else {  // replace each octet with Unicode replacement char in UTF-8.
     for (uint32_t i = 0; i < aLen; i++) {
       c = uint8_t(*aInput++);
-      if (c & 0x80)
+      if (c & 0x80) {
         aOutput.Append(REPLACEMENT_CHAR);
-      else
+      } else {
         aOutput.Append(char(c));
+      }
     }
   }
 }
 
 nsresult DecodeQOrBase64Str(const char* aEncoded, size_t aLen, char aQOrBase64,
                             const nsACString& aCharset, nsACString& aResult) {
   char* decodedText;
   bool b64alloc = false;
   NS_ASSERTION(aQOrBase64 == 'Q' || aQOrBase64 == 'B', "Should be 'Q' or 'B'");
-  if (aQOrBase64 == 'Q')
+  if (aQOrBase64 == 'Q') {
     decodedText = DecodeQ(aEncoded, aLen);
-  else if (aQOrBase64 == 'B') {
+  } else if (aQOrBase64 == 'B') {
     decodedText = PL_Base64Decode(aEncoded, aLen, nullptr);
     b64alloc = true;
   } else {
     return NS_ERROR_INVALID_ARG;
   }
 
   if (!decodedText) {
     return NS_ERROR_INVALID_ARG;
--- a/netwerk/protocol/about/nsAboutCache.h
+++ b/netwerk/protocol/about/nsAboutCache.h
@@ -15,101 +15,107 @@
 #include "nsIOutputStream.h"
 #include "nsILoadContextInfo.h"
 
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 
 #define NS_FORWARD_SAFE_NSICHANNEL_SUBSET(_to)                                 \
   NS_IMETHOD GetOriginalURI(nsIURI** aOriginalURI) override {                  \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->GetOriginalURI(aOriginalURI);   \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->GetOriginalURI(aOriginalURI);                       \
   }                                                                            \
   NS_IMETHOD SetOriginalURI(nsIURI* aOriginalURI) override {                   \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->SetOriginalURI(aOriginalURI);   \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->SetOriginalURI(aOriginalURI);                       \
   }                                                                            \
   NS_IMETHOD GetURI(nsIURI** aURI) override {                                  \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->GetURI(aURI);                   \
+    return !(_to) ? NS_ERROR_NULL_POINTER : (_to)->GetURI(aURI);               \
   }                                                                            \
   NS_IMETHOD GetOwner(nsISupports** aOwner) override {                         \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->GetOwner(aOwner);               \
+    return !(_to) ? NS_ERROR_NULL_POINTER : (_to)->GetOwner(aOwner);           \
   }                                                                            \
   NS_IMETHOD SetOwner(nsISupports* aOwner) override {                          \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->SetOwner(aOwner);               \
+    return !(_to) ? NS_ERROR_NULL_POINTER : (_to)->SetOwner(aOwner);           \
   }                                                                            \
   NS_IMETHOD GetNotificationCallbacks(                                         \
       nsIInterfaceRequestor** aNotificationCallbacks) override {               \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->GetNotificationCallbacks(aNotificationCallbacks);       \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->GetNotificationCallbacks(aNotificationCallbacks);   \
   }                                                                            \
   NS_IMETHOD SetNotificationCallbacks(                                         \
       nsIInterfaceRequestor* aNotificationCallbacks) override {                \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->SetNotificationCallbacks(aNotificationCallbacks);       \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->SetNotificationCallbacks(aNotificationCallbacks);   \
   }                                                                            \
   NS_IMETHOD GetSecurityInfo(nsISupports** aSecurityInfo) override {           \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->GetSecurityInfo(aSecurityInfo); \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->GetSecurityInfo(aSecurityInfo);                     \
   }                                                                            \
   NS_IMETHOD GetContentType(nsACString& aContentType) override {               \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentType(aContentType);   \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->GetContentType(aContentType);                       \
   }                                                                            \
   NS_IMETHOD SetContentType(const nsACString& aContentType) override {         \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentType(aContentType);   \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->SetContentType(aContentType);                       \
   }                                                                            \
   NS_IMETHOD GetContentCharset(nsACString& aContentCharset) override {         \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->GetContentCharset(aContentCharset);                     \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->GetContentCharset(aContentCharset);                 \
   }                                                                            \
   NS_IMETHOD SetContentCharset(const nsACString& aContentCharset) override {   \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->SetContentCharset(aContentCharset);                     \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->SetContentCharset(aContentCharset);                 \
   }                                                                            \
   NS_IMETHOD GetContentLength(int64_t* aContentLength) override {              \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->GetContentLength(aContentLength);                       \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->GetContentLength(aContentLength);                   \
   }                                                                            \
   NS_IMETHOD SetContentLength(int64_t aContentLength) override {               \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->SetContentLength(aContentLength);                       \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->SetContentLength(aContentLength);                   \
   }                                                                            \
   NS_IMETHOD GetContentDisposition(uint32_t* aContentDisposition) override {   \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->GetContentDisposition(aContentDisposition);             \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->GetContentDisposition(aContentDisposition);         \
   }                                                                            \
   NS_IMETHOD SetContentDisposition(uint32_t aContentDisposition) override {    \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->SetContentDisposition(aContentDisposition);             \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->SetContentDisposition(aContentDisposition);         \
   }                                                                            \
   NS_IMETHOD GetContentDispositionFilename(                                    \
       nsAString& aContentDispositionFilename) override {                       \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->GetContentDispositionFilename(                          \
-                      aContentDispositionFilename);                            \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->GetContentDispositionFilename(                      \
+                        aContentDispositionFilename);                          \
   }                                                                            \
   NS_IMETHOD SetContentDispositionFilename(                                    \
       const nsAString& aContentDispositionFilename) override {                 \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->SetContentDispositionFilename(                          \
-                      aContentDispositionFilename);                            \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->SetContentDispositionFilename(                      \
+                        aContentDispositionFilename);                          \
   }                                                                            \
   NS_IMETHOD GetContentDispositionHeader(                                      \
       nsACString& aContentDispositionHeader) override {                        \
-    return !_to ? NS_ERROR_NULL_POINTER                                        \
-                : _to->GetContentDispositionHeader(aContentDispositionHeader); \
+    return !(_to) ? NS_ERROR_NULL_POINTER                                      \
+                  : (_to)->GetContentDispositionHeader(                        \
+                        aContentDispositionHeader);                            \
   }                                                                            \
   NS_IMETHOD GetLoadInfo(nsILoadInfo** aLoadInfo) override {                   \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->GetLoadInfo(aLoadInfo);         \
+    return !(_to) ? NS_ERROR_NULL_POINTER : (_to)->GetLoadInfo(aLoadInfo);     \
   }                                                                            \
   NS_IMETHOD SetLoadInfo(nsILoadInfo* aLoadInfo) override {                    \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->SetLoadInfo(aLoadInfo);         \
+    return !(_to) ? NS_ERROR_NULL_POINTER : (_to)->SetLoadInfo(aLoadInfo);     \
   }                                                                            \
   NS_IMETHOD GetIsDocument(bool* aIsDocument) override {                       \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsDocument(aIsDocument);     \
+    return !(_to) ? NS_ERROR_NULL_POINTER : (_to)->GetIsDocument(aIsDocument); \
   }                                                                            \
   NS_IMETHOD GetCanceled(bool* aCanceled) override {                           \
-    return !_to ? NS_ERROR_NULL_POINTER : _to->GetCanceled(aCanceled);         \
+    return !(_to) ? NS_ERROR_NULL_POINTER : (_to)->GetCanceled(aCanceled);     \
   };
 
 class nsAboutCache final : public nsIAboutModule {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIABOUTMODULE
 
   nsAboutCache() = default;
@@ -155,24 +161,24 @@ class nsAboutCache final : public nsIAbo
     // Writes content of mBuffer to mStream and truncates
     // the buffer.  It may fail when the input stream is closed by canceling
     // the input stream channel.  It can be used to stop the cache iteration
     // process.
     [[nodiscard]] nsresult FlushBuffer();
 
     // Whether we are showing overview status of all available
     // storages.
-    bool mOverview;
+    bool mOverview = false;
 
     // Flag initially false, that indicates the entries header has
     // been added to the output HTML.
-    bool mEntriesHeaderAdded;
+    bool mEntriesHeaderAdded = false;
 
     // Cancelation flag
-    bool mCancel;
+    bool mCancel = false;
 
     // The list of all storage names we want to visit
     nsTArray<nsCString> mStorageList;
     nsCString mStorageName;
     nsCOMPtr<nsICacheStorage> mStorage;
 
     // Output data buffering and streaming output
     nsCString mBuffer;
--- a/netwerk/protocol/about/nsAboutCacheEntry.cpp
+++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp
@@ -210,25 +210,27 @@ nsresult nsAboutCacheEntry::Channel::Par
   if (NS_FAILED(rv)) return rv;
 
   nsACString::const_iterator keyBegin, keyEnd, valBegin, begin, end;
   path.BeginReading(begin);
   path.EndReading(end);
 
   keyBegin = begin;
   keyEnd = end;
-  if (!FindInReadable("?storage="_ns, keyBegin, keyEnd))
+  if (!FindInReadable("?storage="_ns, keyBegin, keyEnd)) {
     return NS_ERROR_FAILURE;
+  }
 
   valBegin = keyEnd;  // the value of the storage key starts after the key
 
   keyBegin = keyEnd;
   keyEnd = end;
-  if (!FindInReadable("&context="_ns, keyBegin, keyEnd))
+  if (!FindInReadable("&context="_ns, keyBegin, keyEnd)) {
     return NS_ERROR_FAILURE;
+  }
 
   storageName.Assign(Substring(valBegin, keyBegin));
   valBegin = keyEnd;  // the value of the context key starts after the key
 
   keyBegin = keyEnd;
   keyEnd = end;
   if (!FindInReadable("&eid="_ns, keyBegin, keyEnd)) return NS_ERROR_FAILURE;
 
--- a/netwerk/protocol/about/nsAboutProtocolHandler.cpp
+++ b/netwerk/protocol/about/nsAboutProtocolHandler.cpp
@@ -50,22 +50,18 @@ static bool IsSafeToLinkForUntrustedCont
   if (f >= 0) {
     path.SetLength(f);
   }
 
   ToLowerCase(path);
 
   // The about modules for these URL types have the
   // URI_SAFE_FOR_UNTRUSTED_CONTENT and MAKE_LINKABLE flags set.
-  if (path.EqualsLiteral("blank") || path.EqualsLiteral("logo") ||
-      path.EqualsLiteral("srcdoc")) {
-    return true;
-  }
-
-  return false;
+  return path.EqualsLiteral("blank") || path.EqualsLiteral("logo") ||
+         path.EqualsLiteral("srcdoc");
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS(nsAboutProtocolHandler, nsIProtocolHandler,
                   nsIProtocolHandlerWithDynamicFlags, nsISupportsWeakReference)
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -297,19 +293,19 @@ nsSafeAboutProtocolHandler::AllowPort(in
 // nsNestedAboutURI implementation
 
 NS_IMPL_CLASSINFO(nsNestedAboutURI, nullptr, nsIClassInfo::THREADSAFE,
                   NS_NESTEDABOUTURI_CID);
 // Empty CI getter. We only need nsIClassInfo for Serialization
 NS_IMPL_CI_INTERFACE_GETTER0(nsNestedAboutURI)
 
 NS_INTERFACE_MAP_BEGIN(nsNestedAboutURI)
-  if (aIID.Equals(kNestedAboutURICID))
+  if (aIID.Equals(kNestedAboutURICID)) {
     foundInterface = static_cast<nsIURI*>(this);
-  else
+  } else
     NS_IMPL_QUERY_CLASSINFO(nsNestedAboutURI)
 NS_INTERFACE_MAP_END_INHERITING(nsSimpleNestedURI)
 
 // nsISerializable
 
 NS_IMETHODIMP
 nsNestedAboutURI::Read(nsIObjectInputStream* aStream) {
   MOZ_ASSERT_UNREACHABLE("Use nsIURIMutator.read() instead");
--- a/netwerk/protocol/about/nsAboutProtocolHandler.h
+++ b/netwerk/protocol/about/nsAboutProtocolHandler.h
@@ -104,17 +104,16 @@ class nsNestedAboutURI final : public ns
       return NS_ERROR_NOT_IMPLEMENTED;
     }
 
     [[nodiscard]] NS_IMETHOD Read(nsIObjectInputStream* aStream) override {
       return InitFromInputStream(aStream);
     }
 
     [[nodiscard]] NS_IMETHOD Finalize(nsIURI** aURI) override {
-      mURI->mMutable = false;
       mURI.forget(aURI);
       return NS_OK;
     }
 
     [[nodiscard]] NS_IMETHOD SetSpec(const nsACString& aSpec,
                                      nsIURIMutator** aMutator) override {
       if (aMutator) {
         NS_ADDREF(*aMutator = this);
@@ -123,22 +122,16 @@ class nsNestedAboutURI final : public ns
     }
 
     [[nodiscard]] NS_IMETHOD InitWithBase(nsIURI* aInnerURI,
                                           nsIURI* aBaseURI) override {
       mURI = new nsNestedAboutURI(aInnerURI, aBaseURI);
       return NS_OK;
     }
 
-    void ResetMutable() {
-      if (mURI) {
-        mURI->mMutable = true;
-      }
-    }
-
     friend class nsNestedAboutURI;
   };
 
   friend BaseURIMutator<nsNestedAboutURI>;
 };
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/protocol/file/nsFileChannel.cpp
+++ b/netwerk/protocol/file/nsFileChannel.cpp
@@ -301,18 +301,19 @@ nsresult nsFileChannel::MakeFileInputStr
       isDir = false;
     } else {
       return rv;
     }
   }
 
   if (isDir) {
     rv = nsDirectoryIndexStream::Create(file, getter_AddRefs(stream));
-    if (NS_SUCCEEDED(rv) && !HasContentTypeHint())
+    if (NS_SUCCEEDED(rv) && !HasContentTypeHint()) {
       contentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
+    }
   } else {
     rv = NS_NewLocalFileInputStream(getter_AddRefs(stream), file, -1, -1,
                                     async ? nsIFileInputStream::DEFER_OPEN : 0);
     if (NS_SUCCEEDED(rv) && !HasContentTypeHint()) {
       // Use file extension to infer content type
       nsCOMPtr<nsIMIMEService> mime = do_GetService("@mozilla.org/mime;1", &rv);
       if (NS_SUCCEEDED(rv)) {
         mime->GetTypeFromFile(file, contentType);
@@ -372,18 +373,19 @@ nsresult nsFileChannel::OpenContentStrea
     stream = std::move(uploadStream);
 
     mContentLength = 0;
 
     // Since there isn't any content to speak of we just set the content-type
     // to something other than "unknown" to avoid triggering the content-type
     // sniffer code in nsBaseChannel.
     // However, don't override explicitly set types.
-    if (!HasContentTypeHint())
+    if (!HasContentTypeHint()) {
       SetContentType(nsLiteralCString(APPLICATION_OCTET_STREAM));
+    }
   } else {
     nsAutoCString contentType;
     rv = MakeFileInputStream(file, stream, contentType, async);
     if (NS_FAILED(rv)) return rv;
 
     EnableSynthesizedProgressEvents(true);
 
     // fixup content length and type
--- a/netwerk/protocol/file/nsFileProtocolHandler.cpp
+++ b/netwerk/protocol/file/nsFileProtocolHandler.cpp
@@ -89,18 +89,19 @@ nsFileProtocolHandler::ReadURLFile(nsIFi
 
 #elif defined(XP_UNIX)
 NS_IMETHODIMP
 nsFileProtocolHandler::ReadURLFile(nsIFile* aFile, nsIURI** aURI) {
   // We only support desktop files that end in ".desktop" like the spec says:
   // http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html
   nsAutoCString leafName;
   nsresult rv = aFile->GetNativeLeafName(leafName);
-  if (NS_FAILED(rv) || !StringEndsWith(leafName, ".desktop"_ns))
+  if (NS_FAILED(rv) || !StringEndsWith(leafName, ".desktop"_ns)) {
     return NS_ERROR_NOT_AVAILABLE;
+  }
 
   bool isFile = false;
   rv = aFile->IsFile(&isFile);
   if (NS_FAILED(rv) || !isFile) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsINIParser parser;
--- a/netwerk/protocol/http/ASpdySession.h
+++ b/netwerk/protocol/http/ASpdySession.h
@@ -86,17 +86,17 @@ class ASpdySession : public nsAHttpTrans
             code == NS_BINDING_RETARGETED ||
             code == NS_ERROR_CORRUPTED_CONTENT);
   }
 
   virtual void SetCleanShutdown(bool) = 0;
   virtual bool CanAcceptWebsocket() = 0;
 };
 
-typedef bool (*ALPNCallback)(nsISupports*);  // nsISSLSocketControl is typical
+using ALPNCallback = bool (*)(nsISupports*);  // nsISSLSocketControl is typical
 
 // this is essentially a single instantiation as a member of nsHttpHandler.
 // It could be all static except using static ctors of XPCOM objects is a
 // bad idea.
 class SpdyInformation {
  public:
   SpdyInformation();
   ~SpdyInformation() = default;
@@ -106,22 +106,22 @@ class SpdyInformation {
   // determine the index (0..kCount-1) of the spdy information that
   // correlates to the npn string. NS_FAILED() if no match is found.
   [[nodiscard]] nsresult GetNPNIndex(const nsACString& npnString,
                                      uint32_t* result) const;
 
   // determine if a version of the protocol is enabled for index < kCount
   bool ProtocolEnabled(uint32_t index) const;
 
-  SpdyVersion Version[kCount];      // telemetry enum e.g. SPDY_VERSION_31
+  SpdyVersion Version[kCount]{};    // telemetry enum e.g. SPDY_VERSION_31
   nsCString VersionString[kCount];  // npn string e.g. "spdy/3.1"
 
   // the ALPNCallback function allows the protocol stack to decide whether or
   // not to offer a particular protocol based on the known TLS information
   // that we will offer in the client hello (such as version). There has
   // not been a Server Hello received yet, so not much else can be considered.
-  ALPNCallback ALPNCallbacks[kCount];
+  ALPNCallback ALPNCallbacks[kCount]{};
 };
 
 }  // namespace net
 }  // namespace mozilla
 
 #endif  // mozilla_net_ASpdySession_h
--- a/netwerk/protocol/http/AlternateServices.h
+++ b/netwerk/protocol/http/AlternateServices.h
@@ -52,29 +52,29 @@ class AltSvcMapping {
                 int32_t originPort, const nsACString& username,
                 bool privateBrowsing, uint32_t expiresAt,
                 const nsACString& alternateHost, int32_t alternatePort,
                 const nsACString& npnToken,
                 const OriginAttributes& originAttributes, bool aIsHttp3);
 
  public:
   AltSvcMapping(DataStorage* storage, int32_t storageEpoch,
-                const nsCString& serialized);
+                const nsCString& str);
 
   static void ProcessHeader(
       const nsCString& buf, const nsCString& originScheme,
       const nsCString& originHost, int32_t originPort,
       const nsACString& username, bool privateBrowsing,
       nsIInterfaceRequestor* callbacks, nsProxyInfo* proxyInfo, uint32_t caps,
       const OriginAttributes& originAttributes,
       bool aDontValidate = false);  // aDontValidate is only used for testing!
 
   // AcceptableProxy() decides whether a particular proxy configuration (pi) is
   // suitable for use with Alt-Svc. No proxy (including a null pi) is suitable.
-  static bool AcceptableProxy(nsProxyInfo* pi);
+  static bool AcceptableProxy(nsProxyInfo* proxyInfo);
 
   const nsCString& AlternateHost() const { return mAlternateHost; }
   const nsCString& OriginHost() const { return mOriginHost; }
   uint32_t OriginPort() const { return mOriginPort; }
   const nsCString& HashKey() const { return mHashKey; }
   uint32_t AlternatePort() const { return mAlternatePort; }
   bool Validated() { return mValidated; }
   int32_t GetExpiresAt() { return mExpiresAt; }
@@ -94,24 +94,24 @@ class AltSvcMapping {
   void SetExpired();
   void Sync();
   void SetSyncOnlyOnSuccess(bool aSOOS) { mSyncOnlyOnSuccess = aSOOS; }
 
   static void MakeHashKey(nsCString& outKey, const nsACString& originScheme,
                           const nsACString& originHost, int32_t originPort,
                           bool privateBrowsing,
                           const OriginAttributes& originAttributes,
-                          bool aIsHttp3);
+                          bool aHttp3);
 
   bool IsHttp3() { return mIsHttp3; }
   const nsCString& NPNToken() const { return mNPNToken; }
 
  private:
   virtual ~AltSvcMapping() = default;
-  void SyncString(const nsCString& val);
+  void SyncString(const nsCString& str);
   RefPtr<DataStorage> mStorage;
   int32_t mStorageEpoch;
   void Serialize(nsCString& out);
 
   nsCString mHashKey;
 
   // If you change any of these members, update Serialize()
   nsCString mAlternateHost;
@@ -121,17 +121,17 @@ class AltSvcMapping {
   MOZ_INIT_OUTSIDE_CTOR int32_t mOriginPort;
 
   nsCString mUsername;
   MOZ_INIT_OUTSIDE_CTOR bool mPrivate;
 
   MOZ_INIT_OUTSIDE_CTOR uint32_t mExpiresAt;  // alt-svc mappping
 
   MOZ_INIT_OUTSIDE_CTOR bool mValidated;
-  MOZ_INIT_OUTSIDE_CTOR bool mHttps;  // origin is https://
+  MOZ_INIT_OUTSIDE_CTOR bool mHttps{};  // origin is https://
   MOZ_INIT_OUTSIDE_CTOR bool
       mMixedScheme;  // .wk allows http and https on same con
 
   nsCString mNPNToken;
 
   OriginAttributes mOriginAttributes;
 
   bool mSyncOnlyOnSuccess;
@@ -186,19 +186,19 @@ class AltSvcCache {
       AltSvcMapping* map, nsProxyInfo* pi, nsIInterfaceRequestor*,
       uint32_t caps,
       const OriginAttributes& originAttributes);  // main thread
   void UpdateAltServiceMappingWithoutValidation(
       AltSvcMapping* map, nsProxyInfo* pi, nsIInterfaceRequestor*,
       uint32_t caps,
       const OriginAttributes& originAttributes);  // main thread
   already_AddRefed<AltSvcMapping> GetAltServiceMapping(
-      const nsACString& scheme, const nsACString& host, int32_t port, bool pb,
-      const OriginAttributes& originAttributes, bool aHttp2Allowed,
-      bool aHttp3Allowed);
+      const nsACString& scheme, const nsACString& host, int32_t port,
+      bool privateBrowsing, const OriginAttributes& originAttributes,
+      bool aHttp2Allowed, bool aHttp3Allowed);
   void ClearAltServiceMappings();
   void ClearHostMapping(const nsACString& host, int32_t port,
                         const OriginAttributes& originAttributes);
   void ClearHostMapping(nsHttpConnectionInfo* ci);
   DataStorage* GetStoragePtr() { return mStorage.get(); }
   int32_t StorageEpoch() { return mStorageEpoch; }
   nsresult GetAltSvcCacheKeys(nsTArray<nsCString>& value);
 
--- a/netwerk/protocol/http/BackgroundChannelRegistrar.h
+++ b/netwerk/protocol/http/BackgroundChannelRegistrar.h
@@ -13,20 +13,20 @@
 
 namespace mozilla {
 namespace net {
 
 class HttpBackgroundChannelParent;
 class HttpChannelParent;
 
 class BackgroundChannelRegistrar final : public nsIBackgroundChannelRegistrar {
-  typedef nsRefPtrHashtable<nsUint64HashKey, HttpChannelParent>
-      ChannelHashtable;
-  typedef nsRefPtrHashtable<nsUint64HashKey, HttpBackgroundChannelParent>
-      BackgroundChannelHashtable;
+  using ChannelHashtable =
+      nsRefPtrHashtable<nsUint64HashKey, HttpChannelParent>;
+  using BackgroundChannelHashtable =
+      nsRefPtrHashtable<nsUint64HashKey, HttpBackgroundChannelParent>;
 
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIBACKGROUNDCHANNELREGISTRAR
 
   explicit BackgroundChannelRegistrar();
 
   // Singleton accessor
--- a/netwerk/protocol/http/ConnectionDiagnostics.cpp
+++ b/netwerk/protocol/http/ConnectionDiagnostics.cpp
@@ -42,17 +42,17 @@ void nsHttpConnectionMgr::OnMsgPrintDiag
   mLogData.AppendPrintf("HTTP Connection Diagnostics\n---------------------\n");
   mLogData.AppendPrintf("IsSpdyEnabled() = %d\n",
                         gHttpHandler->IsSpdyEnabled());
   mLogData.AppendPrintf("MaxSocketCount() = %d\n",
                         gHttpHandler->MaxSocketCount());
   mLogData.AppendPrintf("mNumActiveConns = %d\n", mNumActiveConns);
   mLogData.AppendPrintf("mNumIdleConns = %d\n", mNumIdleConns);
 
-  for (RefPtr<ConnectionEntry> ent : mCT.Values()) {
+  for (const RefPtr<ConnectionEntry>& ent : mCT.Values()) {
     mLogData.AppendPrintf(
         "   AtActiveConnectionLimit = %d\n",
         AtActiveConnectionLimit(ent, NS_HTTP_ALLOW_KEEPALIVE));
 
     ent->PrintDiagnostics(mLogData, MaxPersistConnections(ent));
   }
 
   consoleService->LogStringMessage(NS_ConvertUTF8toUTF16(mLogData).Data());
@@ -143,18 +143,18 @@ void nsHttpConnection::PrintDiagnostics(
 
   log.AppendPrintf("    spdyVersion = %d  reportedSpdy = %d everspdy = %d\n",
                    static_cast<int32_t>(mUsingSpdyVersion), mReportedSpdy,
                    mEverUsedSpdy);
 
   log.AppendPrintf("    iskeepalive = %d  dontReuse = %d isReused = %d\n",
                    IsKeepAlive(), mDontReuse, mIsReused);
 
-  log.AppendPrintf("    mTransaction = %d mSpdySession = %d\n",
-                   !!mTransaction.get(), !!mSpdySession.get());
+  log.AppendPrintf("    mTransaction = %d mSpdySession = %d\n", !!mTransaction,
+                   !!mSpdySession);
 
   PRIntervalTime now = PR_IntervalNow();
   log.AppendPrintf("    time since last read = %ums\n",
                    PR_IntervalToMilliseconds(now - mLastReadTime));
 
   log.AppendPrintf("    max-read/read/written %" PRId64 "/%" PRId64 "/%" PRId64
                    "\n",
                    mMaxBytesRead, mTotalBytesRead, mTotalBytesWritten);
@@ -200,22 +200,23 @@ void Http2Session::PrintDiagnostics(nsCS
   log.AppendPrintf("     Ping Threshold = %ums\n",
                    PR_IntervalToMilliseconds(mPingThreshold));
   log.AppendPrintf("     Ping Timeout = %ums\n",
                    PR_IntervalToMilliseconds(gHttpHandler->SpdyPingTimeout()));
   log.AppendPrintf("     Idle for Any Activity (ping) = %ums\n",
                    PR_IntervalToMilliseconds(now - mLastReadEpoch));
   log.AppendPrintf("     Idle for Data Activity = %ums\n",
                    PR_IntervalToMilliseconds(now - mLastDataReadEpoch));
-  if (mPingSentEpoch)
+  if (mPingSentEpoch) {
     log.AppendPrintf("     Ping Outstanding (ping) = %ums, expired = %d\n",
                      PR_IntervalToMilliseconds(now - mPingSentEpoch),
                      now - mPingSentEpoch >= gHttpHandler->SpdyPingTimeout());
-  else
+  } else {
     log.AppendPrintf("     No Ping Outstanding\n");
+  }
 }
 
 void nsHttpTransaction::PrintDiagnostics(nsCString& log) {
   if (!mRequestHead) return;
 
   nsAutoCString requestURI;
   mRequestHead->RequestURI(requestURI);
   log.AppendPrintf("       :::: uri = %s\n", requestURI.get());
--- a/netwerk/protocol/http/ConnectionEntry.cpp
+++ b/netwerk/protocol/http/ConnectionEntry.cpp
@@ -43,19 +43,18 @@ ConnectionEntry::ConnectionEntry(nsHttpC
        ci->HashKey().get()));
 }
 
 bool ConnectionEntry::AvailableForDispatchNow() {
   if (mIdleConns.Length() && mIdleConns[0]->CanReuse()) {
     return true;
   }
 
-  return gHttpHandler->ConnMgr()->GetH2orH3ActiveConn(this, false, false)
-             ? true
-             : false;
+  return gHttpHandler->ConnMgr()->GetH2orH3ActiveConn(this, false, false) !=
+         nullptr;
 }
 
 uint32_t ConnectionEntry::UnconnectedDnsAndConnectSockets() const {
   uint32_t unconnectedDnsAndConnectSockets = 0;
   for (uint32_t i = 0; i < mDnsAndConnectSockets.Length(); ++i) {
     if (!mDnsAndConnectSockets[i]->HasConnected()) {
       ++unconnectedDnsAndConnectSockets;
     }
@@ -805,17 +804,17 @@ HttpRetParams ConnectionEntry::GetConnec
   for (uint32_t i = 0; i < mIdleConns.Length(); i++) {
     HttpConnInfo info;
     info.ttl = mIdleConns[i]->TimeToLive();
     info.rtt = mIdleConns[i]->Rtt();
     info.SetHTTPProtocolVersion(mIdleConns[i]->Version());
     data.idle.AppendElement(info);
   }
   for (uint32_t i = 0; i < mDnsAndConnectSockets.Length(); i++) {
-    DnsAndConnectSockets dnsAndSock;
+    DnsAndConnectSockets dnsAndSock{};
     dnsAndSock.speculative = mDnsAndConnectSockets[i]->IsSpeculative();
     data.dnsAndSocks.AppendElement(dnsAndSock);
   }
   if (mConnInfo->IsHttp3()) {
     data.httpVersion = "HTTP/3"_ns;
   } else if (mUsingSpdy) {
     data.httpVersion = "HTTP/2"_ns;
   } else {
--- a/netwerk/protocol/http/DelayHttpChannelQueue.cpp
+++ b/netwerk/protocol/http/DelayHttpChannelQueue.cpp
@@ -61,21 +61,17 @@ bool DelayHttpChannelQueue::Initialize()
   }
 
   nsresult rv = obs->AddObserver(this, "fuzzyfox-fire-outbound", false);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return false;
   }
 
   rv = obs->AddObserver(this, "xpcom-shutdown", false);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return false;
-  }
-
-  return true;
+  return !NS_WARN_IF(NS_FAILED(rv));
 }
 
 NS_IMETHODIMP
 DelayHttpChannelQueue::Observe(nsISupports* aSubject, const char* aTopic,
                                const char16_t* aData) {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!strcmp(aTopic, "fuzzyfox-fire-outbound")) {
--- a/netwerk/protocol/http/DnsAndConnectSocket.cpp
+++ b/netwerk/protocol/http/DnsAndConnectSocket.cpp
@@ -1287,26 +1287,25 @@ nsresult DnsAndConnectSocket::TransportS
   mDNSRequest = nullptr;
   if (NS_SUCCEEDED(status)) {
     mDNSRecord = do_QueryInterface(rec);
     MOZ_ASSERT(mDNSRecord);
 
     if (dnsAndSock->mEnt->mConnInfo->IsHttp3()) {
       mState = TransportSetup::TransportSetupState::RESOLVED;
       return status;
+    }
+    nsresult rv = SetupStreams(dnsAndSock);
+    if (NS_SUCCEEDED(rv)) {
+      mState = TransportSetup::TransportSetupState::CONNECTING;
     } else {
-      nsresult rv = SetupStreams(dnsAndSock);
-      if (NS_SUCCEEDED(rv)) {
-        mState = TransportSetup::TransportSetupState::CONNECTING;
-      } else {
-        CloseAll();
-        mState = TransportSetup::TransportSetupState::DONE;
-      }
-      return rv;
+      CloseAll();
+      mState = TransportSetup::TransportSetupState::DONE;
     }
+    return rv;
   }
 
   // DNS lookup status failed
 
   if (ShouldRetryDNS()) {
     mState = TransportSetup::TransportSetupState::RETRY_RESOLVING;
     nsresult rv = ResolveHost(dnsAndSock);
     if (NS_FAILED(rv)) {
--- a/netwerk/protocol/http/Http2Compression.cpp
+++ b/netwerk/protocol/http/Http2Compression.cpp
@@ -557,17 +557,18 @@ nsresult Http2Decompressor::OutputHeader
 
   // http/2 transport level headers shouldn't be gatewayed into http/1
   bool isColonHeader = false;
   for (const char* cPtr = name.BeginReading(); cPtr && cPtr < name.EndReading();
        ++cPtr) {
     if (*cPtr == ':') {
       isColonHeader = true;
       break;
-    } else if (*cPtr != ' ' && *cPtr != '\t') {
+    }
+    if (*cPtr != ' ' && *cPtr != '\t') {
       isColonHeader = false;
       break;
     }
   }
 
   if (isColonHeader) {
     // :status is the only pseudo-header field allowed in received HEADERS
     // frames, PUSH_PROMISE allows the other pseudo-header fields
@@ -1110,29 +1111,31 @@ nsresult Http2Compressor::EncodeHeaderBl
     // colon headers are for http/2 and this is http/1 input, so that
     // is probably a smuggling attack of some kind
     bool isColonHeader = false;
     for (const char* cPtr = name.BeginReading();
          cPtr && cPtr < name.EndReading(); ++cPtr) {
       if (*cPtr == ':') {
         isColonHeader = true;
         break;
-      } else if (*cPtr != ' ' && *cPtr != '\t') {
+      }
+      if (*cPtr != ' ' && *cPtr != '\t') {
         isColonHeader = false;
         break;
       }
     }
     if (isColonHeader) {
       continue;
     }
 
     int32_t valueIndex = colonIndex + 1;
 
-    while (valueIndex < crlfIndex && beginBuffer[valueIndex] == ' ')
+    while (valueIndex < crlfIndex && beginBuffer[valueIndex] == ' ') {
       ++valueIndex;
+    }
 
     nsDependentCSubstring value =
         Substring(beginBuffer + valueIndex, beginBuffer + crlfIndex);
 
     if (name.EqualsLiteral("content-length")) {
       int64_t len;
       nsCString tmp(value);
       if (nsHttp::ParseInt64(tmp.get(), nullptr, &len)) {
--- a/netwerk/protocol/http/Http2Compression.h
+++ b/netwerk/protocol/http/Http2Compression.h
@@ -120,25 +120,25 @@ class Http2Decompressor final : public H
  private:
   [[nodiscard]] nsresult DoIndexed();
   [[nodiscard]] nsresult DoLiteralWithoutIndex();
   [[nodiscard]] nsresult DoLiteralWithIncremental();
   [[nodiscard]] nsresult DoLiteralInternal(nsACString&, nsACString&, uint32_t);
   [[nodiscard]] nsresult DoLiteralNeverIndexed();
   [[nodiscard]] nsresult DoContextUpdate();
 
-  [[nodiscard]] nsresult DecodeInteger(uint32_t prefixLen, uint32_t& result);
+  [[nodiscard]] nsresult DecodeInteger(uint32_t prefixLen, uint32_t& accum);
   [[nodiscard]] nsresult OutputHeader(uint32_t index);
   [[nodiscard]] nsresult OutputHeader(const nsACString& name,
                                       const nsACString& value);
 
   [[nodiscard]] nsresult CopyHeaderString(uint32_t index, nsACString& name);
-  [[nodiscard]] nsresult CopyStringFromInput(uint32_t index, nsACString& val);
+  [[nodiscard]] nsresult CopyStringFromInput(uint32_t bytes, nsACString& val);
   uint8_t ExtractByte(uint8_t bitsLeft, uint32_t& bytesConsumed);
-  [[nodiscard]] nsresult CopyHuffmanStringFromInput(uint32_t index,
+  [[nodiscard]] nsresult CopyHuffmanStringFromInput(uint32_t bytes,
                                                     nsACString& val);
   [[nodiscard]] nsresult DecodeHuffmanCharacter(
       const HuffmanIncomingTable* table, uint8_t& c, uint32_t& bytesConsumed,
       uint8_t& bitsLeft);
   [[nodiscard]] nsresult DecodeFinalHuffmanCharacter(
       const HuffmanIncomingTable* table, uint8_t& c, uint8_t& bitsLeft);
 
   nsCString mHeaderStatus;
--- a/netwerk/protocol/http/Http2Push.cpp
+++ b/netwerk/protocol/http/Http2Push.cpp
@@ -322,18 +322,19 @@ bool Http2PushedStream::IsOrphaned(TimeS
 
 nsresult Http2PushedStream::GetBufferedData(char* buf, uint32_t count,
                                             uint32_t* countWritten) {
   if (NS_FAILED(mStatus)) return mStatus;
 
   nsresult rv = mBufferedPush->GetBufferedData(buf, count, countWritten);
   if (NS_FAILED(rv)) return rv;
 
-  if (!*countWritten)
+  if (!*countWritten) {
     rv = GetPushComplete() ? NS_BASE_STREAM_CLOSED : NS_BASE_STREAM_WOULD_BLOCK;
+  }
 
   return rv;
 }
 
 void Http2PushedStream::TopBrowsingContextIdChanged(uint64_t id) {
   if (mConsumerStream) {
     // Pass through to our sink, who will handle things appropriately.
     mConsumerStream->TopBrowsingContextIdChanged(id);
--- a/netwerk/protocol/http/Http2Push.h
+++ b/netwerk/protocol/http/Http2Push.h
@@ -32,31 +32,31 @@ class Http2PushedStream final : public H
                     uint32_t aID,
                     uint64_t aCurrentForegroundTabOuterContentWindowId);
 
   bool GetPushComplete();
 
   // The consumer stream is the synthetic pull stream hooked up to this push
   virtual Http2Stream* GetConsumerStream() override { return mConsumerStream; };
 
-  void SetConsumerStream(Http2Stream* aStream);
+  void SetConsumerStream(Http2Stream* consumer);
   [[nodiscard]] bool GetHashKey(nsCString& key);
 
   // override of Http2Stream
   [[nodiscard]] nsresult ReadSegments(nsAHttpSegmentReader*, uint32_t,
                                       uint32_t*) override;
   [[nodiscard]] nsresult WriteSegments(nsAHttpSegmentWriter*, uint32_t,
                                        uint32_t*) override;
   void AdjustInitialWindow() override;
 
   nsIRequestContext* RequestContext() override { return mRequestContext; };
-  void ConnectPushedStream(Http2Stream* consumer);
+  void ConnectPushedStream(Http2Stream* stream);
 
   [[nodiscard]] bool TryOnPush();
-  [[nodiscard]] static bool TestOnPush(Http2Stream* consumer);
+  [[nodiscard]] static bool TestOnPush(Http2Stream* stream);
 
   virtual bool DeferCleanup(nsresult status) override;
   void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; }
 
   bool IsOrphaned(TimeStamp now);
   void OnPushFailed() {
     mDeferCleanupOnPush = false;
     mOnPushFailed = true;
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -279,17 +279,17 @@ void Http2Session::LogIO(Http2Session* s
     line += 3;
   }
   if (index) {
     *line = 0;
     LOG5(("%s", linebuf));
   }
 }
 
-typedef nsresult (*Http2ControlFx)(Http2Session* self);
+using Http2ControlFx = nsresult (*)(Http2Session*);
 static Http2ControlFx sControlFunctions[] = {
     nullptr,  // type 0 data is not a control function
     Http2Session::RecvHeaders,
     Http2Session::RecvPriority,
     Http2Session::RecvRstStream,
     Http2Session::RecvSettings,
     Http2Session::RecvPushPromise,
     Http2Session::RecvPing,
@@ -302,18 +302,19 @@ static Http2ControlFx sControlFunctions[
 };
 
 bool Http2Session::RoomForMoreConcurrent() {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
   return (mConcurrent < mMaxConcurrent);
 }
 
 bool Http2Session::RoomForMoreStreams() {
-  if (mNextStreamID + mStreamTransactionHash.Count() * 2 > kMaxStreamID)
+  if (mNextStreamID + mStreamTransactionHash.Count() * 2 > kMaxStreamID) {
     return false;
+  }
 
   return !mShouldGoAway;
 }
 
 PRIntervalTime Http2Session::IdleTime() {
   return PR_IntervalNow() - mLastDataReadEpoch;
 }
 
@@ -367,18 +368,19 @@ uint32_t Http2Session::ReadTimeoutTick(P
   Http2PushedStream* deleteMe;
   TimeStamp timestampNow;
   do {
     deleteMe = nullptr;
 
     for (uint32_t index = mPushedStreams.Length(); index > 0; --index) {
       Http2PushedStream* pushedStream = mPushedStreams[index - 1];
 
-      if (timestampNow.IsNull())
+      if (timestampNow.IsNull()) {
         timestampNow = TimeStamp::Now();  // lazy initializer
+      }
 
       // if stream finished, but is not connected, and its been like that for
       // long then cleanup the stream.
       if (pushedStream->IsOrphaned(timestampNow)) {
         LOG3(("Http2Session Timeout Pushed Stream %p 0x%X\n", this,
               pushedStream->StreamID()));
         deleteMe = pushedStream;
         break;  // don't CleanupStream() while iterating this vector
@@ -1349,20 +1351,21 @@ nsresult Http2Session::RecvHeaders(Http2
              self->mInputFrameType == FRAME_TYPE_CONTINUATION);
 
   bool isContinuation = self->mExpectedHeaderID != 0;
 
   // If this doesn't have END_HEADERS set on it then require the next
   // frame to be HEADERS of the same ID
   bool endHeadersFlag = self->mInputFrameFlags & kFlag_END_HEADERS;
 
-  if (endHeadersFlag)
+  if (endHeadersFlag) {
     self->mExpectedHeaderID = 0;
-  else
+  } else {
     self->mExpectedHeaderID = self->mInputFrameID;
+  }
 
   uint32_t priorityLen = 0;
   if (self->mInputFrameFlags & kFlag_PRIORITY) {
     priorityLen = 5;
   }
   nsresult rv = self->SetInputFrameDataStream(self->mInputFrameID);
   MOZ_ASSERT(NS_SUCCEEDED(rv));
 
@@ -1399,18 +1402,19 @@ nsresult Http2Session::RecvHeaders(Http2
     // Cannot find stream. We can continue the session, but we need to
     // uncompress the header block to maintain the correct compression context
 
     LOG3(
         ("Http2Session::RecvHeaders %p lookup mInputFrameID stream "
          "0x%X failed. NextStreamID = 0x%X\n",
          self, self->mInputFrameID, self->mNextStreamID));
 
-    if (self->mInputFrameID >= self->mNextStreamID)
+    if (self->mInputFrameID >= self->mNextStreamID) {
       self->GenerateRstStream(PROTOCOL_ERROR, self->mInputFrameID);
+    }
 
     self->mDecompressBuffer.Append(
         &self->mInputFrameBuffer[kFrameHeaderBytes + paddingControlBytes +
                                  priorityLen],
         self->mInputFrameDataSize - paddingControlBytes - priorityLen -
             paddingLength);
 
     if (self->mInputFrameFlags & kFlag_END_HEADERS) {
@@ -1536,17 +1540,18 @@ nsresult Http2Session::ResponseHeadersCo
          "reset\n",
          this));
     // This means the stream found connection-oriented auth. Treat this like we
     // got a reset with HTTP_1_1_REQUIRED.
     mInputFrameDataStream->Transaction()->DisableSpdy();
     CleanupStream(mInputFrameDataStream, NS_ERROR_NET_RESET, CANCEL_ERROR);
     ResetDownstreamState();
     return NS_OK;
-  } else if (NS_FAILED(rv)) {
+  }
+  if (NS_FAILED(rv)) {
     return rv;
   }
 
   // allow more headers in the case of 1xx
   if (((httpResponseCode / 100) == 1) && didFirstSetAllRecvd) {
     mInputFrameDataStream->UnsetAllHeadersReceived();
   }
 
@@ -1935,17 +1940,18 @@ nsresult Http2Session::RecvPushPromise(H
   }
 
   if (rv == NS_ERROR_ILLEGAL_VALUE) {
     // This means the decompression completed ok, but there was a problem with
     // the decoded headers. Reset the stream and go away.
     self->GenerateRstStream(PROTOCOL_ERROR, promisedID);
     self->ResetDownstreamState();
     return NS_OK;
-  } else if (NS_FAILED(rv)) {
+  }
+  if (NS_FAILED(rv)) {
     // This is fatal to the session.
     self->mGoAwayReason = COMPRESSION_ERROR;
     return rv;
   }
 
   // Ownership of the pushed stream is by the transaction hash, just as it
   // is for a client initiated stream. Errors that aren't fatal to the
   // whole session must call cleanupStream() after this point in order
@@ -1957,18 +1963,19 @@ nsresult Http2Session::RecvPushPromise(H
       static_cast<Http2PushedStream*>(pushedWeak.get()));
 
   if (self->RegisterStreamID(pushedWeak, promisedID) == kDeadStreamID) {
     LOG3(("Http2Session::RecvPushPromise registerstreamid failed\n"));
     self->mGoAwayReason = INTERNAL_ERROR;
     return NS_ERROR_FAILURE;
   }
 
-  if (promisedID > self->mOutgoingGoAwayID)
+  if (promisedID > self->mOutgoingGoAwayID) {
     self->mOutgoingGoAwayID = promisedID;
+  }
 
   // Fake the request side of the pushed HTTP transaction. Sets up hash
   // key and origin
   uint32_t notUsed;
   Unused << pushedWeak->ReadSegments(nullptr, 1, &notUsed);
 
   nsAutoCString key;
   if (!static_cast<Http2PushedStream*>(pushedWeak.get())->GetHashKey(key)) {
@@ -2164,18 +2171,19 @@ nsresult Http2Session::RecvGoAway(Http2S
   for (size_t count = 0; count < size; ++count) {
     Http2Stream* stream =
         static_cast<Http2Stream*>(self->mGoAwayStreamsToRestart.PopFront());
 
     if (self->mPeerGoAwayReason == HTTP_1_1_REQUIRED) {
       stream->Transaction()->DisableSpdy();
     }
     self->CloseStream(stream, NS_ERROR_NET_RESET);
-    if (stream->HasRegisteredID())
+    if (stream->HasRegisteredID()) {
       self->mStreamIDHash.Remove(stream->StreamID());
+    }
     self->mStreamTransactionHash.Remove(stream->Transaction());
   }
 
   // Queued streams can also be deleted from this session and restarted
   // in another one. (they were never sent on the network so they implicitly
   // are not covered by the last-good id.
   for (const auto& stream : self->mQueuedStreams) {
     MOZ_ASSERT(stream->Queued());
@@ -2218,18 +2226,19 @@ nsresult Http2Session::RecvWindowUpdate(
   if (self->mInputFrameID) {  // stream window
     nsresult rv = self->SetInputFrameDataStream(self->mInputFrameID);
     if (NS_FAILED(rv)) return rv;
 
     if (!self->mInputFrameDataStream) {
       LOG3(("Http2Session::RecvWindowUpdate %p lookup streamID 0x%X failed.\n",
             self, self->mInputFrameID));
       // only resest the session if the ID is one we haven't ever opened
-      if (self->mInputFrameID >= self->mNextStreamID)
+      if (self->mInputFrameID >= self->mNextStreamID) {
         self->GenerateRstStream(PROTOCOL_ERROR, self->mInputFrameID);
+      }
       self->ResetDownstreamState();
       return NS_OK;
     }
 
     if (delta == 0) {
       LOG3(("Http2Session::RecvWindowUpdate %p received 0 stream window update",
             self));
       self->CleanupStream(self->mInputFrameDataStream, NS_ERROR_ILLEGAL_VALUE,
@@ -2927,29 +2936,31 @@ nsresult Http2Session::ReadyToProcessDat
          this, mInputFrameID));
     return rv;
   }
   if (!mInputFrameDataStream) {
     LOG3(
         ("Http2Session::ReadyToProcessDataFrame %p lookup streamID 0x%X "
          "failed. Next = 0x%X",
          this, mInputFrameID, mNextStreamID));
-    if (mInputFrameID >= mNextStreamID)
+    if (mInputFrameID >= mNextStreamID) {
       GenerateRstStream(PROTOCOL_ERROR, mInputFrameID);
+    }
     ChangeDownstreamState(DISCARDING_DATA_FRAME);
   } else if (mInputFrameDataStream->RecvdFin() ||
              mInputFrameDataStream->RecvdReset() ||
              mInputFrameDataStream->SentReset()) {
     LOG3(
         ("Http2Session::ReadyToProcessDataFrame %p streamID 0x%X "
          "Data arrived for already server closed stream.\n",
          this, mInputFrameID));
     if (mInputFrameDataStream->RecvdFin() ||
-        mInputFrameDataStream->RecvdReset())
+        mInputFrameDataStream->RecvdReset()) {
       GenerateRstStream(STREAM_CLOSED_ERROR, mInputFrameID);
+    }
     ChangeDownstreamState(DISCARDING_DATA_FRAME);
   } else if (mInputFrameDataSize == 0 && !mInputFrameFinal) {
     // Only if non-final because the stream properly handles final frames of any
     // size, and we want the stream to be able to notice its own end flag.
     LOG3(
         ("Http2Session::ReadyToProcessDataFrame %p streamID 0x%X "
          "Ignoring 0-length non-terminal data frame.",
          this, mInputFrameID));
@@ -3200,17 +3211,18 @@ nsresult Http2Session::WriteSegmentsAgai
           mInputFrameID, mPaddingLength));
 
     if (1U + mPaddingLength > mInputFrameDataSize) {
       LOG3(
           ("Http2Session::WriteSegments %p stream 0x%X padding too large for "
            "frame",
            this, mInputFrameID));
       return SessionError(PROTOCOL_ERROR);
-    } else if (1U + mPaddingLength == mInputFrameDataSize) {
+    }
+    if (1U + mPaddingLength == mInputFrameDataSize) {
       // This frame consists entirely of padding, we can just discard it
       LOG3(
           ("Http2Session::WriteSegments %p stream 0x%X frame with only padding",
            this, mInputFrameID));
       rv = ReadyToProcessDataFrame(DISCARDING_DATA_FRAME_PADDING);
       if (NS_FAILED(rv)) {
         return rv;
       }
@@ -3368,17 +3380,17 @@ nsresult Http2Session::WriteSegmentsAgai
       if (streamToCleanup) {
         if (discardedPadding && !(streamToCleanup->StreamID() & 1)) {
           // Pushed streams are special on padding-only final data frames.
           // See bug 1409570 comments 6-8 for details.
           streamToCleanup->SetPushComplete();
           Http2Stream* pushSink = streamToCleanup->GetConsumerStream();
           if (pushSink) {
             bool enqueueSink = true;
-            for (auto s : mPushesReadyForRead) {
+            for (const auto& s : mPushesReadyForRead) {
               if (s == pushSink) {
                 enqueueSink = false;
                 break;
               }
             }
             if (enqueueSink) {
               AddStreamToQueue(pushSink, mPushesReadyForRead);
               // No use trying to clean up, it won't do anything, anyway
@@ -3564,18 +3576,20 @@ nsresult Http2Session::ProcessSlowConsum
     rv = NS_OK;
   }
 
   return rv;
 }
 
 void Http2Session::UpdateLocalStreamWindow(Http2Stream* stream,
                                            uint32_t bytes) {
-  if (!stream)  // this is ok - it means there was a data frame for a rst stream
+  if (!stream) {  // this is ok - it means there was a data frame for a rst
+                  // stream
     return;
+  }
 
   // If this data packet was not for a valid or live stream then there
   // is no reason to mess with the flow control
   if (!stream || stream->RecvdFin() || stream->RecvdReset() ||
       mInputFrameFinal) {
     return;
   }
 
@@ -3588,18 +3602,19 @@ void Http2Session::UpdateLocalStreamWind
 
   LOG3(
       ("Http2Session::UpdateLocalStreamWindow this=%p id=0x%X newbytes=%u "
        "unacked=%" PRIu64 " localWindow=%" PRId64 "\n",
        this, stream->StreamID(), bytes, unacked, localWindow));
 
   if (!unacked) return;
 
-  if ((unacked < kMinimumToAck) && (localWindow > kEmergencyWindowThreshold))
+  if ((unacked < kMinimumToAck) && (localWindow > kEmergencyWindowThreshold)) {
     return;
+  }
 
   if (!stream->HasSink()) {
     LOG3(
         ("Http2Session::UpdateLocalStreamWindow %p 0x%X Pushed Stream Has No "
          "Sink\n",
          this, stream->StreamID()));
     return;
   }
@@ -3638,18 +3653,19 @@ void Http2Session::UpdateLocalSessionWin
   LOG3(
       ("Http2Session::UpdateLocalSessionWindow this=%p newbytes=%u "
        "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))
+      (mLocalSessionWindow > kEmergencyWindowThreshold)) {
     return;
+  }
 
   // Only send max  bits of window updates at a time.
   uint64_t toack64 = mInitialRwin - mLocalSessionWindow;
   uint32_t toack = (toack64 <= 0x7fffffffU) ? toack64 : 0x7fffffffU;
 
   LOG3(("Http2Session::UpdateLocalSessionWindow Ack this=%p acksize=%u\n", this,
         toack));
   mLocalSessionWindow += toack;
@@ -3823,48 +3839,51 @@ nsresult Http2Session::OnReadSegment(con
   // queue if it fits. By coalescing multiple small submissions into one larger
   // buffer we can get larger writes out to the network later on.
 
   // This routine should not be allowed to fill up the output queue
   // all on its own - at least kQueueReserved bytes are always left
   // for other routines to use - but this is an all-or-nothing function,
   // so if it will not all fit just return WOULD_BLOCK
 
-  if ((mOutputQueueUsed + count) > (mOutputQueueSize - kQueueReserved))
+  if ((mOutputQueueUsed + count) > (mOutputQueueSize - kQueueReserved)) {
     return NS_BASE_STREAM_WOULD_BLOCK;
+  }
 
   memcpy(mOutputQueueBuffer.get() + mOutputQueueUsed, buf, count);
   mOutputQueueUsed += count;
   *countRead = count;
 
   FlushOutputQueue();
 
   return NS_OK;
 }
 
 nsresult Http2Session::CommitToSegmentSize(uint32_t count,
                                            bool forceCommitment) {
   if (mOutputQueueUsed && !mAttemptingEarlyData) FlushOutputQueue();
 
   // would there be enough room to buffer this if needed?
-  if ((mOutputQueueUsed + count) <= (mOutputQueueSize - kQueueReserved))
+  if ((mOutputQueueUsed + count) <= (mOutputQueueSize - kQueueReserved)) {
     return NS_OK;
+  }
 
   // if we are using part of our buffers already, try again later unless
   // forceCommitment is set.
   if (mOutputQueueUsed && !forceCommitment) return NS_BASE_STREAM_WOULD_BLOCK;
 
   if (mOutputQueueUsed) {
     // normally we avoid the memmove of RealignOutputQueue, but we'll try
     // it if forceCommitment is set before growing the buffer.
     RealignOutputQueue();
 
     // is there enough room now?
-    if ((mOutputQueueUsed + count) <= (mOutputQueueSize - kQueueReserved))
+    if ((mOutputQueueUsed + count) <= (mOutputQueueSize - kQueueReserved)) {
       return NS_OK;
+    }
   }
 
   // resize the buffers as needed
   EnsureOutputBuffer(count + kQueueReserved);
 
   MOZ_ASSERT((mOutputQueueUsed + count) <= (mOutputQueueSize - kQueueReserved),
              "buffer not as large as expected");
 
@@ -3928,18 +3947,19 @@ nsresult Http2Session::OnWriteSegment(ch
            this, mInputFrameID, mInputFrameDataSize, mInputFrameDataRead,
            paddingRead, mPaddingLength, *countWritten));
       *countWritten -= paddingRead;
       LOG3(("Http2Session::OnWriteSegment %p stream 0x%X new countWritten=%d",
             this, mInputFrameID, *countWritten));
     }
 
     mInputFrameDataStream->UpdateTransportReadEvents(*countWritten);
-    if ((mInputFrameDataRead == mInputFrameDataSize) && !mInputFrameFinal)
+    if ((mInputFrameDataRead == mInputFrameDataSize) && !mInputFrameFinal) {
       ResetDownstreamState();
+    }
 
     return rv;
   }
 
   if (mDownstreamState == PROCESSING_COMPLETE_HEADERS) {
     if (mFlatHTTPResponseHeaders.Length() == mFlatHTTPResponseHeadersOut &&
         mInputFrameFinal) {
       *countWritten = 0;
@@ -4201,17 +4221,18 @@ nsresult Http2Session::ConfirmTLSProfile
     return SessionError(INADEQUATE_SECURITY);
   }
 
   uint32_t keybits = ssl->GetKEAKeyBits();
   if (kea == ssl_kea_dh && keybits < 2048) {
     LOG3(("Http2Session::ConfirmTLSProfile %p FAILED due to DH %d < 2048\n",
           this, keybits));
     return SessionError(INADEQUATE_SECURITY);
-  } else if (kea == ssl_kea_ecdh && keybits < 224) {  // see rfc7540 9.2.1.
+  }
+  if (kea == ssl_kea_ecdh && keybits < 224) {  // see rfc7540 9.2.1.
     LOG3(("Http2Session::ConfirmTLSProfile %p FAILED due to ECDH %d < 224\n",
           this, keybits));
     return SessionError(INADEQUATE_SECURITY);
   }
 
   int16_t macAlgorithm = ssl->GetMACAlgorithmUsed();
   LOG3(("Http2Session::ConfirmTLSProfile %p MAC Algortihm (aead==6) %d\n", this,
         macAlgorithm));
@@ -4622,18 +4643,14 @@ void Http2Session::ProcessWaitingWebsock
   mWaitingWebsockets.Clear();
   mWaitingWebsocketCallbacks.Clear();
 }
 
 bool Http2Session::CanAcceptWebsocket() {
   LOG3(("Http2Session::CanAcceptWebsocket %p enable=%d allow=%d processed=%d",
         this, mEnableWebsockets, mPeerAllowsWebsockets,
         mProcessedWaitingWebsockets));
-  if (mEnableWebsockets &&
-      (mPeerAllowsWebsockets || !mProcessedWaitingWebsockets)) {
-    return true;
-  }
-
-  return false;
+  return mEnableWebsockets &&
+         (mPeerAllowsWebsockets || !mProcessedWaitingWebsockets);
 }
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/protocol/http/Http2Session.h
+++ b/netwerk/protocol/http/Http2Session.h
@@ -221,17 +221,17 @@ class Http2Session final : public ASpdyS
   void TransactionHasDataToWrite(nsAHttpTransaction*) override;
   void TransactionHasDataToRecv(nsAHttpTransaction*) override;
 
   // a similar version for Http2Stream
   void TransactionHasDataToWrite(Http2Stream*);
 
   // an overload of nsAHttpSegementReader
   [[nodiscard]] virtual nsresult CommitToSegmentSize(
-      uint32_t size, bool forceCommitment) override;
+      uint32_t count, bool forceCommitment) override;
   [[nodiscard]] nsresult BufferOutput(const char*, uint32_t, uint32_t*);
   void FlushOutputQueue();
   uint32_t AmountOfOutputBuffered() {
     return mOutputQueueUsed - mOutputQueueSent;
   }
 
   uint32_t GetServerInitialStreamWindow() { return mServerInitialStreamWindow; }
 
@@ -549,17 +549,18 @@ class Http2Session final : public ASpdyS
 
   bool mAttemptingEarlyData;
   // The ID(s) of the stream(s) that we are getting 0RTT data from.
   nsTArray<WeakPtr<Http2Stream>> m0RTTStreams;
   // The ID(s) of the stream(s) that are not able to send 0RTT data. We need to
   // remember them put them into mReadyForWrite queue when 0RTT finishes.
   nsTArray<WeakPtr<Http2Stream>> mCannotDo0RTTStreams;
 
-  bool RealJoinConnection(const nsACString& hostname, int32_t port, bool jk);
+  bool RealJoinConnection(const nsACString& hostname, int32_t port,
+                          bool justKidding);
   bool TestOriginFrame(const nsACString& name, int32_t port);
   bool mOriginFrameActivated;
   nsTHashMap<nsCStringHashKey, bool> mOriginFrame;
 
   nsTHashMap<nsCStringHashKey, bool> mJoinConnectionCache;
 
   uint64_t mCurrentTopBrowsingContextId;
 
--- a/netwerk/protocol/http/Http2Stream.cpp
+++ b/netwerk/protocol/http/Http2Stream.cpp
@@ -165,18 +165,19 @@ nsresult Http2Stream::ReadSegments(nsAHt
 
       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)
+          !mRequestHeadersDone) {
         mSession->TransactionHasDataToWrite(this);
+      }
 
       // mTxinlineFrameUsed represents any queued un-sent frame. It might
       // be 0 if there is no such frame, which is not a gurantee that we
       // don't have more request body to send - just that any data that was
       // sent comprised a complete HTTP/2 frame. Likewise, a non 0 value is
       // a queued, but complete, http/2 frame length.
 
       // Mark that we are blocked on read if the http transaction needs to
@@ -838,19 +839,20 @@ void Http2Stream::UpdateTransportSendEve
   // (10Mbit/sec @ 100ms)
   //
   uint32_t bufferSize = gHttpHandler->SpdySendBufferSize();
   if ((mTotalSent > bufferSize) && !mSetTCPSocketBuffer) {
     mSetTCPSocketBuffer = 1;
     mSocketTransport->SetSendBufferSize(bufferSize);
   }
 
-  if (mUpstreamState != SENDING_FIN_STREAM)
+  if (mUpstreamState != SENDING_FIN_STREAM) {
     mTransaction->OnTransportStatus(mSocketTransport, NS_NET_STATUS_SENDING_TO,
                                     mTotalSent);
+  }
 
   if (!mSentWaitingFor && !mRequestBodyLenRemaining) {
     mSentWaitingFor = 1;
     mTransaction->OnTransportStatus(mSocketTransport, NS_NET_STATUS_WAITING_FOR,
                                     0);
   }
 }
 
@@ -897,18 +899,19 @@ nsresult Http2Stream::TransmitFrame(cons
 
   rv = mSegmentReader->CommitToSegmentSize(
       mTxStreamFrameSize + mTxInlineFrameUsed, forceCommitment);
 
   if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
     MOZ_ASSERT(!forceCommitment, "forceCommitment with WOULD_BLOCK");
     mSession->TransactionHasDataToWrite(this);
   }
-  if (NS_FAILED(rv))  // this will include WOULD_BLOCK
+  if (NS_FAILED(rv)) {  // this will include WOULD_BLOCK
     return rv;
+  }
 
   // This function calls mSegmentReader->OnReadSegment to report the actual
   // http/2 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);
@@ -1470,24 +1473,27 @@ nsresult Http2Stream::OnReadSegment(cons
       }
       mBlockedOnRwin = false;
 
       // The chunk is the smallest of: availableData, configured chunkSize,
       // stream window, session window, or 14 bit framing limit.
       // Its amazing we send anything at all.
       dataLength = std::min(count, mChunkSize);
 
-      if (dataLength > Http2Session::kMaxFrameData)
+      if (dataLength > Http2Session::kMaxFrameData) {
         dataLength = Http2Session::kMaxFrameData;
+      }
 
-      if (dataLength > mSession->ServerSessionWindow())
+      if (dataLength > mSession->ServerSessionWindow()) {
         dataLength = static_cast<uint32_t>(mSession->ServerSessionWindow());
+      }
 
-      if (dataLength > mServerReceiveWindow)
+      if (dataLength > mServerReceiveWindow) {
         dataLength = static_cast<uint32_t>(mServerReceiveWindow);
+      }
 
       LOG3(
           ("Http2Stream this=%p id 0x%X send calculation "
            "avail=%d chunksize=%d stream window=%" PRId64
            " session window=%" PRId64 " "
            "max frame=%d USING=%u\n",
            this, mStreamID, count, mChunkSize, mServerReceiveWindow,
            mSession->ServerSessionWindow(), Http2Session::kMaxFrameData,
--- a/netwerk/protocol/http/Http2Stream.h
+++ b/netwerk/protocol/http/Http2Stream.h
@@ -167,17 +167,17 @@ class Http2Stream : public nsAHttpSegmen
                                               nsCOMPtr<nsIURI>& url);
 
   [[nodiscard]] static nsresult MakeOriginURL(const nsACString& scheme,
                                               const nsACString& origin,
                                               nsCOMPtr<nsIURI>& url);
 
   // Mirrors nsAHttpTransaction
   bool Do0RTT();
-  nsresult Finish0RTT(bool aRestart, bool aAlpnIgnored);
+  nsresult Finish0RTT(bool aRestart, bool aAlpnChanged);
 
   nsresult GetOriginAttributes(mozilla::OriginAttributes* oa);
 
   virtual void TopBrowsingContextIdChanged(uint64_t id);
   void TopBrowsingContextIdChangedInternal(
       uint64_t id);  // For use by pushed streams only
 
  protected:
@@ -237,18 +237,18 @@ class Http2Stream : public nsAHttpSegmen
 
   virtual void AdjustInitialWindow();
   [[nodiscard]] nsresult TransmitFrame(const char*, uint32_t*,
                                        bool forceCommitment);
 
   // The underlying socket transport object is needed to propogate some events
   nsISocketTransport* mSocketTransport;
 
-  uint8_t mPriorityWeight;       // h2 weight
-  uint32_t mPriorityDependency;  // h2 stream id this one depends on
+  uint8_t mPriorityWeight = 0;       // h2 weight
+  uint32_t mPriorityDependency = 0;  // h2 stream id this one depends on
   uint64_t mCurrentTopBrowsingContextId;
   uint64_t mTransactionTabId;
 
  private:
   friend class mozilla::DefaultDelete<Http2Stream>;
 
   [[nodiscard]] nsresult ParseHttpRequestHeaders(const char*, uint32_t,
                                                  uint32_t*);
@@ -320,17 +320,17 @@ class Http2Stream : public nsAHttpSegmen
   // Track the content-length of a request body so that we can
   // place the fin flag on the last data packet instead of waiting
   // for a stream closed indication. Relying on stream close results
   // in an extra 0-length runt packet and seems to have some interop
   // problems with the google servers. Connect does rely on stream
   // close by setting this to the max value.
   int64_t mRequestBodyLenRemaining;
 
-  uint32_t mPriority;  // geckoish weight
+  uint32_t mPriority = 0;  // geckoish weight
 
   // mClientReceiveWindow, mServerReceiveWindow, and mLocalUnacked are for flow
   // control. *window are signed because the race conditions in asynchronous
   // SETTINGS messages can force them temporarily negative.
 
   // mClientReceiveWindow is how much data the server will send without getting
   // a
   //   window update
--- a/netwerk/protocol/http/Http3Session.cpp
+++ b/netwerk/protocol/http/Http3Session.cpp
@@ -355,17 +355,17 @@ nsresult Http3Session::ProcessTransactio
 
 nsresult Http3Session::ProcessEvents() {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
 
   LOG(("Http3Session::ProcessEvents [this=%p]", this));
 
   // We need an array to pick up header data or a resumption token.
   nsTArray<uint8_t> data;
-  Http3Event event;
+  Http3Event event{};
   event.tag = Http3Event::Tag::NoEvent;
 
   nsresult rv = mHttp3Connection->GetEvent(&event, data);
   if (NS_FAILED(rv)) {
     LOG(("Http3Session::ProcessEvents [this=%p] rv=%" PRIx32, this,
          static_cast<uint32_t>(rv)));
     return rv;
   }
@@ -740,19 +740,18 @@ bool Http3Session::AddStream(nsAHttpTran
   if (mState == ZERORTT) {
     if (!stream->Do0RTT()) {
       LOG(("Http3Session %p will not get early data from Http3Stream %p", this,
            stream));
       if (!mCannotDo0RTTStreams.Contains(stream)) {
         mCannotDo0RTTStreams.AppendElement(stream);
       }
       return true;
-    } else {
-      m0RTTStreams.AppendElement(stream);
     }
+    m0RTTStreams.AppendElement(stream);
   }
 
   if (!mFirstHttpTransaction && !IsConnected()) {
     mFirstHttpTransaction = aHttpTransaction->QueryHttpTransaction();
     LOG3(("Http3Session::AddStream first session=%p trans=%p ", this,
           mFirstHttpTransaction.get()));
   }
 
@@ -1754,17 +1753,17 @@ void Http3Session::CloseConnectionTeleme
       value = GetAppErrorCodeForTelemetry(aError.app_error._0);
       break;
   }
 
   key.Append(aClosing ? "_closing"_ns : "_closed"_ns);
 
   Telemetry::Accumulate(Telemetry::HTTP3_CONNECTION_CLOSE_CODE_3, key, value);
 
-  Http3Stats stats;
+  Http3Stats stats{};
   mHttp3Connection->GetStats(&stats);
 
   if (stats.packets_tx > 0) {
     unsigned long loss = (stats.lost * 10000) / stats.packets_tx;
     Telemetry::Accumulate(Telemetry::HTTP3_LOSS_RATIO, loss);
 
     Telemetry::Accumulate(Telemetry::HTTP3_LATE_ACK, "ack"_ns, stats.late_ack);
     Telemetry::Accumulate(Telemetry::HTTP3_LATE_ACK, "pto"_ns, stats.pto_ack);
--- a/netwerk/protocol/http/Http3Session.h
+++ b/netwerk/protocol/http/Http3Session.h
@@ -55,19 +55,19 @@ class Http3Session final : public nsAHtt
 
   bool AddStream(nsAHttpTransaction* aHttpTransaction, int32_t aPriority,
                  nsIInterfaceRequestor* aCallbacks);
 
   bool CanReuse();
 
   // The folowing functions are used by Http3Stream:
   nsresult TryActivating(const nsACString& aMethod, const nsACString& aScheme,
-                         const nsACString& aHost, const nsACString& aPath,
-                         const nsACString& aHeaders, uint64_t* aStreamId,
-                         Http3Stream* aStream);
+                         const nsACString& aAuthorityHeader,
+                         const nsACString& aPath, const nsACString& aHeaders,
+                         uint64_t* aStreamId, Http3Stream* aStream);
   void CloseSendingSide(uint64_t aStreamId);
   nsresult SendRequestBody(uint64_t aStreamId, const char* buf, uint32_t count,
                            uint32_t* countRead);
   nsresult ReadResponseHeaders(uint64_t aStreamId,
                                nsTArray<uint8_t>& aResponseHeaders, bool* aFin);
   nsresult ReadResponseData(uint64_t aStreamId, char* aBuf, uint32_t aCount,
                             uint32_t* aCountWritten, bool* aFin);
 
--- a/netwerk/protocol/http/HttpBackgroundChannelChild.h
+++ b/netwerk/protocol/http/HttpBackgroundChannelChild.h
@@ -134,17 +134,17 @@ class HttpBackgroundChannelChild final :
     ODA_FROM_SOCKET = 2   // response coming from the network
   };
   // We need to know the first ODA will be from socket process or parent
   // process. This information is from OnStartRequest message from parent
   // process.
   ODASource mFirstODASource;
 
   // Indicate whether HttpChannelChild::ProcessOnStopRequest is called.
-  bool mOnStopRequestCalled;
+  bool mOnStopRequestCalled = false;
 
   // This is used when we receive the console report from parent process, but
   // still not get the OnStopRequest from socket process.
   std::function<void()> mConsoleReportTask;
 };
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -490,18 +490,18 @@ class HttpBaseChannel : public nsHashPro
 
     uint32_t redirectFlags = 0;
     uint32_t classOfService = 0;
     Maybe<bool> privateBrowsing = Nothing();
     Maybe<nsCString> method;
     nsCOMPtr<nsIReferrerInfo> referrerInfo;
     Maybe<dom::TimedChannelInfo> timedChannel;
     nsCOMPtr<nsIInputStream> uploadStream;
-    uint64_t uploadStreamLength;
-    bool uploadStreamHasHeaders;
+    uint64_t uploadStreamLength = 0;
+    bool uploadStreamHasHeaders = false;
     Maybe<nsCString> contentType;
     Maybe<nsCString> contentLength;
 
     dom::ReplacementChannelConfigInit Serialize(dom::ContentParent* aParent);
   };
 
   enum class ReplacementReason {
     Redirect,
@@ -1017,18 +1017,19 @@ inline void HttpAsyncAborter<T>::HandleA
       return NS_OK;
     };
     return;
   }
 
   mThis->DoNotifyListener();
 
   // finally remove ourselves from the load group.
-  if (mThis->mLoadGroup)
+  if (mThis->mLoadGroup) {
     mThis->mLoadGroup->RemoveRequest(mThis, nullptr, mThis->mStatus);
+  }
 }
 
 template <class T>
 nsresult HttpAsyncAborter<T>::AsyncCall(void (T::*funcPtr)(),
                                         nsRunnableMethod<T>** retval) {
   nsresult rv;
 
   RefPtr<nsRunnableMethod<T>> event =
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -415,18 +415,19 @@ void HttpChannelChild::OnStartRequest(
   if (!mCanceled && NS_SUCCEEDED(mStatus)) {
     mStatus = aArgs.channelStatus();
   }
 
   // Cookies headers should not be visible to the child process
   MOZ_ASSERT(!aRequestHeaders.HasHeader(nsHttp::Cookie));
   MOZ_ASSERT(!nsHttpResponseHead(aResponseHead).HasHeader(nsHttp::Set_Cookie));
 
-  if (aUseResponseHead && !mCanceled)
+  if (aUseResponseHead && !mCanceled) {
     mResponseHead = MakeUnique<nsHttpResponseHead>(aResponseHead);
+  }
 
   if (!aArgs.securityInfoSerialization().IsEmpty()) {
     [[maybe_unused]] nsresult rv = NS_DeserializeObject(
         aArgs.securityInfoSerialization(), getter_AddRefs(mSecurityInfo));
     MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv),
                           "Deserializing security info should not fail");
   }
 
@@ -1794,20 +1795,21 @@ HttpChannelChild::OnRedirectVerifyCallba
   nsCOMPtr<nsIChannel> newChannel = do_QueryInterface(mRedirectChannelChild);
   if (newChannel) {
     ChildLoadInfoForwarderArgs args;
     nsCOMPtr<ns