Rémi Bernon (@rbernon) commented about dlls/windows.devices.usb/usbdevice.c:
+ static const WCHAR *prefix = L"System.Devices.InterfaceClassGuid:=\"{DEE824EF-729B-4A0E-9C14-B7117D33A817}\"" + L" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True" + L" AND System.DeviceInterface.WinUsb.UsbVendorId:="; + static const WCHAR *suffix = L" AND System.DeviceInterface.WinUsb.UsbProductId:="; + WCHAR *buffer; + int length; + HRESULT hr; + + TRACE( "iface %p, vendor %d, product %d, value %p.\n", iface, vendor, product, value ); + + 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) ); You could probably use a static buffer with a large enough fixed size as the format string is known and as %d has a fixed maximum size, which would save the trouble of the allocation and having to pre-compute the length.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/3271#note_38395