From 17bb5643aec1ec67d7a0c45bfc91ad806b842a75 Mon Sep 17 00:00:00 2001 From: mazunki Date: Tue, 9 Nov 2021 18:38:07 +0100 Subject: [PATCH 1/8] explicitly checking for errors to silence unused variable warnings when writing to fd --- include/util/command.hpp | 4 +++- src/modules/sway/ipc/client.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/util/command.hpp b/include/util/command.hpp index 3a38da36..d3a1e437 100644 --- a/include/util/command.hpp +++ b/include/util/command.hpp @@ -68,7 +68,9 @@ inline int close(FILE* fp, pid_t pid) { inline FILE* open(const std::string& cmd, int& pid) { if (cmd == "") return nullptr; int fd[2]; - pipe(fd); + if (pipe(fd) != 0){ + throw std::runtime_error("Couldn't open a file descriptor"); + } pid_t child_pid = fork(); diff --git a/src/modules/sway/ipc/client.cpp b/src/modules/sway/ipc/client.cpp index 58aed60c..1111746a 100644 --- a/src/modules/sway/ipc/client.cpp +++ b/src/modules/sway/ipc/client.cpp @@ -14,12 +14,16 @@ Ipc::~Ipc() { if (fd_ > 0) { // To fail the IPC header - write(fd_, "close-sway-ipc", 14); + if (write(fd_, "close-sway-ipc", 14) == -1) { + std::runtime_error("Couldn't close Sway IPC through fd"); + } close(fd_); fd_ = -1; } if (fd_event_ > 0) { - write(fd_event_, "close-sway-ipc", 14); + if (write(fd_event_, "close-sway-ipc", 14) == -1) { + std::runtime_error("Couldn't close Sway IPC through fd_event"); + } close(fd_event_); fd_event_ = -1; } From b0eab5d793e48af1fcfc4b281aab6bfbd10b769b Mon Sep 17 00:00:00 2001 From: mazunki Date: Tue, 9 Nov 2021 19:03:15 +0100 Subject: [PATCH 2/8] maybe we shouldn't actually runtime error, but still doing a check --- include/util/command.hpp | 2 +- src/modules/sway/ipc/client.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/util/command.hpp b/include/util/command.hpp index d3a1e437..4920333e 100644 --- a/include/util/command.hpp +++ b/include/util/command.hpp @@ -69,7 +69,7 @@ inline FILE* open(const std::string& cmd, int& pid) { if (cmd == "") return nullptr; int fd[2]; if (pipe(fd) != 0){ - throw std::runtime_error("Couldn't open a file descriptor"); + // std::runtime_error("Couldn't open a file descriptor"); } pid_t child_pid = fork(); diff --git a/src/modules/sway/ipc/client.cpp b/src/modules/sway/ipc/client.cpp index 1111746a..15bdf1e2 100644 --- a/src/modules/sway/ipc/client.cpp +++ b/src/modules/sway/ipc/client.cpp @@ -15,14 +15,14 @@ Ipc::~Ipc() { if (fd_ > 0) { // To fail the IPC header if (write(fd_, "close-sway-ipc", 14) == -1) { - std::runtime_error("Couldn't close Sway IPC through fd"); + //std::runtime_error("Couldn't close Sway IPC through fd"); } close(fd_); fd_ = -1; } if (fd_event_ > 0) { if (write(fd_event_, "close-sway-ipc", 14) == -1) { - std::runtime_error("Couldn't close Sway IPC through fd_event"); + //std::runtime_error("Couldn't close Sway IPC through fd_event"); } close(fd_event_); fd_event_ = -1; From e10c9dd011e394b734be7bab6fc2ca6885f9de1f Mon Sep 17 00:00:00 2001 From: mazunki Date: Tue, 9 Nov 2021 19:04:05 +0100 Subject: [PATCH 3/8] changing want_route_dump to default to true, since we say we have gwaddr support --- src/modules/network.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 99ccd8e0..d5f8012c 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -88,7 +88,7 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf family_(config["family"] == "ipv6" ? AF_INET6 : AF_INET), efd_(-1), ev_fd_(-1), - want_route_dump_(false), + want_route_dump_(true), want_link_dump_(false), want_addr_dump_(false), dump_in_progress_(false), @@ -121,7 +121,7 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf } if (!config_["interface"].isString()) { - // "interface" isn't configure, then try to guess the external + // "interface" isn't configured, then try to guess the external // interface currently used for internet. want_route_dump_ = true; } else { From bb7b376fa6edc121890021ed191cdf497a5df66f Mon Sep 17 00:00:00 2001 From: mazunki Date: Wed, 24 Nov 2021 01:37:21 +0100 Subject: [PATCH 4/8] removed commented useless runtime errors --- include/util/command.hpp | 1 - src/modules/sway/ipc/client.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/include/util/command.hpp b/include/util/command.hpp index 4920333e..9c4305a5 100644 --- a/include/util/command.hpp +++ b/include/util/command.hpp @@ -69,7 +69,6 @@ inline FILE* open(const std::string& cmd, int& pid) { if (cmd == "") return nullptr; int fd[2]; if (pipe(fd) != 0){ - // std::runtime_error("Couldn't open a file descriptor"); } pid_t child_pid = fork(); diff --git a/src/modules/sway/ipc/client.cpp b/src/modules/sway/ipc/client.cpp index 15bdf1e2..ea1a3c52 100644 --- a/src/modules/sway/ipc/client.cpp +++ b/src/modules/sway/ipc/client.cpp @@ -22,7 +22,6 @@ Ipc::~Ipc() { } if (fd_event_ > 0) { if (write(fd_event_, "close-sway-ipc", 14) == -1) { - //std::runtime_error("Couldn't close Sway IPC through fd_event"); } close(fd_event_); fd_event_ = -1; From 2301788a810b64be9361b15fbd8f510002c74cc4 Mon Sep 17 00:00:00 2001 From: mazunki Date: Sat, 8 Jan 2022 01:44:46 +0100 Subject: [PATCH 5/8] created a hotfix for libfmt-8.1.0 and above --- src/modules/clock.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 7e7d7420..96fb34ac 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -233,8 +233,9 @@ struct fmt::formatter : fmt::formatter { template auto format(const waybar_time& t, FormatContext& ctx) { #if FMT_VERSION >= 80000 - auto& tm_format = specs; +//auto& tm_format = specs; #endif - return format_to(ctx.out(), "{}", date::format(t.locale, fmt::to_string(tm_format), t.ztime)); +// return format_to(ctx.out(), "{}", date::format(t.locale, fmt::to_string(tm_format), t.ztime)); + return fmt::formatter::format((const std::tm&) t, ctx); } }; From 667d0a45f46d0b2fc34b300e639b035d7c091345 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 24 Jan 2022 09:20:43 +0100 Subject: [PATCH 6/8] Update command.hpp --- include/util/command.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/util/command.hpp b/include/util/command.hpp index 9c4305a5..5f398e19 100644 --- a/include/util/command.hpp +++ b/include/util/command.hpp @@ -69,6 +69,8 @@ inline FILE* open(const std::string& cmd, int& pid) { if (cmd == "") return nullptr; int fd[2]; if (pipe(fd) != 0){ + spdlog::error("Unable to pipe fd"); + return nullptr; } pid_t child_pid = fork(); From 65dd245362fb203942b4a5a968e755a33ed880a6 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 24 Jan 2022 09:21:56 +0100 Subject: [PATCH 7/8] Update clock.cpp --- src/modules/clock.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 96fb34ac..8a0254dd 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -233,9 +233,8 @@ struct fmt::formatter : fmt::formatter { template auto format(const waybar_time& t, FormatContext& ctx) { #if FMT_VERSION >= 80000 -//auto& tm_format = specs; + auto& tm_format = specs; #endif -// return format_to(ctx.out(), "{}", date::format(t.locale, fmt::to_string(tm_format), t.ztime)); - return fmt::formatter::format((const std::tm&) t, ctx); + return format_to(ctx.out(), "{}", date::format(t.locale, fmt::to_string(tm_format), t.ztime)); } }; From c4cc7ae396b8f040522ec3fcf76b9f9fbd1c65d4 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 24 Jan 2022 09:22:47 +0100 Subject: [PATCH 8/8] Update client.cpp --- src/modules/sway/ipc/client.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modules/sway/ipc/client.cpp b/src/modules/sway/ipc/client.cpp index ea1a3c52..58aed60c 100644 --- a/src/modules/sway/ipc/client.cpp +++ b/src/modules/sway/ipc/client.cpp @@ -14,15 +14,12 @@ Ipc::~Ipc() { if (fd_ > 0) { // To fail the IPC header - if (write(fd_, "close-sway-ipc", 14) == -1) { - //std::runtime_error("Couldn't close Sway IPC through fd"); - } + write(fd_, "close-sway-ipc", 14); close(fd_); fd_ = -1; } if (fd_event_ > 0) { - if (write(fd_event_, "close-sway-ipc", 14) == -1) { - } + write(fd_event_, "close-sway-ipc", 14); close(fd_event_); fd_event_ = -1; }