]> sigrok.org Git - libserialport.git/commitdiff
windows: Fix a warning on size_t to USHORT conversion.
authorMartin Ling <redacted>
Fri, 24 Jan 2020 05:06:55 +0000 (05:06 +0000)
committerUwe Hermann <redacted>
Sun, 26 Jan 2020 20:11:46 +0000 (21:11 +0100)
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.

windows.c

index bc07e234c341ebf8cdec4d34aa1344ae2fe4429a..f9c2c41faf768925e6eb38b0a1784150f283cc6c 100644 (file)
--- 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,