From df4e34ff7607c5b8035ae1e012803ae33fb75ecf Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Tue, 11 Aug 2026 08:00:38 +0000 Subject: [PATCH] Bug 2053404 - Cleanup default state for static-analysis on Windows / ipc part r=ipc-reviewers,nika Differential Revision: https://phabricator.services.mozilla.com/D311058 --- ipc/chromium/src/base/message_pump_win.h | 10 +++++----- ipc/chromium/src/base/time.h | 12 ++++++------ ipc/glue/FileDescriptor.cpp | 2 -- ipc/glue/FileDescriptor.h | 2 +- ipc/glue/MessagePump.h | 2 +- ipc/glue/WindowsMessageLoop.cpp | 2 +- ipc/mscom/ProfilerMarkers.cpp | 4 ++-- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/ipc/chromium/src/base/message_pump_win.h b/ipc/chromium/src/base/message_pump_win.h index 4a2043dc7fee..c2c617feb924 100644 --- a/ipc/chromium/src/base/message_pump_win.h +++ b/ipc/chromium/src/base/message_pump_win.h @@ -28,7 +28,7 @@ class MessagePumpWin : public MessagePump { // class Observer { public: - virtual ~Observer() {} + virtual ~Observer() = default; // This method is called before processing a message. // The message may be undefined in which case msg.message is 0 @@ -49,14 +49,14 @@ class MessagePumpWin : public MessagePump { // from Dispatch. class Dispatcher { public: - virtual ~Dispatcher() {} + virtual ~Dispatcher() = default; // Dispatches the event. If true is returned processing continues as // normal. If false is returned, the nested loop exits immediately. virtual bool Dispatch(const MSG& msg) = 0; }; MessagePumpWin() : have_work_(0), state_(nullptr) {} - virtual ~MessagePumpWin() {} + virtual ~MessagePumpWin() = default; // Add an Observer, which will start receiving notifications immediately. void AddObserver(Observer* observer); @@ -273,7 +273,7 @@ class MessagePumpForIO : public MessagePumpWin { // class IOHandler { public: - virtual ~IOHandler() {} + virtual ~IOHandler() = default; // This will be called once the pending IO operation associated with // |context| completes. |error| is the Win32 error code of the IO operation // (ERROR_SUCCESS if there was no error). |bytes_transfered| will be zero @@ -297,7 +297,7 @@ class MessagePumpForIO : public MessagePumpWin { }; MessagePumpForIO(); - virtual ~MessagePumpForIO() {} + virtual ~MessagePumpForIO() = default; // MessagePump methods: virtual void ScheduleWork(); diff --git a/ipc/chromium/src/base/time.h b/ipc/chromium/src/base/time.h index 23b29d4d6d61..1c0aab6bce2c 100644 --- a/ipc/chromium/src/base/time.h +++ b/ipc/chromium/src/base/time.h @@ -38,7 +38,7 @@ class PageLoadTrackerUnitTest; class TimeDelta { public: - TimeDelta() : delta_(0) {} + TimeDelta() = default; // Converts units of time to TimeDeltas. static TimeDelta FromDays(int64_t days); @@ -124,7 +124,7 @@ class TimeDelta { explicit TimeDelta(int64_t delta_us) : delta_(delta_us) {} // Delta in microseconds. - int64_t delta_; + int64_t delta_{0}; }; inline TimeDelta operator*(int64_t a, TimeDelta td) { @@ -164,7 +164,7 @@ class Time { }; // Contains the NULL time. Use Time::Now() to get the current time. - explicit Time() : us_(0) {} + explicit Time() = default; // Returns true if the time object has not been initialized. bool is_null() const { return us_ == 0; } @@ -278,7 +278,7 @@ class Time { static const int64_t kTimeTToMicrosecondsOffset; // Time in microseconds in UTC. - int64_t us_; + int64_t us_{0}; }; inline Time TimeDelta::operator+(Time t) const { return Time(t.us_ + delta_); } @@ -319,7 +319,7 @@ inline TimeDelta TimeDelta::FromMicroseconds(int64_t us) { class TimeTicks { public: - TimeTicks() : ticks_(0) {} + TimeTicks() = default; TimeTicks(const TimeTicks&) = default; // Platform-dependent tick count representing "right now." @@ -378,7 +378,7 @@ class TimeTicks { explicit TimeTicks(int64_t ticks) : ticks_(ticks) {} // Tick count in microseconds. - int64_t ticks_; + int64_t ticks_{0}; }; inline TimeTicks TimeDelta::operator+(TimeTicks t) const { diff --git a/ipc/glue/FileDescriptor.cpp b/ipc/glue/FileDescriptor.cpp index 0b888ebffb3f..ffaafade1b63 100644 --- a/ipc/glue/FileDescriptor.cpp +++ b/ipc/glue/FileDescriptor.cpp @@ -35,8 +35,6 @@ FileDescriptor::FileDescriptor(PlatformHandleType aHandle) FileDescriptor::FileDescriptor(UniquePlatformHandle&& aHandle) : mHandle(std::move(aHandle)) {} -FileDescriptor::~FileDescriptor() = default; - FileDescriptor& FileDescriptor::operator=(const FileDescriptor& aOther) { if (this != &aOther) { mHandle = aOther.ClonePlatformHandle(); diff --git a/ipc/glue/FileDescriptor.h b/ipc/glue/FileDescriptor.h index 5a0e890d20da..bb2e8615ab33 100644 --- a/ipc/glue/FileDescriptor.h +++ b/ipc/glue/FileDescriptor.h @@ -44,7 +44,7 @@ class FileDescriptor { explicit FileDescriptor(UniquePlatformHandle&& aHandle); - ~FileDescriptor(); + ~FileDescriptor() = default; FileDescriptor& operator=(const FileDescriptor& aOther); diff --git a/ipc/glue/MessagePump.h b/ipc/glue/MessagePump.h index 14adc5e3f6b9..4c03b4dd8799 100644 --- a/ipc/glue/MessagePump.h +++ b/ipc/glue/MessagePump.h @@ -124,7 +124,7 @@ class MessagePumpForNonMainUIThreads final : public base::MessagePumpForUI, } private: - ~MessagePumpForNonMainUIThreads() {} + ~MessagePumpForNonMainUIThreads() = default; bool mInWait MOZ_GUARDED_BY(mWaitLock); mozilla::Mutex mWaitLock; diff --git a/ipc/glue/WindowsMessageLoop.cpp b/ipc/glue/WindowsMessageLoop.cpp index ddc7edd24c83..355a101e0927 100644 --- a/ipc/glue/WindowsMessageLoop.cpp +++ b/ipc/glue/WindowsMessageLoop.cpp @@ -824,7 +824,7 @@ bool MessageChannel::WaitForSyncNotify() { NeuteredWindowRegion neuteredRgn(true); { - while (1) { + while (true) { MSG msg = {0}; // Don't get wrapped up in here if the child connection dies. { diff --git a/ipc/mscom/ProfilerMarkers.cpp b/ipc/mscom/ProfilerMarkers.cpp index ba30e46ecbd2..0ca6c3a3e463 100644 --- a/ipc/mscom/ProfilerMarkers.cpp +++ b/ipc/mscom/ProfilerMarkers.cpp @@ -31,7 +31,7 @@ class ProfilerMarkerChannelHook final : public IChannelHook { ~ProfilerMarkerChannelHook() = default; public: - ProfilerMarkerChannelHook() : mRefCnt(0) {} + ProfilerMarkerChannelHook() = default; // IUnknown STDMETHODIMP QueryInterface(REFIID aIid, void** aOutInterface) override; @@ -91,7 +91,7 @@ class ProfilerMarkerChannelHook final : public IChannelHook { void BuildMarkerName(REFIID aIid, nsACString& aOutMarkerName); private: - mozilla::Atomic mRefCnt; + mozilla::Atomic mRefCnt{0}; }; HRESULT ProfilerMarkerChannelHook::QueryInterface(REFIID aIid,