diff --git a/netwerk/base/ArrayBufferInputStream.cpp b/netwerk/base/ArrayBufferInputStream.cpp index 57056e55bfab..fb86d4446987 100644 --- a/netwerk/base/ArrayBufferInputStream.cpp +++ b/netwerk/base/ArrayBufferInputStream.cpp @@ -17,9 +17,6 @@ using mozilla::dom::RootingCx; NS_IMPL_ISUPPORTS(ArrayBufferInputStream, nsIArrayBufferInputStream, nsIInputStream); -ArrayBufferInputStream::ArrayBufferInputStream() - : mBufferLength(0), mPos(0), mClosed(false) {} - NS_IMETHODIMP ArrayBufferInputStream::SetData(JS::Handle aBuffer, uint64_t aByteOffset, uint64_t aLength) { diff --git a/netwerk/base/ArrayBufferInputStream.h b/netwerk/base/ArrayBufferInputStream.h index e38a09676487..3a4811373dbe 100644 --- a/netwerk/base/ArrayBufferInputStream.h +++ b/netwerk/base/ArrayBufferInputStream.h @@ -23,7 +23,7 @@ class ArrayBufferInputStream : public nsIArrayBufferInputStream { public: - ArrayBufferInputStream(); + ArrayBufferInputStream() = default; NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIARRAYBUFFERINPUTSTREAM @@ -32,9 +32,9 @@ class ArrayBufferInputStream : public nsIArrayBufferInputStream { private: virtual ~ArrayBufferInputStream() = default; mozilla::UniquePtr mArrayBuffer; - uint32_t mBufferLength; - uint32_t mPos; - bool mClosed; + uint32_t mBufferLength{0}; + uint32_t mPos{0}; + bool mClosed{false}; }; #endif // ArrayBufferInputStream_h diff --git a/netwerk/base/BackgroundFileSaver.cpp b/netwerk/base/BackgroundFileSaver.cpp index 7c77038f08a5..ea89b8d22c16 100644 --- a/netwerk/base/BackgroundFileSaver.cpp +++ b/netwerk/base/BackgroundFileSaver.cpp @@ -82,27 +82,7 @@ class NotifyTargetChangeRunnable final : public Runnable { uint32_t BackgroundFileSaver::sThreadCount = 0; uint32_t BackgroundFileSaver::sTelemetryMaxThreadCount = 0; -BackgroundFileSaver::BackgroundFileSaver() - : mControlEventTarget(nullptr), - mBackgroundET(nullptr), - mPipeOutputStream(nullptr), - mPipeInputStream(nullptr), - mObserver(nullptr), - mLock("BackgroundFileSaver.mLock"), - mWorkerThreadAttentionRequested(false), - mFinishRequested(false), - mComplete(false), - mStatus(NS_OK), - mAppend(false), - mInitialTarget(nullptr), - mInitialTargetKeepPartial(false), - mRenamedTarget(nullptr), - mRenamedTargetKeepPartial(false), - mAsyncCopyContext(nullptr), - mSha256Enabled(false), - mSignatureInfoEnabled(false), - mActualTarget(nullptr), - mActualTargetKeepPartial(false) { +BackgroundFileSaver::BackgroundFileSaver() { LOG(("Created BackgroundFileSaver [this = %p]", this)); } @@ -931,13 +911,6 @@ BackgroundFileSaverOutputStream::OnOutputStreamReady( NS_IMPL_ISUPPORTS(BackgroundFileSaverStreamListener, nsIBackgroundFileSaver, nsIRequestObserver, nsIStreamListener) -BackgroundFileSaverStreamListener::BackgroundFileSaverStreamListener() - : BackgroundFileSaver(), - mSuspensionLock("BackgroundFileSaverStreamListener.mSuspensionLock"), - mReceivedTooMuchData(false), - mRequest(nullptr), - mRequestSuspended(false) {} - bool BackgroundFileSaverStreamListener::HasInfiniteBuffer() { return true; } nsAsyncCopyProgressFun diff --git a/netwerk/base/BackgroundFileSaver.h b/netwerk/base/BackgroundFileSaver.h index 0ac247786f9d..5edce2e1d65c 100644 --- a/netwerk/base/BackgroundFileSaver.h +++ b/netwerk/base/BackgroundFileSaver.h @@ -117,22 +117,22 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * Protects the shared state between control and worker threads. This mutex * is always locked for a very short time, never during input/output. */ - mozilla::Mutex mLock; + mozilla::Mutex mLock{"BackgroundFileSaver.mLock"}; /** * True if the worker thread is already waiting to process a change in state. */ - bool mWorkerThreadAttentionRequested; + bool mWorkerThreadAttentionRequested{false}; /** * True if the operation should finish as soon as possibile. */ - bool mFinishRequested; + bool mFinishRequested{false}; /** * True if the operation completed, with either success or failure. */ - bool mComplete; + bool mComplete{false}; /** * Holds the current file saver status. This is a success status while the @@ -140,13 +140,13 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * successfully. This becomes an error status when an error occurs on the * worker thread, or when the operation is canceled. */ - nsresult mStatus; + nsresult mStatus{NS_OK}; /** * True if we should append data to the initial target file, instead of * overwriting it. */ - bool mAppend; + bool mAppend{false}; /** * This is set by the first SetTarget call on the control thread, and contains @@ -161,7 +161,7 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * indicates whether mInitialTarget should be kept as partially completed, * rather than deleted, if the operation fails or is canceled. */ - bool mInitialTargetKeepPartial; + bool mInitialTargetKeepPartial{false}; /** * This is set by subsequent SetTarget calls on the control thread, and @@ -179,7 +179,7 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * indicates whether mRenamedTarget should be kept as partially completed, * rather than deleted, if the operation fails or is canceled. */ - bool mRenamedTargetKeepPartial; + bool mRenamedTargetKeepPartial{false}; /** * While NS_AsyncCopy is in progress, allows canceling it. Null otherwise. @@ -197,7 +197,7 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * Whether or not to compute the hash. Must be set on the main thread before * setTarget is called. */ - bool mSha256Enabled; + bool mSha256Enabled{false}; /** * Store the signature info. @@ -208,7 +208,7 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * Whether or not to extract the signature. Must be set on the main thread * before setTarget is called. */ - bool mSignatureInfoEnabled; + bool mSignatureInfoEnabled{false}; ////////////////////////////////////////////////////////////////////////////// //// State handled exclusively by the worker thread @@ -222,7 +222,7 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * Indicates whether mActualTarget should be kept as partially completed, * rather than deleted, if the operation fails or is canceled. */ - bool mActualTargetKeepPartial; + bool mActualTargetKeepPartial{false}; /** * Used to calculate the file hash. This keeps state across file renames and @@ -327,7 +327,7 @@ class BackgroundFileSaverStreamListener final : public BackgroundFileSaver, NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER - BackgroundFileSaverStreamListener(); + BackgroundFileSaverStreamListener() = default; protected: virtual bool HasInfiniteBuffer() override; @@ -339,12 +339,13 @@ class BackgroundFileSaverStreamListener final : public BackgroundFileSaver, /** * Protects the state related to whether the request should be suspended. */ - mozilla::Mutex mSuspensionLock; + mozilla::Mutex mSuspensionLock{ + "BackgroundFileSaverStreamListener.mSuspensionLock"}; /** * Whether we should suspend the request because we received too much data. */ - bool mReceivedTooMuchData; + bool mReceivedTooMuchData{false}; /** * Request for which we received too much data. This is populated when @@ -355,7 +356,7 @@ class BackgroundFileSaverStreamListener final : public BackgroundFileSaver, /** * Whether mRequest is currently suspended. */ - bool mRequestSuspended; + bool mRequestSuspended{false}; /** * Called while NS_AsyncCopy is copying data. diff --git a/netwerk/base/Dashboard.cpp b/netwerk/base/Dashboard.cpp index eae01b4a8a2a..9d67ded12765 100644 --- a/netwerk/base/Dashboard.cpp +++ b/netwerk/base/Dashboard.cpp @@ -38,17 +38,13 @@ class SocketData : public nsISupports { public: NS_DECL_THREADSAFE_ISUPPORTS - SocketData() { - mTotalSent = 0; - mTotalRecv = 0; - mEventTarget = nullptr; - } + SocketData() = default; - uint64_t mTotalSent; - uint64_t mTotalRecv; + uint64_t mTotalSent{0}; + uint64_t mTotalRecv{0}; nsTArray mData; nsMainThreadPtrHandle mCallback; - nsIEventTarget* mEventTarget; + nsIEventTarget* mEventTarget{nullptr}; private: virtual ~SocketData() = default; @@ -64,11 +60,11 @@ class HttpData : public nsISupports { public: NS_DECL_THREADSAFE_ISUPPORTS - HttpData() { mEventTarget = nullptr; } + HttpData() = default; nsTArray mData; nsMainThreadPtrHandle mCallback; - nsIEventTarget* mEventTarget; + nsIEventTarget* mEventTarget{nullptr}; }; NS_IMPL_ISUPPORTS0(HttpData) @@ -79,10 +75,10 @@ class WebSocketRequest : public nsISupports { public: NS_DECL_THREADSAFE_ISUPPORTS - WebSocketRequest() { mEventTarget = nullptr; } + WebSocketRequest() = default; nsMainThreadPtrHandle mCallback; - nsIEventTarget* mEventTarget; + nsIEventTarget* mEventTarget{nullptr}; }; NS_IMPL_ISUPPORTS0(WebSocketRequest) @@ -93,11 +89,11 @@ class DnsData : public nsISupports { public: NS_DECL_THREADSAFE_ISUPPORTS - DnsData() { mEventTarget = nullptr; } + DnsData() = default; nsTArray mData; nsMainThreadPtrHandle mCallback; - nsIEventTarget* mEventTarget; + nsIEventTarget* mEventTarget{nullptr}; }; NS_IMPL_ISUPPORTS0(DnsData) @@ -124,22 +120,19 @@ class ConnectionData : public nsITransportEventSink, void StartTimer(uint32_t aTimeout); void StopTimer(); - explicit ConnectionData(Dashboard* target) : mPort(0), mTimeout(0) { - mEventTarget = nullptr; - mDashboard = target; - } + explicit ConnectionData(Dashboard* target) { mDashboard = target; } nsCOMPtr mSocket; nsCOMPtr mStreamIn; nsCOMPtr mTimer; nsMainThreadPtrHandle mCallback; - nsIEventTarget* mEventTarget; + nsIEventTarget* mEventTarget{nullptr}; Dashboard* mDashboard; nsCString mHost; - uint32_t mPort; + uint32_t mPort{0}; nsCString mProtocol; - uint32_t mTimeout; + uint32_t mTimeout{0}; nsString mStatus; }; @@ -153,10 +146,10 @@ class RcwnData : public nsISupports { public: NS_DECL_THREADSAFE_ISUPPORTS - RcwnData() { mEventTarget = nullptr; } + RcwnData() = default; nsMainThreadPtrHandle mCallback; - nsIEventTarget* mEventTarget; + nsIEventTarget* mEventTarget{nullptr}; }; NS_IMPL_ISUPPORTS0(RcwnData) @@ -243,7 +236,7 @@ class LookupHelper final : public nsIDNSListener { NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIDNSLISTENER - LookupHelper() : mEventTarget{nullptr}, mStatus{NS_ERROR_NOT_INITIALIZED} {} + LookupHelper() = default; nsresult ConstructAnswer(LookupArgument* aArgument); nsresult ConstructHTTPSRRAnswer(LookupArgument* aArgument); @@ -251,8 +244,8 @@ class LookupHelper final : public nsIDNSListener { public: nsCOMPtr mCancel; nsMainThreadPtrHandle mCallback; - nsIEventTarget* mEventTarget; - nsresult mStatus; + nsIEventTarget* mEventTarget{nullptr}; + nsresult mStatus{NS_ERROR_NOT_INITIALIZED}; }; NS_IMPL_ISUPPORTS(LookupHelper, nsIDNSListener) diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index aef56488327c..00640fda14b6 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -104,7 +104,7 @@ LoadInfo::LoadInfo( mLoadingContext(do_GetWeakReference(aLoadingContext)), mSecurityFlags(aSecurityFlags), mSandboxFlags(aSandboxFlags), - mTriggeringSandboxFlags(0), + mInternalContentPolicyType(aContentPolicyType) { MOZ_ASSERT(mLoadingPrincipal); MOZ_ASSERT(mTriggeringPrincipal); @@ -320,7 +320,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow, mContextForTopLevelLoad(do_GetWeakReference(aContextForTopLevelLoad)), mSecurityFlags(aSecurityFlags), mSandboxFlags(aSandboxFlags), - mTriggeringSandboxFlags(0), + mInternalContentPolicyType(nsIContentPolicy::TYPE_DOCUMENT) { // Top-level loads are never third-party // Grab the information we can out of the window. @@ -379,7 +379,7 @@ LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext, : mTriggeringPrincipal(aTriggeringPrincipal), mSecurityFlags(aSecurityFlags), mSandboxFlags(aSandboxFlags), - mTriggeringSandboxFlags(0), + mInternalContentPolicyType(nsIContentPolicy::TYPE_DOCUMENT) { // Top-level loads are never third-party // Grab the information we can out of the window. @@ -575,9 +575,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs) mForcePreflight(rhs.mForcePreflight), mIsPreflight(rhs.mIsPreflight), mLoadTriggeredFromExternal(rhs.mLoadTriggeredFromExternal), - // mServiceWorkerTaintingSynthesized must be handled specially during - // redirect - mServiceWorkerTaintingSynthesized(false), + mDocumentHasUserInteracted(rhs.mDocumentHasUserInteracted), mAllowListFutureDocumentsCreatedFromThisRedirectChain( rhs.mAllowListFutureDocumentsCreatedFromThisRedirectChain), @@ -702,9 +700,7 @@ LoadInfo::LoadInfo( mParserCreatedScript(aParserCreatedScript), mHasStoragePermission(aHasStoragePermission), mIsMetaRefresh(aIsMetaRefresh), - mIsFromProcessingFrameAttributes(false), - mIsMediaRequest(false), - mIsMediaInitialRequest(false), + mLoadingEmbedderPolicy(aLoadingEmbedderPolicy), mUnstrippedURI(aUnstrippedURI) { // Only top level TYPE_DOCUMENT loads can have a null loadingPrincipal diff --git a/netwerk/base/PollableEvent.cpp b/netwerk/base/PollableEvent.cpp index b483ee6cd040..af6e052bedf1 100644 --- a/netwerk/base/PollableEvent.cpp +++ b/netwerk/base/PollableEvent.cpp @@ -138,11 +138,8 @@ failed: #endif PollableEvent::PollableEvent() - : mWriteFD(nullptr), - mReadFD(nullptr), - mSignaled(false), - mWriteFailed(false), - mSignalTimestampAdjusted(false) { + +{ MOZ_COUNT_CTOR(PollableEvent); MOZ_ASSERT(OnSocketThread(), "not on socket thread"); // create pair of prfiledesc that can be used as a poll()ble diff --git a/netwerk/base/PollableEvent.h b/netwerk/base/PollableEvent.h index feb637f6cc85..6a17cd909d75 100644 --- a/netwerk/base/PollableEvent.h +++ b/netwerk/base/PollableEvent.h @@ -46,16 +46,16 @@ class PollableEvent { PRFileDesc* PollableFD() { return mReadFD; } private: - PRFileDesc* mWriteFD; - PRFileDesc* mReadFD; - bool mSignaled; + PRFileDesc* mWriteFD{nullptr}; + PRFileDesc* mReadFD{nullptr}; + bool mSignaled{false}; // true when PR_Write to the socket pair has failed (status < 1) - bool mWriteFailed; + bool mWriteFailed{false}; // Set true after AdjustFirstSignalTimestamp() was called // Set false after Clear() was called // Ensures shifting the timestamp before entering poll() only once // between Clear()'ings. - bool mSignalTimestampAdjusted; + bool mSignalTimestampAdjusted{false}; // Timestamp of the first call to Signal() (or time we enter poll()) // that happened after the last Clear() call TimeStamp mFirstSignalAfterClear; diff --git a/netwerk/base/Predictor.cpp b/netwerk/base/Predictor.cpp index 77f45c715ccf..a31fa743bbb6 100644 --- a/netwerk/base/Predictor.cpp +++ b/netwerk/base/Predictor.cpp @@ -229,10 +229,8 @@ NS_IMPL_ISUPPORTS(Predictor, nsINetworkPredictor, nsIObserver, nsICacheEntryMetaDataVisitor, nsINetworkPredictorVerifier) Predictor::Predictor() - : mInitialized(false), - mStartupTime(0), - mLastStartupTime(0), - mStartupCount(1) { + +{ MOZ_ASSERT(!sSelf, "multiple Predictor instances!"); sSelf = this; } diff --git a/netwerk/base/Predictor.h b/netwerk/base/Predictor.h index 78a3008a7fdb..3d2646e56615 100644 --- a/netwerk/base/Predictor.h +++ b/netwerk/base/Predictor.h @@ -427,7 +427,7 @@ class Predictor final : public nsINetworkPredictor, uint32_t ClampedPrefetchRollingLoadCount(); // Our state - bool mInitialized; + bool mInitialized{false}; nsTArray mKeysToOperateOn; nsTArray mValuesToOperateOn; @@ -437,9 +437,9 @@ class Predictor final : public nsINetworkPredictor, nsCOMPtr mSpeculativeService; nsCOMPtr mStartupURI; - uint32_t mStartupTime; - uint32_t mLastStartupTime; - int32_t mStartupCount; + uint32_t mStartupTime{0}; + uint32_t mLastStartupTime{0}; + int32_t mStartupCount{1}; nsCOMPtr mDnsService; diff --git a/netwerk/base/ProxyAutoConfig.cpp b/netwerk/base/ProxyAutoConfig.cpp index 10135ee7cae2..3f586acc9367 100644 --- a/netwerk/base/ProxyAutoConfig.cpp +++ b/netwerk/base/ProxyAutoConfig.cpp @@ -430,11 +430,8 @@ static bool PACResolve(const nsCString& aHostName, NetAddr* aNetAddr, } ProxyAutoConfig::ProxyAutoConfig() - : mJSContext(nullptr), - mJSNeedsSetup(false), - mShutdown(true), - mIncludePath(false), - mExtraHeapSize(0) { + +{ MOZ_COUNT_CTOR(ProxyAutoConfig); } diff --git a/netwerk/base/ProxyAutoConfig.h b/netwerk/base/ProxyAutoConfig.h index 33f7c8c85d6c..9cbd0db12c58 100644 --- a/netwerk/base/ProxyAutoConfig.h +++ b/netwerk/base/ProxyAutoConfig.h @@ -89,13 +89,13 @@ class ProxyAutoConfig { bool MyIPAddressTryHost(const nsCString& hostName, unsigned int timeout, const JS::CallArgs& aArgs, bool* aResult); - JSContextWrapper* mJSContext; - bool mJSNeedsSetup; - bool mShutdown; + JSContextWrapper* mJSContext{nullptr}; + bool mJSNeedsSetup{false}; + bool mShutdown{true}; nsCString mConcatenatedPACData; nsCString mPACURI; - bool mIncludePath; - uint32_t mExtraHeapSize; + bool mIncludePath{false}; + uint32_t mExtraHeapSize{0}; nsCString mRunningHost; nsCOMPtr mTimer; nsCOMPtr mMainThreadEventTarget; diff --git a/netwerk/base/RequestContextService.cpp b/netwerk/base/RequestContextService.cpp index e6ee3281d9de..3a7774b4f61d 100644 --- a/netwerk/base/RequestContextService.cpp +++ b/netwerk/base/RequestContextService.cpp @@ -423,8 +423,7 @@ RequestContextService* RequestContextService::sSelf = nullptr; NS_IMPL_ISUPPORTS(RequestContextService, nsIRequestContextService, nsIObserver) -RequestContextService::RequestContextService() - : mRCIDNamespace(0), mNextRCID(1) { +RequestContextService::RequestContextService() { MOZ_ASSERT(!sSelf, "multiple rcs instances!"); MOZ_ASSERT(NS_IsMainThread()); sSelf = this; diff --git a/netwerk/base/RequestContextService.h b/netwerk/base/RequestContextService.h index e862969ff183..4aafdb8ed683 100644 --- a/netwerk/base/RequestContextService.h +++ b/netwerk/base/RequestContextService.h @@ -34,8 +34,8 @@ class RequestContextService final : public nsIRequestContextService, static RequestContextService* sSelf; nsInterfaceHashtable mTable; - uint32_t mRCIDNamespace; - uint32_t mNextRCID; + uint32_t mRCIDNamespace{0}; + uint32_t mNextRCID{1}; }; } // namespace net diff --git a/netwerk/base/SSLTokensCache.cpp b/netwerk/base/SSLTokensCache.cpp index 5eaa8cc81c44..b3565d24a0c9 100644 --- a/netwerk/base/SSLTokensCache.cpp +++ b/netwerk/base/SSLTokensCache.cpp @@ -110,9 +110,7 @@ nsresult SSLTokensCache::Shutdown() { return NS_OK; } -SSLTokensCache::SSLTokensCache() : mCacheSize(0) { - LOG(("SSLTokensCache::SSLTokensCache")); -} +SSLTokensCache::SSLTokensCache() { LOG(("SSLTokensCache::SSLTokensCache")); } SSLTokensCache::~SSLTokensCache() { LOG(("SSLTokensCache::~SSLTokensCache")); } diff --git a/netwerk/base/SSLTokensCache.h b/netwerk/base/SSLTokensCache.h index 47e662c19fc8..6a41c39f0ca1 100644 --- a/netwerk/base/SSLTokensCache.h +++ b/netwerk/base/SSLTokensCache.h @@ -65,7 +65,7 @@ class SSLTokensCache : public nsIMemoryReporter { static mozilla::StaticRefPtr gInstance; static StaticMutex sLock; - uint32_t mCacheSize; // Actual cache size in bytes + uint32_t mCacheSize{0}; // Actual cache size in bytes class TokenCacheRecord { public: diff --git a/netwerk/base/SimpleBuffer.cpp b/netwerk/base/SimpleBuffer.cpp index 1791a34b5990..46b8654efa17 100644 --- a/netwerk/base/SimpleBuffer.cpp +++ b/netwerk/base/SimpleBuffer.cpp @@ -10,8 +10,6 @@ namespace mozilla { namespace net { -SimpleBuffer::SimpleBuffer() : mStatus(NS_OK), mAvailable(0) {} - nsresult SimpleBuffer::Write(char* src, size_t len) { NS_ASSERT_OWNINGTHREAD(SimpleBuffer); if (NS_FAILED(mStatus)) { diff --git a/netwerk/base/SimpleBuffer.h b/netwerk/base/SimpleBuffer.h index 161df5bf347c..d72d0e07725d 100644 --- a/netwerk/base/SimpleBuffer.h +++ b/netwerk/base/SimpleBuffer.h @@ -21,19 +21,19 @@ namespace net { class SimpleBufferPage : public LinkedListElement { public: - SimpleBufferPage() : mReadOffset(0), mWriteOffset(0) {} + SimpleBufferPage() = default; static const size_t kSimpleBufferPageSize = 32000; private: friend class SimpleBuffer; char mBuffer[kSimpleBufferPageSize]{0}; - size_t mReadOffset; - size_t mWriteOffset; + size_t mReadOffset{0}; + size_t mWriteOffset{0}; }; class SimpleBuffer { public: - SimpleBuffer(); + SimpleBuffer() = default; ~SimpleBuffer() = default; nsresult Write(char* src, size_t len); // return OK or OUT_OF_MEMORY @@ -44,9 +44,9 @@ class SimpleBuffer { private: NS_DECL_OWNINGTHREAD - nsresult mStatus; + nsresult mStatus{NS_OK}; AutoCleanLinkedList mBufferList; - size_t mAvailable; + size_t mAvailable{0}; }; } // namespace net diff --git a/netwerk/base/TLSServerSocket.cpp b/netwerk/base/TLSServerSocket.cpp index ff4049b316ab..66b0a990c70b 100644 --- a/netwerk/base/TLSServerSocket.cpp +++ b/netwerk/base/TLSServerSocket.cpp @@ -26,8 +26,6 @@ namespace net { // TLSServerSocket //----------------------------------------------------------------------------- -TLSServerSocket::TLSServerSocket() : mServerCert(nullptr) {} - NS_IMPL_ISUPPORTS_INHERITED(TLSServerSocket, nsServerSocket, nsITLSServerSocket) nsresult TLSServerSocket::SetSocketDefaults() { @@ -267,16 +265,6 @@ TLSServerSecurityObserverProxy::OnHandshakeDoneRunnable::Run() { NS_IMPL_ISUPPORTS(TLSServerConnectionInfo, nsITLSServerConnectionInfo, nsITLSClientStatus) -TLSServerConnectionInfo::TLSServerConnectionInfo() - : mServerSocket(nullptr), - mTransport(nullptr), - mPeerCert(nullptr), - mTlsVersionUsed(TLS_VERSION_UNKNOWN), - mKeyLength(0), - mMacLength(0), - mLock("TLSServerConnectionInfo.mLock"), - mSecurityObserver(nullptr) {} - TLSServerConnectionInfo::~TLSServerConnectionInfo() { RefPtr observer; { diff --git a/netwerk/base/TLSServerSocket.h b/netwerk/base/TLSServerSocket.h index 5baba8ee4ac6..be8dd22d3e5d 100644 --- a/netwerk/base/TLSServerSocket.h +++ b/netwerk/base/TLSServerSocket.h @@ -27,7 +27,7 @@ class TLSServerSocket final : public nsServerSocket, public nsITLSServerSocket { virtual nsresult SetSocketDefaults() override; virtual nsresult OnSocketListen() override; - TLSServerSocket(); + TLSServerSocket() = default; private: virtual ~TLSServerSocket() = default; @@ -47,7 +47,7 @@ class TLSServerConnectionInfo : public nsITLSServerConnectionInfo, NS_DECL_NSITLSSERVERCONNECTIONINFO NS_DECL_NSITLSCLIENTSTATUS - TLSServerConnectionInfo(); + TLSServerConnectionInfo() = default; private: virtual ~TLSServerConnectionInfo(); @@ -60,14 +60,14 @@ class TLSServerConnectionInfo : public nsITLSServerConnectionInfo, // reference to the TLSServerConnectionInfo object. This is not handed out to // anyone, and is only used in HandshakeCallback to close the transport in // case of an error. After this, it's set to nullptr. - nsISocketTransport* mTransport; + nsISocketTransport* mTransport{nullptr}; nsCOMPtr mPeerCert; - int16_t mTlsVersionUsed; + int16_t mTlsVersionUsed{TLS_VERSION_UNKNOWN}; nsCString mCipherName; - uint32_t mKeyLength; - uint32_t mMacLength; + uint32_t mKeyLength{0}; + uint32_t mMacLength{0}; // lock protects access to mSecurityObserver - mozilla::Mutex mLock; + mozilla::Mutex mLock{"TLSServerConnectionInfo.mLock"}; nsCOMPtr mSecurityObserver; }; diff --git a/netwerk/base/ThrottleQueue.cpp b/netwerk/base/ThrottleQueue.cpp index 0015a88f77e9..7e61d7a6860d 100644 --- a/netwerk/base/ThrottleQueue.cpp +++ b/netwerk/base/ThrottleQueue.cpp @@ -234,10 +234,8 @@ NS_IMPL_ISUPPORTS(ThrottleQueue, nsIInputChannelThrottleQueue, nsITimerCallback, nsINamed) ThrottleQueue::ThrottleQueue() - : mMeanBytesPerSecond(0), - mMaxBytesPerSecond(0), - mBytesProcessed(0), - mTimerArmed(false) { + +{ nsresult rv; nsCOMPtr sts; nsCOMPtr ioService = do_GetIOService(&rv); diff --git a/netwerk/base/ThrottleQueue.h b/netwerk/base/ThrottleQueue.h index 8dcf638a77f7..0623c05e6bae 100644 --- a/netwerk/base/ThrottleQueue.h +++ b/netwerk/base/ThrottleQueue.h @@ -50,13 +50,13 @@ class ThrottleQueue : public nsIInputChannelThrottleQueue, }; nsTArray mReadEvents; - uint32_t mMeanBytesPerSecond; - uint32_t mMaxBytesPerSecond; - uint64_t mBytesProcessed; + uint32_t mMeanBytesPerSecond{0}; + uint32_t mMaxBytesPerSecond{0}; + uint64_t mBytesProcessed{0}; nsTArray> mAsyncEvents; nsCOMPtr mTimer; - bool mTimerArmed; + bool mTimerArmed{false}; }; } // namespace net diff --git a/netwerk/base/nsASocketHandler.h b/netwerk/base/nsASocketHandler.h index 73b12201c7ce..aaf408b3ff52 100644 --- a/netwerk/base/nsASocketHandler.h +++ b/netwerk/base/nsASocketHandler.h @@ -14,25 +14,21 @@ class nsASocketHandler : public nsISupports { public: - nsASocketHandler() - : mCondition(NS_OK), - mPollFlags(0), - mPollTimeout(UINT16_MAX), - mIsPrivate(false) {} + nsASocketHandler() = default; // // this condition variable will be checked to determine if the socket // handler should be detached. it must only be accessed on the socket // thread. // - nsresult mCondition; + nsresult mCondition{NS_OK}; // // these flags can only be modified on the socket transport thread. // the socket transport service will check these flags before calling // PR_Poll. // - uint16_t mPollFlags; + uint16_t mPollFlags{0}; // // this value specifies the maximum amount of time in seconds that may be @@ -43,9 +39,9 @@ class nsASocketHandler : public nsISupports { // timeout error checking. (i.e., a timeout value of UINT16_MAX is // never reached.) // - uint16_t mPollTimeout; + uint16_t mPollTimeout{UINT16_MAX}; - bool mIsPrivate; + bool mIsPrivate{false}; // // called to service a socket diff --git a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp index d61c00414ce3..d07f4603bce4 100644 --- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp +++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp @@ -47,13 +47,6 @@ class nsAsyncVerifyRedirectCallbackEvent : public Runnable { nsresult mResult; }; -nsAsyncRedirectVerifyHelper::nsAsyncRedirectVerifyHelper() - : mFlags(0), - mWaitingForRedirectCallback(false), - mCallbackInitiated(false), - mExpectedCallbacks(0), - mResult(NS_OK) {} - nsAsyncRedirectVerifyHelper::~nsAsyncRedirectVerifyHelper() { NS_ASSERTION(NS_FAILED(mResult) || mExpectedCallbacks == 0, "Did not receive all required callbacks!"); diff --git a/netwerk/base/nsAsyncRedirectVerifyHelper.h b/netwerk/base/nsAsyncRedirectVerifyHelper.h index 7f0a16194f4a..3e1afa8c6949 100644 --- a/netwerk/base/nsAsyncRedirectVerifyHelper.h +++ b/netwerk/base/nsAsyncRedirectVerifyHelper.h @@ -34,7 +34,7 @@ class nsAsyncRedirectVerifyHelper final NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK public: - nsAsyncRedirectVerifyHelper(); + nsAsyncRedirectVerifyHelper() = default; /* * Calls AsyncOnChannelRedirect() on the given sink with the given @@ -69,12 +69,12 @@ class nsAsyncRedirectVerifyHelper final protected: nsCOMPtr mOldChan; nsCOMPtr mNewChan; - uint32_t mFlags; - bool mWaitingForRedirectCallback; + uint32_t mFlags{0}; + bool mWaitingForRedirectCallback{false}; nsCOMPtr mCallbackEventTarget; - bool mCallbackInitiated; - int32_t mExpectedCallbacks; - nsresult mResult; // value passed to callback + bool mCallbackInitiated{false}; + int32_t mExpectedCallbacks{0}; + nsresult mResult{NS_OK}; // value passed to callback void InitCallback(); diff --git a/netwerk/base/nsAsyncStreamCopier.cpp b/netwerk/base/nsAsyncStreamCopier.cpp index eea2266ca64a..1e379c37b4c4 100644 --- a/netwerk/base/nsAsyncStreamCopier.cpp +++ b/netwerk/base/nsAsyncStreamCopier.cpp @@ -64,14 +64,7 @@ class AsyncApplyBufferingPolicyEvent final : public Runnable { //----------------------------------------------------------------------------- nsAsyncStreamCopier::nsAsyncStreamCopier() - : mLock("nsAsyncStreamCopier.mLock"), - mMode(NS_ASYNCCOPY_VIA_READSEGMENTS), - mChunkSize(nsIOService::gDefaultSegmentSize), - mStatus(NS_OK), - mIsPending(false), - mCloseSource{false}, - mCloseSink{false}, - mShouldSniffBuffering(false) { + : mChunkSize(nsIOService::gDefaultSegmentSize) { LOG(("Creating nsAsyncStreamCopier @%p\n", this)); } diff --git a/netwerk/base/nsAsyncStreamCopier.h b/netwerk/base/nsAsyncStreamCopier.h index fe3a15c46dc5..b1ec9b798407 100644 --- a/netwerk/base/nsAsyncStreamCopier.h +++ b/netwerk/base/nsAsyncStreamCopier.h @@ -59,15 +59,15 @@ class nsAsyncStreamCopier final : public nsIAsyncStreamCopier, nsCOMPtr mCopierCtx; - mozilla::Mutex mLock; + mozilla::Mutex mLock{"nsAsyncStreamCopier.mLock"}; - nsAsyncCopyMode mMode; + nsAsyncCopyMode mMode{NS_ASYNCCOPY_VIA_READSEGMENTS}; uint32_t mChunkSize; - nsresult mStatus; - bool mIsPending; - bool mCloseSource; - bool mCloseSink; - bool mShouldSniffBuffering; + nsresult mStatus{NS_OK}; + bool mIsPending{false}; + bool mCloseSource{false}; + bool mCloseSink{false}; + bool mShouldSniffBuffering{false}; friend class ProceedWithAsyncCopy; friend class AsyncApplyBufferingPolicyEvent; diff --git a/netwerk/base/nsBaseChannel.cpp b/netwerk/base/nsBaseChannel.cpp index 1f2b9ee5ab21..b37298be7732 100644 --- a/netwerk/base/nsBaseChannel.cpp +++ b/netwerk/base/nsBaseChannel.cpp @@ -52,21 +52,7 @@ class ScopedRequestSuspender { //----------------------------------------------------------------------------- // nsBaseChannel -nsBaseChannel::nsBaseChannel() - : NeckoTargetHolder(nullptr), - mPumpingData(false), - mLoadFlags(LOAD_NORMAL), - mQueriedProgressSink(true), - mSynthProgressEvents(false), - mAllowThreadRetargeting(true), - mWaitingOnAsyncRedirect(false), - mOpenRedirectChannel(false), - mRedirectFlags{0}, - mStatus(NS_OK), - mContentDispositionHint(UINT32_MAX), - mContentLength(-1), - mWasOpened(false), - mCanceled(false) { +nsBaseChannel::nsBaseChannel() : NeckoTargetHolder(nullptr) { mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE); } diff --git a/netwerk/base/nsBaseChannel.h b/netwerk/base/nsBaseChannel.h index 2c868917e2a0..cc500ff57f3e 100644 --- a/netwerk/base/nsBaseChannel.h +++ b/netwerk/base/nsBaseChannel.h @@ -271,7 +271,7 @@ class nsBaseChannel RefPtr mPump; RefPtr mRequest; - bool mPumpingData; + bool mPumpingData{false}; nsCOMPtr mProgressSink; nsCOMPtr mOriginalURI; nsCOMPtr mOwner; @@ -279,13 +279,13 @@ class nsBaseChannel nsCOMPtr mRedirectChannel; nsCString mContentType; nsCString mContentCharset; - uint32_t mLoadFlags; - bool mQueriedProgressSink; - bool mSynthProgressEvents; - bool mAllowThreadRetargeting; - bool mWaitingOnAsyncRedirect; - bool mOpenRedirectChannel; - uint32_t mRedirectFlags; + uint32_t mLoadFlags{LOAD_NORMAL}; + bool mQueriedProgressSink{true}; + bool mSynthProgressEvents{false}; + bool mAllowThreadRetargeting{true}; + bool mWaitingOnAsyncRedirect{false}; + bool mOpenRedirectChannel{false}; + uint32_t mRedirectFlags{0}; protected: nsCOMPtr mURI; @@ -293,12 +293,12 @@ class nsBaseChannel nsCOMPtr mLoadInfo; nsCOMPtr mCallbacks; nsCOMPtr mListener; - nsresult mStatus; - uint32_t mContentDispositionHint; + nsresult mStatus{NS_OK}; + uint32_t mContentDispositionHint{UINT32_MAX}; mozilla::UniquePtr mContentDispositionFilename; - int64_t mContentLength; - bool mWasOpened; - bool mCanceled; + int64_t mContentLength{-1}; + bool mWasOpened{false}; + bool mCanceled{false}; friend class mozilla::net::PrivateBrowsingChannel; }; diff --git a/netwerk/base/nsBufferedStreams.cpp b/netwerk/base/nsBufferedStreams.cpp index b5deb0c854d7..1cc249e4223c 100644 --- a/netwerk/base/nsBufferedStreams.cpp +++ b/netwerk/base/nsBufferedStreams.cpp @@ -48,17 +48,6 @@ using mozilla::Some; //////////////////////////////////////////////////////////////////////////////// // nsBufferedStream -nsBufferedStream::nsBufferedStream() - : mBufferSize(0), - mBuffer(nullptr), - mBufferStartOffset(0), - mCursor(0), - mFillPoint(0), - mStream(nullptr), - mBufferDisabled(false), - mEOF(false), - mGetBufferCount(0) {} - nsBufferedStream::~nsBufferedStream() { Close(); } NS_IMPL_ISUPPORTS(nsBufferedStream, nsITellableStream, nsISeekableStream) @@ -313,15 +302,6 @@ NS_IMPL_CI_INTERFACE_GETTER(nsBufferedInputStream, nsIInputStream, nsIBufferedInputStream, nsISeekableStream, nsITellableStream, nsIStreamBufferAccess) -nsBufferedInputStream::nsBufferedInputStream() - : nsBufferedStream(), - mMutex("nsBufferedInputStream::mMutex"), - mIsIPCSerializable(true), - mIsAsyncInputStream(false), - mIsCloneableInputStream(false), - mIsInputStreamLength(false), - mIsAsyncInputStreamLength(false) {} - nsresult nsBufferedInputStream::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult) { NS_ENSURE_NO_AGGREGATION(aOuter); diff --git a/netwerk/base/nsBufferedStreams.h b/netwerk/base/nsBufferedStreams.h index 93868d3c204e..95bff7b0b484 100644 --- a/netwerk/base/nsBufferedStreams.h +++ b/netwerk/base/nsBufferedStreams.h @@ -27,7 +27,7 @@ class nsBufferedStream : public nsISeekableStream { NS_DECL_NSISEEKABLESTREAM NS_DECL_NSITELLABLESTREAM - nsBufferedStream(); + nsBufferedStream() = default; void Close(); @@ -39,26 +39,26 @@ class nsBufferedStream : public nsISeekableStream { NS_IMETHOD Fill() = 0; NS_IMETHOD Flush() = 0; - uint32_t mBufferSize; - char* mBuffer; + uint32_t mBufferSize{0}; + char* mBuffer{nullptr}; // mBufferStartOffset is the offset relative to the start of mStream. - int64_t mBufferStartOffset; + int64_t mBufferStartOffset{0}; // mCursor is the read cursor for input streams, or write cursor for // output streams, and is relative to mBufferStartOffset. - uint32_t mCursor; + uint32_t mCursor{0}; // mFillPoint is the amount available in the buffer for input streams, // or the high watermark of bytes written into the buffer, and therefore // is relative to mBufferStartOffset. - uint32_t mFillPoint; + uint32_t mFillPoint{0}; nsCOMPtr mStream; // cast to appropriate subclass - bool mBufferDisabled; - bool mEOF; // True if mStream is at EOF - uint8_t mGetBufferCount; + bool mBufferDisabled{false}; + bool mEOF{false}; // True if mStream is at EOF + uint8_t mGetBufferCount{0}; }; //////////////////////////////////////////////////////////////////////////////// @@ -86,7 +86,7 @@ class nsBufferedInputStream final : public nsBufferedStream, NS_DECL_NSIASYNCINPUTSTREAMLENGTH NS_DECL_NSIINPUTSTREAMLENGTHCALLBACK - nsBufferedInputStream(); + nsBufferedInputStream() : nsBufferedStream() {} static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult); @@ -120,7 +120,7 @@ class nsBufferedInputStream final : public nsBufferedStream, NS_IMETHOD Fill() override; NS_IMETHOD Flush() override { return NS_OK; } // no-op for input streams - mozilla::Mutex mMutex; + mozilla::Mutex mMutex{"nsBufferedInputStream::mMutex"}; // This value is protected by mutex. nsCOMPtr mAsyncWaitCallback; @@ -128,11 +128,11 @@ class nsBufferedInputStream final : public nsBufferedStream, // This value is protected by mutex. nsCOMPtr mAsyncInputStreamLengthCallback; - bool mIsIPCSerializable; - bool mIsAsyncInputStream; - bool mIsCloneableInputStream; - bool mIsInputStreamLength; - bool mIsAsyncInputStreamLength; + bool mIsIPCSerializable{true}; + bool mIsAsyncInputStream{false}; + bool mIsCloneableInputStream{false}; + bool mIsInputStreamLength{false}; + bool mIsAsyncInputStreamLength{false}; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/netwerk/base/nsDirectoryIndexStream.cpp b/netwerk/base/nsDirectoryIndexStream.cpp index 9ae629a6bde7..6557a127922c 100644 --- a/netwerk/base/nsDirectoryIndexStream.cpp +++ b/netwerk/base/nsDirectoryIndexStream.cpp @@ -38,8 +38,7 @@ using namespace mozilla; static LazyLogModule gLog("nsDirectoryIndexStream"); -nsDirectoryIndexStream::nsDirectoryIndexStream() - : mOffset(0), mStatus(NS_OK), mPos(0) { +nsDirectoryIndexStream::nsDirectoryIndexStream() { MOZ_LOG(gLog, LogLevel::Debug, ("nsDirectoryIndexStream[%p]: created", this)); } diff --git a/netwerk/base/nsDirectoryIndexStream.h b/netwerk/base/nsDirectoryIndexStream.h index e0ed2a8deaf1..6bdebc7cfe37 100644 --- a/netwerk/base/nsDirectoryIndexStream.h +++ b/netwerk/base/nsDirectoryIndexStream.h @@ -17,10 +17,10 @@ class nsIFile; class nsDirectoryIndexStream final : public nsIInputStream { private: nsCString mBuf; - int32_t mOffset; - nsresult mStatus; + int32_t mOffset{0}; + nsresult mStatus{NS_OK}; - int32_t mPos; // position within mArray + int32_t mPos{0}; // position within mArray nsCOMArray mArray; // file objects within the directory nsDirectoryIndexStream(); diff --git a/netwerk/base/nsDownloader.h b/netwerk/base/nsDownloader.h index 1e6879d6019e..fe95dd6ac299 100644 --- a/netwerk/base/nsDownloader.h +++ b/netwerk/base/nsDownloader.h @@ -18,7 +18,7 @@ class nsDownloader : public nsIDownloader { NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER - nsDownloader() : mLocationIsTemp(false) {} + nsDownloader() = default; protected: virtual ~nsDownloader(); @@ -30,7 +30,7 @@ class nsDownloader : public nsIDownloader { nsCOMPtr mObserver; nsCOMPtr mLocation; nsCOMPtr mSink; - bool mLocationIsTemp; + bool mLocationIsTemp{false}; }; #endif // nsDownloader_h__ diff --git a/netwerk/base/nsFileStreams.cpp b/netwerk/base/nsFileStreams.cpp index 9940857c744e..26541a6984da 100644 --- a/netwerk/base/nsFileStreams.cpp +++ b/netwerk/base/nsFileStreams.cpp @@ -43,12 +43,6 @@ using mozilla::Some; //////////////////////////////////////////////////////////////////////////////// // nsFileStreamBase -nsFileStreamBase::nsFileStreamBase() - : mFD(nullptr), - mBehaviorFlags(0), - mState(eUnitialized), - mErrorValue(NS_ERROR_FAILURE) {} - nsFileStreamBase::~nsFileStreamBase() { // We don't want to try to rewrind the stream when shutting down. mBehaviorFlags &= ~nsIFileInputStream::REOPEN_ON_REWIND; diff --git a/netwerk/base/nsFileStreams.h b/netwerk/base/nsFileStreams.h index d546e66d5ae1..8f3eafc9eeaf 100644 --- a/netwerk/base/nsFileStreams.h +++ b/netwerk/base/nsFileStreams.h @@ -35,7 +35,7 @@ class nsFileStreamBase : public nsISeekableStream, public nsIFileMetadata { NS_DECL_NSITELLABLESTREAM NS_DECL_NSIFILEMETADATA - nsFileStreamBase(); + nsFileStreamBase() = default; protected: virtual ~nsFileStreamBase(); @@ -53,12 +53,12 @@ class nsFileStreamBase : public nsISeekableStream, public nsIFileMetadata { nsresult WriteSegments(nsReadSegmentFun aReader, void* aClosure, uint32_t aCount, uint32_t* _retval); - PRFileDesc* mFD; + PRFileDesc* mFD{nullptr}; /** * Flags describing our behavior. See the IDL file for possible values. */ - int32_t mBehaviorFlags; + int32_t mBehaviorFlags{0}; enum { // This is the default value. It will be changed by Deserialize or Init. @@ -72,7 +72,7 @@ class nsFileStreamBase : public nsISeekableStream, public nsIFileMetadata { // Something bad happen in the Open() or in Deserialize(). The actual // error value is stored in mErrorValue. eError - } mState; + } mState{eUnitialized}; struct OpenParams { nsCOMPtr localFile; @@ -85,7 +85,7 @@ class nsFileStreamBase : public nsISeekableStream, public nsIFileMetadata { */ OpenParams mOpenParams; - nsresult mErrorValue; + nsresult mErrorValue{NS_ERROR_FAILURE}; /** * Prepares the data we need to open the file, and either does the open now @@ -148,8 +148,7 @@ class nsFileInputStream : public nsFileStreamBase, // Overrided from nsFileStreamBase NS_IMETHOD Seek(int32_t aWhence, int64_t aOffset) override; - nsFileInputStream() - : mLineBuffer(nullptr), mIOFlags(0), mPerm(0), mCachedPosition(0) {} + nsFileInputStream() : mLineBuffer(nullptr) {} static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult); @@ -171,16 +170,16 @@ class nsFileInputStream : public nsFileStreamBase, /** * The IO flags passed to Init() for the file open. */ - int32_t mIOFlags; + int32_t mIOFlags{0}; /** * The permissions passed to Init() for the file open. */ - int32_t mPerm; + int32_t mPerm{0}; /** * Cached position for Tell for automatically reopening streams. */ - int64_t mCachedPosition; + int64_t mCachedPosition{0}; protected: /** @@ -220,7 +219,7 @@ class nsAtomicFileOutputStream : public nsFileOutputStream, NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSISAFEOUTPUTSTREAM - nsAtomicFileOutputStream() : mTargetFileExists(true), mWriteResult(NS_OK) {} + nsAtomicFileOutputStream() = default; virtual nsresult DoOpen() override; @@ -235,8 +234,8 @@ class nsAtomicFileOutputStream : public nsFileOutputStream, nsCOMPtr mTargetFile; nsCOMPtr mTempFile; - bool mTargetFileExists; - nsresult mWriteResult; // Internally set in Write() + bool mTargetFileExists{true}; + nsresult mWriteResult{NS_OK}; // Internally set in Write() }; //////////////////////////////////////////////////////////////////////////////// diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index c437717aabad..c30634dd5869 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -196,26 +196,9 @@ uint32_t nsIOService::gDefaultSegmentCount = 24; //////////////////////////////////////////////////////////////////////////////// nsIOService::nsIOService() - : mOffline(true), - mOfflineForProfileChange(false), - mManageLinkStatus(false), - mConnectivity(true), - mSettingOffline(false), - mSetOfflineValue(false), - mSocketProcessLaunchComplete(false), - mShutdown(false), - mHttpHandlerAlreadyShutingDown(false), - mNetworkLinkServiceInitialized(false), - mChannelEventSinks(NS_CHANNEL_EVENT_SINK_CATEGORY), - mMutex("nsIOService::mMutex"), - mTotalRequests(0), - mCacheWon(0), - mNetWon(0), - mLastOfflineStateChange(PR_IntervalNow()), + : mLastOfflineStateChange(PR_IntervalNow()), mLastConnectivityChange(PR_IntervalNow()), - mLastNetworkLinkChange(PR_IntervalNow()), - mNetTearingDownStarted(0), - mSocketProcess(nullptr) {} + mLastNetworkLinkChange(PR_IntervalNow()) {} static const char* gCallbackPrefs[] = { PORT_PREF_PREFIX, diff --git a/netwerk/base/nsIOService.h b/netwerk/base/nsIOService.h index ab79dea027c3..0a8623faaf1a 100644 --- a/netwerk/base/nsIOService.h +++ b/netwerk/base/nsIOService.h @@ -25,6 +25,7 @@ #include "nsIObserverService.h" #include "nsTHashSet.h" #include "nsWeakReference.h" +#include "nsNetCID.h" #define NS_N(x) (sizeof(x) / sizeof(*(x))) @@ -199,38 +200,39 @@ class nsIOService final : public nsIIOService, void DestroySocketProcess(); private: - mozilla::Atomic mOffline; - mozilla::Atomic mOfflineForProfileChange; - bool mManageLinkStatus; - mozilla::Atomic mConnectivity; + mozilla::Atomic mOffline{true}; + mozilla::Atomic mOfflineForProfileChange{false}; + bool mManageLinkStatus{false}; + mozilla::Atomic mConnectivity{true}; // Used to handle SetOffline() reentrancy. See the comment in // SetOffline() for more details. - bool mSettingOffline; - bool mSetOfflineValue; + bool mSettingOffline{false}; + bool mSetOfflineValue{false}; - bool mSocketProcessLaunchComplete; + bool mSocketProcessLaunchComplete{false}; - mozilla::Atomic mShutdown; - mozilla::Atomic mHttpHandlerAlreadyShutingDown; + mozilla::Atomic mShutdown{false}; + mozilla::Atomic mHttpHandlerAlreadyShutingDown{false}; nsCOMPtr mSocketTransportService; nsCOMPtr mCaptivePortalService; nsCOMPtr mNetworkLinkService; - bool mNetworkLinkServiceInitialized; + bool mNetworkLinkServiceInitialized{false}; // Cached protocol handlers, only accessed on the main thread nsWeakPtr mWeakHandler[NS_N(gScheme)]; // cached categories - nsCategoryCache mChannelEventSinks; + nsCategoryCache mChannelEventSinks{ + NS_CHANNEL_EVENT_SINK_CATEGORY}; - Mutex mMutex; + Mutex mMutex{"nsIOService::mMutex"}; nsTArray mRestrictedPortList; - uint32_t mTotalRequests; - uint32_t mCacheWon; - uint32_t mNetWon; + uint32_t mTotalRequests{0}; + uint32_t mCacheWon{0}; + uint32_t mNetWon{0}; // These timestamps are needed for collecting telemetry on PR_Connect, // PR_ConnectContinue and PR_Close blocking time. If we spend very long @@ -241,9 +243,9 @@ class nsIOService final : public nsIIOService, mozilla::Atomic mLastNetworkLinkChange; // Time a network tearing down started. - mozilla::Atomic mNetTearingDownStarted; + mozilla::Atomic mNetTearingDownStarted{0}; - SocketProcessHost* mSocketProcess; + SocketProcessHost* mSocketProcess{nullptr}; // Events should be executed after the socket process is launched. Will // dispatch these events while socket process fires OnProcessLaunchComplete. diff --git a/netwerk/base/nsIncrementalDownload.cpp b/netwerk/base/nsIncrementalDownload.cpp index 68c1d472dfe2..dca60f383b36 100644 --- a/netwerk/base/nsIncrementalDownload.cpp +++ b/netwerk/base/nsIncrementalDownload.cpp @@ -103,7 +103,7 @@ class nsIncrementalDownload final : public nsIIncrementalDownload, NS_DECL_NSICHANNELEVENTSINK NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK - nsIncrementalDownload(); + nsIncrementalDownload() = default; private: ~nsIncrementalDownload() = default; @@ -124,39 +124,23 @@ class nsIncrementalDownload final : public nsIIncrementalDownload, nsCOMPtr mChannel; nsCOMPtr mTimer; mozilla::UniquePtr mChunk; - int32_t mChunkLen; - int32_t mChunkSize; - int32_t mInterval; - int64_t mTotalSize; - int64_t mCurrentSize; - uint32_t mLoadFlags; - int32_t mNonPartialCount; - nsresult mStatus; - bool mIsPending; - bool mDidOnStartRequest; - PRTime mLastProgressUpdate; + int32_t mChunkLen{0}; + int32_t mChunkSize{DEFAULT_CHUNK_SIZE}; + int32_t mInterval{DEFAULT_INTERVAL}; + int64_t mTotalSize{-1}; + int64_t mCurrentSize{-1}; + uint32_t mLoadFlags{LOAD_NORMAL}; + int32_t mNonPartialCount{0}; + nsresult mStatus{NS_OK}; + bool mIsPending{false}; + bool mDidOnStartRequest{false}; + PRTime mLastProgressUpdate{0}; nsCOMPtr mRedirectCallback; nsCOMPtr mNewRedirectChannel; nsCString mPartialValidator; - bool mCacheBust; + bool mCacheBust{false}; }; -nsIncrementalDownload::nsIncrementalDownload() - : mChunkLen(0), - mChunkSize(DEFAULT_CHUNK_SIZE), - mInterval(DEFAULT_INTERVAL), - mTotalSize(-1), - mCurrentSize(-1), - mLoadFlags(LOAD_NORMAL), - mNonPartialCount(0), - mStatus(NS_OK), - mIsPending(false), - mDidOnStartRequest(false), - mLastProgressUpdate(0), - mRedirectCallback(nullptr), - mNewRedirectChannel(nullptr), - mCacheBust(false) {} - nsresult nsIncrementalDownload::FlushChunk() { NS_ASSERTION(mTotalSize != int64_t(-1), "total size should be known"); diff --git a/netwerk/base/nsInputStreamChannel.h b/netwerk/base/nsInputStreamChannel.h index f00df9536fab..c8c926020b15 100644 --- a/netwerk/base/nsInputStreamChannel.h +++ b/netwerk/base/nsInputStreamChannel.h @@ -20,7 +20,7 @@ class nsInputStreamChannel : public nsBaseChannel, NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIINPUTSTREAMCHANNEL - nsInputStreamChannel() : mIsSrcdocChannel(false) {} + nsInputStreamChannel() = default; protected: virtual ~nsInputStreamChannel() = default; @@ -34,7 +34,7 @@ class nsInputStreamChannel : public nsBaseChannel, nsCOMPtr mContentStream; nsCOMPtr mBaseURI; nsString mSrcdocData; - bool mIsSrcdocChannel; + bool mIsSrcdocChannel{false}; }; } // namespace net diff --git a/netwerk/base/nsInputStreamPump.cpp b/netwerk/base/nsInputStreamPump.cpp index a662300eb319..d6d4ac33eb3d 100644 --- a/netwerk/base/nsInputStreamPump.cpp +++ b/netwerk/base/nsInputStreamPump.cpp @@ -33,23 +33,7 @@ static mozilla::LazyLogModule gStreamPumpLog("nsStreamPump"); // nsInputStreamPump methods //----------------------------------------------------------------------------- -nsInputStreamPump::nsInputStreamPump() - : mState(STATE_IDLE), - mStreamOffset(0), - mStreamLength(0), - mSegSize(0), - mSegCount(0), - mStatus(NS_OK), - mSuspendCount(0), - mLoadFlags(LOAD_NORMAL), - mIsPending(false), - mProcessingCallbacks(false), - mWaitingForInputStreamReady(false), - mCloseWhenDone(false), - mRetargeting(false), - mAsyncStreamIsBuffered(false), - mOffMainThread(!NS_IsMainThread()), - mMutex("nsInputStreamPump") {} +nsInputStreamPump::nsInputStreamPump() : mOffMainThread(!NS_IsMainThread()) {} nsresult nsInputStreamPump::Create(nsInputStreamPump** result, nsIInputStream* stream, uint32_t segsize, diff --git a/netwerk/base/nsInputStreamPump.h b/netwerk/base/nsInputStreamPump.h index 4dcbdcba37a8..226da77f7230 100644 --- a/netwerk/base/nsInputStreamPump.h +++ b/netwerk/base/nsInputStreamPump.h @@ -74,34 +74,34 @@ class nsInputStreamPump final : public nsIInputStreamPump, uint32_t OnStateStop(); nsresult CreateBufferedStreamIfNeeded(); - uint32_t mState; + uint32_t mState{STATE_IDLE}; nsCOMPtr mLoadGroup; nsCOMPtr mListener; nsCOMPtr mTargetThread; nsCOMPtr mLabeledMainThreadTarget; nsCOMPtr mStream; nsCOMPtr mAsyncStream; - uint64_t mStreamOffset; - uint64_t mStreamLength; - uint32_t mSegSize; - uint32_t mSegCount; - nsresult mStatus; - uint32_t mSuspendCount; - uint32_t mLoadFlags; - bool mIsPending; + uint64_t mStreamOffset{0}; + uint64_t mStreamLength{0}; + uint32_t mSegSize{0}; + uint32_t mSegCount{0}; + nsresult mStatus{NS_OK}; + uint32_t mSuspendCount{0}; + uint32_t mLoadFlags{LOAD_NORMAL}; + bool mIsPending{false}; // True while in OnInputStreamReady, calling OnStateStart, OnStateTransfer // and OnStateStop. Used to prevent calls to AsyncWait during callbacks. - bool mProcessingCallbacks; + bool mProcessingCallbacks{false}; // True if waiting on the "input stream ready" callback. - bool mWaitingForInputStreamReady; - bool mCloseWhenDone; - bool mRetargeting; - bool mAsyncStreamIsBuffered; + bool mWaitingForInputStreamReady{false}; + bool mCloseWhenDone{false}; + bool mRetargeting{false}; + bool mAsyncStreamIsBuffered{false}; // Indicate whether nsInputStreamPump is used completely off main thread. // If true, OnStateStop() is executed off main thread. bool mOffMainThread; // Protects state/member var accesses across multiple threads. - mozilla::RecursiveMutex mMutex; + mozilla::RecursiveMutex mMutex{"nsInputStreamPump"}; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsInputStreamPump, NS_INPUT_STREAM_PUMP_IID) diff --git a/netwerk/base/nsLoadGroup.cpp b/netwerk/base/nsLoadGroup.cpp index a51de7095f1b..51f3e027b681 100644 --- a/netwerk/base/nsLoadGroup.cpp +++ b/netwerk/base/nsLoadGroup.cpp @@ -86,19 +86,7 @@ static void RescheduleRequest(nsIRequest* aRequest, int32_t delta) { } nsLoadGroup::nsLoadGroup() - : mForegroundCount(0), - mLoadFlags(LOAD_NORMAL), - mDefaultLoadFlags(0), - mPriority(PRIORITY_NORMAL), - mRequests(&sRequestHashOps, sizeof(RequestMapEntry)), - mStatus(NS_OK), - mIsCanceling(false), - mDefaultLoadIsTimed(false), - mBrowsingContextDiscarded(false), - mExternalRequestContext(false), - mNotifyObserverAboutBackgroundRequests(false), - mTimedRequests(0), - mCachedRequests(0) { + : mRequests(&sRequestHashOps, sizeof(RequestMapEntry)) { LOG(("LOADGROUP [%p]: Created.\n", this)); } diff --git a/netwerk/base/nsLoadGroup.h b/netwerk/base/nsLoadGroup.h index 971eecbb2689..055e1804d64e 100644 --- a/netwerk/base/nsLoadGroup.h +++ b/netwerk/base/nsLoadGroup.h @@ -76,10 +76,10 @@ class nsLoadGroup : public nsILoadGroup, nsresult NotifyRemovalObservers(nsIRequest* aRequest, nsresult aStatus); protected: - uint32_t mForegroundCount; - uint32_t mLoadFlags; - uint32_t mDefaultLoadFlags; - int32_t mPriority; + uint32_t mForegroundCount{0}; + uint32_t mLoadFlags{LOAD_NORMAL}; + uint32_t mDefaultLoadFlags{0}; + int32_t mPriority{PRIORITY_NORMAL}; nsCOMPtr mLoadGroup; // load groups can contain load groups nsCOMPtr mCallbacks; @@ -92,17 +92,17 @@ class nsLoadGroup : public nsILoadGroup, nsWeakPtr mObserver; nsWeakPtr mParentLoadGroup; - nsresult mStatus; - bool mIsCanceling; - bool mDefaultLoadIsTimed; - bool mBrowsingContextDiscarded; - bool mExternalRequestContext; - bool mNotifyObserverAboutBackgroundRequests; + nsresult mStatus{NS_OK}; + bool mIsCanceling{false}; + bool mDefaultLoadIsTimed{false}; + bool mBrowsingContextDiscarded{false}; + bool mExternalRequestContext{false}; + bool mNotifyObserverAboutBackgroundRequests{false}; /* Telemetry */ mozilla::TimeStamp mDefaultRequestCreationTime; - uint32_t mTimedRequests; - uint32_t mCachedRequests; + uint32_t mTimedRequests{0}; + uint32_t mCachedRequests{0}; }; } // namespace net diff --git a/netwerk/base/nsMIMEInputStream.cpp b/netwerk/base/nsMIMEInputStream.cpp index 7405d0943ca4..c0ed6047a845 100644 --- a/netwerk/base/nsMIMEInputStream.cpp +++ b/netwerk/base/nsMIMEInputStream.cpp @@ -42,7 +42,7 @@ class nsMIMEInputStream : public nsIMIMEInputStream, virtual ~nsMIMEInputStream() = default; public: - nsMIMEInputStream(); + nsMIMEInputStream() = default; NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIINPUTSTREAM @@ -84,9 +84,9 @@ class nsMIMEInputStream : public nsIMIMEInputStream, nsTArray mHeaders; nsCOMPtr mStream; - bool mStartedReading; + bool mStartedReading{false}; - mozilla::Mutex mMutex; + mozilla::Mutex mMutex{"nsMIMEInputStream::mMutex"}; // This is protected by mutex. nsCOMPtr mAsyncWaitCallback; @@ -126,9 +126,6 @@ NS_IMPL_CI_INTERFACE_GETTER(nsMIMEInputStream, nsIMIMEInputStream, nsIAsyncInputStream, nsIInputStream, nsISeekableStream, nsITellableStream) -nsMIMEInputStream::nsMIMEInputStream() - : mStartedReading(false), mMutex("nsMIMEInputStream::mMutex") {} - NS_IMETHODIMP nsMIMEInputStream::AddHeader(const char* aName, const char* aValue) { NS_ENSURE_FALSE(mStartedReading, NS_ERROR_FAILURE); diff --git a/netwerk/base/nsProtocolProxyService.cpp b/netwerk/base/nsProtocolProxyService.cpp index 0a0a72e96630..a6bab4255d89 100644 --- a/netwerk/base/nsProtocolProxyService.cpp +++ b/netwerk/base/nsProtocolProxyService.cpp @@ -128,9 +128,7 @@ class nsAsyncResolveRequest final : public nsIRunnable, nsAsyncResolveRequest(nsProtocolProxyService* pps, nsIChannel* channel, uint32_t aResolveFlags, nsIProtocolProxyCallback* callback) - : mStatus(NS_OK), - mDispatched(false), - mResolveFlags(aResolveFlags), + : mResolveFlags(aResolveFlags), mPPS(pps), mXPComPPS(pps), mChannel(channel), @@ -422,10 +420,10 @@ class nsAsyncResolveRequest final : public nsIRunnable, } private: - nsresult mStatus; + nsresult mStatus{NS_OK}; nsCString mPACString; nsCString mPACURL; - bool mDispatched; + bool mDispatched{false}; uint32_t mResolveFlags; nsProtocolProxyService* mPPS; @@ -770,21 +768,7 @@ NS_INTERFACE_MAP_END NS_IMPL_CI_INTERFACE_GETTER(nsProtocolProxyService, nsIProtocolProxyService, nsIProtocolProxyService2) -nsProtocolProxyService::nsProtocolProxyService() - : mFilterLocalHosts(false), - mProxyConfig(PROXYCONFIG_DIRECT), - mHTTPProxyPort(-1), - mHTTPSProxyPort(-1), - mSOCKSProxyPort(-1), - mSOCKSProxyVersion(4), - mSOCKSProxyRemoteDNS(false), - mProxyOverTLS(true), - mWPADOverDHCPEnabled(false), - mPACMan(nullptr), - mSessionStart(PR_Now()), - mFailedProxyTimeout(30 * 60) // 30 minute default - , - mIsShutdown(false) {} +nsProtocolProxyService::nsProtocolProxyService() : mSessionStart(PR_Now()) {} nsProtocolProxyService::~nsProtocolProxyService() { // These should have been cleaned up in our Observe method. @@ -1505,9 +1489,7 @@ class nsAsyncBridgeRequest final : public nsPACManCallback { nsAsyncBridgeRequest() : mMutex("nsDeprecatedCallback"), - mCondVar(mMutex, "nsDeprecatedCallback"), - mStatus(NS_OK), - mCompleted(false) {} + mCondVar(mMutex, "nsDeprecatedCallback") {} void OnQueryComplete(nsresult status, const nsACString& pacString, const nsACString& newPACURL) override { @@ -1531,10 +1513,10 @@ class nsAsyncBridgeRequest final : public nsPACManCallback { Mutex mMutex; CondVar mCondVar; - nsresult mStatus; + nsresult mStatus{NS_OK}; nsCString mPACString; nsCString mPACURL; - bool mCompleted; + bool mCompleted{false}; }; NS_IMPL_ISUPPORTS0(nsAsyncBridgeRequest) diff --git a/netwerk/base/nsProtocolProxyService.h b/netwerk/base/nsProtocolProxyService.h index 351b0c7280f6..ac5a80a557fb 100644 --- a/netwerk/base/nsProtocolProxyService.h +++ b/netwerk/base/nsProtocolProxyService.h @@ -341,19 +341,19 @@ class nsProtocolProxyService final : public nsIProtocolProxyService2, protected: // simplified array of filters defined by this struct struct HostInfo { - bool is_ipaddr; - int32_t port; + bool is_ipaddr{false}; + int32_t port{0}; + // other members intentionally uninitialized union { - HostInfoIP ip{}; + HostInfoIP ip; HostInfoName name; }; - HostInfo() - : is_ipaddr(false), - port(0) { /* other members intentionally uninitialized */ - } + HostInfo() = default; ~HostInfo() { - if (!is_ipaddr && name.host) free(name.host); + if (!is_ipaddr && name.host) { + free(name.host); + } } }; @@ -364,7 +364,7 @@ class nsProtocolProxyService final : public nsIProtocolProxyService2, protected: // Indicates if local hosts (plain hostnames, no dots) should use the proxy - bool mFilterLocalHosts; + bool mFilterLocalHosts{false}; // Holds an array of HostInfo objects nsTArray> mHostFiltersArray; @@ -372,36 +372,37 @@ class nsProtocolProxyService final : public nsIProtocolProxyService2, // Filters, always sorted by the position. nsTArray> mFilters; - uint32_t mProxyConfig; + uint32_t mProxyConfig{PROXYCONFIG_DIRECT}; nsCString mHTTPProxyHost; - int32_t mHTTPProxyPort; + int32_t mHTTPProxyPort{-1}; nsCString mHTTPSProxyHost; - int32_t mHTTPSProxyPort; + int32_t mHTTPSProxyPort{-1}; // mSOCKSProxyTarget could be a host, a domain socket path, // or a named-pipe name. nsCString mSOCKSProxyTarget; - int32_t mSOCKSProxyPort; - int32_t mSOCKSProxyVersion; - bool mSOCKSProxyRemoteDNS; - bool mProxyOverTLS; - bool mWPADOverDHCPEnabled; + int32_t mSOCKSProxyPort{-1}; + int32_t mSOCKSProxyVersion{4}; + bool mSOCKSProxyRemoteDNS{false}; + bool mProxyOverTLS{true}; + bool mWPADOverDHCPEnabled{false}; RefPtr mPACMan; // non-null if we are using PAC nsCOMPtr mSystemProxySettings; PRTime mSessionStart; nsFailedProxyTable mFailedProxies; - int32_t mFailedProxyTimeout; + // 30 minute default + int32_t mFailedProxyTimeout{30 * 60}; private: nsresult AsyncResolveInternal(nsIChannel* channel, uint32_t flags, nsIProtocolProxyCallback* callback, nsICancelable** result, bool isSyncOK, nsISerialEventTarget* mainThreadEventTarget); - bool mIsShutdown; + bool mIsShutdown{false}; nsCOMPtr mReloadPACTimer; }; diff --git a/netwerk/base/nsProxyInfo.h b/netwerk/base/nsProxyInfo.h index 798f615707e1..5da0aa18cfb4 100644 --- a/netwerk/base/nsProxyInfo.h +++ b/netwerk/base/nsProxyInfo.h @@ -63,13 +63,7 @@ class nsProxyInfo final : public nsIProxyInfo { private: friend class nsProtocolProxyService; - explicit nsProxyInfo(const char* type = nullptr) - : mType(type), - mPort(-1), - mFlags(0), - mResolveFlags(0), - mTimeout(UINT32_MAX), - mNext(nullptr) {} + explicit nsProxyInfo(const char* type = nullptr) : mType(type) {} nsProxyInfo(const nsACString& aType, const nsACString& aHost, int32_t aPort, const nsACString& aUsername, const nsACString& aPassword, @@ -85,13 +79,13 @@ class nsProxyInfo final : public nsIProxyInfo { nsCString mPassword; nsCString mProxyAuthorizationHeader; nsCString mConnectionIsolationKey; - int32_t mPort; - uint32_t mFlags; + int32_t mPort{-1}; + uint32_t mFlags{0}; // We need to read on multiple threads, but don't need to sync on anything // else - Atomic mResolveFlags; - uint32_t mTimeout; - nsProxyInfo* mNext; + Atomic mResolveFlags{0}; + uint32_t mTimeout{UINT32_MAX}; + nsProxyInfo* mNext{nullptr}; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsProxyInfo, NS_PROXYINFO_IID) diff --git a/netwerk/base/nsServerSocket.cpp b/netwerk/base/nsServerSocket.cpp index 8c5bc817b6f3..1a700060d687 100644 --- a/netwerk/base/nsServerSocket.cpp +++ b/netwerk/base/nsServerSocket.cpp @@ -35,20 +35,7 @@ static nsresult PostEvent(nsServerSocket* s, nsServerSocketFunc func) { // nsServerSocket //----------------------------------------------------------------------------- -nsServerSocket::nsServerSocket() - : mFD(nullptr), - mLock("nsServerSocket.mLock"), - mAttached(false), - mKeepWhenOffline(false) { - this->mAddr.raw.family = 0; - this->mAddr.inet.family = 0; - this->mAddr.inet.port = 0; - this->mAddr.inet.ip = 0; - this->mAddr.ipv6.family = 0; - this->mAddr.ipv6.port = 0; - this->mAddr.ipv6.flowinfo = 0; - this->mAddr.ipv6.scope_id = 0; - this->mAddr.local.family = 0; +nsServerSocket::nsServerSocket() { // we want to be able to access the STS directly, and it may not have been // constructed yet. the STS constructor sets gSocketTransportService. if (!gSocketTransportService) { diff --git a/netwerk/base/nsServerSocket.h b/netwerk/base/nsServerSocket.h index 40bba17884d1..f22b94e880d0 100644 --- a/netwerk/base/nsServerSocket.h +++ b/netwerk/base/nsServerSocket.h @@ -40,7 +40,7 @@ class nsServerSocket : public nsASocketHandler, public nsIServerSocket { protected: virtual ~nsServerSocket(); - PRFileDesc* mFD; + PRFileDesc* mFD{nullptr}; nsCOMPtr mListener; private: @@ -51,11 +51,11 @@ class nsServerSocket : public nsASocketHandler, public nsIServerSocket { nsresult TryAttach(); // lock protects access to mListener; so it is not cleared while being used. - mozilla::Mutex mLock; + mozilla::Mutex mLock{"nsServerSocket.mLock"}; PRNetAddr mAddr = {.raw = {0, {0}}}; nsCOMPtr mListenerTarget; - bool mAttached; - bool mKeepWhenOffline; + bool mAttached{false}; + bool mKeepWhenOffline{false}; }; } // namespace net diff --git a/netwerk/base/nsSimpleURI.cpp b/netwerk/base/nsSimpleURI.cpp index 476044c1273b..affb5f31acf8 100644 --- a/netwerk/base/nsSimpleURI.cpp +++ b/netwerk/base/nsSimpleURI.cpp @@ -54,8 +54,6 @@ NS_IMPL_CI_INTERFACE_GETTER0(nsSimpleURI) //////////////////////////////////////////////////////////////////////////////// // nsSimpleURI methods: -nsSimpleURI::nsSimpleURI() : mIsRefValid(false), mIsQueryValid(false) {} - NS_IMPL_ADDREF(nsSimpleURI) NS_IMPL_RELEASE(nsSimpleURI) NS_INTERFACE_TABLE_HEAD(nsSimpleURI) diff --git a/netwerk/base/nsSimpleURI.h b/netwerk/base/nsSimpleURI.h index 9d995c66faf9..ef17940e10bc 100644 --- a/netwerk/base/nsSimpleURI.h +++ b/netwerk/base/nsSimpleURI.h @@ -27,7 +27,7 @@ namespace net { class nsSimpleURI : public nsIURI, public nsISerializable, public nsISizeOf { protected: - nsSimpleURI(); + nsSimpleURI() = default; virtual ~nsSimpleURI() = default; public: @@ -108,8 +108,9 @@ class nsSimpleURI : public nsIURI, public nsISerializable, public nsISizeOf { 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 mIsRefValid; // To distinguish between empty-ref and no-ref. - bool mIsQueryValid; // To distinguish between empty-query and no-query. + bool mIsRefValid{false}; // To distinguish between empty-ref and no-ref. + // To distinguish between empty-query and no-query. + bool mIsQueryValid{false}; public: class Mutator final : public nsIURIMutator, diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index 3ff75a498745..44ffc35b26af 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -253,11 +253,7 @@ nsresult ErrorAccordingToNSPR(PRErrorCode errorCode) { //----------------------------------------------------------------------------- nsSocketInputStream::nsSocketInputStream(nsSocketTransport* trans) - : mTransport(trans), - mReaderRefCnt(0), - mCondition(NS_OK), - mCallbackFlags(0), - mByteCount(0) {} + : mTransport(trans) {} // called on the socket transport thread... // @@ -487,11 +483,7 @@ nsSocketInputStream::AsyncWait(nsIInputStreamCallback* callback, uint32_t flags, //----------------------------------------------------------------------------- nsSocketOutputStream::nsSocketOutputStream(nsSocketTransport* trans) - : mTransport(trans), - mWriterRefCnt(0), - mCondition(NS_OK), - mCallbackFlags(0), - mByteCount(0) {} + : mTransport(trans) {} // called on the socket transport thread... // @@ -679,44 +671,10 @@ nsSocketOutputStream::AsyncWait(nsIOutputStreamCallback* callback, //----------------------------------------------------------------------------- nsSocketTransport::nsSocketTransport() - : mPort(0), - mProxyPort(0), - mOriginPort(0), - mProxyTransparent(false), - mProxyTransparentResolvesHost(false), - mHttpsProxy(false), - mConnectionFlags(0), - mResetFamilyPreference(false), - mTlsFlags(0), - mReuseAddrPort(false), - mState(STATE_CLOSED), - mAttached(false), - mInputClosed(true), - mOutputClosed(true), - mResolving(false), - mEchConfigUsed(false), - mResolvedByTRR(false), - mNetAddrIsSet(false), - mSelfAddrIsSet(false), - mLock("nsSocketTransport.mLock"), - mFD(this), - mFDref(0), - mFDconnected(false), + : mFD(this), mSocketTransportService(gSocketTransportService), mInput(this), - mOutput(this), - mLingerPolarity(false), - mLingerTimeout(0), - mQoSBits(0x00), - mKeepaliveEnabled(false), - mKeepaliveIdleTimeS(-1), - mKeepaliveRetryIntervalS(-1), - mKeepaliveProbeCount(-1), - mDoNotRetryToConnect(false) { - this->mNetAddr.raw.family = 0; - this->mNetAddr.inet = {}; - this->mSelfAddr.raw.family = 0; - this->mSelfAddr.inet = {}; + mOutput(this) { SOCKET_LOG(("creating nsSocketTransport @%p\n", this)); mTimeouts[TIMEOUT_CONNECT] = UINT16_MAX; // no timeout @@ -1986,9 +1944,12 @@ void nsSocketTransport::OnSocketEvent(uint32_t type, nsresult status, #if defined(XP_UNIX) if (mNetAddrIsSet && mNetAddr.raw.family == AF_LOCAL) { mCondition = InitiateSocket(); - } else + } else { +#else + { #endif mCondition = ResolveHost(); + } } else { SOCKET_LOG((" ignoring redundant event\n")); diff --git a/netwerk/base/nsSocketTransport2.h b/netwerk/base/nsSocketTransport2.h index d736a5b57736..022ef9507a24 100644 --- a/netwerk/base/nsSocketTransport2.h +++ b/netwerk/base/nsSocketTransport2.h @@ -64,13 +64,13 @@ class nsSocketInputStream : public nsIAsyncInputStream { private: nsSocketTransport* mTransport; - ThreadSafeAutoRefCnt mReaderRefCnt; + ThreadSafeAutoRefCnt mReaderRefCnt{0}; // access to these is protected by mTransport->mLock - nsresult mCondition; + nsresult mCondition{NS_OK}; nsCOMPtr mCallback; - uint32_t mCallbackFlags; - uint64_t mByteCount; + uint32_t mCallbackFlags{0}; + uint64_t mByteCount{0}; }; //----------------------------------------------------------------------------- @@ -97,13 +97,13 @@ class nsSocketOutputStream : public nsIAsyncOutputStream { uint32_t* countRead); nsSocketTransport* mTransport; - ThreadSafeAutoRefCnt mWriterRefCnt; + ThreadSafeAutoRefCnt mWriterRefCnt{0}; // access to these is protected by mTransport->mLock - nsresult mCondition; + nsresult mCondition{NS_OK}; nsCOMPtr mCallback; - uint32_t mCallbackFlags; - uint64_t mByteCount; + uint32_t mCallbackFlags{0}; + uint64_t mByteCount{0}; }; //----------------------------------------------------------------------------- @@ -275,19 +275,19 @@ class nsSocketTransport final : public nsASocketHandler, nsCString mHost; nsCString mProxyHost; nsCString mOriginHost; - uint16_t mPort; + uint16_t mPort{0}; nsCOMPtr mProxyInfo; - uint16_t mProxyPort; - uint16_t mOriginPort; - bool mProxyTransparent; - bool mProxyTransparentResolvesHost; - bool mHttpsProxy; - uint32_t mConnectionFlags; + uint16_t mProxyPort{0}; + uint16_t mOriginPort{0}; + bool mProxyTransparent{false}; + bool mProxyTransparentResolvesHost{false}; + bool mHttpsProxy{false}; + uint32_t mConnectionFlags{0}; // When we fail to connect using a prefered IP family, we tell the consumer to // reset the IP family preference on the connection entry. - bool mResetFamilyPreference; - uint32_t mTlsFlags; - bool mReuseAddrPort; + bool mResetFamilyPreference{false}; + uint32_t mTlsFlags{0}; + bool mReuseAddrPort{false}; // The origin attributes are used to create sockets. The first party domain // will eventually be used to isolate OCSP cache and is only non-empty when @@ -309,29 +309,29 @@ class nsSocketTransport final : public nsASocketHandler, //------------------------------------------------------------------------- // socket state vars: - uint32_t mState; // STATE_??? flags - bool mAttached; - bool mInputClosed; - bool mOutputClosed; + uint32_t mState{STATE_CLOSED}; // STATE_??? flags + bool mAttached{false}; + bool mInputClosed{true}; + bool mOutputClosed{true}; // this flag is used to determine if the results of a host lookup arrive // recursively or not. this flag is not protected by any lock. - bool mResolving; + bool mResolving{false}; nsCOMPtr mDNSRequest; nsCOMPtr mDNSRecord; nsCString mEchConfig; bool mEchConfigUsed = false; - bool mResolvedByTRR; + bool mResolvedByTRR{false}; // mNetAddr/mSelfAddr is valid from GetPeerAddr()/GetSelfAddr() once we have // reached STATE_TRANSFERRING. It must not change after that. void SetSocketName(PRFileDesc* fd); NetAddr mNetAddr; NetAddr mSelfAddr; // getsockname() - Atomic mNetAddrIsSet; - Atomic mSelfAddrIsSet; + Atomic mNetAddrIsSet{false}; + Atomic mSelfAddrIsSet{false}; UniquePtr mBindAddr; @@ -363,10 +363,11 @@ class nsSocketTransport final : public nsASocketHandler, // socket input/output objects. these may be accessed on any thread with // the exception of some specific methods (XXX). - Mutex mLock; // protects members in this section. + // protects members in this section. + Mutex mLock{"nsSocketTransport.mLock"}; LockedPRFileDesc mFD; - nsrefcnt mFDref; // mFD is closed when mFDref goes to zero. - bool mFDconnected; // mFD is available to consumer when TRUE. + nsrefcnt mFDref{0}; // mFD is closed when mFDref goes to zero. + bool mFDconnected{false}; // mFD is available to consumer when TRUE. // A delete protector reference to gSocketTransportService held for lifetime // of 'this'. Sometimes used interchangably with gSocketTransportService due @@ -387,11 +388,11 @@ class nsSocketTransport final : public nsASocketHandler, uint16_t mTimeouts[2]{0}; // linger options to use when closing - bool mLingerPolarity; - int16_t mLingerTimeout; + bool mLingerPolarity{false}; + int16_t mLingerTimeout{0}; // QoS setting for socket - uint8_t mQoSBits; + uint8_t mQoSBits{0x00}; // // mFD access methods: called with mLock held. @@ -448,14 +449,14 @@ class nsSocketTransport final : public nsASocketHandler, // True if keepalive has been enabled by the socket owner. Note: Keepalive // must also be enabled globally for it to be enabled in TCP. - bool mKeepaliveEnabled; + bool mKeepaliveEnabled{false}; // Keepalive config (support varies by platform). - int32_t mKeepaliveIdleTimeS; - int32_t mKeepaliveRetryIntervalS; - int32_t mKeepaliveProbeCount; + int32_t mKeepaliveIdleTimeS{-1}; + int32_t mKeepaliveRetryIntervalS{-1}; + int32_t mKeepaliveProbeCount{-1}; - bool mDoNotRetryToConnect; + bool mDoNotRetryToConnect{false}; // Whether the port remapping has already been applied. We definitely want to // prevent duplicate calls in case of chaining remapping. diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp index 6471b6e02600..5b8f611e069c 100644 --- a/netwerk/base/nsSocketTransportService2.cpp +++ b/netwerk/base/nsSocketTransportService2.cpp @@ -49,7 +49,6 @@ static Atomic gSocketThread(nullptr); #define KEEPALIVE_RETRY_INTERVAL_PREF "network.tcp.keepalive.retry_interval" #define KEEPALIVE_PROBE_COUNT_PREF "network.tcp.keepalive.probe_count" #define SOCKET_LIMIT_TARGET 1000U -#define SOCKET_LIMIT_MIN 50U #define MAX_TIME_BETWEEN_TWO_POLLS \ "network.sts.max_time_for_events_between_two_polls" #define POLL_BUSY_WAIT_PERIOD "network.sts.poll_busy_wait_period" @@ -119,38 +118,10 @@ void nsSocketTransportService::SocketContext::MaybeResetEpoch() { // ctor/dtor (called on the main/UI thread by the service manager) nsSocketTransportService::nsSocketTransportService() - : mRawThread(nullptr), - mInitialized(false), - mShuttingDown(false), - mLock("nsSocketTransportService::mLock"), - mOffline(false), - mGoingOffline(false), - mActiveListSize(SOCKET_LIMIT_MIN), - mIdleListSize(SOCKET_LIMIT_MIN), - mActiveCount(0), - mIdleCount(0), - mSentBytesCount(0), - mReceivedBytesCount(0), - mSendBufferSize(0), - mKeepaliveIdleTimeS(600), - mKeepaliveRetryIntervalS(1), - mKeepaliveProbeCount(kDefaultTCPKeepCount), - mKeepaliveEnabledPref(false), - mPollableEventTimeout(TimeDuration::FromSeconds(6)), - mServingPendingQueue(false), - mMaxTimePerPollIter(100), + : mPollableEventTimeout(TimeDuration::FromSeconds(6)), mMaxTimeForPrClosePref(PR_SecondsToInterval(5)), - mLastNetworkLinkChangeTime(0), mNetworkLinkChangeBusyWaitPeriod(PR_SecondsToInterval(50)), - mNetworkLinkChangeBusyWaitTimeout(PR_SecondsToInterval(7)), - mSleepPhase(false), - mProbedMaxCount(false) -#if defined(XP_WIN) - , - mPolling(false) -#endif - , - mNotTrustedMitmDetected(false) { + mNetworkLinkChangeBusyWaitTimeout(PR_SecondsToInterval(7)) { NS_ASSERTION(NS_IsMainThread(), "wrong thread"); PR_CallOnce(&gMaxCountInitOnce, DiscoverMaxCount); diff --git a/netwerk/base/nsSocketTransportService2.h b/netwerk/base/nsSocketTransportService2.h index 4abde5fd3f5e..fa8c5a32296d 100644 --- a/netwerk/base/nsSocketTransportService2.h +++ b/netwerk/base/nsSocketTransportService2.h @@ -100,6 +100,8 @@ class nsSocketTransportService final : public nsPISocketTransportService, NS_DECL_NSIOBSERVER NS_DECL_NSIDIRECTTASKDISPATCHER + static const uint32_t SOCKET_LIMIT_MIN = 50U; + nsSocketTransportService(); // Max Socket count may need to get initialized/used by nsHttpHandler @@ -144,7 +146,7 @@ class nsSocketTransportService final : public nsPISocketTransportService, // The value is guaranteed to be valid and not dangling while on the socket // thread as mThread is only ever reset after it's been shutdown. // This member should only ever be read on the socket thread. - nsIThread* mRawThread; + nsIThread* mRawThread{nullptr}; // Returns mThread in a thread-safe manner. already_AddRefed GetThreadSafely(); @@ -155,10 +157,10 @@ class nsSocketTransportService final : public nsPISocketTransportService, // initialization and shutdown (any thread) //------------------------------------------------------------------------- - Atomic mInitialized; + Atomic mInitialized{false}; // indicates whether we are currently in the process of shutting down - Atomic mShuttingDown; - Mutex mLock; + Atomic mShuttingDown{false}; + Mutex mLock{"nsSocketTransportService::mLock"}; // Variables in the next section protected by mLock // mThread and mDirectTaskDispatcher are only ever modified on the main @@ -170,8 +172,8 @@ class nsSocketTransportService final : public nsPISocketTransportService, // to do do_QueryInterface whenever we need to access the interface. nsCOMPtr mDirectTaskDispatcher; UniquePtr mPollableEvent; - bool mOffline; - bool mGoingOffline; + bool mOffline{false}; + bool mGoingOffline{false}; // Detaches all sockets. void Reset(bool aGuardLocals); @@ -218,10 +220,10 @@ class nsSocketTransportService final : public nsPISocketTransportService, SocketContext* mActiveList; /* mListSize entries */ SocketContext* mIdleList; /* mListSize entries */ - uint32_t mActiveListSize; - uint32_t mIdleListSize; - uint32_t mActiveCount; - uint32_t mIdleCount; + uint32_t mActiveListSize{SOCKET_LIMIT_MIN}; + uint32_t mIdleListSize{SOCKET_LIMIT_MIN}; + uint32_t mActiveCount{0}; + uint32_t mIdleCount{0}; nsresult DetachSocket(SocketContext*, SocketContext*); nsresult AddToIdleList(SocketContext*); @@ -236,8 +238,8 @@ class nsSocketTransportService final : public nsPISocketTransportService, void InitMaxCount(); // Total bytes number transfered through all the sockets except active ones - uint64_t mSentBytesCount; - uint64_t mReceivedBytesCount; + uint64_t mSentBytesCount{0}; + uint64_t mReceivedBytesCount{0}; //------------------------------------------------------------------------- // poll list (socket thread only) // @@ -267,24 +269,24 @@ class nsSocketTransportService final : public nsPISocketTransportService, nsresult UpdatePrefs(); static void UpdatePrefs(const char* aPref, void* aSelf); void UpdateSendBufferPref(); - int32_t mSendBufferSize; + int32_t mSendBufferSize{0}; // Number of seconds of connection is idle before first keepalive ping. - int32_t mKeepaliveIdleTimeS; + int32_t mKeepaliveIdleTimeS{600}; // Number of seconds between retries should keepalive pings fail. - int32_t mKeepaliveRetryIntervalS; + int32_t mKeepaliveRetryIntervalS{1}; // Number of keepalive probes to send. - int32_t mKeepaliveProbeCount; + int32_t mKeepaliveProbeCount{kDefaultTCPKeepCount}; // True if TCP keepalive is enabled globally. - bool mKeepaliveEnabledPref; + bool mKeepaliveEnabledPref{false}; // Timeout of pollable event signalling. TimeDuration mPollableEventTimeout; - Atomic mServingPendingQueue; - Atomic mMaxTimePerPollIter; + Atomic mServingPendingQueue{false}; + Atomic mMaxTimePerPollIter{100}; Atomic mMaxTimeForPrClosePref; // Timestamp of the last network link change event, tracked // also on child processes. - Atomic mLastNetworkLinkChangeTime; + Atomic mLastNetworkLinkChangeTime{0}; // Preference for how long we do busy wait after network link // change has been detected. Atomic mNetworkLinkChangeBusyWaitPeriod; @@ -294,7 +296,7 @@ class nsSocketTransportService final : public nsPISocketTransportService, // Between a computer going to sleep and waking up the PR_*** telemetry // will be corrupted - so do not record it. - Atomic mSleepPhase; + Atomic mSleepPhase{false}; nsCOMPtr mAfterWakeUpTimer; // Lazily created array of forced port remappings. The tuple members meaning @@ -317,7 +319,7 @@ class nsSocketTransportService final : public nsPISocketTransportService, #if defined(XP_WIN) void ProbeMaxCount(); #endif - bool mProbedMaxCount; + bool mProbedMaxCount{false}; void AnalyzeConnection(nsTArray* data, SocketContext* context, bool aActive); @@ -329,7 +331,7 @@ class nsSocketTransportService final : public nsPISocketTransportService, void MarkTheLastElementOfPendingQueue(); #if defined(XP_WIN) - Atomic mPolling; + Atomic mPolling{false}; nsCOMPtr mPollRepairTimer; void StartPollWatchdog(); void DoPollRepair(); @@ -339,7 +341,7 @@ class nsSocketTransportService final : public nsPISocketTransportService, void TryRepairPollableEvent(); - bool mNotTrustedMitmDetected; + bool mNotTrustedMitmDetected{false}; CopyableTArray> mShutdownObservers; }; diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index 5e2e73e1dc44..ae86424eb9e8 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -205,10 +205,7 @@ static LinkedList gAllURLs; #endif nsStandardURL::nsStandardURL(bool aSupportsFileURL, bool aTrackURL) - : mDefaultPort(-1), - mPort(-1), - mDisplayHost(nullptr), - mURLType(URLTYPE_STANDARD), + : mURLType(URLTYPE_STANDARD), mSupportsFileURL(aSupportsFileURL), mCheckedIfHostA(false) { LOG(("Creating nsStandardURL @%p\n", this)); diff --git a/netwerk/base/nsStandardURL.h b/netwerk/base/nsStandardURL.h index 6683db650244..b75666d19745 100644 --- a/netwerk/base/nsStandardURL.h +++ b/netwerk/base/nsStandardURL.h @@ -74,10 +74,10 @@ class nsStandardURL : public nsIFileURL, // location and length of an url segment relative to mSpec // struct URLSegment { - uint32_t mPos; - int32_t mLen; + uint32_t mPos{0}; + int32_t mLen{-1}; - URLSegment() : mPos(0), mLen(-1) {} + URLSegment() = default; URLSegment(uint32_t pos, int32_t len) : mPos(pos), mLen(len) {} URLSegment(const URLSegment& aCopy) = default; void Reset() { @@ -265,8 +265,8 @@ class nsStandardURL : public nsIFileURL, // mSpec contains the normalized version of the URL spec (UTF-8 encoded). nsCString mSpec; - int32_t mDefaultPort; - int32_t mPort; + int32_t mDefaultPort{-1}; + int32_t mPort{-1}; // url parts (relative to mSpec) URLSegment mScheme; @@ -446,7 +446,7 @@ class nsStandardURL : public nsIFileURL, return NS_OK; } - explicit TemplatedMutator() : mMarkedFileURL(false) {} + explicit TemplatedMutator() = default; private: virtual ~TemplatedMutator() = default; diff --git a/netwerk/base/nsStreamTransportService.cpp b/netwerk/base/nsStreamTransportService.cpp index d1e88eb253b3..7f9fed292124 100644 --- a/netwerk/base/nsStreamTransportService.cpp +++ b/netwerk/base/nsStreamTransportService.cpp @@ -41,18 +41,14 @@ class nsInputStreamTransport : public nsITransport, NS_DECL_NSIINPUTSTREAMCALLBACK nsInputStreamTransport(nsIInputStream* source, bool closeWhenDone) - : mMutex("nsInputStreamTransport::mMutex"), - mSource(source), - mOffset(0), - mCloseWhenDone(closeWhenDone), - mInProgress(false) { + : mSource(source), mCloseWhenDone(closeWhenDone) { mAsyncSource = do_QueryInterface(mSource); } private: virtual ~nsInputStreamTransport() = default; - Mutex mMutex; + Mutex mMutex{"nsInputStreamTransport::mMutex"}; // This value is protected by mutex. nsCOMPtr mAsyncWaitCallback; @@ -67,12 +63,12 @@ class nsInputStreamTransport : public nsITransport, // It can be null. nsCOMPtr mAsyncSource; - int64_t mOffset; + int64_t mOffset{0}; const bool mCloseWhenDone; // this variable serves as a lock to prevent the state of the transport // from being modified once the copy is in progress. - bool mInProgress; + bool mInProgress{false}; }; NS_IMPL_ADDREF(nsInputStreamTransport); @@ -248,9 +244,7 @@ nsInputStreamTransport::OnInputStreamReady(nsIAsyncInputStream* aStream) { nsStreamTransportService::nsStreamTransportService() : mScheduledDelayedRunnables( - "nsStreamTransportService.mScheduledDelayedRunnables"), - mShutdownLock("nsStreamTransportService.mShutdownLock"), - mIsShutdown(false) {} + "nsStreamTransportService.mScheduledDelayedRunnables") {} nsStreamTransportService::~nsStreamTransportService() { NS_ASSERTION(!mPool, "thread pool wasn't shutdown"); diff --git a/netwerk/base/nsStreamTransportService.h b/netwerk/base/nsStreamTransportService.h index ba956cc26aef..e03615139629 100644 --- a/netwerk/base/nsStreamTransportService.h +++ b/netwerk/base/nsStreamTransportService.h @@ -49,8 +49,8 @@ class nsStreamTransportService final : public nsIStreamTransportService, DataMutex>> mScheduledDelayedRunnables; - mozilla::Mutex mShutdownLock; - bool mIsShutdown; + mozilla::Mutex mShutdownLock{"nsStreamTransportService.mShutdownLock"}; + bool mIsShutdown{false}; }; } // namespace net diff --git a/netwerk/base/nsSyncStreamListener.h b/netwerk/base/nsSyncStreamListener.h index 8ed2b5c21ae0..997cb86faf3b 100644 --- a/netwerk/base/nsSyncStreamListener.h +++ b/netwerk/base/nsSyncStreamListener.h @@ -25,7 +25,7 @@ class nsSyncStreamListener final : public nsISyncStreamListener, static already_AddRefed Create(); private: - nsSyncStreamListener() : mStatus(NS_OK), mKeepWaiting(false), mDone(false) {} + nsSyncStreamListener() = default; ~nsSyncStreamListener() = default; nsresult Init(); @@ -34,9 +34,9 @@ class nsSyncStreamListener final : public nsISyncStreamListener, nsCOMPtr mPipeIn; nsCOMPtr mPipeOut; - nsresult mStatus; - bool mKeepWaiting; - bool mDone; + nsresult mStatus{NS_OK}; + bool mKeepWaiting{false}; + bool mDone{false}; }; #endif // nsSyncStreamListener_h__ diff --git a/netwerk/base/nsUDPSocket.cpp b/netwerk/base/nsUDPSocket.cpp index 5497e9aeaa6a..4702b9a89d65 100644 --- a/netwerk/base/nsUDPSocket.cpp +++ b/netwerk/base/nsUDPSocket.cpp @@ -221,15 +221,7 @@ FallibleTArray& nsUDPMessage::GetDataAsTArray() { return mData; } // nsUDPSocket //----------------------------------------------------------------------------- -nsUDPSocket::nsUDPSocket() - : mLock("nsUDPSocket.mLock"), - mFD(nullptr), - mOriginAttributes(), - mAttached(false), - mByteReadCount(0), - mByteWriteCount(0) { - this->mAddr.inet = {}; - mAddr.raw.family = PR_AF_UNSPEC; +nsUDPSocket::nsUDPSocket() { // we want to be able to access the STS directly, and it may not have been // constructed yet. the STS constructor sets gSocketTransportService. if (!gSocketTransportService) { diff --git a/netwerk/base/nsUDPSocket.h b/netwerk/base/nsUDPSocket.h index dfc8987d89a0..954365fb153e 100644 --- a/netwerk/base/nsUDPSocket.h +++ b/netwerk/base/nsUDPSocket.h @@ -58,18 +58,18 @@ class nsUDPSocket final : public nsASocketHandler, public nsIUDPSocket { // lock protects access to mListener; // so mListener is not cleared while being used/locked. - Mutex mLock; - PRFileDesc* mFD; + Mutex mLock{"nsUDPSocket.mLock"}; + PRFileDesc* mFD{nullptr}; NetAddr mAddr; OriginAttributes mOriginAttributes; nsCOMPtr mListener; nsCOMPtr mSyncListener; nsCOMPtr mListenerTarget; - bool mAttached; + bool mAttached{false}; RefPtr mSts; - uint64_t mByteReadCount; - uint64_t mByteWriteCount; + uint64_t mByteReadCount{0}; + uint64_t mByteWriteCount{0}; }; //----------------------------------------------------------------------------- diff --git a/netwerk/cache/nsDeleteDir.cpp b/netwerk/cache/nsDeleteDir.cpp index 8b306335bb3c..9b186d3dd641 100644 --- a/netwerk/cache/nsDeleteDir.cpp +++ b/netwerk/cache/nsDeleteDir.cpp @@ -32,11 +32,7 @@ class nsBlockOnBackgroundThreadEvent : public Runnable { nsDeleteDir* nsDeleteDir::gInstance = nullptr; nsDeleteDir::nsDeleteDir() - : mLock("nsDeleteDir.mLock"), - mCondVar(mLock, "nsDeleteDir.mCondVar"), - mNotified(false), - mShutdownPending(false), - mStopDeleting(false) { + : mLock("nsDeleteDir.mLock"), mCondVar(mLock, "nsDeleteDir.mCondVar") { NS_ASSERTION(gInstance == nullptr, "multiple nsCacheService instances!"); } diff --git a/netwerk/cache/nsDeleteDir.h b/netwerk/cache/nsDeleteDir.h index 7487d1ba8dad..b50bb5a262b7 100644 --- a/netwerk/cache/nsDeleteDir.h +++ b/netwerk/cache/nsDeleteDir.h @@ -69,11 +69,11 @@ class nsDeleteDir { static nsDeleteDir* gInstance; mozilla::Mutex mLock; mozilla::CondVar mCondVar; - bool mNotified; + bool mNotified{false}; nsCOMArray mTimers; nsCOMPtr mBackgroundET; - bool mShutdownPending; - bool mStopDeleting; + bool mShutdownPending{false}; + bool mStopDeleting{false}; }; #endif // nsDeleteDir_h__ diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp index ce502c51e07f..ffe972b62410 100644 --- a/netwerk/cache2/CacheEntry.cpp +++ b/netwerk/cache2/CacheEntry.cpp @@ -44,8 +44,7 @@ NS_IMPL_ISUPPORTS(CacheEntryHandle, nsICacheEntry) // CacheEntryHandle -CacheEntryHandle::CacheEntryHandle(CacheEntry* aEntry) - : mEntry(aEntry), mClosed(false) { +CacheEntryHandle::CacheEntryHandle(CacheEntry* aEntry) : mEntry(aEntry) { #ifdef DEBUG if (!mEntry->HandlesCount()) { // CacheEntry.mHandlesCount must go from zero to one only under @@ -202,25 +201,16 @@ uint64_t CacheEntry::GetNextId() { CacheEntry::CacheEntry(const nsACString& aStorageID, const nsACString& aURI, const nsACString& aEnhanceID, bool aUseDisk, bool aSkipSizeCheck, bool aPin) - : mFrecency(0), - mSortingExpirationTime(uint32_t(-1)), - mLock("CacheEntry"), - mFileStatus(NS_ERROR_NOT_INITIALIZED), - mURI(aURI), + : mURI(aURI), mEnhanceID(aEnhanceID), mStorageID(aStorageID), mUseDisk(aUseDisk), mSkipSizeCheck(aSkipSizeCheck), - mIsDoomed(false), mSecurityInfoLoaded(false), mPreventCallbacks(false), mHasData(false), mPinned(aPin), mPinningKnown(false), - mState(NOTLOADED), - mRegistration(NEVERREGISTERED), - mWriter(nullptr), - mUseCount(0), mCacheEntryId(GetNextId()) { LOG(("CacheEntry::CacheEntry [this=%p]", this)); diff --git a/netwerk/cache2/CacheEntry.h b/netwerk/cache2/CacheEntry.h index 08129c1c723b..c3c6fdc179b7 100644 --- a/netwerk/cache2/CacheEntry.h +++ b/netwerk/cache2/CacheEntry.h @@ -151,8 +151,9 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener { const nsACString& aURISpec, nsACString& aResult); // Accessed only on the service management thread - double mFrecency; - ::mozilla::Atomic mSortingExpirationTime; + double mFrecency{0}; + ::mozilla::Atomic mSortingExpirationTime{ + uint32_t(-1)}; // Memory reporting size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const; @@ -307,7 +308,7 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener { bool aMemoryOnly, nsICacheEntryOpenCallback* aCallback); void TransferCallbacks(CacheEntry& aFromEntry); - mozilla::Mutex mLock; + mozilla::Mutex mLock{"CacheEntry"}; // Reflects the number of existing handles for this entry ::mozilla::ThreadSafeAutoRefCnt mHandlesCount; @@ -320,7 +321,7 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener { // Using ReleaseAcquire since we only control access to mFile with this. // When mFileStatus is read and found success it is ensured there is mFile and // that it is after a successful call to Init(). - ::mozilla::Atomic mFileStatus; + Atomic mFileStatus{NS_ERROR_NOT_INITIALIZED}; nsCString mURI; nsCString mEnhanceID; nsCString mStorageID; @@ -334,7 +335,7 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener { // Whether it should skip max size check. bool const mSkipSizeCheck; // Set when entry is doomed with AsyncDoom() or DoomAlreadyRemoved(). - bool mIsDoomed; + bool mIsDoomed{false}; // Following flags are all synchronized with the cache entry lock. @@ -368,7 +369,7 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener { }; // State of this entry. - EState mState; + EState mState{NOTLOADED}; enum ERegistration { NEVERREGISTERED = 0, // The entry has never been registered @@ -378,7 +379,7 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener { // Accessed only on the management thread. Records the state of registration // this entry in the memory pool intermediate cache. - ERegistration mRegistration; + ERegistration mRegistration{NEVERREGISTERED}; // If a new (empty) entry is requested to open an input stream before // output stream has been opened, we must open output stream internally @@ -389,7 +390,7 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener { // Weak reference to the current writter. There can be more then one // writer at a time and OnHandleClosed() must be processed only for the // current one. - CacheEntryHandle* mWriter; + CacheEntryHandle* mWriter{nullptr}; // Background thread scheduled operation. Set (under the lock) one // of this flags to tell the background thread what to do. @@ -400,7 +401,7 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener { static uint32_t const CALLBACKS = 1 << 2; static uint32_t const UNREGISTER = 1 << 3; - Ops() : mFlags(0) {} + Ops() = default; uint32_t Grab() { uint32_t flags = mFlags; mFlags = 0; @@ -413,12 +414,12 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener { } private: - uint32_t mFlags; + uint32_t mFlags{0}; } mBackgroundOperations; nsCOMPtr mSecurityInfo; mozilla::TimeStamp mLoadStart; - uint32_t mUseCount; + uint32_t mUseCount{0}; const uint64_t mCacheEntryId; }; @@ -547,7 +548,7 @@ class CacheEntryHandle final : public nsICacheEntry { // This is |false| until Dismiss() was called and prevents OnHandleClosed // being called more than once. - Atomic mClosed; + Atomic mClosed{false}; }; class CacheOutputCloseListener final : public Runnable { diff --git a/netwerk/cache2/CacheFile.cpp b/netwerk/cache2/CacheFile.cpp index a6a8667a994f..4888e9061ae3 100644 --- a/netwerk/cache2/CacheFile.cpp +++ b/netwerk/cache2/CacheFile.cpp @@ -160,27 +160,7 @@ NS_INTERFACE_MAP_BEGIN(CacheFile) mozilla::net::CacheFileChunkListener) NS_INTERFACE_MAP_END -CacheFile::CacheFile() - : mLock("CacheFile.mLock"), - mOpeningFile(false), - mReady(false), - mMemoryOnly(false), - mSkipSizeCheck(false), - mOpenAsMemoryOnly(false), - mPinned(false), - mPriority(false), - mDataAccessed(false), - mDataIsDirty(false), - mWritingMetadata(false), - mPreloadWithoutInputStreams(true), - mPreloadChunkCount(0), - mStatus(NS_OK), - mDataSize(-1), - mAltDataOffset(-1), - mKill(false), - mOutput(nullptr) { - LOG(("CacheFile::CacheFile() [this=%p]", this)); -} +CacheFile::CacheFile() { LOG(("CacheFile::CacheFile() [this=%p]", this)); } CacheFile::~CacheFile() { LOG(("CacheFile::~CacheFile() [this=%p]", this)); diff --git a/netwerk/cache2/CacheFile.h b/netwerk/cache2/CacheFile.h index 1b33f90340f6..77eaf4b24067 100644 --- a/netwerk/cache2/CacheFile.h +++ b/netwerk/cache2/CacheFile.h @@ -189,26 +189,27 @@ class CacheFile final : public CacheFileChunkListener, nsresult InitIndexEntry(); - mozilla::Mutex mLock; - bool mOpeningFile; - bool mReady; - bool mMemoryOnly; - bool mSkipSizeCheck; - bool mOpenAsMemoryOnly; - bool mPinned; - bool mPriority; - bool mDataAccessed; - bool mDataIsDirty; - bool mWritingMetadata; - bool mPreloadWithoutInputStreams; - uint32_t mPreloadChunkCount; - nsresult mStatus; - int64_t mDataSize; // Size of the whole data including eventual - // alternative data represenation. - int64_t mAltDataOffset; // If there is alternative data present, it - // contains size of the original data, i.e. - // offset where alternative data starts. - // Otherwise it is -1. + mozilla::Mutex mLock{"CacheFile.mLock"}; + bool mOpeningFile{false}; + bool mReady{false}; + bool mMemoryOnly{false}; + bool mSkipSizeCheck{false}; + bool mOpenAsMemoryOnly{false}; + bool mPinned{false}; + bool mPriority{false}; + bool mDataAccessed{false}; + bool mDataIsDirty{false}; + bool mWritingMetadata{false}; + bool mPreloadWithoutInputStreams{true}; + uint32_t mPreloadChunkCount{0}; + nsresult mStatus{NS_OK}; + // Size of the whole data including eventual alternative data represenation. + int64_t mDataSize{-1}; + + // If there is alternative data present, it contains size of the original + // data, i.e. offset where alternative data starts. Otherwise it is -1. + int64_t mAltDataOffset{-1}; + nsCString mKey; nsCString mAltDataType; // The type of the saved alt-data. May be empty. @@ -216,7 +217,7 @@ class CacheFile final : public CacheFileChunkListener, RefPtr mMetadata; nsCOMPtr mListener; nsCOMPtr mDoomAfterOpenListener; - Atomic mKill; + Atomic mKill{false}; nsRefPtrHashtable mChunks; nsClassHashtable mChunkListeners; @@ -231,7 +232,7 @@ class CacheFile final : public CacheFileChunkListener, nsTArray> mDiscardedChunks; nsTArray mInputs; - CacheFileOutputStream* mOutput; + CacheFileOutputStream* mOutput{nullptr}; nsTArray> mObjsToRelease; }; diff --git a/netwerk/cache2/CacheFileContextEvictor.cpp b/netwerk/cache2/CacheFileContextEvictor.cpp index c8be80ba9db8..0e680892078b 100644 --- a/netwerk/cache2/CacheFileContextEvictor.cpp +++ b/netwerk/cache2/CacheFileContextEvictor.cpp @@ -28,8 +28,7 @@ const uint32_t kContextEvictionPrefixLength = bool CacheFileContextEvictor::sDiskAlreadySearched = false; -CacheFileContextEvictor::CacheFileContextEvictor() - : mEvicting(false), mIndexIsUpToDate(false) { +CacheFileContextEvictor::CacheFileContextEvictor() { LOG(("CacheFileContextEvictor::CacheFileContextEvictor() [this=%p]", this)); } diff --git a/netwerk/cache2/CacheFileContextEvictor.h b/netwerk/cache2/CacheFileContextEvictor.h index 28300a562755..518d3b7d5ffc 100644 --- a/netwerk/cache2/CacheFileContextEvictor.h +++ b/netwerk/cache2/CacheFileContextEvictor.h @@ -79,12 +79,12 @@ class CacheFileContextEvictor { void EvictEntries(); // Whether eviction is in progress - bool mEvicting; + bool mEvicting{false}; // Whether index is up to date. We wait with eviction until the index finishes // update process when it is outdated. NOTE: We also stop eviction in progress // when the index is found outdated, the eviction is restarted again once the // update process finishes. - bool mIndexIsUpToDate; + bool mIndexIsUpToDate{false}; // Whether we already tried to restore unfinished jobs from previous run after // startup. static bool sDiskAlreadySearched; diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index b3482fbdcd2b..e591400eaab6 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -517,9 +517,7 @@ size_t CacheFileHandles::SizeOfExcludingThis( class ShutdownEvent : public Runnable { public: ShutdownEvent() - : Runnable("net::ShutdownEvent"), - mMonitor("ShutdownEvent.mMonitor"), - mNotified(false) {} + : Runnable("net::ShutdownEvent"), mMonitor("ShutdownEvent.mMonitor") {} protected: ~ShutdownEvent() = default; @@ -565,7 +563,7 @@ class ShutdownEvent : public Runnable { protected: mozilla::Monitor mMonitor; - bool mNotified; + bool mNotified{false}; }; // Class responsible for reporting IO performance stats @@ -1104,12 +1102,8 @@ StaticRefPtr CacheFileIOManager::gInstance; NS_IMPL_ISUPPORTS(CacheFileIOManager, nsITimerCallback, nsINamed) CacheFileIOManager::CacheFileIOManager() - : mShuttingDown(false), - mTreeCreated(false), - mTreeCreationFailed(false), - mOverLimitEvicting(false), - mCacheSizeOnHardLimit(false), - mRemovingTrashDirs(false) { + +{ LOG(("CacheFileIOManager::CacheFileIOManager [this=%p]", this)); MOZ_ASSERT(!gInstance, "multiple CacheFileIOManager instances!"); } diff --git a/netwerk/cache2/CacheFileIOManager.h b/netwerk/cache2/CacheFileIOManager.h index cc19b74e64a9..8dc1265cc985 100644 --- a/netwerk/cache2/CacheFileIOManager.h +++ b/netwerk/cache2/CacheFileIOManager.h @@ -442,7 +442,7 @@ class CacheFileIOManager final : public nsITimerCallback, public nsINamed { TimeStamp mStartTime; // Set true on the IO thread, CLOSE level as part of the internal shutdown // procedure. - bool mShuttingDown; + bool mShuttingDown{false}; RefPtr mIOThread; nsCOMPtr mCacheDirectory; #if defined(MOZ_WIDGET_ANDROID) @@ -452,19 +452,19 @@ class CacheFileIOManager final : public nsITimerCallback, public nsINamed { // w/o the profile name in the path. Here it is stored. nsCOMPtr mCacheProfilelessDirectory; #endif - bool mTreeCreated; - bool mTreeCreationFailed; + bool mTreeCreated{false}; + bool mTreeCreationFailed{false}; CacheFileHandles mHandles; nsTArray mHandlesByLastUsed; nsTArray mSpecialHandles; nsTArray > mScheduledMetadataWrites; nsCOMPtr mMetadataWritesTimer; - bool mOverLimitEvicting; + bool mOverLimitEvicting{false}; // When overlimit eviction is too slow and cache size reaches 105% of the // limit, this flag is set and no other content is cached to prevent // uncontrolled cache growing. - bool mCacheSizeOnHardLimit; - bool mRemovingTrashDirs; + bool mCacheSizeOnHardLimit{false}; + bool mRemovingTrashDirs{false}; nsCOMPtr mTrashTimer; nsCOMPtr mTrashDir; nsCOMPtr mTrashDirEnumerator; diff --git a/netwerk/cache2/CacheFileMetadata.cpp b/netwerk/cache2/CacheFileMetadata.cpp index 1629f305e821..a900b5b2626c 100644 --- a/netwerk/cache2/CacheFileMetadata.cpp +++ b/netwerk/cache2/CacheFileMetadata.cpp @@ -42,14 +42,7 @@ CacheFileMetadata::CacheFileMetadata(CacheFileHandle* aHandle, const nsACString& aKey) : CacheMemoryConsumer(NORMAL), mHandle(aHandle), - mHashArray(nullptr), - mHashArraySize(0), - mHashCount(0), mOffset(-1), - mBuf(nullptr), - mBufSize(0), - mWriteBuf(nullptr), - mElementsSize(0), mIsDirty(false), mAnonymous(false), mAllocExactSize(false), @@ -70,15 +63,6 @@ CacheFileMetadata::CacheFileMetadata(CacheFileHandle* aHandle, CacheFileMetadata::CacheFileMetadata(bool aMemoryOnly, bool aPinned, const nsACString& aKey) : CacheMemoryConsumer(aMemoryOnly ? MEMORY_ONLY : NORMAL), - mHandle(nullptr), - mHashArray(nullptr), - mHashArraySize(0), - mHashCount(0), - mOffset(0), - mBuf(nullptr), - mBufSize(0), - mWriteBuf(nullptr), - mElementsSize(0), mIsDirty(true), mAnonymous(false), mAllocExactSize(false), @@ -102,15 +86,6 @@ CacheFileMetadata::CacheFileMetadata(bool aMemoryOnly, bool aPinned, CacheFileMetadata::CacheFileMetadata() : CacheMemoryConsumer(DONT_REPORT /* This is a helper class */), - mHandle(nullptr), - mHashArray(nullptr), - mHashArraySize(0), - mHashCount(0), - mOffset(0), - mBuf(nullptr), - mBufSize(0), - mWriteBuf(nullptr), - mElementsSize(0), mIsDirty(false), mAnonymous(false), mAllocExactSize(false), diff --git a/netwerk/cache2/CacheFileMetadata.h b/netwerk/cache2/CacheFileMetadata.h index f3b992f46055..c977a0f34b02 100644 --- a/netwerk/cache2/CacheFileMetadata.h +++ b/netwerk/cache2/CacheFileMetadata.h @@ -212,16 +212,16 @@ class CacheFileMetadata final : public CacheFileIOListener, RefPtr mHandle; nsCString mKey; - 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; + CacheHash::Hash16_t* mHashArray{nullptr}; + uint32_t mHashArraySize{0}; + uint32_t mHashCount{0}; + int64_t mOffset{0}; + // used for parsing, then points to elements + char* mBuf{nullptr}; + uint32_t mBufSize{0}; + char* mWriteBuf{nullptr}; CacheFileMetadataHeader mMetaHdr{0}; - uint32_t mElementsSize; + uint32_t mElementsSize{0}; bool mIsDirty : 1; bool mAnonymous : 1; bool mAllocExactSize : 1; diff --git a/netwerk/cache2/CacheHashUtils.cpp b/netwerk/cache2/CacheHashUtils.cpp index a62d353133d9..0372081de7d0 100644 --- a/netwerk/cache2/CacheHashUtils.cpp +++ b/netwerk/cache2/CacheHashUtils.cpp @@ -124,15 +124,7 @@ CacheHash::Hash16_t CacheHash::Hash16(const char* aData, uint32_t aSize, NS_IMPL_ISUPPORTS0(CacheHash) -CacheHash::CacheHash(uint32_t aInitval) - : mA(0x9e3779b9), - mB(0x9e3779b9), - mC(aInitval), - mPos(0), - mBuf(0), - mBufPos(0), - mLength(0), - mFinalized(false) {} +CacheHash::CacheHash(uint32_t aInitval) : mC(aInitval) {} void CacheHash::Feed(uint32_t aVal, uint8_t aLen) { switch (mPos) { diff --git a/netwerk/cache2/CacheHashUtils.h b/netwerk/cache2/CacheHashUtils.h index adf21093c41a..6ab7df972a52 100644 --- a/netwerk/cache2/CacheHashUtils.h +++ b/netwerk/cache2/CacheHashUtils.h @@ -49,12 +49,14 @@ class CacheHash : public nsISupports { void Feed(uint32_t aVal, uint8_t aLen = 4); - uint32_t mA, mB, mC; - uint8_t mPos; - uint32_t mBuf; - uint8_t mBufPos; - uint32_t mLength; - bool mFinalized; + static const uint32_t kGoldenRation = 0x9e3779b9; + + uint32_t mA{kGoldenRation}, mB{kGoldenRation}, mC; + uint8_t mPos{0}; + uint32_t mBuf{0}; + uint8_t mBufPos{0}; + uint32_t mLength{0}; + bool mFinalized{false}; }; using OriginAttrsHash = uint64_t; diff --git a/netwerk/cache2/CacheIOThread.cpp b/netwerk/cache2/CacheIOThread.cpp index 80170b2f9204..55c1e6dd0f11 100644 --- a/netwerk/cache2/CacheIOThread.cpp +++ b/netwerk/cache2/CacheIOThread.cpp @@ -206,22 +206,7 @@ CacheIOThread* CacheIOThread::sSelf = nullptr; NS_IMPL_ISUPPORTS(CacheIOThread, nsIThreadObserver) -CacheIOThread::CacheIOThread() - : mMonitor("CacheIOThread"), - mThread(nullptr), - mXPCOMThread(nullptr), - mLowestLevelWaiting(LAST_LEVEL), - mCurrentlyExecutingLevel(0), - mHasXPCOMEvents(false), - mRerunCurrentEvent(false), - mShutdown(false), - mIOCancelableEvents(0), - mEventCounter(0) -#ifdef DEBUG - , - mInsideLoop(true) -#endif -{ +CacheIOThread::CacheIOThread() { for (auto& item : mQueueLength) { item = 0; } diff --git a/netwerk/cache2/CacheIOThread.h b/netwerk/cache2/CacheIOThread.h index bbb12faea788..33daf1d30478 100644 --- a/netwerk/cache2/CacheIOThread.h +++ b/netwerk/cache2/CacheIOThread.h @@ -111,12 +111,12 @@ class CacheIOThread final : public nsIThreadObserver { static CacheIOThread* sSelf; - mozilla::Monitor mMonitor; - PRThread* mThread; + mozilla::Monitor mMonitor{"CacheIOThread"}; + PRThread* mThread{nullptr}; UniquePtr mBlockingIOWatcher; - Atomic mXPCOMThread; - Atomic mLowestLevelWaiting; - uint32_t mCurrentlyExecutingLevel; + Atomic mXPCOMThread{nullptr}; + Atomic mLowestLevelWaiting{LAST_LEVEL}; + uint32_t mCurrentlyExecutingLevel{0}; // Keeps the length of the each event queue, since LoopOneLevel moves all // events into a local array. @@ -124,20 +124,20 @@ class CacheIOThread final : public nsIThreadObserver { EventQueue mEventQueue[LAST_LEVEL]; // Raised when nsIEventTarget.Dispatch() is called on this thread - Atomic mHasXPCOMEvents; + Atomic mHasXPCOMEvents{false}; // See YieldAndRerun() above - bool mRerunCurrentEvent; + bool mRerunCurrentEvent{false}; // Signal to process all pending events and then shutdown // Synchronized by mMonitor - bool mShutdown; + bool mShutdown{false}; // If > 0 there is currently an I/O operation on the thread that // can be canceled when after shutdown, see the Shutdown() method // for usage. Made a counter to allow nesting of the Cancelable class. - Atomic mIOCancelableEvents; + Atomic mIOCancelableEvents{0}; // Event counter that increases with every event processed. - Atomic mEventCounter; + Atomic mEventCounter{0}; #ifdef DEBUG - bool mInsideLoop; + bool mInsideLoop{true}; #endif }; diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp index 7d2adde990b6..09af5532ced1 100644 --- a/netwerk/cache2/CacheIndex.cpp +++ b/netwerk/cache2/CacheIndex.cpp @@ -249,23 +249,8 @@ NS_INTERFACE_MAP_BEGIN(CacheIndex) NS_INTERFACE_MAP_END CacheIndex::CacheIndex() - : mState(INITIAL), - mShuttingDown(false), - mIndexNeedsUpdate(false), - mRemovingAll(false), - mIndexOnDiskIsValid(false), - mDontMarkIndexClean(false), - mIndexTimeStamp(0), - mUpdateEventPending(false), - mSkipEntries(0), - mProcessEntries(0), - mRWBuf(nullptr), - mRWBufSize(0), - mRWBufPos(0), - mRWPending(false), - mJournalReadSuccessfully(false), - mAsyncGetDiskConsumptionBlocked(false), - mTotalBytesWritten(0) { + +{ sLock.AssertCurrentThreadOwns(); LOG(("CacheIndex::CacheIndex [this=%p]", this)); MOZ_ASSERT(!gInstance, "multiple CacheIndex instances!"); diff --git a/netwerk/cache2/CacheIndex.h b/netwerk/cache2/CacheIndex.h index ac1a5827afa0..7800b02b326d 100644 --- a/netwerk/cache2/CacheIndex.h +++ b/netwerk/cache2/CacheIndex.h @@ -75,11 +75,11 @@ static_assert(sizeof(CacheIndexHeader::mVersion) + #pragma pack(push, 1) struct CacheIndexRecord { SHA1Sum::Hash mHash{}; - uint32_t mFrecency; - OriginAttrsHash mOriginAttrsHash; - uint16_t mOnStartTime; - uint16_t mOnStopTime; - uint8_t mContentType; + uint32_t mFrecency{0}; + OriginAttrsHash mOriginAttrsHash{0}; + uint16_t mOnStartTime{kIndexTimeNotAvailable}; + uint16_t mOnStopTime{kIndexTimeNotAvailable}; + uint8_t mContentType{nsICacheEntry::CONTENT_TYPE_UNKNOWN}; /* * 1000 0000 0000 0000 0000 0000 0000 0000 : initialized @@ -92,15 +92,9 @@ struct CacheIndexRecord { * 0000 0001 0000 0000 0000 0000 0000 0000 : reserved * 0000 0000 1111 1111 1111 1111 1111 1111 : file size (in kB) */ - uint32_t mFlags; + uint32_t mFlags{0}; - CacheIndexRecord() - : mFrecency(0), - mOriginAttrsHash(0), - mOnStartTime(kIndexTimeNotAvailable), - mOnStopTime(kIndexTimeNotAvailable), - mContentType(nsICacheEntry::CONTENT_TYPE_UNKNOWN), - mFlags(0) {} + CacheIndexRecord() = default; }; #pragma pack(pop) @@ -491,20 +485,7 @@ class CacheIndexEntryUpdate : public CacheIndexEntry { class CacheIndexStats { public: - CacheIndexStats() - : mCount(0), - mNotInitialized(0), - mRemoved(0), - mDirty(0), - mFresh(0), - mEmpty(0), - mSize(0) -#ifdef DEBUG - , - mStateLogged(false), - mDisableLogging(false) -#endif - { + CacheIndexStats() { for (uint32_t i = 0; i < nsICacheEntry::CONTENT_TYPE_LAST; ++i) { mCountByType[i] = 0; mSizeByType[i] = 0; @@ -689,14 +670,14 @@ class CacheIndexStats { } private: - uint32_t mCount; + uint32_t mCount{0}; uint32_t mCountByType[nsICacheEntry::CONTENT_TYPE_LAST]{0}; - uint32_t mNotInitialized; - uint32_t mRemoved; - uint32_t mDirty; - uint32_t mFresh; - uint32_t mEmpty; - uint32_t mSize; + uint32_t mNotInitialized{0}; + uint32_t mRemoved{0}; + uint32_t mDirty{0}; + uint32_t mFresh{0}; + uint32_t mEmpty{0}; + uint32_t mSize{0}; uint32_t mSizeByType[nsICacheEntry::CONTENT_TYPE_LAST]{0}; #ifdef DEBUG // We completely remove the data about an entry from the stats in @@ -704,10 +685,10 @@ class CacheIndexStats { // 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; + bool mStateLogged{false}; // Disables logging in this instance of CacheIndexStats - bool mDisableLogging; + bool mDisableLogging{false}; #endif }; @@ -1066,35 +1047,35 @@ class CacheIndex final : public CacheFileIOListener, public nsIRunnable { nsCOMPtr mCacheDirectory; - EState mState; + EState mState{INITIAL}; // Timestamp of time when the index was initialized. We use it to delay // initial update or build of index. TimeStamp mStartTime; // Set to true in PreShutdown(), it is checked on variaous places to prevent // starting any process (write, update, etc.) during shutdown. - bool mShuttingDown; + bool mShuttingDown{false}; // When set to true, update process should start as soon as possible. This // flag is set whenever we find some inconsistency which would be fixed by // update process. The flag is checked always when switching to READY state. // To make sure we start the update process as soon as possible, methods that // set this flag should also call StartUpdatingIndexIfNeeded() to cover the // case when we are currently in READY state. - bool mIndexNeedsUpdate; + bool mIndexNeedsUpdate{false}; // Set at the beginning of RemoveAll() which clears the whole index. When // removing all entries we must stop any pending reading, writing, updating or // building operation. This flag is checked at various places and it prevents // we won't start another operation (e.g. canceling reading of the index would // normally start update or build process) - bool mRemovingAll; + bool mRemovingAll{false}; // Whether the index file on disk exists and is valid. - bool mIndexOnDiskIsValid; + bool mIndexOnDiskIsValid{false}; // When something goes wrong during updating or building process, we don't // mark index clean (and also don't write journal) to ensure that update or // build will be initiated on the next start. - bool mDontMarkIndexClean; + bool mDontMarkIndexClean{false}; // Timestamp value from index file. It is used during update process to skip // entries that were last modified before this timestamp. - uint32_t mIndexTimeStamp; + uint32_t mIndexTimeStamp{0}; // Timestamp of last time the index was dumped to disk. // NOTE: The index might not be necessarily dumped at this time. The value // is used to schedule next dump of the index. @@ -1103,28 +1084,28 @@ class CacheIndex final : public CacheFileIOListener, public nsIRunnable { // Timer of delayed update/build. nsCOMPtr mUpdateTimer; // True when build or update event is posted - bool mUpdateEventPending; + bool mUpdateEventPending{false}; // Helper members used when reading/writing index from/to disk. // Contains number of entries that should be skipped: // - in hashtable when writing index because they were already written // - in index file when reading index because they were already read - uint32_t mSkipEntries; + uint32_t mSkipEntries{0}; // Number of entries that should be written to disk. This is number of entries // in hashtable that are initialized and are not marked as removed when // writing begins. - uint32_t mProcessEntries; - char* mRWBuf; - uint32_t mRWBufSize; - uint32_t mRWBufPos; + uint32_t mProcessEntries{0}; + char* mRWBuf{nullptr}; + uint32_t mRWBufSize{0}; + uint32_t mRWBufPos{0}; RefPtr mRWHash; // True if read or write operation is pending. It is used to ensure that // mRWBuf is not freed until OnDataRead or OnDataWritten is called. - bool mRWPending; + bool mRWPending{false}; // Reading of journal succeeded if true. - bool mJournalReadSuccessfully; + bool mJournalReadSuccessfully{false}; // Handle used for writing and reading index file. RefPtr mIndexHandle; @@ -1197,7 +1178,7 @@ class CacheIndex final : public CacheFileIOListener, public nsIRunnable { public: Iterator Iter() { return Iterator(&mRecs); } - FrecencyArray() : mUnsortedElements(0), mRemovedElements(0) {} + FrecencyArray() = default; // Methods used by CacheIndexEntryAutoManage to keep the array up to date. void AppendRecord(CacheIndexRecordWrapper* aRecord); @@ -1213,12 +1194,12 @@ class CacheIndex final : public CacheFileIOListener, public nsIRunnable { friend class CacheIndex; nsTArray> mRecs; - uint32_t mUnsortedElements; + uint32_t mUnsortedElements{0}; // Instead of removing elements from the array immediately, we null them out // and the iterator skips them when accessing the array. The null pointers // are placed at the end during sorting and we strip them out all at once. // This saves moving a lot of memory in nsTArray::RemoveElementsAt. - uint32_t mRemovedElements; + uint32_t mRemovedElements{0}; }; FrecencyArray mFrecencyArray; @@ -1228,7 +1209,7 @@ class CacheIndex final : public CacheFileIOListener, public nsIRunnable { // This flag is true iff we are between CacheStorageService:Clear() and // processing all contexts to be evicted. It will make UI to show // "calculating" instead of any intermediate cache size. - bool mAsyncGetDiskConsumptionBlocked; + bool mAsyncGetDiskConsumptionBlocked{false}; class DiskConsumptionObserver : public Runnable { public: @@ -1280,7 +1261,7 @@ class CacheIndex final : public CacheFileIOListener, public nsIRunnable { nsTArray> mDiskConsumptionObservers; // Number of bytes written to the cache since the last telemetry report - uint64_t mTotalBytesWritten; + uint64_t mTotalBytesWritten{0}; }; } // namespace net diff --git a/netwerk/cache2/CacheStorageService.h b/netwerk/cache2/CacheStorageService.h index 6e93ca950445..65082b9f4891 100644 --- a/netwerk/cache2/CacheStorageService.h +++ b/netwerk/cache2/CacheStorageService.h @@ -397,8 +397,7 @@ class CacheStorageService final : public nsICacheStorageService, public: IOThreadSuspender() : Runnable("net::CacheStorageService::IOThreadSuspender"), - mMon("IOThreadSuspender"), - mSignaled(false) {} + mMon("IOThreadSuspender") {} void Notify(); private: @@ -406,7 +405,7 @@ class CacheStorageService final : public nsICacheStorageService, NS_IMETHOD Run() override; Monitor mMon; - bool mSignaled; + bool mSignaled{false}; }; RefPtr mActiveIOSuspender; diff --git a/netwerk/cookie/CookieStorage.cpp b/netwerk/cookie/CookieStorage.cpp index 204d8b6e5265..b029ef2cc4b6 100644 --- a/netwerk/cookie/CookieStorage.cpp +++ b/netwerk/cookie/CookieStorage.cpp @@ -108,16 +108,6 @@ size_t CookieEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { NS_IMPL_ISUPPORTS(CookieStorage, nsIObserver, nsISupportsWeakReference) -CookieStorage::CookieStorage() - : mCookieCount(0), - mCookieOldestTime(INT64_MAX), - mMaxNumberOfCookies(kMaxNumberOfCookies), - mMaxCookiesPerHost(kMaxCookiesPerHost), - mCookieQuotaPerHost(kCookieQuotaPerHost), - mCookiePurgeAge(kCookiePurgeAge) {} - -CookieStorage::~CookieStorage() = default; - void CookieStorage::Init() { // init our pref and observer nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); diff --git a/netwerk/cookie/CookieStorage.h b/netwerk/cookie/CookieStorage.h index 36df7c765c35..9a4abb2d7cb9 100644 --- a/netwerk/cookie/CookieStorage.h +++ b/netwerk/cookie/CookieStorage.h @@ -12,6 +12,7 @@ #include "nsTHashtable.h" #include "nsWeakReference.h" #include +#include "CookieCommons.h" class nsIArray; class nsICookie; @@ -127,8 +128,8 @@ class CookieStorage : public nsIObserver, public nsSupportsWeakReference { virtual void Close() = 0; protected: - CookieStorage(); - virtual ~CookieStorage(); + CookieStorage() = default; + virtual ~CookieStorage() = default; void Init(); @@ -163,7 +164,7 @@ class CookieStorage : public nsIObserver, public nsSupportsWeakReference { nsTHashtable mHostTable; - uint32_t mCookieCount; + uint32_t mCookieCount{0}; private: void PrefChanged(nsIPrefBranch* aPrefBranch); @@ -187,12 +188,12 @@ class CookieStorage : public nsIObserver, public nsSupportsWeakReference { uint16_t aMaxNumberOfCookies, int64_t aCookiePurgeAge) = 0; - int64_t mCookieOldestTime; + int64_t mCookieOldestTime{INT64_MAX}; - uint16_t mMaxNumberOfCookies; - uint16_t mMaxCookiesPerHost; - uint16_t mCookieQuotaPerHost; - int64_t mCookiePurgeAge; + uint16_t mMaxNumberOfCookies{kMaxNumberOfCookies}; + uint16_t mMaxCookiesPerHost{kMaxCookiesPerHost}; + uint16_t mCookieQuotaPerHost{kCookieQuotaPerHost}; + int64_t mCookiePurgeAge{kCookiePurgeAge}; }; } // namespace net diff --git a/netwerk/dns/TRR.cpp b/netwerk/dns/TRR.cpp index 94a23ba5bc37..62dacb4eed3f 100644 --- a/netwerk/dns/TRR.cpp +++ b/netwerk/dns/TRR.cpp @@ -81,10 +81,7 @@ TRR::TRR(AHostResolver* aResolver, nsHostRecord* aRec, nsCString& aHost, // used on push TRR::TRR(AHostResolver* aResolver, bool aPB) - : mozilla::Runnable("TRR"), - mHostResolver(aResolver), - mType(TRRTYPE_A), - mPB(aPB) { + : mozilla::Runnable("TRR"), mHostResolver(aResolver), mPB(aPB) { MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess() || XRE_IsSocketProcess(), "TRR must be in parent or socket process"); } diff --git a/netwerk/ipc/InputChannelThrottleQueueParent.cpp b/netwerk/ipc/InputChannelThrottleQueueParent.cpp index e68ff1417ac0..d1e6e82f9f5b 100644 --- a/netwerk/ipc/InputChannelThrottleQueueParent.cpp +++ b/netwerk/ipc/InputChannelThrottleQueueParent.cpp @@ -50,9 +50,6 @@ InputChannelThrottleQueueParent::Release(void) { return count; } -InputChannelThrottleQueueParent::InputChannelThrottleQueueParent() - : mBytesProcessed(0), mMeanBytesPerSecond(0), mMaxBytesPerSecond(0) {} - mozilla::ipc::IPCResult InputChannelThrottleQueueParent::RecvRecordRead( const uint32_t& aBytesRead) { mBytesProcessed += aBytesRead; diff --git a/netwerk/ipc/InputChannelThrottleQueueParent.h b/netwerk/ipc/InputChannelThrottleQueueParent.h index a81424fd3031..74d1a00bd70e 100644 --- a/netwerk/ipc/InputChannelThrottleQueueParent.h +++ b/netwerk/ipc/InputChannelThrottleQueueParent.h @@ -30,16 +30,16 @@ class InputChannelThrottleQueueParent final friend class PInputChannelThrottleQueueParent; - explicit InputChannelThrottleQueueParent(); + explicit InputChannelThrottleQueueParent() = default; mozilla::ipc::IPCResult RecvRecordRead(const uint32_t& aBytesRead); void ActorDestroy(ActorDestroyReason aWhy) override {} private: virtual ~InputChannelThrottleQueueParent() = default; - uint64_t mBytesProcessed; - uint32_t mMeanBytesPerSecond; - uint32_t mMaxBytesPerSecond; + uint64_t mBytesProcessed{0}; + uint32_t mMeanBytesPerSecond{0}; + uint32_t mMaxBytesPerSecond{0}; }; NS_DEFINE_STATIC_IID_ACCESSOR(InputChannelThrottleQueueParent, diff --git a/netwerk/ipc/SocketProcessChild.cpp b/netwerk/ipc/SocketProcessChild.cpp index 27a344998bbf..3e9297632a7e 100644 --- a/netwerk/ipc/SocketProcessChild.cpp +++ b/netwerk/ipc/SocketProcessChild.cpp @@ -72,8 +72,7 @@ using namespace ipc; SocketProcessChild* sSocketProcessChild; -SocketProcessChild::SocketProcessChild() - : mShuttingDown(false), mMutex("SocketProcessChild::mMutex") { +SocketProcessChild::SocketProcessChild() { LOG(("CONSTRUCT SocketProcessChild::SocketProcessChild\n")); nsDebugImpl::SetMultiprocessMode("Socket"); diff --git a/netwerk/ipc/SocketProcessChild.h b/netwerk/ipc/SocketProcessChild.h index 900577aa5b91..fc5004ce86fc 100644 --- a/netwerk/ipc/SocketProcessChild.h +++ b/netwerk/ipc/SocketProcessChild.h @@ -155,9 +155,9 @@ class SocketProcessChild final RefPtr mProfilerController; #endif - bool mShuttingDown; + bool mShuttingDown{false}; // Protect the table below. - Mutex mMutex; + Mutex mMutex{"SocketProcessChild::mMutex"}; nsTHashMap> mBackgroundDataBridgeMap; }; diff --git a/netwerk/protocol/about/nsAboutCacheEntry.h b/netwerk/protocol/about/nsAboutCacheEntry.h index 4c4e6c2ee8d5..af94f12ccca7 100644 --- a/netwerk/protocol/about/nsAboutCacheEntry.h +++ b/netwerk/protocol/about/nsAboutCacheEntry.h @@ -39,7 +39,7 @@ class nsAboutCacheEntry final : public nsIAboutModule { NS_FORWARD_SAFE_NSICHANNEL(mChannel) NS_FORWARD_SAFE_NSIREQUEST(mChannel) - Channel() : mBuffer(nullptr), mWaitingForData(false), mHexDumpState(0) {} + Channel() = default; private: virtual ~Channel() = default; @@ -66,10 +66,10 @@ class nsAboutCacheEntry final : public nsIAboutModule { nsCOMPtr mLoadInfo; nsCOMPtr mCacheURI; - nsCString* mBuffer; + nsCString* mBuffer{nullptr}; nsCOMPtr mOutputStream; - bool mWaitingForData; - uint32_t mHexDumpState; + bool mWaitingForData{false}; + uint32_t mHexDumpState{0}; nsCOMPtr mChannel; }; diff --git a/netwerk/protocol/gio/GIOChannelChild.cpp b/netwerk/protocol/gio/GIOChannelChild.cpp index 9becbebbb2e3..487912c7511f 100644 --- a/netwerk/protocol/gio/GIOChannelChild.cpp +++ b/netwerk/protocol/gio/GIOChannelChild.cpp @@ -31,13 +31,7 @@ namespace mozilla { namespace net { GIOChannelChild::GIOChannelChild(nsIURI* aUri) - : mIPCOpen(false), - mEventQ(new ChannelEventQueue(static_cast(this))), - mCanceled(false), - mSuspendCount(0), - mIsPending(false), - mStartPos(0), - mSuspendSent(false) { + : mEventQ(new ChannelEventQueue(static_cast(this))) { SetURI(aUri); // We could support thread retargeting, but as long as we're being driven by // IPDL on the main thread it doesn't buy us anything. diff --git a/netwerk/protocol/gio/GIOChannelChild.h b/netwerk/protocol/gio/GIOChannelChild.h index 87eb214cb4d8..0d35ab521598 100644 --- a/netwerk/protocol/gio/GIOChannelChild.h +++ b/netwerk/protocol/gio/GIOChannelChild.h @@ -86,19 +86,20 @@ class GIOChannelChild final : public PGIOChannelChild, private: nsCOMPtr mUploadStream; - bool mIPCOpen; + bool mIPCOpen = false; const RefPtr mEventQ; bool mCanceled = false; - uint32_t mSuspendCount; + uint32_t mSuspendCount = 0; + ; bool mIsPending = false; - uint64_t mStartPos; + uint64_t mStartPos = 0; nsCString mEntityID; // Set if SendSuspend is called. Determines if SendResume is needed when // diverting callbacks to parent. - bool mSuspendSent; + bool mSuspendSent = false; }; inline bool GIOChannelChild::IsSuspended() const { return mSuspendCount != 0; } diff --git a/netwerk/protocol/res/ExtensionProtocolHandler.cpp b/netwerk/protocol/res/ExtensionProtocolHandler.cpp index 815ec896e45b..959e430d9c9a 100644 --- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp +++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp @@ -346,16 +346,7 @@ ExtensionProtocolHandler::GetSingleton() { } ExtensionProtocolHandler::ExtensionProtocolHandler() - : SubstitutingProtocolHandler(EXTENSION_SCHEME) -#if !defined(XP_WIN) -# if defined(XP_MACOSX) - , - mAlreadyCheckedDevRepo(false) -# endif /* XP_MACOSX */ - , - mAlreadyCheckedAppDir(false) -#endif /* ! XP_WIN */ -{ + : SubstitutingProtocolHandler(EXTENSION_SCHEME) { // Note, extensions.webextensions.protocol.remote=false is for // debugging purposes only. With process-level sandboxing, child // processes (specifically content and extension processes), will diff --git a/netwerk/protocol/res/ExtensionProtocolHandler.h b/netwerk/protocol/res/ExtensionProtocolHandler.h index ec253702e98b..0824d7dd99a5 100644 --- a/netwerk/protocol/res/ExtensionProtocolHandler.h +++ b/netwerk/protocol/res/ExtensionProtocolHandler.h @@ -189,7 +189,7 @@ class ExtensionProtocolHandler final // Set to true once we've already tried to load the dev repo path, // allowing for lazy initialization of |mDevRepo|. - bool mAlreadyCheckedDevRepo; + bool mAlreadyCheckedDevRepo{false}; #endif /* XP_MACOSX */ #if !defined(XP_WIN) @@ -214,7 +214,7 @@ class ExtensionProtocolHandler final // Set to true once we've already read the AppDir, allowing for lazy // initialization of |mAppDir|. - bool mAlreadyCheckedAppDir; + bool mAlreadyCheckedAppDir{false}; #endif /* !defined(XP_WIN) */ // Used for opening JAR files off the main thread when we just need to diff --git a/netwerk/protocol/viewsource/nsViewSourceChannel.h b/netwerk/protocol/viewsource/nsViewSourceChannel.h index c8c71a799c58..87c490f6b7c7 100644 --- a/netwerk/protocol/viewsource/nsViewSourceChannel.h +++ b/netwerk/protocol/viewsource/nsViewSourceChannel.h @@ -49,8 +49,7 @@ class nsViewSourceChannel final : public nsIViewSourceChannel, NS_FORWARD_SAFE_NSIHTTPCHANNELINTERNAL(mHttpChannelInternal) // nsViewSourceChannel methods: - nsViewSourceChannel() - : mIsDocument(false), mOpened(false), mIsSrcdocChannel(false) {} + nsViewSourceChannel() = default; [[nodiscard]] nsresult Init(nsIURI* uri, nsILoadInfo* aLoadInfo); @@ -91,9 +90,9 @@ class nsViewSourceChannel final : public nsIViewSourceChannel, nsCOMPtr mOriginalURI; nsCOMPtr mBaseURI; nsCString mContentType; - bool mIsDocument; // keeps track of the LOAD_DOCUMENT_URI flag - bool mOpened; - bool mIsSrcdocChannel; + bool mIsDocument{false}; // keeps track of the LOAD_DOCUMENT_URI flag + bool mOpened{false}; + bool mIsSrcdocChannel{false}; }; #endif /* nsViewSourceChannel_h___ */ diff --git a/netwerk/protocol/websocket/WebSocketFrame.cpp b/netwerk/protocol/websocket/WebSocketFrame.cpp index c8032dfa333e..63673021f96e 100644 --- a/netwerk/protocol/websocket/WebSocketFrame.cpp +++ b/netwerk/protocol/websocket/WebSocketFrame.cpp @@ -68,14 +68,11 @@ WebSocketFrame::GetPayload(nsACString& aValue) { } WebSocketFrameData::WebSocketFrameData() - : mTimeStamp(0), - mFinBit(false), + : mFinBit(false), mRsvBit1(false), mRsvBit2(false), mRsvBit3(false), - mMaskBit(false), - mOpCode(0), - mMask(0) { + mMaskBit(false) { MOZ_COUNT_CTOR(WebSocketFrameData); } diff --git a/netwerk/protocol/websocket/WebSocketFrame.h b/netwerk/protocol/websocket/WebSocketFrame.h index 62d37447c792..8278867648f1 100644 --- a/netwerk/protocol/websocket/WebSocketFrame.h +++ b/netwerk/protocol/websocket/WebSocketFrame.h @@ -44,16 +44,16 @@ class WebSocketFrameData final { void WriteIPCParams(IPC::Message* aMessage) const; bool ReadIPCParams(const IPC::Message* aMessage, PickleIterator* aIter); - DOMHighResTimeStamp mTimeStamp; + DOMHighResTimeStamp mTimeStamp{0}; bool mFinBit : 1; bool mRsvBit1 : 1; bool mRsvBit2 : 1; bool mRsvBit3 : 1; bool mMaskBit : 1; - uint8_t mOpCode; + uint8_t mOpCode{0}; - uint32_t mMask; + uint32_t mMask{0}; nsCString mPayload; }; diff --git a/netwerk/socket/nsSOCKSIOLayer.cpp b/netwerk/socket/nsSOCKSIOLayer.cpp index 130b35f387bf..119a3cbf4c51 100644 --- a/netwerk/socket/nsSOCKSIOLayer.cpp +++ b/netwerk/socket/nsSOCKSIOLayer.cpp @@ -188,61 +188,31 @@ class nsSOCKSSocketInfo : public nsISOCKSSocketInfo, public nsIDNSListener { } private: - State mState; - uint8_t* mData; - uint8_t* mDataIoPtr; - uint32_t mDataLength; - uint32_t mReadOffset; - uint32_t mAmountToRead; + State mState{SOCKS_INITIAL}; + uint8_t* mData{nullptr}; + uint8_t* mDataIoPtr{nullptr}; + uint32_t mDataLength{0}; + uint32_t mReadOffset{0}; + uint32_t mAmountToRead{0}; nsCOMPtr mDnsRec; nsCOMPtr mLookup; - nsresult mLookupStatus; - PRFileDesc* mFD; + nsresult mLookupStatus{NS_ERROR_NOT_INITIALIZED}; + PRFileDesc* mFD{nullptr}; nsCString mDestinationHost; nsCOMPtr mProxy; - int32_t mVersion; // SOCKS version 4 or 5 - int32_t mDestinationFamily; - uint32_t mFlags; - uint32_t mTlsFlags; + int32_t mVersion{-1}; // SOCKS version 4 or 5 + int32_t mDestinationFamily{AF_INET}; + uint32_t mFlags{0}; + uint32_t mTlsFlags{0}; NetAddr mInternalProxyAddr; NetAddr mExternalProxyAddr; NetAddr mDestinationAddr; - PRIntervalTime mTimeout; + PRIntervalTime mTimeout{PR_INTERVAL_NO_TIMEOUT}; nsCString mProxyUsername; // Cache, from mProxy }; -nsSOCKSSocketInfo::nsSOCKSSocketInfo() - : mState(SOCKS_INITIAL), - mDataIoPtr(nullptr), - mDataLength(0), - mReadOffset(0), - mAmountToRead(0), - mLookupStatus(NS_ERROR_NOT_INITIALIZED), - mFD(nullptr), - mVersion(-1), - mDestinationFamily(AF_INET), - mFlags(0), - mTlsFlags(0), - mTimeout(PR_INTERVAL_NO_TIMEOUT) { - this->mInternalProxyAddr.inet.family = 0; - this->mInternalProxyAddr.inet6.family = 0; - this->mInternalProxyAddr.inet6.port = 0; - this->mInternalProxyAddr.inet6.flowinfo = 0; - this->mInternalProxyAddr.inet6.scope_id = 0; - this->mInternalProxyAddr.local.family = 0; - this->mExternalProxyAddr.inet.family = 0; - this->mExternalProxyAddr.inet6.family = 0; - this->mExternalProxyAddr.inet6.port = 0; - this->mExternalProxyAddr.inet6.flowinfo = 0; - this->mExternalProxyAddr.inet6.scope_id = 0; - this->mExternalProxyAddr.local.family = 0; - this->mDestinationAddr.inet.family = 0; - this->mDestinationAddr.inet6.family = 0; - this->mDestinationAddr.inet6.port = 0; - this->mDestinationAddr.inet6.flowinfo = 0; - this->mDestinationAddr.inet6.scope_id = 0; - this->mDestinationAddr.local.family = 0; +nsSOCKSSocketInfo::nsSOCKSSocketInfo() { mData = new uint8_t[BUFFER_SIZE]; mInternalProxyAddr.raw.family = AF_INET; @@ -290,7 +260,7 @@ nsSOCKSSocketInfo::nsSOCKSSocketInfo() template class Buffer { public: - Buffer() : mBuf(nullptr), mLength(0) {} + Buffer() = default; explicit Buffer(uint8_t* aBuf, size_t aLength = 0) : mBuf(aBuf), mLength(aLength) {} @@ -364,8 +334,8 @@ class Buffer { return result; } - uint8_t* mBuf; - size_t mLength; + uint8_t* mBuf{nullptr}; + size_t mLength{0}; }; void nsSOCKSSocketInfo::Init(int32_t version, int32_t family, @@ -803,11 +773,10 @@ PRStatus nsSOCKSSocketInfo::ReadV5AuthResponse() { if (!mProxyUsername.IsEmpty() && authMethod == 0x02) { // username/pw LOGDEBUG(("socks5: auth method accepted by server")); return WriteV5UsernameRequest(); - } else { // 0xFF signals error - LOGERROR(("socks5: server did not accept our authentication method")); - HandshakeFinished(PR_CONNECT_REFUSED_ERROR); - return PR_FAILURE; - } + } // 0xFF signals error + LOGERROR(("socks5: server did not accept our authentication method")); + HandshakeFinished(PR_CONNECT_REFUSED_ERROR); + return PR_FAILURE; } PRStatus nsSOCKSSocketInfo::WriteV5UsernameRequest() { diff --git a/netwerk/streamconv/converters/nsDirIndex.cpp b/netwerk/streamconv/converters/nsDirIndex.cpp index c6e89fd7c562..6d7f19c11e83 100644 --- a/netwerk/streamconv/converters/nsDirIndex.cpp +++ b/netwerk/streamconv/converters/nsDirIndex.cpp @@ -7,9 +7,6 @@ NS_IMPL_ISUPPORTS(nsDirIndex, nsIDirIndex) -nsDirIndex::nsDirIndex() - : mType(TYPE_UNKNOWN), mSize(UINT64_MAX), mLastModified(-1LL) {} - NS_IMETHODIMP nsDirIndex::GetType(uint32_t* aType) { NS_ENSURE_ARG_POINTER(aType); diff --git a/netwerk/streamconv/converters/nsDirIndex.h b/netwerk/streamconv/converters/nsDirIndex.h index 2ff411de54c2..eb6009295c9c 100644 --- a/netwerk/streamconv/converters/nsDirIndex.h +++ b/netwerk/streamconv/converters/nsDirIndex.h @@ -15,18 +15,18 @@ class nsDirIndex final : public nsIDirIndex { ~nsDirIndex() = default; public: - nsDirIndex(); + nsDirIndex() = default; NS_DECL_ISUPPORTS NS_DECL_NSIDIRINDEX protected: - uint32_t mType; + uint32_t mType{TYPE_UNKNOWN}; nsCString mContentType; nsCString mLocation; nsString mDescription; - int64_t mSize; - PRTime mLastModified; + int64_t mSize{INT64_MAX}; + PRTime mLastModified{-1LL}; }; #endif diff --git a/netwerk/streamconv/converters/nsDirIndexParser.cpp b/netwerk/streamconv/converters/nsDirIndexParser.cpp index c4d9e160096e..b9e4a55b3d80 100644 --- a/netwerk/streamconv/converters/nsDirIndexParser.cpp +++ b/netwerk/streamconv/converters/nsDirIndexParser.cpp @@ -83,8 +83,6 @@ GetFTPFallbackEncodingDoNotAddNewCallersToThisFunction() { NS_IMPL_ISUPPORTS(nsDirIndexParser, nsIRequestObserver, nsIStreamListener, nsIDirIndexParser) -nsDirIndexParser::nsDirIndexParser() : mLineStart(0), mHasDescription(false) {} - nsresult nsDirIndexParser::Init() { mLineStart = 0; mHasDescription = false; @@ -169,7 +167,7 @@ nsDirIndexParser::Field nsDirIndexParser::gFieldTable[] = { {nullptr, FIELD_UNKNOWN}}; nsrefcnt nsDirIndexParser::gRefCntParser = 0; -nsITextToSubURI* nsDirIndexParser::gTextToSubURI; +nsITextToSubURI* nsDirIndexParser::gTextToSubURI = nullptr; void nsDirIndexParser::ParseFormat(const char* aFormatStr) { // Parse a "200" format line, and remember the fields and their diff --git a/netwerk/streamconv/converters/nsDirIndexParser.h b/netwerk/streamconv/converters/nsDirIndexParser.h index 1776aeaa1eee..4c6fd9475c87 100644 --- a/netwerk/streamconv/converters/nsDirIndexParser.h +++ b/netwerk/streamconv/converters/nsDirIndexParser.h @@ -20,7 +20,7 @@ class nsDirIndexParser : public nsIDirIndexParser { private: virtual ~nsDirIndexParser(); - nsDirIndexParser(); + nsDirIndexParser() = default; nsresult Init(); public: @@ -53,9 +53,9 @@ class nsDirIndexParser : public nsIDirIndexParser { nsCString mEncoding; nsCString mComment; nsCString mBuf; - int32_t mLineStart; - bool mHasDescription; - int mFormat[8]{0}; + int32_t mLineStart{0}; + bool mHasDescription{false}; + int mFormat[8]{-1}; nsresult ProcessData(nsIRequest* aRequest, nsISupports* aCtxt); void ParseFormat(const char* aFormatStr); diff --git a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp index 8a66b9144f6c..2a782ecabd90 100644 --- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp +++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp @@ -37,23 +37,7 @@ NS_IMPL_ISUPPORTS(nsHTTPCompressConv, nsIStreamConverter, nsIStreamListener, nsIThreadRetargetableStreamListener) // nsFTPDirListingConv methods -nsHTTPCompressConv::nsHTTPCompressConv() - : mMode(HTTP_COMPRESS_IDENTITY), - mOutBuffer(nullptr), - mInpBuffer(nullptr), - mOutBufferLen(0), - mInpBufferLen(0), - mCheckHeaderDone(false), - mStreamEnded(false), - mStreamInitialized(false), - mDummyStreamInitialised(false), - d_stream{}, - mLen(0), - hMode(0), - mSkipCount(0), - mFlags(0), - mDecodedDataLength(0), - mMutex("nsHTTPCompressConv") { +nsHTTPCompressConv::nsHTTPCompressConv() { LOG(("nsHttpCompresssConv %p ctor\n", this)); if (NS_IsMainThread()) { mFailUncleanStops = diff --git a/netwerk/streamconv/converters/nsHTTPCompressConv.h b/netwerk/streamconv/converters/nsHTTPCompressConv.h index e76417f822e3..be92cb71fe57 100644 --- a/netwerk/streamconv/converters/nsHTTPCompressConv.h +++ b/netwerk/streamconv/converters/nsHTTPCompressConv.h @@ -45,25 +45,19 @@ namespace net { class BrotliWrapper { public: - BrotliWrapper() - : mTotalOut(0), - mStatus(NS_OK), - mBrotliStateIsStreamEnd(false), - mRequest(nullptr), - mContext(nullptr), - mSourceOffset(0) { + BrotliWrapper() { BrotliDecoderStateInit(&mState, nullptr, nullptr, nullptr); } ~BrotliWrapper() { BrotliDecoderStateCleanup(&mState); } BrotliDecoderState mState{}; - Atomic mTotalOut; - nsresult mStatus; - Atomic mBrotliStateIsStreamEnd; + Atomic mTotalOut{0}; + nsresult mStatus = NS_OK; + Atomic mBrotliStateIsStreamEnd{false}; - nsIRequest* mRequest; - nsISupports* mContext; - uint64_t mSourceOffset; + nsIRequest* mRequest{nullptr}; + nsISupports* mContext{nullptr}; + uint64_t mSourceOffset{0}; }; class nsHTTPCompressConv : public nsIStreamConverter, @@ -95,13 +89,13 @@ class nsHTTPCompressConv : public nsIStreamConverter, nsCOMPtr mListener; // this guy gets the converted data via his OnDataAvailable () - Atomic mMode; + Atomic mMode{HTTP_COMPRESS_IDENTITY}; - unsigned char* mOutBuffer; - unsigned char* mInpBuffer; + unsigned char* mOutBuffer{nullptr}; + unsigned char* mInpBuffer{nullptr}; - uint32_t mOutBufferLen; - uint32_t mInpBufferLen; + uint32_t mOutBufferLen{0}; + uint32_t mInpBufferLen{0}; UniquePtr mBrotli; @@ -115,20 +109,20 @@ class nsHTTPCompressConv : public nsIStreamConverter, uint64_t aSourceOffset, const char* buffer, uint32_t aCount); - bool mCheckHeaderDone; - Atomic mStreamEnded; - bool mStreamInitialized; - bool mDummyStreamInitialised; + bool mCheckHeaderDone{false}; + Atomic mStreamEnded{false}; + bool mStreamInitialized{false}; + bool mDummyStreamInitialised{false}; bool mFailUncleanStops; - z_stream d_stream; - unsigned mLen, hMode, mSkipCount, mFlags; + z_stream d_stream{}; + unsigned mLen{0}, hMode{0}, mSkipCount{0}, mFlags{0}; uint32_t check_header(nsIInputStream* iStr, uint32_t streamLen, nsresult* rs); - Atomic mDecodedDataLength; + Atomic mDecodedDataLength{0}; - mutable mozilla::Mutex mMutex; + mutable mozilla::Mutex mMutex{"nsHTTPCompressConv"}; }; } // namespace net diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp index b68a2d7eb3b3..7fa28c71f6bb 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -48,8 +48,6 @@ static void AppendNonAsciiToNCR(const nsAString& in, nsCString& out) { } } -nsIndexedToHTML::nsIndexedToHTML() : mExpectAbsLoc(false) {} - nsresult nsIndexedToHTML::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult) { nsresult rv; diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.h b/netwerk/streamconv/converters/nsIndexedToHTML.h index 6173ecb52308..6ee1b47453c1 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.h +++ b/netwerk/streamconv/converters/nsIndexedToHTML.h @@ -29,7 +29,7 @@ class nsIndexedToHTML : public nsIStreamConverter, public nsIDirIndexListener { NS_DECL_NSISTREAMLISTENER NS_DECL_NSIDIRINDEXLISTENER - nsIndexedToHTML(); + nsIndexedToHTML() = default; nsresult Init(nsIStreamListener* aListener); @@ -53,7 +53,7 @@ class nsIndexedToHTML : public nsIStreamConverter, public nsIDirIndexListener { private: // Expecting absolute locations, given by 201 lines. - bool mExpectAbsLoc; + bool mExpectAbsLoc{false}; virtual ~nsIndexedToHTML() = default; }; diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/netwerk/streamconv/converters/nsMultiMixedConv.cpp index 7f7ca48a9a84..320e771d3848 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -25,15 +25,7 @@ nsPartChannel::nsPartChannel(nsIChannel* aMultipartChannel, uint32_t aPartID, nsIStreamListener* aListener) : mMultipartChannel(aMultipartChannel), mListener(aListener), - mStatus(NS_OK), - mLoadFlags(0), - mContentDisposition(0), - mContentLength(UINT64_MAX), - mIsByteRangeRequest(false), - mByteRangeStart(0), - mByteRangeEnd(0), - mPartID(aPartID), - mIsLastPart(false) { + mPartID(aPartID) { // Inherit the load flags from the original channel... mMultipartChannel->GetLoadFlags(&mLoadFlags); @@ -771,27 +763,15 @@ void nsMultiMixedConv::SwitchToControlParsing() { // nsMultiMixedConv methods nsMultiMixedConv::nsMultiMixedConv() - : mCurrentPartID(0), - mInOnDataAvailable(false), - mResponseHeader(HEADER_UNKNOWN), - // XXX: This is a hack to bypass the raw pointer to refcounted object in - // lambda analysis. It should be removed and replaced when the - // IncrementalTokenizer API is improved to avoid the need for such - // workarounds. - // - // This is safe because `mTokenizer` will not outlive `this`, meaning that - // this std::bind object will be destroyed before `this` dies. - mTokenizer(std::bind(&nsMultiMixedConv::ConsumeToken, this, - std::placeholders::_1)) { - mContentLength = UINT64_MAX; - mByteRangeStart = 0; - mByteRangeEnd = 0; - mTotalSent = 0; - mIsByteRangeRequest = false; - mParserState = INIT; - mRawData = nullptr; - mRequestListenerNotified = false; -} + // XXX: This is a hack to bypass the raw pointer to refcounted object in + // lambda analysis. It should be removed and replaced when the + // IncrementalTokenizer API is improved to avoid the need for such + // workarounds. + // + // This is safe because `mTokenizer` will not outlive `this`, meaning + // that this std::bind object will be destroyed before `this` dies. + : mTokenizer(std::bind(&nsMultiMixedConv::ConsumeToken, this, + std::placeholders::_1)) {} nsresult nsMultiMixedConv::SendStart() { nsresult rv = NS_OK; diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.h b/netwerk/streamconv/converters/nsMultiMixedConv.h index 0d567c31a72a..ce28fb29b567 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.h +++ b/netwerk/streamconv/converters/nsMultiMixedConv.h @@ -64,25 +64,25 @@ class nsPartChannel final : public nsIChannel, nsCOMPtr mListener; UniquePtr mResponseHead; - nsresult mStatus; - nsLoadFlags mLoadFlags; + nsresult mStatus{NS_OK}; + nsLoadFlags mLoadFlags{0}; nsCOMPtr mLoadGroup; nsCString mContentType; nsCString mContentCharset; - uint32_t mContentDisposition; + uint32_t mContentDisposition{0}; nsString mContentDispositionFilename; nsCString mContentDispositionHeader; - uint64_t mContentLength; + uint64_t mContentLength{UINT64_MAX}; - bool mIsByteRangeRequest; - int64_t mByteRangeStart; - int64_t mByteRangeEnd; + bool mIsByteRangeRequest{false}; + int64_t mByteRangeStart{0}; + int64_t mByteRangeEnd{0}; uint32_t mPartID; // unique ID that can be used to identify // this part of the multipart document - bool mIsLastPart; + bool mIsLastPart{false}; }; // The nsMultiMixedConv stream converter converts a stream of type @@ -157,26 +157,26 @@ class nsMultiMixedConv : public nsIStreamConverter { nsCString mContentDisposition; nsCString mContentSecurityPolicy; nsCString mRootContentSecurityPolicy; - uint64_t mContentLength; - uint64_t mTotalSent; + uint64_t mContentLength{UINT64_MAX}; + uint64_t mTotalSent{0}; // The following members are for tracking the byte ranges in // multipart/mixed content which specified the 'Content-Range:' // header... - int64_t mByteRangeStart; - int64_t mByteRangeEnd; - bool mIsByteRangeRequest; + int64_t mByteRangeStart{0}; + int64_t mByteRangeEnd{0}; + bool mIsByteRangeRequest{false}; // This flag is set first time we create a part channel. // We use it to prevent duplicated OnStopRequest call on the listener // when we fail from some reason to ever create a part channel that // ensures correct notifications. - bool mRequestListenerNotified; + bool mRequestListenerNotified{false}; - uint32_t mCurrentPartID; + uint32_t mCurrentPartID{0}; // Flag preventing reenter of OnDataAvailable in case the target listener // ends up spinning the event loop. - bool mInOnDataAvailable; + bool mInOnDataAvailable{false}; // Current state of the incremental parser enum EParserState { @@ -192,7 +192,7 @@ class nsMultiMixedConv : public nsIStreamConverter { EPILOGUE, INIT = PREAMBLE - } mParserState; + } mParserState{INIT}; // Response part header value, valid when we find a header name // we recognize. @@ -206,7 +206,7 @@ class nsMultiMixedConv : public nsIStreamConverter { HEADER_RANGE, HEADER_CONTENT_SECURITY_POLICY, HEADER_UNKNOWN - } mResponseHeader; + } mResponseHeader{HEADER_UNKNOWN}; // Cumulated value of a response header. nsCString mResponseHeaderValue; @@ -219,7 +219,7 @@ class nsMultiMixedConv : public nsIStreamConverter { // body data begins or continues. mRawDataLength is a cumulated length // of that data during a single tokenizer input feed. This is always // flushed right after we fed the tokenizer. - nsACString::const_char_iterator mRawData; + nsACString::const_char_iterator mRawData{nullptr}; nsACString::size_type mRawDataLength{0}; // At the start we don't know if the server will be sending boundary with diff --git a/netwerk/system/netlink/NetlinkService.cpp b/netwerk/system/netlink/NetlinkService.cpp index a8e9ad345f35..404e09ce53ec 100644 --- a/netwerk/system/netlink/NetlinkService.cpp +++ b/netwerk/system/netlink/NetlinkService.cpp @@ -176,7 +176,7 @@ class NetlinkAddress { class NetlinkNeighbor { public: - NetlinkNeighbor() : mHasMAC(false) {} + NetlinkNeighbor() = default; uint8_t Family() const { return mNeigh.ndm_family; } uint32_t GetIndex() const { return mNeigh.ndm_ifindex; } @@ -239,7 +239,7 @@ class NetlinkNeighbor { } private: - bool mHasMAC; + bool mHasMAC{false}; uint8_t mMAC[ETH_ALEN]{}; in_common_addr mAddr{}; struct ndmsg mNeigh {}; @@ -481,7 +481,7 @@ class NetlinkMsg { static uint8_t const kGenMsg = 1; static uint8_t const kRtMsg = 2; - NetlinkMsg() : mIsPending(false) {} + NetlinkMsg() = default; virtual ~NetlinkMsg() = default; virtual bool Send(int aFD) = 0; @@ -519,7 +519,7 @@ class NetlinkMsg { return mIsPending; } - bool mIsPending; + bool mIsPending{false}; }; class NetlinkGenMsg : public NetlinkMsg { @@ -630,17 +630,7 @@ bool NetlinkService::LinkInfo::UpdateStatus() { NS_IMPL_ISUPPORTS(NetlinkService, nsIRunnable) -NetlinkService::NetlinkService() - : mMutex("NetlinkService::mMutex"), - mInitialScanFinished(false), - mMsgId(0), - mLinkUp(true), - mRecalculateNetworkId(false), - mSendNetworkChangeEvent(false) { - mPid = getpid(); - mShutdownPipe[0] = -1; - mShutdownPipe[1] = -1; -} +NetlinkService::NetlinkService() : mPid(getpid()) {} NetlinkService::~NetlinkService() { MOZ_ASSERT(!mThread, "NetlinkService thread shutdown failed"); diff --git a/netwerk/system/netlink/NetlinkService.h b/netwerk/system/netlink/NetlinkService.h index 208c75933f1d..0734e4440c63 100644 --- a/netwerk/system/netlink/NetlinkService.h +++ b/netwerk/system/netlink/NetlinkService.h @@ -62,7 +62,7 @@ class NetlinkService : public nsIRunnable { void EnqueueRtMsg(uint8_t aFamily, void* aAddress); void RemovePendingMsg(); - mozilla::Mutex mMutex; + mozilla::Mutex mMutex{"NetlinkService::mMutex"}; void OnNetlinkMessage(int aNetlinkSocket); void OnLinkMessage(struct nlmsghdr* aNlh); @@ -83,28 +83,28 @@ class NetlinkService : public nsIRunnable { nsCOMPtr mThread; - bool mInitialScanFinished; + bool mInitialScanFinished{false}; // A pipe to signal shutdown with. - int mShutdownPipe[2]{}; + int mShutdownPipe[2]{-1, -1}; // IP addresses that are used to check the route for public traffic. struct in_addr mRouteCheckIPv4 {}; struct in6_addr mRouteCheckIPv6 {}; pid_t mPid; - uint32_t mMsgId; + uint32_t mMsgId{0}; - bool mLinkUp; + bool mLinkUp{true}; // Flag indicating that network ID could change and should be recalculated. // Calculation is postponed until we receive responses to all enqueued // messages. - bool mRecalculateNetworkId; + bool mRecalculateNetworkId{false}; // Flag indicating that network change event needs to be sent even if // network ID hasn't changed. - bool mSendNetworkChangeEvent; + bool mSendNetworkChangeEvent{false}; // Time stamp of setting mRecalculateNetworkId to true mozilla::TimeStamp mTriggerTime; diff --git a/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp b/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp index 9681cfcce22a..254d2bfb0757 100644 --- a/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp +++ b/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp @@ -275,7 +275,7 @@ class FeatureData { }; public: - FeatureData(); + FeatureData() = default; ~FeatureData(); nsresult Initialize(FeatureTask* aTask, nsIChannel* aChannel, @@ -291,7 +291,7 @@ class FeatureData { nsIUrlClassifierFeature::listType aListType, nsTArray>& aList); - State mState; + State mState{eUnclassified}; nsCOMPtr mFeature; nsCOMPtr mChannel; @@ -302,8 +302,6 @@ class FeatureData { nsCString mHostInPrefTables[2]; }; -FeatureData::FeatureData() : mState(eUnclassified) {} - FeatureData::~FeatureData() { NS_ReleaseOnMainThread("FeatureData:mFeature", mFeature.forget()); } diff --git a/netwerk/wifi/nsWifiScannerDBus.cpp b/netwerk/wifi/nsWifiScannerDBus.cpp index b9b3761ce75c..d74341078a8b 100644 --- a/netwerk/wifi/nsWifiScannerDBus.cpp +++ b/netwerk/wifi/nsWifiScannerDBus.cpp @@ -320,13 +320,14 @@ nsresult nsWifiScannerDBus::SetMac(DBusMessageIter* aVariant, const uint32_t MAC_LEN = 6; uint8_t macAddress[MAC_LEN]; - char* token = strtok(hwAddress, ":"); - for (uint32_t i = 0; i < ArrayLength(macAddress); i++) { + char* savedPtr = nullptr; + char* token = strtok_r(hwAddress, ":", &savedPtr); + for (unsigned char& macAddres : macAddress) { if (!token) { return NS_ERROR_FAILURE; } - macAddress[i] = strtoul(token, nullptr, 16); - token = strtok(nullptr, ":"); + macAddres = strtoul(token, nullptr, 16); + token = strtok_r(nullptr, ":", &savedPtr); } aAp->setMac(macAddress); return NS_OK;