From d4733585b1e5e6d542a0e43c94ec59b037eae584 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 23 Jul 2024 00:00:29 -0500 Subject: [PATCH] custom: clang-tidy --- include/modules/custom.hpp | 3 +-- src/modules/custom.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/modules/custom.hpp b/include/modules/custom.hpp index 6c17c6e45..549b8a6a1 100644 --- a/include/modules/custom.hpp +++ b/include/modules/custom.hpp @@ -2,7 +2,6 @@ #include -#include #include #include "ALabel.hpp" @@ -15,7 +14,7 @@ namespace waybar::modules { class Custom : public ALabel { public: Custom(const std::string&, const std::string&, const Json::Value&, const std::string&); - virtual ~Custom(); + ~Custom() override; auto update() -> void override; void refresh(int /*signal*/) override; diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index 20d8d9348..a63cf289f 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -2,6 +2,8 @@ #include +#include + #include "util/scope_guard.hpp" waybar::modules::Custom::Custom(const std::string& name, const std::string& id, @@ -28,7 +30,7 @@ waybar::modules::Custom::Custom(const std::string& name, const std::string& id, waybar::modules::Custom::~Custom() { if (pid_ != -1) { killpg(pid_, SIGTERM); - waitpid(pid_, NULL, 0); + waitpid(pid_, nullptr, 0); pid_ = -1; } } @@ -57,20 +59,20 @@ void waybar::modules::Custom::continuousWorker() { auto cmd = config_["exec"].asString(); pid_ = -1; fp_ = util::command::open(cmd, pid_, output_name_); - if (!fp_) { + if (fp_ == nullptr) { throw std::runtime_error("Unable to open " + cmd); } thread_ = [this, cmd] { char* buff = nullptr; waybar::util::ScopeGuard buff_deleter([buff]() { - if (buff) { + if (buff != nullptr) { free(buff); } }); size_t len = 0; if (getline(&buff, &len, fp_) == -1) { int exit_code = 1; - if (fp_) { + if (fp_ != nullptr) { exit_code = WEXITSTATUS(util::command::close(fp_, pid_)); fp_ = nullptr; } @@ -83,7 +85,7 @@ void waybar::modules::Custom::continuousWorker() { pid_ = -1; thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt())); fp_ = util::command::open(cmd, pid_, output_name_); - if (!fp_) { + if (fp_ == nullptr) { throw std::runtime_error("Unable to open " + cmd); } } else { @@ -266,7 +268,7 @@ void waybar::modules::Custom::parseOutputJson() { } } if (!parsed["percentage"].asString().empty() && parsed["percentage"].isNumeric()) { - percentage_ = (int)lround(parsed["percentage"].asFloat()); + percentage_ = (int)std::lround(parsed["percentage"].asFloat()); } else { percentage_ = 0; }