diff --git a/src/btop.cpp b/src/btop.cpp index 3ceb3411..cdfdb3d0 100644 --- a/src/btop.cpp +++ b/src/btop.cpp @@ -468,10 +468,14 @@ namespace Runner { pthread_mutex_init(&pt_mutex, nullptr); status = pthread_mutex_lock(&pt_mutex); } - ~thread_lock() { + ~thread_lock() noexcept { if (status == 0) pthread_mutex_unlock(&pt_mutex); } + thread_lock(const thread_lock& other) = delete; + thread_lock& operator=(const thread_lock& other) = delete; + thread_lock(thread_lock&& other) = delete; + thread_lock& operator=(thread_lock&& other) = delete; }; //* Wrapper for raising privileges when using SUID bit @@ -482,10 +486,14 @@ namespace Runner { if (Global::real_uid != Global::set_uid) this->status = seteuid(Global::set_uid); } - ~gain_priv() { + ~gain_priv() noexcept { if (status == 0) status = seteuid(Global::real_uid); } + gain_priv(const gain_priv& other) = delete; + gain_priv& operator=(const gain_priv& other) = delete; + gain_priv(gain_priv&& other) = delete; + gain_priv& operator=(gain_priv&& other) = delete; }; string output; diff --git a/src/btop_shared.hpp b/src/btop_shared.hpp index 7e24078a..3a4e3fca 100644 --- a/src/btop_shared.hpp +++ b/src/btop_shared.hpp @@ -313,7 +313,11 @@ namespace Net { int status; public: IfAddrsPtr() { status = getifaddrs(&ifaddr); } - ~IfAddrsPtr() { freeifaddrs(ifaddr); } + ~IfAddrsPtr() noexcept { freeifaddrs(ifaddr); } + IfAddrsPtr(const IfAddrsPtr &) = delete; + IfAddrsPtr& operator=(IfAddrsPtr& other) = delete; + IfAddrsPtr(IfAddrsPtr &&) = delete; + IfAddrsPtr& operator=(IfAddrsPtr&& other) = delete; [[nodiscard]] constexpr auto operator()() -> struct ifaddrs* { return ifaddr; } [[nodiscard]] constexpr auto get() -> struct ifaddrs* { return ifaddr; } [[nodiscard]] constexpr auto get_status() const noexcept -> int { return status; }; diff --git a/src/btop_tools.cpp b/src/btop_tools.cpp index c98ce39f..3fe1c9f8 100644 --- a/src/btop_tools.cpp +++ b/src/btop_tools.cpp @@ -523,7 +523,7 @@ namespace Tools { else this->atom.store(true); } - atomic_lock::~atomic_lock() { + atomic_lock::~atomic_lock() noexcept { this->atom.store(false); } @@ -654,11 +654,15 @@ namespace Logger { this->status = seteuid(Global::real_uid); } } - ~lose_priv() { + ~lose_priv() noexcept { if (status == 0) { status = seteuid(Global::set_uid); } } + lose_priv(const lose_priv& other) = delete; + lose_priv& operator=(const lose_priv& other) = delete; + lose_priv(lose_priv&& other) = delete; + lose_priv& operator=(lose_priv&& other) = delete; }; void set(const string& level) { diff --git a/src/btop_tools.hpp b/src/btop_tools.hpp index fce93c23..fa8f7275 100644 --- a/src/btop_tools.hpp +++ b/src/btop_tools.hpp @@ -411,7 +411,11 @@ namespace Tools { bool not_true{}; public: explicit atomic_lock(atomic& atom, bool wait = false); - ~atomic_lock(); + ~atomic_lock() noexcept; + atomic_lock(const atomic_lock& other) = delete; + atomic_lock& operator=(const atomic_lock& other) = delete; + atomic_lock(atomic_lock&& other) = delete; + atomic_lock& operator=(atomic_lock&& other) = delete; }; //* Read a complete file and return as a string @@ -440,6 +444,10 @@ namespace Tools { DebugTimer() = default; explicit DebugTimer(const string name, bool start = true, bool delayed_report = true); ~DebugTimer(); + DebugTimer(const DebugTimer& other) = delete; + DebugTimer& operator=(const DebugTimer& other) = delete; + DebugTimer(DebugTimer&& other) = delete; + DebugTimer& operator=(DebugTimer&& other) = delete; void start(); void stop(bool report = true);