summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/lsusb.c3
-rw-r--r--libusb/core.c8
-rw-r--r--libusb/descriptor.c2
-rw-r--r--libusb/io.c2
-rw-r--r--libusb/libusb.h11
-rw-r--r--libusb/os/windows_usb.c2
6 files changed, 19 insertions, 9 deletions
diff --git a/examples/lsusb.c b/examples/lsusb.c
index 43806de..317adf0 100644
--- a/examples/lsusb.c
+++ b/examples/lsusb.c
@@ -44,7 +44,8 @@ static void print_devs(libusb_device **devs)
int main(void)
{
libusb_device **devs;
- int r, cnt;
+ int r;
+ ssize_t cnt;
r = libusb_init(NULL);
if (r < 0)
diff --git a/libusb/core.c b/libusb/core.c
index 94b22e1..6adf67e 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -602,13 +602,13 @@ struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx,
* \returns the number of devices in the outputted list, or LIBUSB_ERROR_NO_MEM
* on memory allocation failure.
*/
-API_EXPORTED int libusb_get_device_list(libusb_context *ctx,
+API_EXPORTED ssize_t libusb_get_device_list(libusb_context *ctx,
libusb_device ***list)
{
struct discovered_devs *discdevs = discovered_devs_alloc();
struct libusb_device **ret;
int r = 0;
- int i, len;
+ ssize_t i, len;
USBI_GET_CONTEXT(ctx);
usbi_dbg("");
@@ -873,7 +873,7 @@ API_EXPORTED int libusb_open(libusb_device *dev, libusb_device_handle **handle)
struct libusb_device_handle *_handle;
size_t priv_size = usbi_backend->device_handle_priv_size;
unsigned char dummy = 1;
- int r;
+ ssize_t r;
usbi_dbg("open %d.%d", dev->bus_number, dev->device_address);
_handle = malloc(sizeof(*_handle) + priv_size);
@@ -892,7 +892,7 @@ API_EXPORTED int libusb_open(libusb_device *dev, libusb_device_handle **handle)
if (r < 0) {
libusb_unref_device(dev);
free(_handle);
- return r;
+ return (int)r;
}
pthread_mutex_lock(&ctx->open_devs_lock);
diff --git a/libusb/descriptor.c b/libusb/descriptor.c
index 638ed85..32cd795 100644
--- a/libusb/descriptor.c
+++ b/libusb/descriptor.c
@@ -65,7 +65,7 @@ int usbi_parse_descriptor(unsigned char *source, char *descriptor, void *dest,
}
}
- return sp - source;
+ return (int)(sp - source);
}
static void clear_endpoint(struct libusb_endpoint_descriptor *endpoint)
diff --git a/libusb/io.c b/libusb/io.c
index 4ed956c..2e1daf4 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1170,7 +1170,7 @@ API_EXPORTED struct libusb_transfer *libusb_alloc_transfer(int iso_packets)
{
size_t os_alloc_size = usbi_backend->transfer_priv_size
+ (usbi_backend->add_iso_packet_size * iso_packets);
- int alloc_size = sizeof(struct usbi_transfer)
+ size_t alloc_size = sizeof(struct usbi_transfer)
+ sizeof(struct libusb_transfer)
+ (sizeof(struct libusb_iso_packet_descriptor) * iso_packets)
+ os_alloc_size;
diff --git a/libusb/libusb.h b/libusb/libusb.h
index 8caa3e2..6456652 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -40,6 +40,15 @@
#define interface usb_interface
#endif
+// Windows doesn't know ssize_t
+#if !defined(ssize_t)
+#if defined (_WIN64)
+#define ssize_t __int64
+#else
+#define ssize_t long
+#endif
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -782,7 +791,7 @@ int libusb_init(libusb_context **ctx);
void libusb_exit(libusb_context *ctx);
void libusb_set_debug(libusb_context *ctx, int level);
-int libusb_get_device_list(libusb_context *ctx,
+ssize_t libusb_get_device_list(libusb_context *ctx,
libusb_device ***list);
void libusb_free_device_list(libusb_device **list, int unref_devices);
libusb_device *libusb_ref_device(libusb_device *dev);
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 193408e..1962391 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -174,7 +174,7 @@ static char* sanitize_path(const char* path)
const char root_prefix[] = "\\\\.\\";
size_t j, size, root_size;
char* ret_path = NULL;
- int add_root = 0;
+ size_t add_root = 0;
if (path == NULL)
return NULL;