From 9b67a12c8a5e144dccb7edeef0ccc2fd7dc7a6cc Mon Sep 17 00:00:00 2001 From: Mateusz Daniluk <121170681+VeithMetro@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:30:07 +0100 Subject: [PATCH] [Warnings] Remove unnecessary member variables to save some memory (#1793) * Use the warning suppression instead of the variable is not used macro in SystemInfo * Use the warning suppression instead of the variable is not used macro in NetworkInfo * Introduce a new DISABLE_WARNING_UNUSED_PRIVATE_FIELD macro Which is specific to clang * Change the macro to in NetworkInfo * Change the macro in SystemInfo * Change macros in PluginServer * Make sure to define the DISABLE_WARNING_UNUSED_PRIVATE_FIELD macro only for clang * Remove unused member variables, declare _hibernateStorage only if hibernate support is enabled * AdapterObserver callback member variable shouldn't be present on Windows and Apple * m_lastUpdateCpuStats is only used on Linux * m_lastUpdateCpuStats should be in the constructor only in case of Linux * Remove the -Wunused-private-field macro as it is no longer needed * Make sure not to initliaze callback for Windows and Apple * Make sure so that m_lastUpdateCpuStats is not defined on Apple but just Linux * Simplify the conditions for m_lastUpdateCpuStats initialization * Remove initialization of _state member variable from ControlData --- Source/Thunder/PluginServer.h | 10 ++++------ Source/core/NetworkInfo.cpp | 4 +++- Source/core/NetworkInfo.h | 4 +++- Source/core/SystemInfo.cpp | 2 +- Source/core/SystemInfo.h | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/Thunder/PluginServer.h b/Source/Thunder/PluginServer.h index 9ddc623bb..9da464f97 100644 --- a/Source/Thunder/PluginServer.h +++ b/Source/Thunder/PluginServer.h @@ -676,7 +676,6 @@ namespace PluginHost { ControlData(const uint32_t maxRequests) : _isExtended(false) , _maxRequests(maxRequests) - , _state(0) , _major(~0) , _minor(~0) , _patch(~0) @@ -753,7 +752,6 @@ namespace PluginHost { private: bool _isExtended; uint32_t _maxRequests; - VARIABLE_IS_NOT_USED uint8_t _state; uint8_t _major; uint8_t _minor; uint8_t _patch; @@ -803,9 +801,8 @@ namespace PluginHost { Service& operator=(Service&&) = delete; Service& operator=(const Service&) = delete; - Service(const PluginHost::Config& server, const Plugin::Config& plugin, ServiceMap& administrator, const mode type, const Core::ProxyType& handler) + Service(const PluginHost::Config& server, const Plugin::Config& plugin, ServiceMap& administrator, const mode /* type */, const Core::ProxyType& handler) : PluginHost::Service(plugin, server.WebPrefix(), server.PersistentPath(), server.DataPath(), server.VolatilePath()) - , _mode(type) , _pluginHandling() , _handler(nullptr) , _extended(nullptr) @@ -1626,7 +1623,6 @@ namespace PluginHost { } private: - VARIABLE_IS_NOT_USED const mode _mode; mutable Core::CriticalSection _pluginHandling; // The handlers that implement the actual logic behind the service @@ -1646,7 +1642,9 @@ namespace PluginHost { uint32_t _lastId; ControlData _metadata; Core::Library _library; - VARIABLE_IS_NOT_USED void* _hibernateStorage; +#ifdef HIBERNATE_SUPPORT_ENABLED + void* _hibernateStorage; +#endif ExternalAccess _external; ServiceMap& _administrator; Core::SinkType _composit; diff --git a/Source/core/NetworkInfo.cpp b/Source/core/NetworkInfo.cpp index 8127300cd..0f877b626 100644 --- a/Source/core/NetworkInfo.cpp +++ b/Source/core/NetworkInfo.cpp @@ -1863,8 +1863,10 @@ namespace Core { #endif - AdapterObserver::AdapterObserver(INotification* callback) + AdapterObserver::AdapterObserver(INotification* callback VARIABLE_IS_NOT_USED) +#if !defined(__WINDOWS__) && !defined(__APPLE__) : _callback(callback) +#endif { #ifdef __WINDOWS__ //IoWMIOpenBlock(&GUID_NDIS_STATUS_LINK_STATE, WMIGUID_NOTIFICATION, . . .); diff --git a/Source/core/NetworkInfo.h b/Source/core/NetworkInfo.h index cd063ca21..683ce67a5 100644 --- a/Source/core/NetworkInfo.h +++ b/Source/core/NetworkInfo.h @@ -206,7 +206,9 @@ namespace Core { uint32_t Close(); private: - VARIABLE_IS_NOT_USED INotification* _callback; +#if !defined(__WINDOWS__) && !defined(__APPLE__) + INotification* _callback; +#endif }; #if defined(__WINDOWS__) || defined(__APPLE__) diff --git a/Source/core/SystemInfo.cpp b/Source/core/SystemInfo.cpp index f4878c46e..e519b8c55 100644 --- a/Source/core/SystemInfo.cpp +++ b/Source/core/SystemInfo.cpp @@ -141,7 +141,6 @@ namespace Core { SystemInfo::SystemInfo() : m_HostName(ConstructHostname()) - , m_lastUpdateCpuStats(0) { #ifdef __LINUX__ #ifdef __APPLE__ @@ -171,6 +170,7 @@ namespace Core { m_cpuloadavg[0]=info.loads[0]; m_cpuloadavg[1]=info.loads[1]; m_cpuloadavg[2]=info.loads[2]; + m_lastUpdateCpuStats = 0; #endif #endif diff --git a/Source/core/SystemInfo.h b/Source/core/SystemInfo.h index 39301480d..4202eff51 100644 --- a/Source/core/SystemInfo.h +++ b/Source/core/SystemInfo.h @@ -239,8 +239,6 @@ namespace Core { mutable uint64_t m_freeswap; mutable uint64_t m_cpuload; mutable uint64_t m_cpuloadavg[3]; - VARIABLE_IS_NOT_USED mutable time_t m_lastUpdateCpuStats; - void UpdateCpuStats() const; void UpdateRealtimeInfo(); @@ -250,6 +248,8 @@ namespace Core { mutable uint64_t m_prevCpuSystemTicks; mutable uint64_t m_prevCpuUserTicks; mutable uint64_t m_prevCpuIdleTicks; +#elif defined(__LINUX__) + mutable time_t m_lastUpdateCpuStats; #endif }; // class SystemInfo } // namespace Core