From fad62a3e1c85ec5d709db59bbca173758a8beaf0 Mon Sep 17 00:00:00 2001 From: Arvin Ignaci Date: Mon, 9 Jul 2018 14:45:19 +0000 Subject: [PATCH] fix: handle 32 bit time_t (or smaller) --- types/wlr_export_dmabuf_v1.c | 5 +++-- types/wlr_screencopy_v1.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/types/wlr_export_dmabuf_v1.c b/types/wlr_export_dmabuf_v1.c index e68b0fef..060f4afa 100644 --- a/types/wlr_export_dmabuf_v1.c +++ b/types/wlr_export_dmabuf_v1.c @@ -46,8 +46,9 @@ static void frame_output_handle_swap_buffers(struct wl_listener *listener, wl_list_remove(&frame->output_swap_buffers.link); wl_list_init(&frame->output_swap_buffers.link); - uint32_t tv_sec_hi = event->when->tv_sec >> 32; - uint32_t tv_sec_lo = event->when->tv_sec & 0xFFFFFFFF; + time_t tv_sec = event->when->tv_sec; + uint32_t tv_sec_hi = (sizeof(tv_sec) > 4) ? tv_sec >> 32 : 0; + uint32_t tv_sec_lo = tv_sec & 0xFFFFFFFF; zwlr_export_dmabuf_frame_v1_send_ready(frame->resource, tv_sec_hi, tv_sec_lo, event->when->tv_nsec); } diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index 0760eaaf..f994d972 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -66,8 +66,9 @@ static void frame_handle_output_swap_buffers(struct wl_listener *listener, zwlr_screencopy_frame_v1_send_flags(frame->resource, flags); - uint32_t tv_sec_hi = event->when->tv_sec >> 32; - uint32_t tv_sec_lo = event->when->tv_sec & 0xFFFFFFFF; + time_t tv_sec = event->when->tv_sec; + uint32_t tv_sec_hi = (sizeof(tv_sec) > 4) ? tv_sec >> 32 : 0; + uint32_t tv_sec_lo = tv_sec & 0xFFFFFFFF; zwlr_screencopy_frame_v1_send_ready(frame->resource, tv_sec_hi, tv_sec_lo, event->when->tv_nsec);