`WS_POPUP` for instance is `0x80000000`, which overflows a `LONG`. Coverity complained about this. The return type of `get_window_long()` already was `DWORD`.
-- v2: win32u: Store window styles in a DWORD (Coverity).
From: Sven Baars sbaars@codeweavers.com
--- dlls/win32u/dce.c | 4 ++-- dlls/win32u/defwnd.c | 12 ++++++------ dlls/win32u/input.c | 4 ++-- dlls/win32u/window.c | 22 +++++++++++----------- 4 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index ed6f0488c42..68de024c8b3 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -1241,7 +1241,7 @@ HDC WINAPI NtUserGetDCEx( HWND hwnd, HRGN clip_rgn, DWORD flags ) BOOL update_vis_rgn = TRUE; struct dce *dce; HWND parent; - LONG window_style = get_window_long( hwnd, GWL_STYLE ); + DWORD window_style = get_window_long( hwnd, GWL_STYLE );
if (!hwnd) hwnd = get_desktop_window(); else hwnd = get_full_window_handle( hwnd ); @@ -1280,7 +1280,7 @@ HDC WINAPI NtUserGetDCEx( HWND hwnd, HRGN clip_rgn, DWORD flags )
if( flags & DCX_PARENTCLIP ) { - LONG parent_style = get_window_long( parent, GWL_STYLE ); + DWORD parent_style = get_window_long( parent, GWL_STYLE ); if( (window_style & WS_VISIBLE) && (parent_style & WS_VISIBLE) ) { flags &= ~DCX_CLIPCHILDREN; diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c index 0cbb41d8604..34fb2cab1f5 100644 --- a/dlls/win32u/defwnd.c +++ b/dlls/win32u/defwnd.c @@ -471,7 +471,7 @@ static LRESULT handle_set_cursor( HWND hwnd, WPARAM wparam, LPARAM lparam )
static LONG handle_window_pos_changing( HWND hwnd, WINDOWPOS *winpos ) { - LONG style = get_window_long( hwnd, GWL_STYLE ); + DWORD style = get_window_long( hwnd, GWL_STYLE );
if (winpos->flags & SWP_NOSIZE) return 0; if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0)) @@ -1850,8 +1850,8 @@ static LRESULT handle_nc_activate( HWND hwnd, WPARAM wparam, LPARAM lparam ) static void handle_nc_calc_size( HWND hwnd, WPARAM wparam, RECT *win_rect ) { RECT rect = { 0, 0, 0, 0 }; - LONG style = get_window_long( hwnd, GWL_STYLE ); - LONG ex_style = get_window_long( hwnd, GWL_EXSTYLE ); + DWORD style = get_window_long( hwnd, GWL_STYLE ); + DWORD ex_style = get_window_long( hwnd, GWL_EXSTYLE );
if (!win_rect) return;
@@ -2178,7 +2178,7 @@ static void track_close_button( HWND hwnd, WPARAM wparam, LPARAM lparam )
static LRESULT handle_nc_lbutton_down( HWND hwnd, WPARAM wparam, LPARAM lparam ) { - LONG style = get_window_long( hwnd, GWL_STYLE ); + DWORD style = get_window_long( hwnd, GWL_STYLE );
switch (wparam) /* Hit test */ { @@ -2372,7 +2372,7 @@ static LRESULT handle_nc_mouse_move( HWND hwnd, WPARAM wparam, LPARAM lparam )
static LRESULT handle_nc_mouse_leave( HWND hwnd ) { - LONG style = get_window_long( hwnd, GWL_STYLE ); + DWORD style = get_window_long( hwnd, GWL_STYLE ); POINT pt = {0, 0};
TRACE( "hwnd=%p\n", hwnd ); @@ -2687,7 +2687,7 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
case WM_SHOWWINDOW: { - LONG style = get_window_long( hwnd, GWL_STYLE ); + DWORD style = get_window_long( hwnd, GWL_STYLE ); WND *win; if (!lparam) break; /* sent from ShowWindow */ if ((style & WS_VISIBLE) && wparam) break; diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index e1a0b11a584..008a8b4943d 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -2082,7 +2082,7 @@ HWND WINAPI NtUserSetActiveWindow( HWND hwnd )
if (hwnd) { - LONG style; + DWORD style;
hwnd = get_full_window_handle( hwnd ); if (!is_window( hwnd )) @@ -2123,7 +2123,7 @@ HWND WINAPI NtUserSetFocus( HWND hwnd ) for (;;) { HWND parent; - LONG style = get_window_long( hwndTop, GWL_STYLE ); + DWORD style = get_window_long( hwndTop, GWL_STYLE ); if (style & (WS_MINIMIZE | WS_DISABLED)) return 0; if (!(style & WS_CHILD)) break; parent = NtUserGetAncestor( hwndTop, GA_PARENT ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index c681333aa4a..3fb64755ba0 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -360,7 +360,7 @@ HWND get_parent( HWND hwnd ) if (win == WND_DESKTOP) return 0; if (win == WND_OTHER_PROCESS) { - LONG style = get_window_long( hwnd, GWL_STYLE ); + DWORD style = get_window_long( hwnd, GWL_STYLE ); if (style & (WS_POPUP | WS_CHILD)) { SERVER_START_REQ( get_window_tree ) @@ -744,7 +744,7 @@ BOOL is_window_drawable( HWND hwnd, BOOL icon ) HWND *list; BOOL retval = TRUE; int i; - LONG style = get_window_long( hwnd, GWL_STYLE ); + DWORD style = get_window_long( hwnd, GWL_STYLE );
if (!(style & WS_VISIBLE)) return FALSE; if ((style & WS_MINIMIZE) && icon && get_class_long_ptr( hwnd, GCLP_HICON, FALSE )) return FALSE; @@ -849,7 +849,7 @@ static BOOL is_hung_app_window( HWND hwnd ) /* see IsWindowEnabled */ BOOL is_window_enabled( HWND hwnd ) { - LONG ret; + DWORD ret;
RtlSetLastWin32Error( NO_ERROR ); ret = get_window_long( hwnd, GWL_STYLE ); @@ -2592,7 +2592,7 @@ HWND window_from_point( HWND hwnd, POINT pt, INT *hittest )
for (i = 0; list[i]; i++) { - LONG style = get_window_long( list[i], GWL_STYLE ); + DWORD style = get_window_long( list[i], GWL_STYLE );
/* If window is minimized or disabled, return at once */ if (style & WS_DISABLED) @@ -2652,7 +2652,7 @@ HWND WINAPI NtUserChildWindowFromPointEx( HWND parent, LONG x, LONG y, UINT flag if (!PtInRect( &rect, pt )) continue; if (flags & (CWP_SKIPINVISIBLE|CWP_SKIPDISABLED)) { - LONG style = get_window_long( list[i], GWL_STYLE ); + DWORD style = get_window_long( list[i], GWL_STYLE ); if ((flags & CWP_SKIPINVISIBLE) && !(style & WS_VISIBLE)) continue; if ((flags & CWP_SKIPDISABLED) && (style & WS_DISABLED)) continue; } @@ -4129,7 +4129,7 @@ UINT win_set_flags( HWND hwnd, UINT set_mask, UINT clear_mask ) */ static BOOL can_activate_window( HWND hwnd ) { - LONG style; + DWORD style;
if (!hwnd) return FALSE; style = get_window_long( hwnd, GWL_STYLE ); @@ -4205,11 +4205,11 @@ static void send_parent_notify( HWND hwnd, UINT msg ) */ MINMAXINFO get_min_max_info( HWND hwnd ) { - LONG style = get_window_long( hwnd, GWL_STYLE ); - LONG exstyle = get_window_long( hwnd, GWL_EXSTYLE ); + DWORD style = get_window_long( hwnd, GWL_STYLE ); + DWORD exstyle = get_window_long( hwnd, GWL_EXSTYLE ); UINT context; RECT rc_work, rc_primary; - LONG adjusted_style; + DWORD adjusted_style; MINMAXINFO minmax; INT xinc, yinc; RECT rc; @@ -4426,7 +4426,7 @@ static POINT get_minimized_pos( HWND hwnd, POINT pt ) static UINT window_min_maximize( HWND hwnd, UINT cmd, RECT *rect ) { UINT swp_flags = 0; - LONG old_style; + DWORD old_style; MINMAXINFO minmax; WINDOWPLACEMENT wpl;
@@ -4615,7 +4615,7 @@ static BOOL show_window( HWND hwnd, INT cmd ) { WND *win; HWND parent; - LONG style = get_window_long( hwnd, GWL_STYLE ), new_style; + DWORD style = get_window_long( hwnd, GWL_STYLE ), new_style; BOOL was_visible = (style & WS_VISIBLE) != 0; BOOL show_flag = TRUE; RECT newPos = {0, 0, 0, 0};
While changing it I'd suggest to use UINT on the unix side, to make eventual tracing easier.