[PATCH 0/1] MR10598: winex11: Use unsigned long for monitor indices generation.
Avoiding invisible padding in the structure that could make memcmp to constantly fail when comparing old / new values. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10598
From: Rémi Bernon <rbernon@codeweavers.com> Avoiding invisible padding in the structure that could make memcmp to constantly fail when comparing old / new values. --- dlls/winex11.drv/window.c | 4 ++-- dlls/winex11.drv/x11drv.h | 4 ++-- dlls/winex11.drv/xinerama.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 33d8ceee438..a83359b2d74 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1318,7 +1318,7 @@ static void window_set_net_wm_fullscreen_monitors( struct x11drv_win_data *data, * windows spanning multiple monitors */ static void update_net_wm_fullscreen_monitors( struct x11drv_win_data *data ) { - struct monitor_indices monitors; + struct monitor_indices monitors = {0}; /* If the current display device handler cannot detect dynamic device changes, do not use * _NET_WM_FULLSCREEN_MONITORS because xinerama_get_fullscreen_monitors() may report wrong @@ -1736,7 +1736,7 @@ static UINT window_update_client_config( struct x11drv_win_data *data ) { static const UINT fullscreen_mask = (1 << NET_WM_STATE_MAXIMIZED) | (1 << NET_WM_STATE_FULLSCREEN); RECT rect, old_rect = data->rects.window, new_rect; - unsigned int old_generation, generation; + unsigned long old_generation, generation; long old_monitors[4], monitors[4]; UINT flags; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 9f38ceba0df..e1fe1b55620 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -635,7 +635,7 @@ enum x11drv_net_wm_state struct monitor_indices { - unsigned int generation; + unsigned long generation; long indices[4]; }; @@ -763,7 +763,7 @@ extern POINT virtual_screen_to_root( INT x, INT y ); extern POINT root_to_virtual_screen( INT x, INT y ); extern RECT get_host_primary_monitor_rect(void); extern RECT get_work_area( const RECT *monitor_rect ); -extern BOOL xinerama_get_fullscreen_monitors( const RECT *rect, unsigned int *generation, long *indices ); +extern BOOL xinerama_get_fullscreen_monitors( const RECT *rect, unsigned long *generation, long *indices ); extern void xinerama_init( unsigned int width, unsigned int height ); extern void init_recursive_mutex( pthread_mutex_t *mutex ); extern void init_icm_profile(void); diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c index 81f739285e0..d6478fcd03a 100644 --- a/dlls/winex11.drv/xinerama.c +++ b/dlls/winex11.drv/xinerama.c @@ -126,7 +126,7 @@ static inline int query_screens(void) /* Get xinerama monitor indices required for _NET_WM_FULLSCREEN_MONITORS. Return FALSE if rect is * not fullscreen */ -BOOL xinerama_get_fullscreen_monitors( const RECT *rect, unsigned int *generation, long *indices ) +BOOL xinerama_get_fullscreen_monitors( const RECT *rect, unsigned long *generation, long *indices ) { RECT window_rect, intersected_rect, monitor_rect; BOOL ret = FALSE; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10598
Let's compare `generation` separately and only use memcmp() for `indices`. Changing `generation` to `unsigned long` works, but someday someone might add a new field and the comparison will break silently again. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10598#note_135456
On Wed Apr 8 10:41:11 2026 +0000, Zhiyi Zhang wrote:
Let's compare `generation` separately and only use memcmp() for `indices`. Changing `generation` to `unsigned long` works, but someday someone might add a new field and the comparison will break silently again. It's never going to be fully future proof, adding new fields we might also forget to add them to the comparison. Other state structures use memcmp directly, and I think it is better to use a common pattern. We'll just need to be mindful of alignment, which could be indicated with a comment.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10598#note_135474
participants (3)
-
Rémi Bernon -
Rémi Bernon (@rbernon) -
Zhiyi Zhang (@zhiyi)