Skip to content

Commit 634288e

Browse files
Merge pull request ceph#63970 from tchaikov/wip-osd-scrubber-localtime
osd/scrubber: replace deprecated fmt::localtime() with localtime_r()
2 parents 562c79c + f350520 commit 634288e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/osd/scrubber/pg_scrubber.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,18 +2760,19 @@ void PgScrubber::update_scrub_stats(ceph::coarse_real_clock::time_point now_is)
27602760

27612761
/// \todo use the date library (either the one included in Arrow or directly)
27622762
/// to get the formatting of the time_points.
2763-
27642763
if (g_conf()->subsys.should_gather<ceph_subsys_osd, 25>()) {
27652764
// will only create the debug strings if required
2766-
char buf[50];
2767-
auto printable_last = fmt::localtime(clock::to_time_t(m_last_stat_upd));
2768-
strftime(buf, sizeof(buf), "%Y-%m-%dT%T", &printable_last);
2769-
dout(20) << fmt::format("{}: period: {}/{}-> {} last:{}",
2765+
std::time_t time = clock::to_time_t(m_last_stat_upd);
2766+
std::tm tm_local;
2767+
if (!localtime_r(&time, &tm_local)) {
2768+
throw fmt::format_error("time_t value out of range");
2769+
}
2770+
dout(20) << fmt::format("{}: period: {}/{}-> {} last:{:%FT%T}",
27702771
__func__,
27712772
period_active,
27722773
period_inactive,
27732774
period,
2774-
buf)
2775+
tm_local)
27752776
<< dendl;
27762777
}
27772778

0 commit comments

Comments
 (0)