Skip to content

Commit

Permalink
[Warnings] Remove unnecessary member variables to save some memory (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
VeithMetro authored Nov 21, 2024
1 parent ee17481 commit 9b67a12
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
10 changes: 4 additions & 6 deletions Source/Thunder/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ namespace PluginHost {
ControlData(const uint32_t maxRequests)
: _isExtended(false)
, _maxRequests(maxRequests)
, _state(0)
, _major(~0)
, _minor(~0)
, _patch(~0)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<RPC::InvokeServer>& handler)
Service(const PluginHost::Config& server, const Plugin::Config& plugin, ServiceMap& administrator, const mode /* type */, const Core::ProxyType<RPC::InvokeServer>& handler)
: PluginHost::Service(plugin, server.WebPrefix(), server.PersistentPath(), server.DataPath(), server.VolatilePath())
, _mode(type)
, _pluginHandling()
, _handler(nullptr)
, _extended(nullptr)
Expand Down Expand Up @@ -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
Expand All @@ -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> _composit;
Expand Down
4 changes: 3 additions & 1 deletion Source/core/NetworkInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, . . .);
Expand Down
4 changes: 3 additions & 1 deletion Source/core/NetworkInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
2 changes: 1 addition & 1 deletion Source/core/SystemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ namespace Core {

SystemInfo::SystemInfo()
: m_HostName(ConstructHostname())
, m_lastUpdateCpuStats(0)
{
#ifdef __LINUX__
#ifdef __APPLE__
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Source/core/SystemInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
Expand Down

0 comments on commit 9b67a12

Please sign in to comment.