Skip to content

Commit f5daff0

Browse files
committed
Suppress Teensy 4 USB stack GCC warnings
There were two warnings from the Teensy 4 core updates: /usr/local/share/arduino/hardware/teensy/avr/cores/teensy4/usb.c: In function 'endpoint0_complete': /usr/local/share/arduino/hardware/teensy/avr/cores/teensy4/usb.c:766:10: warning: variable 'setup' set but not used [-Wunused-but-set-variable] setup_t setup; ^ /usr/local/share/arduino/hardware/teensy/avr/cores/teensy4/usb.c: At top level: /usr/local/share/arduino/hardware/teensy/avr/cores/teensy4/usb.c:98:16: warning: 'endpoint0_buffer' defined but not used [-Wunused-variable] static uint8_t endpoint0_buffer[8]; Both of these are from not reading the endpoint 0 data in the `endpoint0_complete()` function. Reading and casting to `void` suppresses the warnings and should be optimized out by the compiler.
1 parent c9d74b7 commit f5daff0

File tree

1 file changed

+5
-0
lines changed
  • teensy/avr/cores/teensy4

1 file changed

+5
-0
lines changed

teensy/avr/cores/teensy4/usb.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,11 @@ static void endpoint0_complete(void)
822822
usb_audio_set_feature(&endpoint0_setupdata, endpoint0_buffer);
823823
}
824824
#endif
825+
#ifdef XINPUT_INTERFACE
826+
// dummy reads to suppress '-Wunused-but-set-variable' and '-Wunused-variable' warnings from GCC
827+
(void) setup.wIndex;
828+
(void) endpoint0_buffer;
829+
#endif
825830
}
826831

827832
static void usb_endpoint_config(endpoint_t *qh, uint32_t config, void (*callback)(transfer_t *))

0 commit comments

Comments
 (0)