From 27dfffa4e3dd561c233fa7d3140def86cd1dad38 Mon Sep 17 00:00:00 2001 From: Alexis Date: Sat, 18 Aug 2018 15:05:18 +0200 Subject: [PATCH] refactor: style issue --- include/ALabel.hpp | 2 +- include/modules/custom.hpp | 2 +- src/ALabel.cpp | 5 ----- src/client.cpp | 2 +- src/modules/battery.cpp | 2 +- src/modules/cpu.cpp | 2 +- src/modules/network.cpp | 4 ++-- 7 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/ALabel.hpp b/include/ALabel.hpp index 9c1dc4c..991a006 100644 --- a/include/ALabel.hpp +++ b/include/ALabel.hpp @@ -8,7 +8,7 @@ namespace waybar { class ALabel : public IModule { public: ALabel(Json::Value); - virtual ~ALabel(); + virtual ~ALabel() = default; virtual auto update() -> void; virtual operator Gtk::Widget &(); protected: diff --git a/include/modules/custom.hpp b/include/modules/custom.hpp index 5313b17..4bd5fdb 100644 --- a/include/modules/custom.hpp +++ b/include/modules/custom.hpp @@ -11,7 +11,7 @@ class Custom : public ALabel { Custom(const std::string&, Json::Value); auto update() -> void; private: - const std::string name_; + const std::string& name_; waybar::util::SleeperThread thread_; }; diff --git a/src/ALabel.cpp b/src/ALabel.cpp index f20bf21..1f72136 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -9,11 +9,6 @@ waybar::ALabel::ALabel(Json::Value config) } } -waybar::ALabel::~ALabel() -{ - // Nothing here -} - auto waybar::ALabel::update() -> void { // Nothing here diff --git a/src/client.cpp b/src/client.cpp index 41e456a..022e319 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -81,7 +81,7 @@ void waybar::Client::bindInterfaces() int waybar::Client::main(int /*argc*/, char* /*argv*/[]) { bindInterfaces(); - gtk_main.run(); + Gtk::Main::run(); bars.clear(); zxdg_output_manager_v1_destroy(xdg_output_manager); zwlr_layer_shell_v1_destroy(layer_shell); diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 0fa38b9..7e3280a 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -16,7 +16,7 @@ waybar::modules::Battery::Battery(Json::Value config) if (batteries_.empty()) { throw std::runtime_error("No batteries."); } - auto fd = inotify_init(); + auto fd = inotify_init1(IN_CLOEXEC); if (fd == -1) { throw std::runtime_error("Unable to listen batteries."); } diff --git a/src/modules/cpu.cpp b/src/modules/cpu.cpp index 5308539..5aea971 100644 --- a/src/modules/cpu.cpp +++ b/src/modules/cpu.cpp @@ -15,7 +15,7 @@ auto waybar::modules::Cpu::update() -> void { struct sysinfo info = {0}; if (sysinfo(&info) == 0) { - float f_load = 1.f / (1U << SI_LOAD_SHIFT); + float f_load = 1.f / (1u << SI_LOAD_SHIFT); uint16_t load = info.loads[0] * f_load * 100 / get_nprocs(); auto format = config_["format"] ? config_["format"].asString() : "{}%"; label_.set_text(fmt::format(format, load)); diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 775aff0..56565ec 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -234,9 +234,9 @@ int waybar::modules::Network::getExternalInterface() } while (true); out: - if (req) + if (req != nullptr) free(req); - if (resp) + if (resp != nullptr) free(resp); return ifidx; }