From 6e82983f86988956c40f5aa47d64e7f486c42068 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 7 Mar 2023 17:14:15 +0100 Subject: [PATCH] fix(serial): warning Warray-bounds when USB CDC enabled and generic Serial warning: array subscript 'HardwareSerial[0]' is partly outside array bounds of 'USBSerial [1]' [-Warray-bounds] Signed-off-by: Frederic Pillon --- cores/arduino/HardwareSerial.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 3aba60253d..a06a6275eb 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -132,6 +132,7 @@ HardwareSerial::HardwareSerial(void *peripheral, HalfDuplexMode_t halfDuplex) // If Serial is defined in variant set // the Rx/Tx pins for com port if defined #if defined(Serial) && defined(PIN_SERIAL_TX) +#if !defined(USBCON) || defined(USBD_USE_CDC) && defined(DISABLE_GENERIC_SERIALUSB) if ((void *)this == (void *)&Serial) { #if defined(PIN_SERIAL_RX) setRx(PIN_SERIAL_RX); @@ -139,6 +140,7 @@ HardwareSerial::HardwareSerial(void *peripheral, HalfDuplexMode_t halfDuplex) setTx(PIN_SERIAL_TX); } else #endif +#endif #if defined(PIN_SERIAL1_TX) && defined(USART1_BASE) if (peripheral == USART1) { #if defined(PIN_SERIAL1_RX)