As promised. Hopefully this will silence the warnings raised by Clang on OS-X.

And again, if someone wants to look into silencing that -std=gnu99 one, you're welcome to submit a patch. I'm not planning to look into it, but that doesn't mean there won't be review+integration of a patch if one is submitted.

Regards,

/Pete
>From 169d66bc8fe189d6ab52f02dd0d683975dc10640 Mon Sep 17 00:00:00 2001
From: Pete Batard <p...@akeo.ie>
Date: Thu, 28 Jun 2012 22:49:47 +0100
Subject: [PATCH] Misc: Fix more Clang warnings in core and darwin

* http://sourceforge.net/mailarchive/message.php?msg_id=29418038
* core.c:700:4: warning: Function call argument is an uninitialized value
* darwin_usb.c:1713:11: warning: Access to field 'cfSource' results in a
  dereference of a null pointer (loaded from variable 'hpriv')
* sync.c/dpfp.c/dpfp_threaded.c: warning: Result of 'malloc' is converted
  to a pointer of type 'unsigned char', which is incompatible with sizeof
  operand type
---
 examples/dpfp.c          | 2 +-
 examples/dpfp_threaded.c | 2 +-
 libusb/core.c            | 2 +-
 libusb/os/darwin_usb.c   | 2 ++
 libusb/sync.c            | 2 +-
 5 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/examples/dpfp.c b/examples/dpfp.c
index c7d6347..ff98b5d 100644
--- a/examples/dpfp.c
+++ b/examples/dpfp.c
@@ -164,7 +164,7 @@ static void LIBUSB_CALL cb_mode_changed(struct 
libusb_transfer *transfer)
 
 static int set_mode_async(unsigned char data)
 {
-       unsigned char *buf = malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
+       unsigned char *buf = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE 
+ 1);
        struct libusb_transfer *transfer;
 
        if (!buf)
diff --git a/examples/dpfp_threaded.c b/examples/dpfp_threaded.c
index e1df6ee..c8cbb28 100644
--- a/examples/dpfp_threaded.c
+++ b/examples/dpfp_threaded.c
@@ -193,7 +193,7 @@ static void LIBUSB_CALL cb_mode_changed(struct 
libusb_transfer *transfer)
 
 static int set_mode_async(unsigned char data)
 {
-       unsigned char *buf = malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
+       unsigned char *buf = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE 
+ 1);
        struct libusb_transfer *transfer;
 
        if (!buf)
diff --git a/libusb/core.c b/libusb/core.c
index 82cf782..8845909 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -683,7 +683,7 @@ int API_EXPORTED libusb_get_port_path(libusb_context *ctx, 
libusb_device *dev, u
 {
        int i = path_len;
        ssize_t r;
-       struct libusb_device **devs;
+       struct libusb_device **devs = NULL;
 
        /* The device needs to be open, else the parents may have been 
destroyed */
        r = libusb_get_device_list(ctx, &devs);
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index ac67b35..63c2bae 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -1698,6 +1698,8 @@ static int op_handle_events(struct libusb_context *ctx, 
struct pollfd *fds, POLL
       if (hpriv->fds[0] == pollfd->fd)
        break;
     }
+    if (!hpriv)
+      continue;
 
     if (!(pollfd->revents & POLLERR)) {
       ret = read (hpriv->fds[0], &message, sizeof (message));
diff --git a/libusb/sync.c b/libusb/sync.c
index 9defc14..5033387 100644
--- a/libusb/sync.c
+++ b/libusb/sync.c
@@ -81,7 +81,7 @@ int API_EXPORTED libusb_control_transfer(libusb_device_handle 
*dev_handle,
        if (!transfer)
                return LIBUSB_ERROR_NO_MEM;
 
-       buffer = malloc(LIBUSB_CONTROL_SETUP_SIZE + wLength);
+       buffer = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE + wLength);
        if (!buffer) {
                libusb_free_transfer(transfer);
                return LIBUSB_ERROR_NO_MEM;
-- 
1.7.11.msysgit.0

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to