From cb979446425f42d8e0c711e28ba4c9a72d5f0f02 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 16:45:54 -0800 Subject: [PATCH 01/22] Can we mark jobs as allowed to fail? --- .github/workflows/githubci.yml | 4 ++++ extras/build_all.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index ca5b922e2..403198303 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -56,4 +56,8 @@ jobs: arduino-cli lib install $LIB_DEPS - name: Build examples + allow_failure: true run: python3 extras/build_all.py ${{ matrix.arduino-platform }} + +# - name: Build examples with all warnings enabled +# run: python3 extras/build_all.py ${{ matrix.arduino-platform }} all_warnings diff --git a/extras/build_all.py b/extras/build_all.py index 83f0e19e9..e6af66590 100644 --- a/extras/build_all.py +++ b/extras/build_all.py @@ -23,6 +23,9 @@ else: build_boards = default_boards +all_warnings = True if 'all_warnings' in sys.arv[2:] + + def errorOutputFilter(line): if len(line) == 0: return False From 622d9f61831df6e497ccc1216051606c8e19c5d0 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 18:05:41 -0800 Subject: [PATCH 02/22] re-enable builds with all warnings --- .github/workflows/githubci.yml | 8 ++--- extras/build_all.py | 60 ++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index 403198303..fa3f84791 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -49,15 +49,15 @@ jobs: arduino-cli core update-index --additional-urls $BSP_URL arduino-cli core install arduino:samd --additional-urls $BSP_URL arduino-cli core install adafruit:samd --additional-urls $BSP_URL - # Repalce release BSP with our code + # Replace release BSP with our code BSP_VERSION=`eval ls $HOME/$BSP_PATH` rm -r $HOME/$BSP_PATH/* ln -s $GITHUB_WORKSPACE $HOME/$BSP_PATH/$BSP_VERSION arduino-cli lib install $LIB_DEPS - name: Build examples - allow_failure: true run: python3 extras/build_all.py ${{ matrix.arduino-platform }} -# - name: Build examples with all warnings enabled -# run: python3 extras/build_all.py ${{ matrix.arduino-platform }} all_warnings + # How to mark this as allowed-to-fail? + - name: Build default boards with all warnings enabled + run: python3 extras/build_all.py --all_warnings --warnings_do_not_cause_job_failure diff --git a/extras/build_all.py b/extras/build_all.py index e6af66590..4e701ace9 100644 --- a/extras/build_all.py +++ b/extras/build_all.py @@ -3,30 +3,42 @@ import sys import subprocess import time +import argparse + +FQBN_PREFIX='adafruit:samd:adafruit_' + + +parser = argparse.ArgumentParser( + description='python wrapper for adafruit arduino CI workflows', + allow_abbrev=False + ) +parser.add_argument( + '--all_warnings', '--Wall', + action='store_true', + help='build with all warnings enabled (`--warnings all`)', + ) +parser.add_argument( + '--warnings_do_not_cause_job_failure', + action='store_true', + help='failed builds will be listed as failed, but not cause job to exit with an error status', + ) +parser.add_argument( + 'build_boards', + metavar='board', + nargs='*', + help='list of boards to be built -- Note that the fqbn is created by prepending "{}"'.format(FQBN_PREFIX), + default= [ 'metro_m0', 'metro_m4', 'circuitplayground_m0' ] + ) +args = parser.parse_args() -all_warnings = False exit_status = 0 success_count = 0 fail_count = 0 skip_count = 0 - build_format = '| {:22} | {:30} | {:9} ' build_separator = '-' * 80 -default_boards = [ 'metro_m0', 'metro_m4', 'circuitplayground_m0'] - -build_boards = [] - -# build all variants if input not existed -if len(sys.argv) > 1: - build_boards.append(sys.argv[1]) -else: - build_boards = default_boards - -all_warnings = True if 'all_warnings' in sys.arv[2:] - - -def errorOutputFilter(line): +def errorOutputFilter(line: str): if len(line) == 0: return False if line.isspace(): # Note: empty string does not match here! @@ -34,9 +46,8 @@ def errorOutputFilter(line): # TODO: additional items to remove? return True - -def build_examples(variant): - global exit_status, success_count, fail_count, skip_count, build_format, build_separator +def build_examples(variant: str): + global args, exit_status, success_count, fail_count, skip_count, build_format, build_separator print('\n') print(build_separator) @@ -45,7 +56,7 @@ def build_examples(variant): print((build_format + '| {:6} |').format('Library', 'Example', 'Result', 'Time')) print(build_separator) - fqbn = "adafruit:samd:adafruit_{}".format(variant) + fqbn = "{}{}".format(FQBN_PREFIX, variant) for sketch in glob.iglob('libraries/**/*.ino', recursive=True): start_time = time.monotonic() @@ -61,14 +72,14 @@ def build_examples(variant): # TODO - preferably, would have STDERR show up in **both** STDOUT and STDERR. # preferably, would use Python logging handler to get both distinct outputs and one merged output # for now, split STDERR when building with all warnings enabled, so can detect warning/error output. - if all_warnings: + if args.all_warnings: build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: build_result = subprocess.run("arduino-cli compile --warnings default --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # get stderr into a form where len(warningLines) indicates a true warning was output to stderr warningLines = []; - if all_warnings and build_result.stderr: + if args.all_warnings and build_result.stderr: tmpWarningLines = build_result.stderr.decode("utf-8").splitlines() warningLines = list(filter(errorOutputFilter, (tmpWarningLines))) @@ -77,7 +88,8 @@ def build_examples(variant): success = "\033[31mfailed\033[0m " fail_count += 1 elif len(warningLines) != 0: - exit_status = -1 + if not args.warnings_do_not_cause_job_failure: + exit_status = -1 success = "\033[31mwarnings\033[0m " fail_count += 1 else: @@ -101,7 +113,7 @@ def build_examples(variant): build_time = time.monotonic() -for board in build_boards: +for board in args.build_boards: build_examples(board) print(build_separator) From 155cbc526276a34b3a070f6b77b10a26ef57387a Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 19:53:01 -0800 Subject: [PATCH 03/22] Friendlier name for -Wall build --- .github/workflows/githubci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index fa3f84791..41c0a771d 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -59,5 +59,5 @@ jobs: run: python3 extras/build_all.py ${{ matrix.arduino-platform }} # How to mark this as allowed-to-fail? - - name: Build default boards with all warnings enabled + - name: Build examples (-Wall) run: python3 extras/build_all.py --all_warnings --warnings_do_not_cause_job_failure From 9ab68e1aff6e8923cd706815302f09639789c8ac Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 21:42:06 -0800 Subject: [PATCH 04/22] avoid warnings on unused parameter --- libraries/SPI/SPI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SPI/SPI.h b/libraries/SPI/SPI.h index b87175ea6..a5e583590 100644 --- a/libraries/SPI/SPI.h +++ b/libraries/SPI/SPI.h @@ -149,7 +149,7 @@ class SPIClass { #else // On SAMD21, this compiles to nothing, so user code doesn't need to // check and conditionally compile lines for different architectures. - void setClockSource(SercomClockSource clk) { }; + void setClockSource(SercomClockSource clk) { (void)clk; }; #endif // end __SAMD51__ private: From 4f80972c2394b4444cb378ea3dd24249b9d06caa Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 21:44:31 -0800 Subject: [PATCH 05/22] cast to uint32_t to avoid compiler warning that said, it's possible this api might return a variety of non-zero codes. code could benefit from being updated (e.g., documenting return codes) --- .../USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino | 2 +- .../examples/KeyboardController/KeyboardController.ino | 3 +-- .../USBHost/examples/MouseController/MouseController.ino | 2 +- libraries/USBHost/examples/USB_desc/USB_desc.ino | 8 +++++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino b/libraries/USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino index ea7509cbc..21d6ef522 100644 --- a/libraries/USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino +++ b/libraries/USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino @@ -37,7 +37,7 @@ void setup(void) while (!SERIAL_PORT_MONITOR); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection SERIAL_PORT_MONITOR.println("\r\nADK demo start"); - if (usb.Init() == -1) + if (usb.Init() == (uint32_t)-1) SERIAL_PORT_MONITOR.println("OSC did not start."); delay(20); diff --git a/libraries/USBHost/examples/KeyboardController/KeyboardController.ino b/libraries/USBHost/examples/KeyboardController/KeyboardController.ino index 126bd4754..0daf7b02d 100644 --- a/libraries/USBHost/examples/KeyboardController/KeyboardController.ino +++ b/libraries/USBHost/examples/KeyboardController/KeyboardController.ino @@ -83,8 +83,7 @@ void setup() { SerialDebug.begin( 115200 ); SerialDebug.println("USB Host Keyboard Controller Program started"); - - if (usb.Init() == -1) + if (usb.Init() == (uint32_t)-1) SerialDebug.println("USB Host did not start."); SerialDebug.println("USB Host started"); diff --git a/libraries/USBHost/examples/MouseController/MouseController.ino b/libraries/USBHost/examples/MouseController/MouseController.ino index a7d7d6cba..90e6dce2b 100644 --- a/libraries/USBHost/examples/MouseController/MouseController.ino +++ b/libraries/USBHost/examples/MouseController/MouseController.ino @@ -91,7 +91,7 @@ void setup() SerialDebug.begin( 115200 ); SerialDebug.println("USB Host Mouse Controller Program started"); - if (usb.Init() == -1) + if (usb.Init() == (uint32_t)-1) SerialDebug.println("USB Host did not start."); SerialDebug.println("USB Host started"); diff --git a/libraries/USBHost/examples/USB_desc/USB_desc.ino b/libraries/USBHost/examples/USB_desc/USB_desc.ino index dc7b1569f..8a94aa5d3 100644 --- a/libraries/USBHost/examples/USB_desc/USB_desc.ino +++ b/libraries/USBHost/examples/USB_desc/USB_desc.ino @@ -59,8 +59,8 @@ void setup() SerialDebug.println("Starting USB Descriptor test"); SerialDebug.println("Initializing USB"); - if (usb.Init() == -1) - SerialDebug.println("USBhost did not start."); + if (usb.Init() == (uint32_t)-1) + SerialDebug.println("USBhost did not start."); delay( 20 ); @@ -159,7 +159,7 @@ byte getdevdescr( byte addr, byte &num_conf ) return( 0 ); } -void printhubdescr(uint8_t *descrptr, uint8_t addr) +void printhubdescr(uint8_t *descrptr, __attribute__((unused)) uint8_t addr) { HubDescriptor *pHub = (HubDescriptor*) descrptr; uint8_t len = *((uint8_t*)descrptr); @@ -213,6 +213,7 @@ byte getconfdescr( byte addr, byte conf ) byte descr_length; byte descr_type; uint16_t total_length; + // BUGBUG -- no check of return code from usb.getConfDescr() rcode = usb.getConfDescr( addr, 0, 4, conf, buf ); //get total length LOBYTE( total_length ) = buf[ 2 ]; HIBYTE( total_length ) = buf[ 3 ]; @@ -220,6 +221,7 @@ byte getconfdescr( byte addr, byte conf ) printProgStr(Conf_Trunc_str); total_length = sizeof(buf); } + // BUGBUG -- no check of return code from usb.getConfDescr() rcode = usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor while( buf_ptr < buf + total_length ) { //parsing descriptors descr_length = *( buf_ptr ); From d5935a8c512a797c9627f55f50b7e73357216434 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 21:47:11 -0800 Subject: [PATCH 06/22] remove 'unused parameter' compiler warning --- libraries/Wire/examples/slave_receiver/slave_receiver.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/Wire/examples/slave_receiver/slave_receiver.ino b/libraries/Wire/examples/slave_receiver/slave_receiver.ino index 60dd4bdde..a3103f8b9 100644 --- a/libraries/Wire/examples/slave_receiver/slave_receiver.ino +++ b/libraries/Wire/examples/slave_receiver/slave_receiver.ino @@ -28,6 +28,8 @@ void loop() // this function is registered as an event, see setup() void receiveEvent(int howMany) { + (void)howMany; // avoid compiler warning about unused parameter + while(1 < Wire.available()) // loop through all but the last { char c = Wire.read(); // receive byte as a character From 3253d46f4514cd34bd45c4e1e709877bbfd72ffb Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 22:20:17 -0800 Subject: [PATCH 07/22] Avoid unused parameter compiler warnings --- cores/arduino/WInterrupts.c | 2 +- .../Adafruit_ZeroDMA/examples/zerodma_spi1/zerodma_spi1.ino | 1 + .../Adafruit_ZeroDMA/examples/zerodma_spi2/zerodma_spi2.ino | 1 + libraries/Servo/src/samd/Servo.cpp | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index e0abc2d7d..53fcbffc3 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -250,7 +250,7 @@ void detachInterrupt(uint32_t pin) * External Interrupt Controller NVIC Interrupt Handler */ #if defined(__SAMD51__) -void InterruptHandler(uint32_t i) +void InterruptHandler(__attribute__((unused)) uint32_t i) { // Calling the routine directly from -here- takes about 1us // Depending on where you are in the list it will take longer diff --git a/libraries/Adafruit_ZeroDMA/examples/zerodma_spi1/zerodma_spi1.ino b/libraries/Adafruit_ZeroDMA/examples/zerodma_spi1/zerodma_spi1.ino index 2160969a8..ea29a25d1 100644 --- a/libraries/Adafruit_ZeroDMA/examples/zerodma_spi1/zerodma_spi1.ino +++ b/libraries/Adafruit_ZeroDMA/examples/zerodma_spi1/zerodma_spi1.ino @@ -19,6 +19,7 @@ volatile bool transfer_is_done = false; // Done yet? // Callback for end-of-DMA-transfer void dma_callback(Adafruit_ZeroDMA *dma) { + (void)dma; // avoid compiler warning about unused parameter transfer_is_done = true; } diff --git a/libraries/Adafruit_ZeroDMA/examples/zerodma_spi2/zerodma_spi2.ino b/libraries/Adafruit_ZeroDMA/examples/zerodma_spi2/zerodma_spi2.ino index c466c7b07..f33839283 100644 --- a/libraries/Adafruit_ZeroDMA/examples/zerodma_spi2/zerodma_spi2.ino +++ b/libraries/Adafruit_ZeroDMA/examples/zerodma_spi2/zerodma_spi2.ino @@ -33,6 +33,7 @@ volatile bool transfer_is_done = true; // Done yet? // Callback for end-of-DMA-transfer void dma_callback(Adafruit_ZeroDMA *dma) { + (void)dma; // avoid compiler warning about unused parameter transfer_is_done = true; } diff --git a/libraries/Servo/src/samd/Servo.cpp b/libraries/Servo/src/samd/Servo.cpp index 7030a57ac..e2474265c 100644 --- a/libraries/Servo/src/samd/Servo.cpp +++ b/libraries/Servo/src/samd/Servo.cpp @@ -172,7 +172,7 @@ static inline void resetTC (Tc* TCx) while (TCx->COUNT16.CTRLA.bit.SWRST); } -static void _initISR(Tc *tc, uint8_t channel, uint32_t id, IRQn_Type irqn, uint8_t gcmForTimer, uint8_t intEnableBit) +static void _initISR(Tc *tc, uint8_t channel, __attribute__((unused)) uint32_t id, IRQn_Type irqn, uint8_t gcmForTimer, uint8_t intEnableBit) { // Select GCLK0 as timer/counter input clock source #if defined(__SAMD51__) @@ -263,7 +263,7 @@ static void initISR(timer16_Sequence_t timer) #endif } -static void finISR(timer16_Sequence_t timer) +static void finISR(__attribute__((unused)) timer16_Sequence_t timer) { #if defined (_useTimer1) // Disable the match channel interrupt request From a2dd8614d42cae2adc39830e41e6de22d4982041 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 22:20:49 -0800 Subject: [PATCH 08/22] Avoid signed/unsigned comparison warning. --- cores/arduino/math_helper.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/cores/arduino/math_helper.c b/cores/arduino/math_helper.c index da6d47b0d..60887c708 100644 --- a/cores/arduino/math_helper.c +++ b/cores/arduino/math_helper.c @@ -164,18 +164,19 @@ void arm_float_to_q12_20(float *pIn, q31_t * pOut, uint32_t numSamples) uint32_t arm_compare_fixed_q15(q15_t *pIn, q15_t * pOut, uint32_t numSamples) { uint32_t i; - int32_t diff, diffCrnt = 0; + int32_t diff; + uint32_t diffCrnt = 0; uint32_t maxDiff = 0; for (i = 0; i < numSamples; i++) { - diff = pIn[i] - pOut[i]; - diffCrnt = (diff > 0) ? diff : -diff; + diff = pIn[i] - pOut[i]; + diffCrnt = (uint32_t)( (diff > 0) ? diff : -diff ); - if(diffCrnt > maxDiff) - { - maxDiff = diffCrnt; - } + if(diffCrnt > maxDiff) + { + maxDiff = diffCrnt; + } } return(maxDiff); @@ -192,18 +193,19 @@ uint32_t arm_compare_fixed_q15(q15_t *pIn, q15_t * pOut, uint32_t numSamples) uint32_t arm_compare_fixed_q31(q31_t *pIn, q31_t * pOut, uint32_t numSamples) { uint32_t i; - int32_t diff, diffCrnt = 0; + int32_t diff; + uint32_t diffCrnt = 0; uint32_t maxDiff = 0; for (i = 0; i < numSamples; i++) { - diff = pIn[i] - pOut[i]; - diffCrnt = (diff > 0) ? diff : -diff; + diff = pIn[i] - pOut[i]; + diffCrnt = (uint32_t)( (diff > 0) ? diff : -diff ); - if(diffCrnt > maxDiff) - { - maxDiff = diffCrnt; - } + if(diffCrnt > maxDiff) + { + maxDiff = diffCrnt; + } } return(maxDiff); From 4276526c67888c48ef3d034a9b16b77f995e5aaf Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 23:44:24 -0800 Subject: [PATCH 09/22] Avoid compiler warning for unused parameter --- .../Adafruit_ZeroDMA/examples/zerodma_memcpy/zerodma_memcpy.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/Adafruit_ZeroDMA/examples/zerodma_memcpy/zerodma_memcpy.ino b/libraries/Adafruit_ZeroDMA/examples/zerodma_memcpy/zerodma_memcpy.ino index 191ab50ac..5a48a6b56 100644 --- a/libraries/Adafruit_ZeroDMA/examples/zerodma_memcpy/zerodma_memcpy.ino +++ b/libraries/Adafruit_ZeroDMA/examples/zerodma_memcpy/zerodma_memcpy.ino @@ -17,6 +17,7 @@ volatile bool transfer_is_done = false; // Done yet? // Callback for end-of-DMA-transfer void dma_callback(Adafruit_ZeroDMA *dma) { + (void)dma; // avoid compiler warning about unused function parameter transfer_is_done = true; } From e1e7b37ff393768c907dca9fce1a84d61481c5df Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 23:46:31 -0800 Subject: [PATCH 10/22] Disable `-Wimplicit-fallthrough` for these two files. These two files contain code with multiple switch statements, where one case "fall through" to the next case. As it's not currently clear if this is intentional or not, rather than modifying the code in any way (regression risk), use GCC diagnostic pragmas to disable this warning for only these two files, with BUGBUG marking to encourage review by someone more familiar with this code. --- libraries/USBHost/src/confdescparser.h | 13 +++++++++++++ libraries/USBHost/src/parsetools.h | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/libraries/USBHost/src/confdescparser.h b/libraries/USBHost/src/confdescparser.h index 4b2b41b4f..6861160e9 100644 --- a/libraries/USBHost/src/confdescparser.h +++ b/libraries/USBHost/src/confdescparser.h @@ -19,6 +19,17 @@ e-mail : support@circuitsathome.com #error "Never include confdescparser.h directly; include Usb.h instead" #else +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" + + #define __CONFDESCPARSER_H__ #include @@ -220,4 +231,6 @@ void ConfigDescParser::PrintHidDescrip } +#pragma GCC diagnostic pop + #endif // __CONFDESCPARSER_H__ diff --git a/libraries/USBHost/src/parsetools.h b/libraries/USBHost/src/parsetools.h index d46335891..41a8bc974 100644 --- a/libraries/USBHost/src/parsetools.h +++ b/libraries/USBHost/src/parsetools.h @@ -23,6 +23,19 @@ e-mail : support@circuitsathome.com #include //#include "Arduino.h" +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" + + + + struct MultiValueBuffer { uint8_t valueSize; void *pValue; @@ -140,4 +153,7 @@ class PTPListParser { bool Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me = NULL); }; + +#pragma GCC diagnostic pop + #endif // __PARSETOOLS_H__ From 1a89b145ef4b48da65e71c44824bfd0ce2e1df7b Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 23:48:55 -0800 Subject: [PATCH 11/22] Enhance warning output. Add comment to line GCC points finger at. This is not intended to fix the warning. Rather, it is intended to make it clearer that this may need a deeper review before determining what (if any) code change would be appropriate. --- libraries/USBHost/examples/USB_desc/USB_desc.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/USBHost/examples/USB_desc/USB_desc.ino b/libraries/USBHost/examples/USB_desc/USB_desc.ino index 8a94aa5d3..30479c411 100644 --- a/libraries/USBHost/examples/USB_desc/USB_desc.ino +++ b/libraries/USBHost/examples/USB_desc/USB_desc.ino @@ -209,7 +209,7 @@ byte getconfdescr( byte addr, byte conf ) { uint8_t buf[ BUFSIZE ]; uint8_t* buf_ptr = buf; - byte rcode; + byte rcode; // BUGBUG -- code does not actually check return code (no error handling!) byte descr_length; byte descr_type; uint16_t total_length; From 5cbfd74f4d91e286a432c5e3348863fd6c091c52 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 16 Jan 2020 23:51:00 -0800 Subject: [PATCH 12/22] TEST: Is `LITTLE_ENDIAN` already properly defined? --- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h | 6 ++---- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h | 6 ++---- 24 files changed, 48 insertions(+), 96 deletions(-) diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h index 89fe03db6..b13743632 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h @@ -218,10 +218,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h index c9d769004..550d00730 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h @@ -218,10 +218,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h index cd2768281..fc2c74cc8 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h @@ -218,10 +218,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h index f0da13ef3..be6964357 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h @@ -218,10 +218,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h index 4b3d8407e..7939c6ca5 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h @@ -222,10 +222,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h index fe4134f28..e97deded8 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h @@ -222,10 +222,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h index 837d1eac0..fc71a94ec 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h @@ -222,10 +222,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h index 79fcea154..d67f4ca82 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h @@ -222,10 +222,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h index 81dbb9d48..b877490e5 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h @@ -226,10 +226,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h index 9696f4766..8b4b7c1b1 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h @@ -226,10 +226,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h index 50f0daa95..1380abd3e 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h @@ -226,10 +226,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h index a8a34c543..eb9e9656f 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h @@ -226,10 +226,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h index 92c3c952f..e51c89b96 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h @@ -218,10 +218,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h index 7544772c3..6ab03ebe3 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h @@ -218,10 +218,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h index 985a53228..3848770f1 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h @@ -218,10 +218,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h index 1d668f82d..7474139d7 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h @@ -218,10 +218,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h index 37eef1c48..e45ffbecd 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h @@ -222,10 +222,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h index 74240e3ca..4ca7c22f8 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h @@ -222,10 +222,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h index 44cd3d6ff..abf6d9926 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h @@ -222,10 +222,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h index b7b0d2b59..ad7398ffe 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h @@ -222,10 +222,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h index ea4c601eb..ca376da5d 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h @@ -226,10 +226,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h index c510e92c4..50f4e42df 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h @@ -226,10 +226,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h index 8e07a4caf..9a45a1c6e 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h @@ -226,10 +226,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h index b32987a06..e2d095335 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h @@ -226,10 +226,8 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) - #error "Little Endian is already defined, but to different value than expected?!" -#else - #define LITTLE_ENDIAN 1 +#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) + #error "Little Endian is not already defined, or defined to a value other than 1?!" #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ From c68c0b19ae528c30364ac906d3db701e739e5dc4 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Fri, 17 Jan 2020 00:34:40 -0800 Subject: [PATCH 13/22] Disable `-Wimplicit-fallthrough` in sections These two files contain code with switch statements, where one case "fall through" to the next case. As it's not currently clear if this is intentional or not, rather than modifying the code in any way (regression risk), use GCC diagnostic pragmas to disable this warning for only these two files, with BUGBUG marking to encourage review by someone more familiar with this code. --- libraries/USBHost/src/hidescriptorparser.cpp | 20 ++++++++++++++++++++ libraries/USBHost/src/parsetools.cpp | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/libraries/USBHost/src/hidescriptorparser.cpp b/libraries/USBHost/src/hidescriptorparser.cpp index 353874300..e462b87b7 100644 --- a/libraries/USBHost/src/hidescriptorparser.cpp +++ b/libraries/USBHost/src/hidescriptorparser.cpp @@ -1088,6 +1088,15 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) { } // switch (**pp & (TYPE_MASK | TAG_MASK)) } +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) { //uint8_t ret = enErrorSuccess; //reinterpret_cast<>(varBuffer); @@ -1210,6 +1219,7 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) { itemParseState = 0; return enErrorSuccess; } +#pragma GCC diagnostic pop ReportDescParserBase::UsagePageFunc ReportDescParserBase::usagePageFunctions[] /*PROGMEM*/ = { &ReportDescParserBase::PrintGenericDesktopPageUsage, @@ -1437,6 +1447,15 @@ void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) { else E_Notify(pstrUsagePageUndefined, 0x80); } +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) { //uint8_t ret = enErrorSuccess; @@ -1522,6 +1541,7 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) { itemParseState = 0; return enErrorSuccess; } +#pragma GCC diagnostic pop void ReportDescParser2::OnInputItem(uint8_t itm) { uint8_t byte_offset = (totalSize >> 3); // calculate offset to the next unhandled byte i = (int)(totalCount / 8); diff --git a/libraries/USBHost/src/parsetools.cpp b/libraries/USBHost/src/parsetools.cpp index 00ca9e642..c1e164152 100644 --- a/libraries/USBHost/src/parsetools.cpp +++ b/libraries/USBHost/src/parsetools.cpp @@ -31,6 +31,15 @@ bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) { return true; } +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { switch(nStage) { case 0: @@ -65,3 +74,4 @@ bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, } return true; } +#pragma GCC diagnostic pop From 12c45064377642fd49a7c1c8de6d16d99947e3d0 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Fri, 17 Jan 2020 00:37:57 -0800 Subject: [PATCH 14/22] Improve variant compliance Starting in SAMD CORE 1.6.6, `digitalPinToInterrupt` was moved to Arduino.h, variant.h must no longer define it. --- variants/circuitplay/variant.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/variants/circuitplay/variant.h b/variants/circuitplay/variant.h index bb4f16d50..43c4eb2fe 100644 --- a/variants/circuitplay/variant.h +++ b/variants/circuitplay/variant.h @@ -51,7 +51,10 @@ #define portInputRegister(port) (&(port->IN.reg)) #define portModeRegister(port) (&(port->DIR.reg)) #define digitalPinHasPWM(P) (g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER) -#define digitalPinToInterrupt(P) (g_APinDescription[P].ulExtInt) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE < 10606) + #define digitalPinToInterrupt(P) (g_APinDescription[P].ulExtInt) +#endif /* * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD From 00dd2e0097718b8f48f009f1363f3ea26b9b2e1f Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 3 Aug 2020 17:04:46 -0700 Subject: [PATCH 15/22] Per @hathach request --- cores/arduino/WInterrupts.c | 3 ++- libraries/Servo/src/samd/Servo.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index 53fcbffc3..85b744673 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -250,8 +250,9 @@ void detachInterrupt(uint32_t pin) * External Interrupt Controller NVIC Interrupt Handler */ #if defined(__SAMD51__) -void InterruptHandler(__attribute__((unused)) uint32_t i) +void InterruptHandler(uint32_t unused_i) { + (void)unused_i; // Calling the routine directly from -here- takes about 1us // Depending on where you are in the list it will take longer diff --git a/libraries/Servo/src/samd/Servo.cpp b/libraries/Servo/src/samd/Servo.cpp index e2474265c..39b96b544 100644 --- a/libraries/Servo/src/samd/Servo.cpp +++ b/libraries/Servo/src/samd/Servo.cpp @@ -172,8 +172,9 @@ static inline void resetTC (Tc* TCx) while (TCx->COUNT16.CTRLA.bit.SWRST); } -static void _initISR(Tc *tc, uint8_t channel, __attribute__((unused)) uint32_t id, IRQn_Type irqn, uint8_t gcmForTimer, uint8_t intEnableBit) +static void _initISR(Tc *tc, uint8_t channel, uint32_t id, IRQn_Type irqn, uint8_t gcmForTimer, uint8_t intEnableBit) { + (void)id; // Select GCLK0 as timer/counter input clock source #if defined(__SAMD51__) int idx = gcmForTimer; // see datasheet Table 14-9 From a2801a1602c399a5ee784ac5ec397adc091718e5 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 3 Aug 2020 20:43:13 -0700 Subject: [PATCH 16/22] fix tab/space mixtures -- whitespace only change --- libraries/USBHost/src/confdescparser.h | 132 ++++++++++--------- libraries/USBHost/src/hidescriptorparser.cpp | 28 ++-- libraries/USBHost/src/parsetools.cpp | 47 ++++--- libraries/USBHost/src/parsetools.h | 35 +++-- 4 files changed, 120 insertions(+), 122 deletions(-) diff --git a/libraries/USBHost/src/confdescparser.h b/libraries/USBHost/src/confdescparser.h index 6861160e9..a8739ea87 100644 --- a/libraries/USBHost/src/confdescparser.h +++ b/libraries/USBHost/src/confdescparser.h @@ -19,6 +19,8 @@ e-mail : support@circuitsathome.com #error "Never include confdescparser.h directly; include Usb.h instead" #else + + #pragma GCC diagnostic push // Available since GCC 4.6.4 /* * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages @@ -70,15 +72,15 @@ class ConfigDescParser : public USBReadParser { uint32_t ifaceNumber; // Interface number uint32_t ifaceAltSet; // Interface alternate settings - bool UseOr; + bool UseOr; bool ParseDescriptor(uint8_t **pp, uint32_t *pcntdn); void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc); public: - void SetOR(void) { - UseOr = true; - } + void SetOR(void) { + UseOr = true; + } ConfigDescParser(UsbConfigXtracter *xtractor); virtual void Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t &offset); }; @@ -109,8 +111,8 @@ void ConfigDescParser::Parse(const uin compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */ template bool ConfigDescParser::ParseDescriptor(uint8_t **pp, uint32_t *pcntdn) { - USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); - USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); + USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); + USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); switch(stateParseDescr) { case 0: theBuffer.valueSize = 2; @@ -123,7 +125,7 @@ bool ConfigDescParser::ParseDescriptor dscrType = *((uint8_t*)theBuffer.pValue + 1); stateParseDescr = 2; case 2: - // This is a sort of hack. Assuming that two bytes are all ready in the buffer + // This is a sort of hack. Assuming that two bytes are all ready in the buffer // the pointer is positioned two bytes ahead in order for the rest of descriptor // to be read right after the size and the type fields. // This should be used carefully. varBuffer should be used directly to handle data @@ -131,14 +133,14 @@ bool ConfigDescParser::ParseDescriptor theBuffer.pValue = varBuffer + 2; stateParseDescr = 3; case 3: - switch(dscrType) { - case USB_DESCRIPTOR_INTERFACE: - isGoodInterface = false; - case USB_DESCRIPTOR_CONFIGURATION: - theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2; - break; - case USB_DESCRIPTOR_ENDPOINT: - theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2; + switch(dscrType) { + case USB_DESCRIPTOR_INTERFACE: + isGoodInterface = false; + case USB_DESCRIPTOR_CONFIGURATION: + theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2; + break; + case USB_DESCRIPTOR_ENDPOINT: + theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2; break; case HID_DESCRIPTOR_HID: theBuffer.valueSize = dscrLen - 2; @@ -147,37 +149,37 @@ bool ConfigDescParser::ParseDescriptor valParser.Initialize(&theBuffer); stateParseDescr = 4; case 4: - switch(dscrType) { + switch(dscrType) { case USB_DESCRIPTOR_CONFIGURATION: - if(!valParser.Parse(pp, pcntdn)) - return false; - confValue = ucd->bConfigurationValue; + if(!valParser.Parse(pp, pcntdn)) + return false; + confValue = ucd->bConfigurationValue; break; case USB_DESCRIPTOR_INTERFACE: - if(!valParser.Parse(pp, pcntdn)) - return false; - if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID) - break; - if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID) - break; - if(UseOr) { - if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol))) - break; - } else { - if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID) - break; - } - isGoodInterface = true; - ifaceNumber = uid->bInterfaceNumber; - ifaceAltSet = uid->bAlternateSetting; - protoValue = uid->bInterfaceProtocol; - break; - case USB_DESCRIPTOR_ENDPOINT: - if(!valParser.Parse(pp, pcntdn)) - return false; - if(isGoodInterface) - if(theXtractor) - theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer); + if(!valParser.Parse(pp, pcntdn)) + return false; + if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID) + break; + if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID) + break; + if(UseOr) { + if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol))) + break; + } else { + if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID) + break; + } + isGoodInterface = true; + ifaceNumber = uid->bInterfaceNumber; + ifaceAltSet = uid->bAlternateSetting; + protoValue = uid->bInterfaceProtocol; + break; + case USB_DESCRIPTOR_ENDPOINT: + if(!valParser.Parse(pp, pcntdn)) + return false; + if(isGoodInterface) + if(theXtractor) + theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer); break; //case HID_DESCRIPTOR_HID: // if (!valParser.Parse(pp, pcntdn)) @@ -196,38 +198,38 @@ bool ConfigDescParser::ParseDescriptor template void ConfigDescParser::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) { - Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); - Notify(PSTR("bDescLength:\t\t"), 0x80); - PrintHex (pDesc->bLength, 0x80); + Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); + Notify(PSTR("bDescLength:\t\t"), 0x80); + PrintHex (pDesc->bLength, 0x80); - Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); - PrintHex (pDesc->bDescriptorType, 0x80); + Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); + PrintHex (pDesc->bDescriptorType, 0x80); - Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); - PrintHex (pDesc->bcdHID, 0x80); + Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); + PrintHex (pDesc->bcdHID, 0x80); - Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); - PrintHex (pDesc->bCountryCode, 0x80); + Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); + PrintHex (pDesc->bCountryCode, 0x80); - Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); - PrintHex (pDesc->bNumDescriptors, 0x80); + Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); + PrintHex (pDesc->bNumDescriptors, 0x80); - //Notify(PSTR("\r\nbDescrType:\t\t")); - //PrintHex(pDesc->bDescrType); - // - //Notify(PSTR("\r\nwDescriptorLength:\t")); - //PrintHex(pDesc->wDescriptorLength); + //Notify(PSTR("\r\nbDescrType:\t\t")); + //PrintHex(pDesc->bDescrType); + // + //Notify(PSTR("\r\nwDescriptorLength:\t")); + //PrintHex(pDesc->wDescriptorLength); for (uint32_t i = 0; i < pDesc->bNumDescriptors; i++) { HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType); - Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); - PrintHex (pLT[i].bDescrType, 0x80); + Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); + PrintHex (pLT[i].bDescrType, 0x80); - Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); - PrintHex (pLT[i].wDescriptorLength, 0x80); - } - Notify(PSTR("\r\n"), 0x80); + Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); + PrintHex (pLT[i].wDescriptorLength, 0x80); + } + Notify(PSTR("\r\n"), 0x80); } diff --git a/libraries/USBHost/src/hidescriptorparser.cpp b/libraries/USBHost/src/hidescriptorparser.cpp index e462b87b7..851a5c780 100644 --- a/libraries/USBHost/src/hidescriptorparser.cpp +++ b/libraries/USBHost/src/hidescriptorparser.cpp @@ -994,7 +994,6 @@ void ReportDescParserBase::Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t cntdn = (uint32_t)len; uint8_t *p = (uint8_t*)pbuf; - totalSize = 0; while(cntdn) { @@ -1246,18 +1245,18 @@ void ReportDescParserBase::SetUsagePage(uint16_t page) { if(VALUE_BETWEEN(page, 0x00, 0x11)) pfUsage = (usagePageFunctions[page - 1]); - // Dead code... - // - // pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]); - //else if (page > 0x7f && page < 0x84) - // E_Notify(pstrUsagePageMonitor); - //else if (page > 0x83 && page < 0x8c) - // E_Notify(pstrUsagePagePower); - //else if (page > 0x8b && page < 0x92) - // E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c])); - //else if (page > 0xfeff && page <= 0xffff) - // E_Notify(pstrUsagePageVendorDefined); - // + // Dead code... + // + // pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]); + //else if (page > 0x7f && page < 0x84) + // E_Notify(pstrUsagePageMonitor); + //else if (page > 0x83 && page < 0x8c) + // E_Notify(pstrUsagePagePower); + //else if (page > 0x8b && page < 0x92) + // E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c])); + //else if (page > 0xfeff && page <= 0xffff) + // E_Notify(pstrUsagePageVendorDefined); + // else switch(page) { case 0x14: @@ -1578,8 +1577,7 @@ void ReportDescParser2::OnInputItem(uint8_t itm) { // bits_to_copy - number of bits to copy to result buffer // for each bit in a field - for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left; - bits_left -= bits_to_copy) { + for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left; bits_left -= bits_to_copy) { bits_to_copy = (bits_left > bits_of_byte) ? bits_of_byte : bits_left; result.dwResult <<= bits_to_copy; // Result buffer is shifted by the number of bits to be copied into it diff --git a/libraries/USBHost/src/parsetools.cpp b/libraries/USBHost/src/parsetools.cpp index c1e164152..2c018ec06 100644 --- a/libraries/USBHost/src/parsetools.cpp +++ b/libraries/USBHost/src/parsetools.cpp @@ -17,14 +17,14 @@ e-mail : support@circuitsathome.com #include "Usb.h" bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) { - if(!pBuf) { - Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); + if(!pBuf) { + Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); return false; } for (; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++) pBuf[valueSize - countDown] = (**pp); - if(countDown) + if(countDown) return false; countDown = valueSize; @@ -41,35 +41,34 @@ bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) { */ #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { - switch(nStage) { - case 0: - pBuf->valueSize = lenSize; - theParser.Initialize(pBuf); - nStage = 1; + switch(nStage) { + case 0: + pBuf->valueSize = lenSize; + theParser.Initialize(pBuf); + nStage = 1; - case 1: - if(!theParser.Parse(pp, pcntdn)) - return false; + case 1: + if(!theParser.Parse(pp, pcntdn)) + return false; - arLen = 0; - arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); - arLenCntdn = arLen; - nStage = 2; + arLen = 0; + arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); + arLenCntdn = arLen; + nStage = 2; - case 2: - pBuf->valueSize = valSize; - theParser.Initialize(pBuf); - nStage = 3; + case 2: + pBuf->valueSize = valSize; + theParser.Initialize(pBuf); + nStage = 3; - case 3: - for(; arLenCntdn; arLenCntdn--) { - if(!theParser.Parse(pp, pcntdn)) - return false; + case 3: + for(; arLenCntdn; arLenCntdn--) { + if(!theParser.Parse(pp, pcntdn)) + return false; if(pf) pf(pBuf, (arLen - arLenCntdn), me); } - nStage = 0; } return true; diff --git a/libraries/USBHost/src/parsetools.h b/libraries/USBHost/src/parsetools.h index 41a8bc974..a505255a1 100644 --- a/libraries/USBHost/src/parsetools.h +++ b/libraries/USBHost/src/parsetools.h @@ -48,12 +48,12 @@ class MultiByteValueParser { public: - MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) { - }; + MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) { + }; - const uint8_t* GetBuffer() { - return pBuf; - }; + const uint8_t* GetBuffer() { + return pBuf; + }; void Initialize(MultiValueBuffer * const pbuf) { pBuf = (uint8_t*)pbuf->pValue; @@ -71,7 +71,7 @@ class ByteSkipper { public: ByteSkipper() : pBuf(NULL), nStage(0), countDown(0) { - }; + }; void Initialize(MultiValueBuffer *pbuf) { pBuf = (uint8_t*)pbuf->pValue; @@ -79,15 +79,14 @@ class ByteSkipper { }; bool Skip(uint8_t **pp, uint32_t *pcntdn, uint32_t bytes_to_skip) { - switch(nStage) { - case 0: - countDown = bytes_to_skip; - nStage++; - case 1: - for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--); - - if(!countDown) - nStage = 0; + switch(nStage) { + case 0: + countDown = bytes_to_skip; + nStage++; + case 1: + for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--); + if(!countDown) + nStage = 0; }; return (!countDown); }; @@ -99,9 +98,9 @@ typedef void (*PTP_ARRAY_EL_FUNC)(const MultiValueBuffer * const p, uint32_t cou class PTPListParser { public: - enum ParseMode { - modeArray, modeRange/*, modeEnum*/ - }; + enum ParseMode { + modeArray, modeRange/*, modeEnum*/ + }; private: uint32_t nStage; From eb3c11472c482a555ee84f874960c324c03afb0b Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Tue, 4 Aug 2020 21:08:58 -0700 Subject: [PATCH 17/22] Revert "TEST: Is `LITTLE_ENDIAN` already properly defined?" This reverts commit 5cbfd74f4d91e286a432c5e3348863fd6c091c52. --- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h | 6 ++++-- .../src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h | 6 ++++-- 24 files changed, 96 insertions(+), 48 deletions(-) diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h index b13743632..89fe03db6 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h @@ -218,8 +218,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h index 550d00730..c9d769004 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h @@ -218,8 +218,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h index fc2c74cc8..cd2768281 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h @@ -218,8 +218,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h index be6964357..f0da13ef3 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h @@ -218,8 +218,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h index 7939c6ca5..4b3d8407e 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h @@ -222,8 +222,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h index e97deded8..fe4134f28 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h @@ -222,8 +222,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h index fc71a94ec..837d1eac0 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h @@ -222,8 +222,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h index d67f4ca82..79fcea154 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h @@ -222,8 +222,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h index b877490e5..81dbb9d48 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h @@ -226,8 +226,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h index 8b4b7c1b1..9696f4766 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h @@ -226,8 +226,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h index 1380abd3e..50f0daa95 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h @@ -226,8 +226,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h index eb9e9656f..a8a34c543 100644 --- a/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h +++ b/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h @@ -226,8 +226,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h index e51c89b96..92c3c952f 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e15a.h @@ -218,8 +218,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h index 6ab03ebe3..7544772c3 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e16a.h @@ -218,8 +218,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h index 3848770f1..985a53228 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e17a.h @@ -218,8 +218,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h index 7474139d7..1d668f82d 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21e18a.h @@ -218,8 +218,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h index e45ffbecd..37eef1c48 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g15a.h @@ -222,8 +222,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h index 4ca7c22f8..74240e3ca 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g16a.h @@ -222,8 +222,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h index abf6d9926..44cd3d6ff 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g17a.h @@ -222,8 +222,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h index ad7398ffe..b7b0d2b59 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21g18a.h @@ -222,8 +222,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h index ca376da5d..ea4c601eb 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j15a.h @@ -226,8 +226,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h index 50f4e42df..c510e92c4 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j16a.h @@ -226,8 +226,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h index 9a45a1c6e..8e07a4caf 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j17a.h @@ -226,8 +226,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ diff --git a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h index e2d095335..b32987a06 100755 --- a/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h +++ b/bootloaders/sofia/Bootloader_D21_Sofia_V2.1/src/ASF/sam0/utils/cmsis/samd21/include/samd21j18a.h @@ -226,8 +226,10 @@ void I2S_Handler ( void ); * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals */ -#if !defined(LITTLE_ENDIAN) || (LITTLE_ENDIAN != 1) - #error "Little Endian is not already defined, or defined to a value other than 1?!" +#if defined(LITTLE_ENDIAN) && (LITTLE_ENDIAN != 1) + #error "Little Endian is already defined, but to different value than expected?!" +#else + #define LITTLE_ENDIAN 1 #endif #define __CM0PLUS_REV 1 /*!< Core revision r0p1 */ #define __MPU_PRESENT 0 /*!< MPU present or not */ From adc0866b7dd17f46d3fe3e9b0931ae35519176b1 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Wed, 5 Aug 2020 01:54:03 -0700 Subject: [PATCH 18/22] Hathach doesn't like attributes on parameters --- libraries/Servo/src/samd/Servo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Servo/src/samd/Servo.cpp b/libraries/Servo/src/samd/Servo.cpp index 39b96b544..9f06e9ec5 100644 --- a/libraries/Servo/src/samd/Servo.cpp +++ b/libraries/Servo/src/samd/Servo.cpp @@ -264,8 +264,9 @@ static void initISR(timer16_Sequence_t timer) #endif } -static void finISR(__attribute__((unused)) timer16_Sequence_t timer) +static void finISR(timer16_Sequence_t timer) { + (void)timer; #if defined (_useTimer1) // Disable the match channel interrupt request TC_FOR_TIMER1->COUNT16.INTENCLR.reg = INTENCLR_BIT_FOR_TIMER_1; From 528a25e0ab24fbef6604a8a65fb8d0f5f94e5f95 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Wed, 5 Aug 2020 21:27:36 -0700 Subject: [PATCH 19/22] @hathach is uncomfortable with attributes on function parameters --- cores/arduino/SERCOM.h | 2 +- libraries/USBHost/examples/USB_desc/USB_desc.ino | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cores/arduino/SERCOM.h b/cores/arduino/SERCOM.h index b60c245f9..3cd0a7f3a 100644 --- a/cores/arduino/SERCOM.h +++ b/cores/arduino/SERCOM.h @@ -248,7 +248,7 @@ class SERCOM uint32_t getFreqRef(void) { return freqRef; }; #else // The equivalent SAMD21 dummy functions... - void setClockSource(__attribute__((unused)) int8_t idx, __attribute__((unused)) SercomClockSource src, __attribute__((unused)) bool core) { }; + void setClockSource(int8_t idx, SercomClockSource src, bool core) { (void)idx; (void)src; (void)core }; SercomClockSource getClockSource(void) { return SERCOM_CLOCK_SOURCE_FCPU; }; uint32_t getFreqRef(void) { return F_CPU; }; #endif diff --git a/libraries/USBHost/examples/USB_desc/USB_desc.ino b/libraries/USBHost/examples/USB_desc/USB_desc.ino index 30479c411..9f2f54964 100644 --- a/libraries/USBHost/examples/USB_desc/USB_desc.ino +++ b/libraries/USBHost/examples/USB_desc/USB_desc.ino @@ -159,8 +159,9 @@ byte getdevdescr( byte addr, byte &num_conf ) return( 0 ); } -void printhubdescr(uint8_t *descrptr, __attribute__((unused)) uint8_t addr) +void printhubdescr(uint8_t *descrptr, uint8_t addr) { + (void)addr; HubDescriptor *pHub = (HubDescriptor*) descrptr; uint8_t len = *((uint8_t*)descrptr); From 134ebe7e18b337ada134714d95e53d42dfa24fe7 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 6 Aug 2020 16:11:10 -0700 Subject: [PATCH 20/22] typo - missing semicolon --- cores/arduino/SERCOM.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/SERCOM.h b/cores/arduino/SERCOM.h index 3cd0a7f3a..c717e78b6 100644 --- a/cores/arduino/SERCOM.h +++ b/cores/arduino/SERCOM.h @@ -248,7 +248,7 @@ class SERCOM uint32_t getFreqRef(void) { return freqRef; }; #else // The equivalent SAMD21 dummy functions... - void setClockSource(int8_t idx, SercomClockSource src, bool core) { (void)idx; (void)src; (void)core }; + void setClockSource(int8_t idx, SercomClockSource src, bool core) { (void)idx; (void)src; (void)core; }; SercomClockSource getClockSource(void) { return SERCOM_CLOCK_SOURCE_FCPU; }; uint32_t getFreqRef(void) { return F_CPU; }; #endif From 55a9930808c74087ede6080d9e0f66c3260e3119 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Fri, 7 Aug 2020 11:28:53 -0700 Subject: [PATCH 21/22] reduce affected area of diagnostic push/pop --- libraries/USBHost/src/confdescparser.h | 27 ++++++++++---------- libraries/USBHost/src/hidescriptorparser.cpp | 19 ++++++++------ libraries/USBHost/src/parsetools.cpp | 7 +++-- libraries/USBHost/src/parsetools.h | 26 ++++++++----------- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/libraries/USBHost/src/confdescparser.h b/libraries/USBHost/src/confdescparser.h index a8739ea87..ad2807aaa 100644 --- a/libraries/USBHost/src/confdescparser.h +++ b/libraries/USBHost/src/confdescparser.h @@ -19,19 +19,6 @@ e-mail : support@circuitsathome.com #error "Never include confdescparser.h directly; include Usb.h instead" #else - - -#pragma GCC diagnostic push // Available since GCC 4.6.4 -/* - * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages - * This code has multiple switch statements that "fall through" to the - * next case -- but it's not always clear if this is intentional or not. - * Review and commenting of code, and reducing cyclomatic complexity - * are highly recommended.... - */ -#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" - - #define __CONFDESCPARSER_H__ #include @@ -113,6 +100,17 @@ template ::ParseDescriptor(uint8_t **pp, uint32_t *pcntdn) { USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); + + +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" switch(stateParseDescr) { case 0: theBuffer.valueSize = 2; @@ -193,6 +191,8 @@ bool ConfigDescParser::ParseDescriptor theBuffer.pValue = varBuffer; stateParseDescr = 0; } +#pragma GCC diagnostic pop + return true; } @@ -233,6 +233,5 @@ void ConfigDescParser::PrintHidDescrip } -#pragma GCC diagnostic pop #endif // __CONFDESCPARSER_H__ diff --git a/libraries/USBHost/src/hidescriptorparser.cpp b/libraries/USBHost/src/hidescriptorparser.cpp index 851a5c780..389674e2f 100644 --- a/libraries/USBHost/src/hidescriptorparser.cpp +++ b/libraries/USBHost/src/hidescriptorparser.cpp @@ -1087,6 +1087,11 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) { } // switch (**pp & (TYPE_MASK | TAG_MASK)) } +uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) { + //uint8_t ret = enErrorSuccess; + //reinterpret_cast<>(varBuffer); + + #pragma GCC diagnostic push // Available since GCC 4.6.4 /* * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages @@ -1096,9 +1101,6 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) { * are highly recommended.... */ #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" -uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) { - //uint8_t ret = enErrorSuccess; - //reinterpret_cast<>(varBuffer); switch(itemParseState) { case 0: if(**pp == HID_LONG_ITEM_PREFIX) @@ -1215,10 +1217,10 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) { } // switch (**pp & (TYPE_MASK | TAG_MASK)) } } // switch (itemParseState) +#pragma GCC diagnostic pop itemParseState = 0; return enErrorSuccess; } -#pragma GCC diagnostic pop ReportDescParserBase::UsagePageFunc ReportDescParserBase::usagePageFunctions[] /*PROGMEM*/ = { &ReportDescParserBase::PrintGenericDesktopPageUsage, @@ -1446,6 +1448,9 @@ void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) { else E_Notify(pstrUsagePageUndefined, 0x80); } +uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) { + //uint8_t ret = enErrorSuccess; + #pragma GCC diagnostic push // Available since GCC 4.6.4 /* * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages @@ -1455,9 +1460,6 @@ void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) { * are highly recommended.... */ #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" -uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) { - //uint8_t ret = enErrorSuccess; - switch(itemParseState) { case 0: if(**pp == HID_LONG_ITEM_PREFIX) @@ -1537,10 +1539,11 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) { } // switch (**pp & (TYPE_MASK | TAG_MASK)) } } // switch (itemParseState) +#pragma GCC diagnostic pop + itemParseState = 0; return enErrorSuccess; } -#pragma GCC diagnostic pop void ReportDescParser2::OnInputItem(uint8_t itm) { uint8_t byte_offset = (totalSize >> 3); // calculate offset to the next unhandled byte i = (int)(totalCount / 8); diff --git a/libraries/USBHost/src/parsetools.cpp b/libraries/USBHost/src/parsetools.cpp index 2c018ec06..de8170578 100644 --- a/libraries/USBHost/src/parsetools.cpp +++ b/libraries/USBHost/src/parsetools.cpp @@ -31,6 +31,8 @@ bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) { return true; } +bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { + #pragma GCC diagnostic push // Available since GCC 4.6.4 /* * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages @@ -40,7 +42,7 @@ bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) { * are highly recommended.... */ #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" -bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { + switch(nStage) { case 0: pBuf->valueSize = lenSize; @@ -71,6 +73,7 @@ bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, } nStage = 0; } +#pragma GCC diagnostic pop + return true; } -#pragma GCC diagnostic pop diff --git a/libraries/USBHost/src/parsetools.h b/libraries/USBHost/src/parsetools.h index a505255a1..82196a2ac 100644 --- a/libraries/USBHost/src/parsetools.h +++ b/libraries/USBHost/src/parsetools.h @@ -23,19 +23,6 @@ e-mail : support@circuitsathome.com #include //#include "Arduino.h" -#pragma GCC diagnostic push // Available since GCC 4.6.4 -/* - * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages - * This code has multiple switch statements that "fall through" to the - * next case -- but it's not always clear if this is intentional or not. - * Review and commenting of code, and reducing cyclomatic complexity - * are highly recommended.... - */ -#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" - - - - struct MultiValueBuffer { uint8_t valueSize; void *pValue; @@ -79,6 +66,15 @@ class ByteSkipper { }; bool Skip(uint8_t **pp, uint32_t *pcntdn, uint32_t bytes_to_skip) { +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" switch(nStage) { case 0: countDown = bytes_to_skip; @@ -88,6 +84,7 @@ class ByteSkipper { if(!countDown) nStage = 0; }; +#pragma GCC diagnostic pop return (!countDown); }; }; @@ -152,7 +149,4 @@ class PTPListParser { bool Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me = NULL); }; - -#pragma GCC diagnostic pop - #endif // __PARSETOOLS_H__ From 66b0a740730676eabfae9bfa402b6900e70d00fc Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Sun, 9 Aug 2020 23:50:13 -0700 Subject: [PATCH 22/22] Use FIXME instead of BUGBUG --- libraries/USBHost/examples/USB_desc/USB_desc.ino | 6 +++--- libraries/USBHost/src/confdescparser.h | 2 +- libraries/USBHost/src/hidescriptorparser.cpp | 4 ++-- libraries/USBHost/src/parsetools.cpp | 2 +- libraries/USBHost/src/parsetools.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/USBHost/examples/USB_desc/USB_desc.ino b/libraries/USBHost/examples/USB_desc/USB_desc.ino index 9f2f54964..20838ccbe 100644 --- a/libraries/USBHost/examples/USB_desc/USB_desc.ino +++ b/libraries/USBHost/examples/USB_desc/USB_desc.ino @@ -210,11 +210,11 @@ byte getconfdescr( byte addr, byte conf ) { uint8_t buf[ BUFSIZE ]; uint8_t* buf_ptr = buf; - byte rcode; // BUGBUG -- code does not actually check return code (no error handling!) + byte rcode; // FIXME -- code does not actually check return code (no error handling!) byte descr_length; byte descr_type; uint16_t total_length; - // BUGBUG -- no check of return code from usb.getConfDescr() + // FIXME -- no check of return code from usb.getConfDescr() rcode = usb.getConfDescr( addr, 0, 4, conf, buf ); //get total length LOBYTE( total_length ) = buf[ 2 ]; HIBYTE( total_length ) = buf[ 3 ]; @@ -222,7 +222,7 @@ byte getconfdescr( byte addr, byte conf ) printProgStr(Conf_Trunc_str); total_length = sizeof(buf); } - // BUGBUG -- no check of return code from usb.getConfDescr() + // FIXME -- no check of return code from usb.getConfDescr() rcode = usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor while( buf_ptr < buf + total_length ) { //parsing descriptors descr_length = *( buf_ptr ); diff --git a/libraries/USBHost/src/confdescparser.h b/libraries/USBHost/src/confdescparser.h index ad2807aaa..de69e2ccd 100644 --- a/libraries/USBHost/src/confdescparser.h +++ b/libraries/USBHost/src/confdescparser.h @@ -104,7 +104,7 @@ bool ConfigDescParser::ParseDescriptor #pragma GCC diagnostic push // Available since GCC 4.6.4 /* - * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages * This code has multiple switch statements that "fall through" to the * next case -- but it's not always clear if this is intentional or not. * Review and commenting of code, and reducing cyclomatic complexity diff --git a/libraries/USBHost/src/hidescriptorparser.cpp b/libraries/USBHost/src/hidescriptorparser.cpp index 389674e2f..b137cb8ab 100644 --- a/libraries/USBHost/src/hidescriptorparser.cpp +++ b/libraries/USBHost/src/hidescriptorparser.cpp @@ -1094,7 +1094,7 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) { #pragma GCC diagnostic push // Available since GCC 4.6.4 /* - * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages * This code has multiple switch statements that "fall through" to the * next case -- but it's not always clear if this is intentional or not. * Review and commenting of code, and reducing cyclomatic complexity @@ -1453,7 +1453,7 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) { #pragma GCC diagnostic push // Available since GCC 4.6.4 /* - * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages * This code has multiple switch statements that "fall through" to the * next case -- but it's not always clear if this is intentional or not. * Review and commenting of code, and reducing cyclomatic complexity diff --git a/libraries/USBHost/src/parsetools.cpp b/libraries/USBHost/src/parsetools.cpp index de8170578..9867cbc46 100644 --- a/libraries/USBHost/src/parsetools.cpp +++ b/libraries/USBHost/src/parsetools.cpp @@ -35,7 +35,7 @@ bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, #pragma GCC diagnostic push // Available since GCC 4.6.4 /* - * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages * This code has multiple switch statements that "fall through" to the * next case -- but it's not always clear if this is intentional or not. * Review and commenting of code, and reducing cyclomatic complexity diff --git a/libraries/USBHost/src/parsetools.h b/libraries/USBHost/src/parsetools.h index 82196a2ac..947ba02dc 100644 --- a/libraries/USBHost/src/parsetools.h +++ b/libraries/USBHost/src/parsetools.h @@ -68,7 +68,7 @@ class ByteSkipper { bool Skip(uint8_t **pp, uint32_t *pcntdn, uint32_t bytes_to_skip) { #pragma GCC diagnostic push // Available since GCC 4.6.4 /* - * BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages * This code has multiple switch statements that "fall through" to the * next case -- but it's not always clear if this is intentional or not. * Review and commenting of code, and reducing cyclomatic complexity