]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
log: fix timestamps on Windows
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 18 Mar 2020 16:33:08 +0000 (16:33 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Thu, 22 Oct 2020 12:04:38 +0000 (12:04 +0000)
timeval.tv_usec uses long, although on Windows long uses 32b, even
on x64.

For this reason, we'll have to avoid a direct cast from time_t,
which is 64b long.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/log/LogClock.h

index 6648f44f0b7072f02f4907782ff5cd69d131e3c9..1a9bc6cba2ce162b545defd56f32a5bab1a8bd6c 100644 (file)
@@ -134,7 +134,8 @@ inline int append_time(const log_time& t, char *out, int outlen) {
   bool coarse = t.time_since_epoch().count().coarse;
   auto tv = log_clock::to_timeval(t);
   std::tm bdt;
-  localtime_r((time_t*)&tv.tv_sec, &bdt);
+  time_t t_sec = tv.tv_sec;
+  localtime_r(&t_sec, &bdt);
   char tz[32] = { 0 };
   strftime(tz, sizeof(tz), "%z", &bdt);