Clarify alignment requirements for the control transfer buffer
authorPaul Fertser <fercerpav@gmail.com>
Mon, 1 Jul 2013 17:07:24 +0000 (21:07 +0400)
committerHans de Goede <hdegoede@redhat.com>
Wed, 21 Aug 2013 14:04:08 +0000 (16:04 +0200)
commitc089900c486e94b067e4d30ef9047a80cbb6d689
treef096bf80a530a0444e020d625120ba5454e2404e
parent6732582bb17662aa02a913008be899ef9ace5870
Clarify alignment requirements for the control transfer buffer

Since the buffer pointer will later be casted to ``struct
libusb_control_setup *'', it should point to memory aligned to at least
2 bytes boundary as that's the strictest requirement of the struct fields.

Also, use a (void *) casting trick to convince the compiler the cast is
safe, to fix warnings such as:

/usr/local/include/libusb-1.0/libusb.h: In function 'libusb_control_transfer_get_setup':
/usr/local/include/libusb-1.0/libusb.h:1435:9: error: cast increases required alignment of target type [-Werror=cast-align]
/usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_setup':
/usr/local/include/libusb-1.0/libusb.h:1464:39: error: cast increases required alignment of target type [-Werror=cast-align]
/usr/local/include/libusb-1.0/libusb.h: In function 'libusb_fill_control_transfer':
/usr/local/include/libusb-1.0/libusb.h:1509:39: error: cast increases required alignment of target type [-Werror=cast-align]
cc1: all warnings being treated as errors

This actually can lead to failure to build from the sources for certain
projects which use -Werror=cast-align on ARM.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
libusb/io.c
libusb/libusb.h
libusb/version_nano.h