am7xxx: specify LIBUSB_CALL for send_data_async_complete_cb()
authorAntonio Ospite <ao2@ao2.it>
Mon, 26 Feb 2018 15:05:20 +0000 (16:05 +0100)
committerAntonio Ospite <ao2@ao2.it>
Tue, 27 Feb 2018 16:20:06 +0000 (17:20 +0100)
send_data_async_complete_cb() is used as a callback for
libusb_fill_bulk_transfer() and it is expected to be of type
'libusb_transfer_cb_fn' which is defined using LIBUSB_CALL.

LIBUSB_CALL is only used on Windows and not having it results in the
following warning when compiling for Windows:

  .../libam7xxx/src/am7xxx.c: In function ‘send_data_async’:
  .../libam7xxx/src/am7xxx.c:508:7: warning: passing argument 6 of ‘libusb_fill_bulk_transfer’ from incompatible pointer type [-Wincompatible-pointer-types]
         send_data_async_complete_cb, dev, 0);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /home/ao2/Proj/picoProjector/libam7xxx/src/am7xxx.c:24:0:
  .../libam7xxx/build/libusb-1.0.21/include/libusb-1.0/libusb.h:1553:20: note: expected ‘libusb_transfer_cb_fn’ but argument is of type ‘void (*)(struct libusb_transfer *)’
   static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
                      ^~~~~~~~~~~~~~~~~~~~~~~~~

src/am7xxx.c

index 84d7e9c..1e05601 100644 (file)
@@ -414,7 +414,7 @@ static int send_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len)
        return 0;
 }
 
-static void send_data_async_complete_cb(struct libusb_transfer *transfer)
+static void LIBUSB_CALL send_data_async_complete_cb(struct libusb_transfer *transfer)
 {
        am7xxx_device *dev = (am7xxx_device *)(transfer->user_data);
        int *completed = &(dev->transfer_completed);