From 0988936e4894579424bf327d04951c1dac5a6142 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Tue, 19 Nov 2024 12:00:48 +0100 Subject: [PATCH] fix: User `localtime_r` instead of `localtime` This popped up as a warning in the ATLAS build: /builds/acts/acts-athena-ci/acts-install/include/Acts/Utilities/Logger.hpp:485:61: warning: Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'. [localtimeCalled] std::strftime(buffer, sizeof(buffer), m_format.c_str(), localtime(&t)); --- Core/include/Acts/Utilities/Logger.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/include/Acts/Utilities/Logger.hpp b/Core/include/Acts/Utilities/Logger.hpp index 48cadb49ec4..83dc989ca85 100644 --- a/Core/include/Acts/Utilities/Logger.hpp +++ b/Core/include/Acts/Utilities/Logger.hpp @@ -482,7 +482,9 @@ class TimedOutputDecorator final : public OutputDecorator { char buffer[20]; time_t t{}; std::time(&t); - std::strftime(buffer, sizeof(buffer), m_format.c_str(), localtime(&t)); + struct tm tbuf {}; + std::strftime(buffer, sizeof(buffer), m_format.c_str(), + localtime_r(&t, &tbuf)); return buffer; }