Commit b0b77d4b authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

user32: Fixed some more side effect functions in assert() (Coverity).

parent 06b78fea
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <assert.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
...@@ -63,17 +62,19 @@ static void flush_events(void) ...@@ -63,17 +62,19 @@ static void flush_events(void)
static void create_dde_window(HWND *hwnd, LPCSTR name, WNDPROC wndproc) static void create_dde_window(HWND *hwnd, LPCSTR name, WNDPROC wndproc)
{ {
WNDCLASSA wcA; WNDCLASSA wcA;
ATOM aclass;
memset(&wcA, 0, sizeof(wcA)); memset(&wcA, 0, sizeof(wcA));
wcA.lpfnWndProc = wndproc; wcA.lpfnWndProc = wndproc;
wcA.lpszClassName = name; wcA.lpszClassName = name;
wcA.hInstance = GetModuleHandleA(0); wcA.hInstance = GetModuleHandleA(0);
assert(RegisterClassA(&wcA)); aclass = RegisterClassA(&wcA);
ok (aclass, "RegisterClass failed\n");
*hwnd = CreateWindowExA(0, name, NULL, WS_POPUP, *hwnd = CreateWindowExA(0, name, NULL, WS_POPUP,
500, 500, CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, CW_USEDEFAULT, CW_USEDEFAULT,
GetDesktopWindow(), 0, GetModuleHandleA(0), NULL); GetDesktopWindow(), 0, GetModuleHandleA(0), NULL);
assert(*hwnd); ok(*hwnd != NULL, "CreateWindowExA failed\n");
} }
static void destroy_dde_window(HWND *hwnd, LPCSTR name) static void destroy_dde_window(HWND *hwnd, LPCSTR name)
......
...@@ -559,6 +559,7 @@ static HWND create_editcontrol (DWORD style, DWORD exstyle) ...@@ -559,6 +559,7 @@ static HWND create_editcontrol (DWORD style, DWORD exstyle)
style, style,
10, 10, 300, 300, 10, 10, 300, 300,
NULL, NULL, hinst, NULL); NULL, NULL, hinst, NULL);
ok (handle != NULL, "CreateWindow EDIT Control failed\n");
assert (handle); assert (handle);
if (winetest_interactive) if (winetest_interactive)
ShowWindow (handle, SW_SHOW); ShowWindow (handle, SW_SHOW);
...@@ -570,12 +571,14 @@ static HWND create_child_editcontrol (DWORD style, DWORD exstyle) ...@@ -570,12 +571,14 @@ static HWND create_child_editcontrol (DWORD style, DWORD exstyle)
HWND parentWnd; HWND parentWnd;
HWND editWnd; HWND editWnd;
RECT rect; RECT rect;
BOOL b;
rect.left = 0; rect.left = 0;
rect.top = 0; rect.top = 0;
rect.right = 300; rect.right = 300;
rect.bottom = 300; rect.bottom = 300;
assert(AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE)); b = AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
ok(b, "AdjustWindowRect failed\n");
parentWnd = CreateWindowEx(0, parentWnd = CreateWindowEx(0,
szEditTextPositionClass, szEditTextPositionClass,
...@@ -584,6 +587,7 @@ static HWND create_child_editcontrol (DWORD style, DWORD exstyle) ...@@ -584,6 +587,7 @@ static HWND create_child_editcontrol (DWORD style, DWORD exstyle)
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
rect.right - rect.left, rect.bottom - rect.top, rect.right - rect.left, rect.bottom - rect.top,
NULL, NULL, hinst, NULL); NULL, NULL, hinst, NULL);
ok (parentWnd != NULL, "CreateWindow EDIT Test failed\n");
assert(parentWnd); assert(parentWnd);
editWnd = CreateWindowEx(exstyle, editWnd = CreateWindowEx(exstyle,
...@@ -592,6 +596,7 @@ static HWND create_child_editcontrol (DWORD style, DWORD exstyle) ...@@ -592,6 +596,7 @@ static HWND create_child_editcontrol (DWORD style, DWORD exstyle)
WS_CHILD | style, WS_CHILD | style,
0, 0, 300, 300, 0, 0, 300, 300,
parentWnd, NULL, hinst, NULL); parentWnd, NULL, hinst, NULL);
ok (editWnd != NULL, "CreateWindow EDIT Test Text failed\n");
assert(editWnd); assert(editWnd);
if (winetest_interactive) if (winetest_interactive)
ShowWindow (parentWnd, SW_SHOW); ShowWindow (parentWnd, SW_SHOW);
...@@ -1572,7 +1577,7 @@ static void test_text_position_style(DWORD style) ...@@ -1572,7 +1577,7 @@ static void test_text_position_style(DWORD style)
HDC dc; HDC dc;
TEXTMETRIC metrics; TEXTMETRIC metrics;
INT b, bm, b2, b3; INT b, bm, b2, b3;
BOOL single_line = !(style & ES_MULTILINE); BOOL xb, single_line = !(style & ES_MULTILINE);
b = GetSystemMetrics(SM_CYBORDER) + 1; b = GetSystemMetrics(SM_CYBORDER) + 1;
b2 = 2 * b; b2 = 2 * b;
...@@ -1580,10 +1585,13 @@ static void test_text_position_style(DWORD style) ...@@ -1580,10 +1585,13 @@ static void test_text_position_style(DWORD style)
bm = b2 - 1; bm = b2 - 1;
/* Get a stock font for which we can determine the metrics */ /* Get a stock font for which we can determine the metrics */
assert(font = GetStockObject(SYSTEM_FONT)); font = GetStockObject(SYSTEM_FONT);
assert(dc = GetDC(NULL)); ok (font != NULL, "GetStockObjcet SYSTEM_FONT failed\n");
dc = GetDC(NULL);
ok (dc != NULL, "GetDC() failed\n");
oldFont = SelectObject(dc, font); oldFont = SelectObject(dc, font);
assert(GetTextMetrics(dc, &metrics)); xb = GetTextMetrics(dc, &metrics);
ok (xb, "GetTextMetrics failed\n");
SelectObject(dc, oldFont); SelectObject(dc, oldFont);
ReleaseDC(NULL, dc); ReleaseDC(NULL, dc);
...@@ -2448,10 +2456,14 @@ static void test_dialogmode(void) ...@@ -2448,10 +2456,14 @@ static void test_dialogmode(void)
START_TEST(edit) START_TEST(edit)
{ {
BOOL b;
init_function_pointers(); init_function_pointers();
hinst = GetModuleHandleA(NULL); hinst = GetModuleHandleA(NULL);
assert(RegisterWindowClasses()); b = RegisterWindowClasses();
ok (b, "RegisterWindowClasses failed\n");
if (!b) return;
test_edit_control_1(); test_edit_control_1();
test_edit_control_2(); test_edit_control_2();
......
...@@ -239,8 +239,9 @@ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] ) ...@@ -239,8 +239,9 @@ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] )
} }
for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++) for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++)
; ;
assert( evtctr <= MAXKEYEVENTS ); ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" );
assert( evtctr == pSendInput(evtctr, &inputs[0], sizeof(INPUT))); if( evtctr != pSendInput(evtctr, &inputs[0], sizeof(INPUT)))
ok (FALSE, "SendInput failed to send some events\n");
i = 0; i = 0;
if (winetest_debug > 1) if (winetest_debug > 1)
trace("======== key stroke sequence #%d: %s =============\n", trace("======== key stroke sequence #%d: %s =============\n",
......
...@@ -291,7 +291,7 @@ static void test_ownerdraw(void) ...@@ -291,7 +291,7 @@ static void test_ownerdraw(void)
cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.hbrBackground = GetStockObject(WHITE_BRUSH);
cls.lpszMenuName = NULL; cls.lpszMenuName = NULL;
cls.lpszClassName = "main_window_class"; cls.lpszClassName = "main_window_class";
assert(RegisterClass(&cls)); ok (RegisterClass(&cls), "RegisterClass failed\n");
parent = CreateWindowEx(0, "main_window_class", NULL, parent = CreateWindowEx(0, "main_window_class", NULL,
WS_POPUP | WS_VISIBLE, WS_POPUP | WS_VISIBLE,
......
...@@ -3367,7 +3367,7 @@ static void test_mdi_messages(void) ...@@ -3367,7 +3367,7 @@ static void test_mdi_messages(void)
RECT rc; RECT rc;
HMENU hMenu = CreateMenu(); HMENU hMenu = CreateMenu();
assert(mdi_RegisterWindowClasses()); if (!mdi_RegisterWindowClasses()) assert(0);
flush_sequence(); flush_sequence();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment