From: Martin Ling Date: Fri, 24 Jan 2020 05:06:55 +0000 (+0000) Subject: windows: Fix a warning on size_t to USHORT conversion. X-Git-Tag: libserialport-0.1.2~38 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=60fc49ceab499a979ba9053cce86944335ab5488;p=libserialport.git windows: Fix a warning on size_t to USHORT conversion. Building with MSVC gave: warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data The value here is known to be safe for the sizes involved. Add an explicit cast to suppress the warning. --- diff --git a/windows.c b/windows.c index bc07e23..f9c2c41 100644 --- a/windows.c +++ b/windows.c @@ -143,7 +143,7 @@ static char *get_string_descriptor(HANDLE hub_device, ULONG connection_index, desc_req->SetupPacket.wValue = (USB_STRING_DESCRIPTOR_TYPE << 8) | descriptor_index; desc_req->SetupPacket.wIndex = 0; - desc_req->SetupPacket.wLength = size - sizeof(*desc_req); + desc_req->SetupPacket.wLength = (USHORT) (size - sizeof(*desc_req)); if (!DeviceIoControl(hub_device, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION,