On Fri Feb 2 23:54:43 2024 +0000, Krzysztof Bogacki wrote:
It is zero-initialized, but won't be zeroed at this point. In line 200 I'm checking `pD3DKMTEnumAdapters2(&enum_adapters_2_desc) == STATUS_PROCEDURE_NOT_FOUND` to see if current version of Wine/Windows implements this API. I chose to pass a valid pointer instead of `NULL` when doing the availability check because I didn't want to consider a stub that does `return params ? STATUS_PROCEDURE_NOT_FOUND : STATUS_INVALID_PARAMETER;` to be a valid implementation worth running the rest of this test against (and this would be pretty much how wow64 stub would behave unless we changed it to `if (!desc32) return NtGdiDdDDIEnumAdapters2( NULL );`). But if it's not a stub, the structure will pretty much already contain the maximum number of supported adapters, so I'm zeroing it again. You are right, however, that this is not necessary. If `pAdapters` is `NULL`, Windows (and Wine) will ignore whatever was passed in `NumAdapters` and always overwrite it with the expected result. With this in mind, we can:
- Just remove this memset. We'd be then implicitly relying on
`pAdapters` staying `NULL` between calls but this is probably fine.
- Let this memset stay or change it to just
`enum_adapters_2_desc->pAdapters = NULL;`.
- Save the result of first
`pD3DKMTEnumAdapters2(&enum_adapters_2_desc)` in `status` and if it succeeds, immediately consider the "Query the array to allocate" part of the test to have succeeded as well, effectively reusing the result. So something like this:
{ … if (!pD3DKMTEnumAdapters2) { skip("D3DKMTEnumAdapters2() is missing.\n"); return; } /* Query the array to allocate */ status = pD3DKMTEnumAdapters2(&enum_adapters_2_desc); if (status == STATUS_PROCEDURE_NOT_FOUND) { skip("D3DKMTEnumAdapters2() is not supported.\n"); return; } ok(status == STATUS_SUCCESS, "Got unexpected return code %#lx.\n", status); … /* at the very end of the test, Invalid parameters */ status = pD3DKMTEnumAdapters2(NULL); ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#lx.\n", status); }
… which would make this test more similar to how the test for `D3DKMTOpenAdapterFromHdc` is written. For now I'll go with simple removal of this `memset` but if you prefer another solution, let me know and I'll change it.
Let's keep the memset(0) then.