Huw Davies (@huw) commented about dlls/advapi32/tests/registry.c:
}
-/* tests that show that RegConnectRegistry and +/* Helper function to wait for a file blocked by the registry to be available */ +static void wait_file_available(char *path) +{ + int attempts = 0; + HANDLE file = NULL; + + while (((file = CreateFileA(path, GENERIC_READ, 0, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) + && attempts++ <= 10) + { + Sleep(200); + } + ok(attempts <= 10, "couldn't open file %s after 10 attempts error %ld.\n", path, GetLastError()); Sorry, missed this earlier, but you'd be better off testing `file != INVALID_HANDLE_VALUE`.
Also, not that it really matters, but to get ten iterations you'd want `attempts++ < 10` in the loop condition. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/766#note_8004