Hi,
While trying to manage to fix warning about unused values, I've found a problem about some usages of ok() macro.
ok() macros is defined in include/wine/test.h as:
#define ok_(file, line) (winetest_set_location(file, line), 0) ? 0 : winetest_ok #define ok ok_(__FILE__, __LINE__)
One good example: ok( val != NULL, "Invalid value\n"); is expanded as (winetest_set_location(file, line), 0) ? 0 : winetest_ok(val != NULL, "Invalid value\n");
One bad example: if (!ok( val != NULL, "Invalid value\n")) is expanded as if (!(winetest_set_location(file, line), 0) ? 0 : winetest_ok(val != NULL, "Invalid value\n"))
And is then evaluated as
1) if ( !(0) ? 0 : winetest_ok(val != NULL, "Invalid value\n")) 2) if ( 1 ? 0 : winetest_ok(val != NULL, "Invalid value\n")) ^ ouch ! 3) if (0)
So this is pretty useless.
Hopefully, this is only of limited use in wine test suite: find . -type d -name tests | xargs grep -r '[=!][[:space:](]*ok[[:space:]]*(' returns only four cases:
./dlls/user32/tests/scroll.c: if ( !ok( hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n" ) ) ./dlls/kernel32/tests/file.c: !ok( UnlockFile( handle, 100, 0, 10, 0 ), "UnlockFile 100,10 failed\n" ); ./dlls/comctl32/tests/treeview.c: if ( !ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n") ) ./dlls/shell32/tests/autocomplete.c: if(!ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n"))
There's only 3 case with a real problem. The fourth is something very strange: the !ok() in ./dlls/kernel32/tests/file.c seems to be a typo, or someone wanted to disable the test.
Regards.