From 8dc7691a6f4adaf259062f4844a023d6f23cabd0 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 11 Apr 2016 14:50:01 +0200 Subject: [PATCH 1/2] Remove "dereferencing type-punned pointer" warning Fix the remaining warning discussed in #1538. This is obviously a false positive from gcc. --- src/floating.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/floating.c b/src/floating.c index 65a2810a..094d0e88 100644 --- a/src/floating.c +++ b/src/floating.c @@ -782,16 +782,17 @@ drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_ .callback = callback, .extra = extra, }; + ev_check *check = &loop.check; if (con) loop.old_rect = con->rect; - ev_check_init(&loop.check, xcb_drag_check_cb); + ev_check_init(check, xcb_drag_check_cb); main_set_x11_cb(false); - ev_check_start(main_loop, &loop.check); + ev_check_start(main_loop, check); while (loop.result == DRAGGING) ev_run(main_loop, EVRUN_ONCE); - ev_check_stop(main_loop, &loop.check); + ev_check_stop(main_loop, check); main_set_x11_cb(true); xcb_ungrab_keyboard(conn, XCB_CURRENT_TIME); From b52482705e805021c5c37a9139c60e63409a08f2 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 11 Apr 2016 15:00:47 +0200 Subject: [PATCH 2/2] Avoid hazardous casting. --- src/floating.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/floating.c b/src/floating.c index 094d0e88..17a99638 100644 --- a/src/floating.c +++ b/src/floating.c @@ -621,7 +621,7 @@ void floating_resize_window(Con *con, const bool proportional, con->scratchpad_state = SCRATCHPAD_CHANGED; } -/* As endorsed by “ASSOCIATING CUSTOM DATA WITH A WATCHER” in ev(3) */ +/* Custom data structure used to track dragging-related events. */ struct drag_x11_cb { ev_check check; @@ -643,7 +643,7 @@ struct drag_x11_cb { }; static void xcb_drag_check_cb(EV_P_ ev_check *w, int revents) { - struct drag_x11_cb *dragloop = (struct drag_x11_cb *)w; + struct drag_x11_cb *dragloop = (struct drag_x11_cb *)w->data; xcb_motion_notify_event_t *last_motion_notify = NULL; xcb_generic_event_t *event; @@ -786,6 +786,7 @@ drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_ if (con) loop.old_rect = con->rect; ev_check_init(check, xcb_drag_check_cb); + check->data = &loop; main_set_x11_cb(false); ev_check_start(main_loop, check);