Replace fmt::localtime with localtime_r #2457
Replace fmt::localtime with localtime_r #2457tchaikov wants to merge 1 commit intoosm2pgsql-dev:masterfrom
Conversation
|
Can you please show how you have tested locally that your proposed change fixes the problem? |
|
There is a reason
This shows the mess that |
4f8bdbd to
a55ac19
Compare
@lonvia hi Sarah, locally i tested it just by compiling it with fmt 12. see https://copr.fedorainfracloud.org/coprs/tchaikov/fmt-12/build/10289349/ . I am a maintainer of fmt library for fedora, so i need to fix all dependent packages that fail to build when bumping the packaged fmt library in the distro i am targeting. osm2pgsql is one of them. unfortunately, i don't use osm2pgsql myself, and i don't have a pgsql db around to run the test suite against. but i also use COPR/Koji build environment runs the full test suite. see https://download.copr.fedorainfracloud.org/results/tchaikov/fmt-12/fedora-rawhide-aarch64/10289349-osm2pgsql/builder-live.log @joto i concur with you. so i've rewritten it and repushed the change to replicate the implementation used by |
|
https://en.cppreference.com/w/c/chrono/localtime.html says |
|
See also fmtlib/fmt#4458 and fmtlib/fmt#4464 and other issues. We can not use |
fmt::localtime was removed in fmt 12. Replace it with an equivalent that is thread-safe and portable: - POSIX: localtime_r(&time, &tm) - MSVC: localtime_s(&tm, &time) (reversed argument order) Both are re-entrant and thread-safe, matching the guarantee that fmt::localtime provided. Signed-off-by: Kefu Chai <[email protected]>
a55ac19 to
dec2937
Compare
|
@joto hi Jochen, thank you for your insights. indeed, i completely missed that we had to be compatible with windows platforms and removed the MSVC bits in fmt's implementation. just updated the change to use |
fmt::localtime was deprecated in fmt 11.2.0 and removed in fmt 12.0.0.
Replace with localtime_r, which is what fmt::localtime was implemented
with internally. The new implementation maintains identical behavior by
throwing a fmt::format_error exception when localtime_r() fails,
matching the original fmt::localtime() behavior.
See: https://github.com/fmtlib/fmt/releases/tag/12.0.0
Fixes #2456