aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ceph/decode.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h
index 9575a52e011f..379f71508995 100644
--- a/include/linux/ceph/decode.h
+++ b/include/linux/ceph/decode.h
@@ -154,14 +154,19 @@ bad:
154static inline void ceph_decode_timespec(struct timespec *ts, 154static inline void ceph_decode_timespec(struct timespec *ts,
155 const struct ceph_timespec *tv) 155 const struct ceph_timespec *tv)
156{ 156{
157 ts->tv_sec = le32_to_cpu(tv->tv_sec); 157 ts->tv_sec = (__kernel_time_t)le32_to_cpu(tv->tv_sec);
158 ts->tv_nsec = le32_to_cpu(tv->tv_nsec); 158 ts->tv_nsec = (long)le32_to_cpu(tv->tv_nsec);
159} 159}
160static inline void ceph_encode_timespec(struct ceph_timespec *tv, 160static inline void ceph_encode_timespec(struct ceph_timespec *tv,
161 const struct timespec *ts) 161 const struct timespec *ts)
162{ 162{
163 tv->tv_sec = cpu_to_le32(ts->tv_sec); 163 BUG_ON(ts->tv_sec < 0);
164 tv->tv_nsec = cpu_to_le32(ts->tv_nsec); 164 BUG_ON(ts->tv_sec > (__kernel_time_t)U32_MAX);
165 BUG_ON(ts->tv_nsec < 0);
166 BUG_ON(ts->tv_nsec > (long)U32_MAX);
167
168 tv->tv_sec = cpu_to_le32((u32)ts->tv_sec);
169 tv->tv_nsec = cpu_to_le32((u32)ts->tv_nsec);
165} 170}
166 171
167/* 172/*