From 44fd6822cff133e2762d0cd578d18329ca1218b6 Mon Sep 17 00:00:00 2001 From: Anthony Lieuallen Date: Sat, 28 Jan 2017 12:41:10 -0500 Subject: [PATCH 1/3] Address "dereferencing type-punned pointer" warnings. With compiler warnings set to "More", and compiling against this library, I see warnings of the form: hidboot.h:381:21: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations; ^ This change addresses those warnings, making issues in my own code easier to notice. --- hidboot.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hidboot.h b/hidboot.h index 4d0b0b26..61d63b59 100644 --- a/hidboot.h +++ b/hidboot.h @@ -286,6 +286,7 @@ uint8_t HIDBoot::Init(uint8_t parent, uint8_t port, bool lowspeed const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); uint8_t buf[constBufSize]; + USB_DEVICE_DESCRIPTOR* device; uint8_t rcode; UsbDevice *p = NULL; EpInfo *oldep_ptr = NULL; @@ -330,6 +331,8 @@ uint8_t HIDBoot::Init(uint8_t parent, uint8_t port, bool lowspeed if(!rcode) len = (buf[0] > constBufSize) ? constBufSize : buf[0]; + device = reinterpret_cast(buf); + if(rcode) { // Restore p->epinfo p->epinfo = oldep_ptr; @@ -347,7 +350,7 @@ uint8_t HIDBoot::Init(uint8_t parent, uint8_t port, bool lowspeed return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0; + epInfo[0].maxPktSize = (uint8_t)(device->bMaxPacketSize0); // Assign new address to the device rcode = pUsb->setAddr(0, 0, bAddress); @@ -378,7 +381,7 @@ uint8_t HIDBoot::Init(uint8_t parent, uint8_t port, bool lowspeed if(rcode) goto FailGetDevDescr; - num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations; + num_of_conf = device->bNumConfigurations; USBTRACE2("NC:", num_of_conf); From 3a2d0c6e1b27fd0686cd9c3ff3ad26a4aabab90b Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Tue, 31 Jan 2017 00:32:09 +0100 Subject: [PATCH 2/3] Only show build status for master branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7345efb..b26b9503 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The code is released under the GNU General Public License. __________ -[![Build Status](https://travis-ci.org/felis/USB_Host_Shield_2.0.svg)](https://travis-ci.org/felis/USB_Host_Shield_2.0) +[![Build Status](https://travis-ci.org/felis/USB_Host_Shield_2.0.svg?branch=master)](https://travis-ci.org/felis/USB_Host_Shield_2.0) # Summary This is Revision 2.0 of MAX3421E-based USB Host Shield Library for AVR's. From f89593e4ce82374b57e929f1f42cf534791656e5 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Tue, 31 Jan 2017 01:18:38 +0100 Subject: [PATCH 3/3] Re-enable strict-aliasing warnings for Travis build See #280 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1640595b..06af6041 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,7 @@ env: install: - pip install -U platformio - - export PLATFORMIO_BUILD_FLAGS="-DDEBUG_USB_HOST -DWIICAMERA -Wall -Werror -Wno-strict-aliasing" + - export PLATFORMIO_BUILD_FLAGS="-DDEBUG_USB_HOST -DWIICAMERA -Wall -Werror" # # Libraries from PlatformIO Library Registry: