mirror of
https://github.com/gabime/spdlog.git
synced 2025-04-29 20:13:52 +00:00
Fixd some clang-tidy warnings
This commit is contained in:
parent
91bf60a316
commit
aaebfbb5c6
@ -11,6 +11,7 @@ clang-analyzer-*,
|
|||||||
-google-runtime-references,
|
-google-runtime-references,
|
||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
-readability-braces-around-statements,
|
-readability-braces-around-statements,
|
||||||
|
-readability-identifier-length,
|
||||||
-google-readability-braces-around-statements,
|
-google-readability-braces-around-statements,
|
||||||
-cppcoreguidelines-avoid-magic-numbers,
|
-cppcoreguidelines-avoid-magic-numbers,
|
||||||
-readability-magic-numbers,
|
-readability-magic-numbers,
|
||||||
@ -21,7 +22,8 @@ clang-analyzer-*,
|
|||||||
-modernize-avoid-c-arrays,
|
-modernize-avoid-c-arrays,
|
||||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||||
-readability-named-parameter,
|
-readability-named-parameter,
|
||||||
-cert-env33-c
|
-cert-env33-c,
|
||||||
|
-modernize-concat-nested-namespaces
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ SPDLOG_API level get_level();
|
|||||||
SPDLOG_API void set_level(level level);
|
SPDLOG_API void set_level(level level);
|
||||||
|
|
||||||
// Determine whether the default logger should log messages with a certain level
|
// Determine whether the default logger should log messages with a certain level
|
||||||
SPDLOG_API bool should_log(level lvl);
|
SPDLOG_API bool should_log(level level);
|
||||||
|
|
||||||
// Set global flush level
|
// Set global flush level
|
||||||
SPDLOG_API void flush_on(level level);
|
SPDLOG_API void flush_on(level level);
|
||||||
|
@ -23,8 +23,8 @@ void file_helper::open(const filename_t &fname, bool truncate) {
|
|||||||
close();
|
close();
|
||||||
filename_ = fname;
|
filename_ = fname;
|
||||||
|
|
||||||
auto *mode = SPDLOG_FILENAME_T("ab");
|
const auto *mode = SPDLOG_FILENAME_T("ab");
|
||||||
auto *trunc_mode = SPDLOG_FILENAME_T("wb");
|
const auto *trunc_mode = SPDLOG_FILENAME_T("wb");
|
||||||
|
|
||||||
if (event_handlers_.before_open) {
|
if (event_handlers_.before_open) {
|
||||||
event_handlers_.before_open(filename_);
|
event_handlers_.before_open(filename_);
|
||||||
@ -37,7 +37,7 @@ void file_helper::open(const filename_t &fname, bool truncate) {
|
|||||||
// opening the actual log-we-write-to in "ab" mode, since that
|
// opening the actual log-we-write-to in "ab" mode, since that
|
||||||
// interacts more politely with eternal processes that might
|
// interacts more politely with eternal processes that might
|
||||||
// rotate/truncate the file underneath us.
|
// rotate/truncate the file underneath us.
|
||||||
std::FILE *tmp;
|
std::FILE *tmp = nullptr;
|
||||||
if (os::fopen_s(&tmp, fname, trunc_mode)) {
|
if (os::fopen_s(&tmp, fname, trunc_mode)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ void file_helper::close() {
|
|||||||
void file_helper::write(const memory_buf_t &buf) {
|
void file_helper::write(const memory_buf_t &buf) {
|
||||||
if (fd_ == nullptr) return;
|
if (fd_ == nullptr) return;
|
||||||
size_t msg_size = buf.size();
|
size_t msg_size = buf.size();
|
||||||
auto data = buf.data();
|
const auto *data = buf.data();
|
||||||
if (std::fwrite(data, 1, msg_size, fd_) != msg_size) {
|
if (std::fwrite(data, 1, msg_size, fd_) != msg_size) {
|
||||||
throw_spdlog_ex("Failed writing to file " + os::filename_to_str(filename_), errno);
|
throw_spdlog_ex("Failed writing to file " + os::filename_to_str(filename_), errno);
|
||||||
}
|
}
|
||||||
|
@ -84,12 +84,12 @@ spdlog::log_clock::time_point now() noexcept {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
std::tm localtime(const std::time_t &time_tt) noexcept {
|
std::tm localtime(const std::time_t &time_tt) noexcept {
|
||||||
std::tm* rv;
|
|
||||||
std::tm tm;
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
rv = ::localtime_s(&tm, &time_tt);
|
std::tm tm;
|
||||||
|
const auto *rv = ::localtime_s(&tm, &time_tt);
|
||||||
#else
|
#else
|
||||||
rv = ::localtime_r(&time_tt, &tm);
|
std::tm tm;
|
||||||
|
const auto *rv = ::localtime_r(&time_tt, &tm);
|
||||||
#endif
|
#endif
|
||||||
return rv != nullptr ? tm : std::tm{};
|
return rv != nullptr ? tm : std::tm{};
|
||||||
}
|
}
|
||||||
@ -548,7 +548,7 @@ std::string getenv(const char *field) {
|
|||||||
#endif
|
#endif
|
||||||
#else // revert to getenv
|
#else // revert to getenv
|
||||||
char *buf = ::getenv(field);
|
char *buf = ::getenv(field);
|
||||||
return buf ? buf : std::string{};
|
return buf != nullptr ? buf : std::string{};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user