Skip to content

Commit

Permalink
fix: User localtime_r instead of localtime (#3872)
Browse files Browse the repository at this point in the history
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));
```
  • Loading branch information
paulgessinger authored Nov 19, 2024
1 parent be67ec3 commit f2fbbdc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Core/include/Acts/Utilities/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f2fbbdc

Please sign in to comment.