mirror of
https://github.com/gabime/spdlog.git
synced 2025-11-16 09:28:56 +08:00
Fixed some tidy warnings
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <utility>
|
||||
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/details/os.h"
|
||||
@@ -12,8 +13,8 @@
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
|
||||
file_helper::file_helper(const file_event_handlers &event_handlers)
|
||||
: event_handlers_(event_handlers) {}
|
||||
file_helper::file_helper(file_event_handlers event_handlers)
|
||||
: event_handlers_(std::move(event_handlers)) {}
|
||||
|
||||
file_helper::~file_helper() { close(); }
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ int rename(const filename_t &filename1, const filename_t &filename2) noexcept {
|
||||
|
||||
// Return true if path exists (file or directory)
|
||||
bool path_exists(const filename_t &filename) noexcept {
|
||||
struct stat buffer;
|
||||
struct stat buffer{};
|
||||
return (::stat(filename.c_str(), &buffer) == 0);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ size_t filesize(FILE *f) {
|
||||
#endif
|
||||
// 64 bits(but not in osx, linux/musl or cygwin, where fstat64 is deprecated)
|
||||
#if ((defined(__linux__) && defined(__GLIBC__)) || defined(__sun) || defined(_AIX)) && (defined(__LP64__) || defined(_LP64))
|
||||
struct stat64 st;
|
||||
struct stat64 st{};
|
||||
if (::fstat64(fd, &st) == 0) {
|
||||
return static_cast<size_t>(st.st_size);
|
||||
}
|
||||
@@ -275,7 +275,7 @@ bool is_color_terminal() noexcept {
|
||||
bool in_terminal(FILE *file) noexcept { return ::isatty(fileno(file)) != 0; }
|
||||
|
||||
// return true on success
|
||||
static bool mkdir_(const filename_t &path) { return ::mkdir(path.c_str(), mode_t(0755)) == 0; }
|
||||
static bool mkdir_(const filename_t &path) { return ::mkdir(path.c_str(), static_cast<mode_t>(0755)) == 0; }
|
||||
|
||||
// create the given directory - and all directories leading to it
|
||||
// return true on success or if the directory already exists
|
||||
|
||||
@@ -80,10 +80,9 @@ std::shared_ptr<logger> registry::get(const std::string &logger_name) {
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
} else {
|
||||
auto found = loggers_.find(logger_name);
|
||||
return found == loggers_.end() ? nullptr : found->second;
|
||||
}
|
||||
auto found = loggers_.find(logger_name);
|
||||
return found == loggers_.end() ? nullptr : found->second;
|
||||
}
|
||||
|
||||
// if the map is small do a sequential search and avoid creating string for find(logger_name)
|
||||
@@ -99,10 +98,8 @@ std::shared_ptr<logger> registry::get(std::string_view logger_name) {
|
||||
return nullptr;
|
||||
}
|
||||
// otherwise use the normal map lookup
|
||||
else {
|
||||
auto found = loggers_.find(std::string(logger_name));
|
||||
return found == loggers_.end() ? nullptr : found->second;
|
||||
}
|
||||
const auto found = loggers_.find(std::string(logger_name));
|
||||
return found == loggers_.end() ? nullptr : found->second;
|
||||
}
|
||||
|
||||
std::shared_ptr<logger> registry::get(const char *logger_name) { return get(std::string_view(logger_name)); }
|
||||
|
||||
Reference in New Issue
Block a user