]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
include/utime_fmt.h: replace deprecated fmt::localtime() with localtime_r() 63800/head
authorKefu Chai <tchaikov@gmail.com>
Sun, 8 Jun 2025 12:11:21 +0000 (20:11 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sun, 8 Jun 2025 12:19:15 +0000 (20:19 +0800)
commit35fdacb01b8431acebcdf3fa812df7b4a1f6eab0
tree2f3e35e6cd3fb88701fd0490c3d32cc827b31915
parent4da6c31ebc66cb43a6ae39d5052b0526f9454bc1
include/utime_fmt.h: replace deprecated fmt::localtime() with localtime_r()

Replace fmt::localtime() with localtime_r() to fix build failure with
fmt 11.2.0, where fmt::localtime() was deprecated in favor of std::localtime.

The deprecated function causes build errors when treating warnings as errors:

```
In file included from /home/jenkins-build/build/workspace/ceph-pull-requests/src/common/LogEntry.cc:7:
In file included from /home/jenkins-build/build/workspace/ceph-pull-requests/src/common/LogEntry.h:22:
/home/jenkins-build/build/workspace/ceph-pull-requests/src/include/utime_fmt.h:37:25: error: 'localtime' is deprecated [-Werror,-Wdeprecated-declarations]
   37 |     auto aslocal = fmt::localtime(utime.sec());
      |                         ^
/home/jenkins-build/build/workspace/ceph-pull-requests/src/fmt/include/fmt/chrono.h:538:1: note: 'localtime' has been explicitly marked deprecated here
  538 | FMT_DEPRECATED inline auto localtime(std::time_t time) -> std::tm {
      | ^
/home/jenkins-build/build/workspace/ceph-pull-requests/src/fmt/include/fmt/base.h:207:28: note: expanded from macro 'FMT_DEPRECATED'
  207 | #  define FMT_DEPRECATED [[deprecated]]
      |                            ^
1 error generated.
```

Using localtime_r() provides thread-safe behavior with user-provided
buffers instead of static storage, addressing the deprecation while
maintaining functionality.

See: https://github.com/fmtlib/fmt/releases/tag/11.2.0

This should address the build failure, and should prepare us for
switching to fmt 11.2.0, which in turn includes a bug fix preventing us
from building with Clang 20.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/include/utime_fmt.h