Skip to content

Commit be92ae7

Browse files
committed
dispatch: explicitly cast to avoid truncation warning
Add an explicit cast from `void *` to `uintptr_t` before truncating the context to the `dispatch_flags_t`. Add an assertion to ensure that we are not dropping something.
1 parent 8ca15bc commit be92ae7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/queue.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,10 @@ _dispatch_async_redirect_invoke(dispatch_continuation_t dc,
794794
{
795795
dispatch_thread_frame_s dtf;
796796
struct dispatch_continuation_s *other_dc = dc->dc_other;
797-
dispatch_invoke_flags_t ctxt_flags = (dispatch_invoke_flags_t)dc->dc_ctxt;
797+
#if DISPATCH_SIZEOF_PTR == 8
798+
dispatch_assert(((uintptr_t)dc->dc_ctxt >> 32) == 0);
799+
#endif
800+
dispatch_invoke_flags_t ctxt_flags = (dispatch_invoke_flags_t)(uintptr_t)dc->dc_ctxt;
798801
// if we went through _dispatch_root_queue_push_override,
799802
// the "right" root queue was stuffed into dc_func
800803
dispatch_queue_global_t assumed_rq = (dispatch_queue_global_t)dc->dc_func;

0 commit comments

Comments
 (0)