diff --git a/include/components/builder.hpp b/include/components/builder.hpp index 9b45a7eb..eac5afac 100644 --- a/include/components/builder.hpp +++ b/include/components/builder.hpp @@ -20,7 +20,7 @@ using namespace drawtypes; class builder { public: - explicit builder(const bar_settings bar); + explicit builder(const bar_settings& bar); string flush(); void append(string text); diff --git a/include/components/controller.hpp b/include/components/controller.hpp index a1ae93af..e62b9c75 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -57,7 +57,7 @@ class controller : public signal_receiver&& tokens = {}) + explicit label(string text, string foreground = ""s, string background = ""s, string underline = ""s, + string overline = ""s, int font = 0, struct side_values padding = {0U,0U}, struct side_values margin = {0U,0U}, + size_t maxlen = 0_z, bool ellipsis = true, vector&& tokens = {}) : m_foreground(foreground) , m_background(background) , m_underline(underline) @@ -72,11 +72,11 @@ namespace drawtypes { const vector m_tokens{}; }; - label_t load_label(const config& conf, const string& section, string name, bool required = true, string def = ""); - label_t load_optional_label(const config& conf, string section, string name, string def = ""); + label_t load_label(const config& conf, const string& section, string name, bool required = true, string def = ""s); + label_t load_optional_label(const config& conf, string section, string name, string def = ""s); - icon_t load_icon(const config& conf, string section, string name, bool required = true, string def = ""); - icon_t load_optional_icon(const config& conf, string section, string name, string def = ""); + icon_t load_icon(const config& conf, string section, string name, bool required = true, string def = ""s); + icon_t load_optional_icon(const config& conf, string section, string name, string def = ""s); } POLYBAR_NS_END diff --git a/include/utils/file.hpp b/include/utils/file.hpp index b8a5eb3e..8f894a8b 100644 --- a/include/utils/file.hpp +++ b/include/utils/file.hpp @@ -66,8 +66,8 @@ class fd_streambuf : public std::streambuf { private: file_descriptor m_fd; - char m_out[BUFSIZ]; - char m_in[BUFSIZ - 1]; + char m_out[BUFSIZ]{'\0'}; + char m_in[BUFSIZ - 1]{'\0'}; }; template diff --git a/src/components/builder.cpp b/src/components/builder.cpp index e229a228..f66fbc9c 100644 --- a/src/components/builder.cpp +++ b/src/components/builder.cpp @@ -12,7 +12,7 @@ POLYBAR_NS #define BUILDER_SPACE_TOKEN "%__" #endif -builder::builder(const bar_settings bar) : m_bar(bar) { +builder::builder(const bar_settings& bar) : m_bar(bar) { m_tags[syntaxtag::A] = 0; m_tags[syntaxtag::B] = 0; m_tags[syntaxtag::F] = 0; @@ -311,7 +311,7 @@ void builder::space() { * Remove trailing space */ void builder::remove_trailing_space(size_t len) { - if (len == 0_z || len > m_output.size()) { + if (len == 0_z || len > m_output.size()) { return; } else if (m_output.substr(m_output.size() - len) == string(len, ' ')) { m_output.erase(m_output.size() - len); diff --git a/src/components/logger.cpp b/src/components/logger.cpp index 04ee0b63..3758b831 100644 --- a/src/components/logger.cpp +++ b/src/components/logger.cpp @@ -11,7 +11,7 @@ POLYBAR_NS /** * Convert string */ -const char* logger::convert(string arg) const { +const char* logger::convert(string arg) const { // NOLINT return arg.c_str(); } diff --git a/src/drawtypes/label.cpp b/src/drawtypes/label.cpp index 4f6e7eea..865f6d4c 100644 --- a/src/drawtypes/label.cpp +++ b/src/drawtypes/label.cpp @@ -39,10 +39,10 @@ namespace drawtypes { for (auto&& tok : m_tokens) { if (token == tok.token) { - if (tok.max != 0 && replacement.length() > tok.max) { + if (tok.max != 0_z && replacement.length() > tok.max) { replacement = replacement.erase(tok.max) + tok.suffix; - } else if (tok.min != 0 && replacement.length() < tok.min) { - replacement.insert(0, tok.min - replacement.length(), ' '); + } else if (tok.min != 0_z && replacement.length() < tok.min) { + replacement.insert(0_z, tok.min - replacement.length(), ' '); } m_tokenized = string_util::replace_all(m_tokenized, token, move(replacement)); } @@ -65,19 +65,19 @@ namespace drawtypes { if (label->m_font != 0) { m_font = label->m_font; } - if (label->m_padding.left != 0) { + if (label->m_padding.left != 0U) { m_padding.left = label->m_padding.left; } - if (label->m_padding.right != 0) { + if (label->m_padding.right != 0U) { m_padding.right = label->m_padding.right; } - if (label->m_margin.left != 0) { + if (label->m_margin.left != 0U) { m_margin.left = label->m_margin.left; } - if (label->m_margin.right != 0) { + if (label->m_margin.right != 0U) { m_margin.right = label->m_margin.right; } - if (label->m_maxlen != 0) { + if (label->m_maxlen != 0_z) { m_maxlen = label->m_maxlen; m_ellipsis = label->m_ellipsis; } @@ -99,19 +99,19 @@ namespace drawtypes { if (m_font == 0 && label->m_font != 0) { m_font = label->m_font; } - if (m_padding.left == 0 && label->m_padding.left != 0) { + if (m_padding.left == 0U && label->m_padding.left != 0U) { m_padding.left = label->m_padding.left; } - if (m_padding.right == 0 && label->m_padding.right != 0) { + if (m_padding.right == 0U && label->m_padding.right != 0U) { m_padding.right = label->m_padding.right; } - if (m_margin.left == 0 && label->m_margin.left != 0) { + if (m_margin.left == 0U && label->m_margin.left != 0U) { m_margin.left = label->m_margin.left; } - if (m_margin.right == 0 && label->m_margin.right != 0) { + if (m_margin.right == 0U && label->m_margin.right != 0U) { m_margin.right = label->m_margin.right; } - if (m_maxlen == 0 && label->m_maxlen != 0) { + if (m_maxlen == 0_z && label->m_maxlen != 0_z) { m_maxlen = label->m_maxlen; m_ellipsis = label->m_ellipsis; } @@ -144,7 +144,7 @@ namespace drawtypes { } const auto get_left_right = [&](string key) { - auto value = conf.get(section, key, 0); + auto value = conf.get(section, key, 0U); auto left = conf.get(section, key + "-left", value); auto right = conf.get(section, key + "-right", value); return side_values{static_cast(left), static_cast(right)}; @@ -165,7 +165,7 @@ namespace drawtypes { } line.erase(start, end - start + 1); - tokens.emplace_back(token{token_str, 0, 0}); + tokens.emplace_back(token{token_str, 0_z, 0_z}); auto& token = tokens.back(); // find min delimiter @@ -196,7 +196,7 @@ namespace drawtypes { // ignore max lengths less than min if (token.max < token.min) { - token.max = 0; + token.max = 0_z; } // find suffix delimiter diff --git a/src/modules/memory.cpp b/src/modules/memory.cpp index 77e553ce..3aa9ae9a 100644 --- a/src/modules/memory.cpp +++ b/src/modules/memory.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include #include "modules/memory.hpp" diff --git a/src/modules/meta/base.cpp b/src/modules/meta/base.cpp index ef782035..befa3cd7 100644 --- a/src/modules/meta/base.cpp +++ b/src/modules/meta/base.cpp @@ -104,7 +104,7 @@ namespace modules { } else if (find(whitelist.begin(), whitelist.end(), tag) != whitelist.end()) { continue; } else { - throw undefined_format_tag(tag + " is not a valid format tag for \""+ name +"\""); + throw undefined_format_tag(tag + " is not a valid format tag for \"" + name + "\""); } }