Hi all,

When building my own code, where ever I #include libusbx (1.0.12), I get:

libusb.h:1069:9: warning: cast from 'unsigned char *' to 'struct 
libusb_control_setup *' increases required alignment from 1 to 2 [-Wcast-align]

libusb.h:1098:39: warning: cast from 'unsigned char *' to 'struct 
libusb_control_setup *' increases required alignment from 1 to 2 [-Wcast-align]

libusb.h:1143:39: warning: cast from 'unsigned char *' to 'struct 
libusb_control_setup *' increases required alignment from 1 to 2 [-Wcast-align]

Though pedantic, I believe this is a legitimate complaint.  C doesn't guarantee 
much about struct alignment/padding and different compilers will do different 
things.

As such, it's not ideal that libusb_transfer's byte-aligned 'buffer' be cast to 
a libusb_control_setup*.

Building libusbx itself results in many more -Wcast-align warnings, but I care 
most about the public headers.

Fixing libusbx to be -Wcast-align-clean looks like a non-trivial job, so how 
about:
 1) making libusb_control_transfer_get_setup not inline, so it's iffy cast is 
hidden in a .c file
 2) making libusb_transfer's 'buffer' void*.  This silences the warning, but 
doesn't really fix anything.  This will also require other casts elsewhere, 
since pointer arithmetic on void* is also not kosher.
 3) ???

Thanks,

-- 
____________________________________________________________
Sean McBride, B. Eng                 s...@rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada



------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to