diff --git a/include/spdlog/details/fast_istostr.h b/include/spdlog/details/fast_istostr.h index 5b7cdc12..55500955 100644 --- a/include/spdlog/details/fast_istostr.h +++ b/include/spdlog/details/fast_istostr.h @@ -49,7 +49,7 @@ const char digit_pairs[201] = }; -inline std::string& fast_itostr(int n, std::string& s, int padding) +inline std::string& fast_itostr(int n, std::string& s, size_t padding) { if (n == 0) { @@ -58,9 +58,9 @@ inline std::string& fast_itostr(int n, std::string& s, int padding) } int sign = -(n < 0); - unsigned int val = (n^sign) - sign; + unsigned int val = static_cast((n^sign) - sign); - int size; + size_t size; if (val >= 10000) { if (val >= 10000000) @@ -111,14 +111,14 @@ inline std::string& fast_itostr(int n, std::string& s, int padding) c += size - 1; while (val >= 100) { - int pos = val % 100; + size_t pos = val % 100; val /= 100; *(short*)(c - 1) = *(short*)(digit_pairs + 2 * pos); c -= 2; } while (val > 0) { - *c-- = '0' + (val % 10); + *c-- = static_cast('0' + (val % 10)); val /= 10; } diff --git a/include/spdlog/details/fast_oss.h b/include/spdlog/details/fast_oss.h index cb7f8eb5..3ac35ded 100644 --- a/include/spdlog/details/fast_oss.h +++ b/include/spdlog/details/fast_oss.h @@ -158,7 +158,7 @@ public: } // put int and pad with zeroes if smalled than min_width - void put_int(int n, int padding) + void put_int(int n, size_t padding) { std::string s; details::fast_itostr(n, s, padding); diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index b5a43fee..da389d8d 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -55,6 +55,7 @@ public: _flush_countdown(flush_inverval) {}; file_helper(const file_helper&) = delete; + file_helper& operator=(const file_helper&) = delete; ~file_helper() { diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 88459512..8eab7b85 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -134,6 +134,7 @@ inline int utc_minutes_offset(const std::tm& tm = localtime()) { #ifdef _WIN32 + (void)tm; // avoid unused param warning DYNAMIC_TIME_ZONE_INFORMATION tzinfo; auto rv = GetDynamicTimeZoneInformation(&tzinfo); if (!rv) diff --git a/include/spdlog/details/pattern_formatter_impl.h b/include/spdlog/details/pattern_formatter_impl.h index 8de6beb9..e063583c 100644 --- a/include/spdlog/details/pattern_formatter_impl.h +++ b/include/spdlog/details/pattern_formatter_impl.h @@ -42,6 +42,7 @@ namespace details class flag_formatter { public: + virtual ~flag_formatter() {} virtual void format(details::log_msg& msg) = 0; }; @@ -295,6 +296,9 @@ class T_formatter :public flag_formatter class z_formatter :public flag_formatter { public: + z_formatter() {} + z_formatter(const z_formatter&) = delete; + z_formatter& operator=(const z_formatter&) = delete; void format(log_msg& msg) override { @@ -312,6 +316,8 @@ public: private: log_clock::time_point _last_update; std::string _value; + std::mutex _mutex; + std::string get_value(const log_msg& msg) { int total_minutes = os::utc_minutes_offset(msg.tm_time); @@ -324,7 +330,7 @@ private: oss.put_int(m, 2); return oss.str(); } - std::mutex _mutex; + }; @@ -451,7 +457,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag) { switch (flag) { - // logger name + // logger name case 'n': _formatters.push_back(std::unique_ptr(new details::name_formatter())); break; diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index 7ac6c564..e84adad0 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -122,6 +122,7 @@ public: private: registry() = default; registry(const registry&) = delete; + registry& operator=(const registry&) = delete; std::mutex _mutex; std::unordered_map > _loggers; formatter_ptr _formatter; diff --git a/include/spdlog/formatter.h b/include/spdlog/formatter.h index e502fd90..35ea0416 100644 --- a/include/spdlog/formatter.h +++ b/include/spdlog/formatter.h @@ -44,6 +44,7 @@ class pattern_formatter : public formatter public: explicit pattern_formatter(const std::string& pattern); pattern_formatter(const pattern_formatter&) = delete; + pattern_formatter& operator=(const pattern_formatter&) = delete; void format(details::log_msg& msg) override; private: const std::string _pattern;