Rémi Bernon (@rbernon) commented about dlls/windows.devices.usb/tests/usb.c:
- HRESULT hr;
- if (!value) return E_INVALIDARG;
- length = _snwprintf( NULL, 0, L"%ls%d%ls%d", prefix, (INT32)vendor, suffix, (INT32)product );
- if (length < 0) return E_FAIL;
- buffer = (WCHAR *)malloc( (length + 1) * sizeof(WCHAR) );
- if (!buffer) return E_OUTOFMEMORY;
- _snwprintf( buffer, length + 1, L"%ls%d%ls%d", prefix, (INT32)vendor, suffix, (INT32)product );
- hr = WindowsCreateString( buffer, length, value );
- free( buffer );
- return hr;
+}
With the suggested changes in the previous commit I think this should be reduced down to a simple swprintf to a temp static buffer, I'm not sure it deserves a helper.
I understand the idea of checking against the exact Wine implementation, but I think that in general we're interested in the results, not how they are computed. So, copying Wine implementation into tests is probably not a good habit.