From: Adam C. Emerson Date: Fri, 22 Jan 2016 02:10:46 +0000 (-0500) Subject: time: Fix encode/decode for real_time values X-Git-Tag: v10.0.4~53^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d1160a030cde9a062612917a7aea61730da87d55;p=ceph.git time: Fix encode/decode for real_time values Signed-off-by: Adam C. Emerson --- diff --git a/src/common/ceph_time.h b/src/common/ceph_time.h index a634e7fec554..a5ae0fec5ab8 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); }