- LGTM fixes.

This commit is contained in:
faluco 2020-10-20 10:05:13 +02:00 committed by Andre Puschmann
parent 03b88f6149
commit 8376111419
3 changed files with 6 additions and 3 deletions

View File

@ -339,7 +339,7 @@ inline std::tm localtime(std::time_t time) {
#if !FMT_MSC_VER
bool fallback(detail::null<>) {
using namespace fmt::detail;
std::tm* tm = std::localtime(&time_);
std::tm* tm = std::localtime(&time_); // lgtm[cpp/potentially-dangerous-function]
if (tm) tm_ = *tm;
return tm != nullptr;
}
@ -375,7 +375,7 @@ inline std::tm gmtime(std::time_t time) {
#if !FMT_MSC_VER
bool fallback(detail::null<>) {
std::tm* tm = std::gmtime(&time_);
std::tm* tm = std::gmtime(&time_); // lgtm[cpp/potentially-dangerous-function]
if (tm) tm_ = *tm;
return tm != nullptr;
}

View File

@ -509,6 +509,7 @@ template <typename S> struct char_t_impl<S, enable_if_t<is_string<S>::value>> {
struct error_handler {
constexpr error_handler() = default;
constexpr error_handler(const error_handler&) = default;
error_handler& operator=(const error_handler&) = default;
// This function is intentionally not constexpr to give a compile-time error.
FMT_NORETURN FMT_API void on_error(const char* message);

View File

@ -64,7 +64,9 @@ void srslog::event_trace_init(log_channel& c)
static void format_time(char* buffer, size_t len)
{
std::time_t t = std::time(nullptr);
std::strftime(buffer, len, "%FT%T", std::localtime(&t));
std::tm lt{};
::localtime_r(&t, &lt);
std::strftime(buffer, len, "%FT%T", &lt);
}
namespace srslog {