]> sigrok.org Git - libserialport.git/blobdiff - windows.c
change type of result variables to ssize_t
[libserialport.git] / windows.c
index 357feed1e80009f5e19e8cbd750ee135051178ae..2825a92082672a3c05aa5997390dc5d25f5b00b7 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -18,8 +18,6 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <config.h>
-#include "libserialport.h"
 #include "libserialport_internal.h"
 
 /* USB path is a string of at most 8 decimal numbers < 128 separated by dots. */
@@ -145,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,
@@ -267,8 +265,8 @@ static void enumerate_hub(struct sp_port *port, const char *hub_name,
                return;
        strcpy(device_name, "\\\\.\\");
        strcat(device_name, hub_name);
-       hub_device = CreateFile(device_name, GENERIC_WRITE, FILE_SHARE_WRITE,
-                               NULL, OPEN_EXISTING, 0, NULL);
+       hub_device = CreateFileA(device_name, GENERIC_WRITE, FILE_SHARE_WRITE,
+                                NULL, OPEN_EXISTING, 0, NULL);
        free(device_name);
        if (hub_device == INVALID_HANDLE_VALUE)
                return;
@@ -469,9 +467,9 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port)
                        if (!(escaped_port_name = malloc(strlen(port->name) + 5)))
                                RETURN_ERROR(SP_ERR_MEM, "Escaped port name malloc failed");
                        sprintf(escaped_port_name, "\\\\.\\%s", port->name);
-                       handle = CreateFile(escaped_port_name, GENERIC_READ, 0, 0,
-                                           OPEN_EXISTING,
-                                           FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, 0);
+                       handle = CreateFileA(escaped_port_name, GENERIC_READ, 0, 0,
+                                            OPEN_EXISTING,
+                                            FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, 0);
                        free(escaped_port_name);
                        CloseHandle(handle);