- LGTM fixes.

master
faluco 4 years ago committed by Andre Puschmann
parent 03b88f6149
commit 8376111419

@ -339,7 +339,7 @@ inline std::tm localtime(std::time_t time) {
#if !FMT_MSC_VER #if !FMT_MSC_VER
bool fallback(detail::null<>) { bool fallback(detail::null<>) {
using namespace fmt::detail; 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; if (tm) tm_ = *tm;
return tm != nullptr; return tm != nullptr;
} }
@ -375,7 +375,7 @@ inline std::tm gmtime(std::time_t time) {
#if !FMT_MSC_VER #if !FMT_MSC_VER
bool fallback(detail::null<>) { 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; if (tm) tm_ = *tm;
return tm != nullptr; return tm != nullptr;
} }

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

@ -64,7 +64,9 @@ void srslog::event_trace_init(log_channel& c)
static void format_time(char* buffer, size_t len) static void format_time(char* buffer, size_t len)
{ {
std::time_t t = std::time(nullptr); 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 { namespace srslog {

Loading…
Cancel
Save