From d1160a030cde9a062612917a7aea61730da87d55 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Thu, 21 Jan 2016 21:10:46 -0500 Subject: [PATCH] time: Fix encode/decode for real_time values Signed-off-by: Adam C. Emerson --- src/common/ceph_time.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/ceph_time.h b/src/common/ceph_time.h index a634e7fec55..a5ae0fec5ab 100644 --- a/src/common/ceph_time.h +++ b/src/common/ceph_time.h @@ -345,18 +345,21 @@ namespace ceph { template void encode(const std::chrono::time_point& t, ceph::bufferlist &bl) { - struct timespec ts = Clock::to_timespec(); + auto ts = Clock::to_timespec(t); // A 32 bit count of seconds causes me vast unhappiness. - ::encode((uint32_t) ts.tv_sec, bl); - ::encode((uint32_t) ts.tv_nsec, bl); + uint32_t s = ts.tv_sec; + uint32_t ns = ts.tv_nsec; + ::encode(s, bl); + ::encode(ns, bl); } template void decode(std::chrono::time_point& t, bufferlist::iterator& p) { - struct timespec ts; - ::decode((uint32_t&) ts.tv_sec, p); - ::decode((uint32_t&) ts.tv_nsec, p); + uint32_t s, ns; + ::decode(s, p); + ::decode(ns, p); + struct timespec ts = {s, ns}; t = Clock::from_timespec(ts); } -- 2.47.3