From 41705529d9995291324e1d06d45861ce63b1c72e Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Thu, 21 Jun 2018 11:48:50 +0200 Subject: xcb: Refactor align of xcb events Use C++11 alignas instead of a union to pad the xcb_*_event. It allows using the struct directly without accessing a union member. Change-Id: I221a6708ef7af844bd6b71a57dcbab75e1319c72 Reviewed-by: Jesus Fernandez --- src/plugins/platforms/xcb/qxcbconnection.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/xcb/qxcbconnection.h') diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 3a2aee873d..eb8ec5d7d6 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -772,18 +772,11 @@ struct QStdFreeDeleter { call##_reply(Q_XCB_REPLY_CONNECTION_ARG(__VA_ARGS__), call##_unchecked(__VA_ARGS__), nullptr) \ ) -template -union q_padded_xcb_event { - T event; - char padding[32]; -}; - // The xcb_send_event() requires all events to have 32 bytes. It calls memcpy() on the // passed in event. If the passed in event is less than 32 bytes, memcpy() reaches into // unrelated memory. -#define Q_DECLARE_XCB_EVENT(event_var, event_type) \ - q_padded_xcb_event store = {}; \ - auto &event_var = store.event; +template +struct alignas(32) q_padded_xcb_event : T { }; QT_END_NAMESPACE -- cgit v1.2.3