Skip to content

Commit 898b52b

Browse files
committed
update rp2040 warnings
- remove "-Wno-stringop-overflow -Wno-array-bounds" - skip -Wconversion for gcc 9 and prior - suppress_tinyusb_warnings only when building with gcc 9 and below
1 parent 83602ea commit 898b52b

File tree

4 files changed

+37
-32
lines changed

4 files changed

+37
-32
lines changed

examples/device/cdc_dual_ports/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,19 @@ int main(void)
5555
// with Serial0 as all lower case, Serial1 as all upper case
5656
static void echo_serial_port(uint8_t itf, uint8_t buf[], uint32_t count)
5757
{
58+
uint8_t const case_diff = 'a' - 'A';
59+
5860
for(uint32_t i=0; i<count; i++)
5961
{
6062
if (itf == 0)
6163
{
6264
// echo back 1st port as lower case
63-
if (isupper(buf[i])) buf[i] = (uint8_t) (buf[i] + 'a' - 'A');
65+
if (isupper(buf[i])) buf[i] += case_diff;
6466
}
6567
else
6668
{
6769
// echo back 2nd port as upper case
68-
if (islower(buf[i])) buf[i] = (uint8_t) (buf[i] - 'a' - 'A');
70+
if (islower(buf[i])) buf[i] -= case_diff;
6971
}
7072

7173
tud_cdc_n_write_char(itf, buf[i]);

examples/device/hid_composite/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_
230230
(void) instance;
231231
(void) len;
232232

233-
uint8_t next_report_id = (uint8_t)(report[0] + 1);
233+
uint8_t next_report_id = report[0] + 1u;
234234

235235
if (next_report_id < REPORT_ID_COUNT)
236236
{

examples/example.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,11 @@ target_compile_options(${PROJECT} PUBLIC
2121
-Wuninitialized
2222
-Wunused
2323
-Wredundant-decls
24+
)
25+
26+
# GCC version 9 or prior has a bug with incorrect Wconversion warnings
27+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
28+
target_compile_options(${PROJECT} PUBLIC
2429
-Wconversion
2530
)
31+
endif()

hw/bsp/rp2040/family.cmake

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -235,34 +235,31 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
235235

236236
# This method must be called from the project scope to suppress known warnings in TinyUSB source files
237237
function(suppress_tinyusb_warnings)
238-
# some of these are pretty silly warnings only occurring in some older GCC versions
239-
set(CONVERSION_WARNING_FILES
240-
${PICO_TINYUSB_PATH}/src/tusb.c
241-
${PICO_TINYUSB_PATH}/src/common/tusb_fifo.c
242-
${PICO_TINYUSB_PATH}/src/device/usbd.c
243-
${PICO_TINYUSB_PATH}/src/device/usbd_control.c
244-
${PICO_TINYUSB_PATH}/src/host/usbh.c
245-
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
246-
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_host.c
247-
${PICO_TINYUSB_PATH}/src/class/hid/hid_device.c
248-
${PICO_TINYUSB_PATH}/src/class/hid/hid_host.c
249-
${PICO_TINYUSB_PATH}/src/class/audio/audio_device.c
250-
${PICO_TINYUSB_PATH}/src/class/dfu/dfu_device.c
251-
${PICO_TINYUSB_PATH}/src/class/dfu/dfu_rt_device.c
252-
${PICO_TINYUSB_PATH}/src/class/midi/midi_device.c
253-
${PICO_TINYUSB_PATH}/src/class/usbtmc/usbtmc_device.c
254-
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
255-
)
256-
foreach(SOURCE_FILE IN LISTS CONVERSION_WARNING_FILES)
257-
set_source_files_properties(
258-
${SOURCE_FILE}
259-
PROPERTIES
260-
COMPILE_FLAGS "-Wno-conversion")
261-
endforeach()
262-
set_source_files_properties(
263-
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/rp2040_usb.c
264-
PROPERTIES
265-
COMPILE_FLAGS "-Wno-stringop-overflow -Wno-array-bounds"
266-
)
238+
# some of these are pretty silly warnings only occurring in some older GCC versions 9 or prior
239+
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0)
240+
set(CONVERSION_WARNING_FILES
241+
${PICO_TINYUSB_PATH}/src/tusb.c
242+
${PICO_TINYUSB_PATH}/src/common/tusb_fifo.c
243+
${PICO_TINYUSB_PATH}/src/device/usbd.c
244+
${PICO_TINYUSB_PATH}/src/device/usbd_control.c
245+
${PICO_TINYUSB_PATH}/src/host/usbh.c
246+
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
247+
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_host.c
248+
${PICO_TINYUSB_PATH}/src/class/hid/hid_device.c
249+
${PICO_TINYUSB_PATH}/src/class/hid/hid_host.c
250+
${PICO_TINYUSB_PATH}/src/class/audio/audio_device.c
251+
${PICO_TINYUSB_PATH}/src/class/dfu/dfu_device.c
252+
${PICO_TINYUSB_PATH}/src/class/dfu/dfu_rt_device.c
253+
${PICO_TINYUSB_PATH}/src/class/midi/midi_device.c
254+
${PICO_TINYUSB_PATH}/src/class/usbtmc/usbtmc_device.c
255+
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
256+
)
257+
foreach(SOURCE_FILE IN LISTS CONVERSION_WARNING_FILES)
258+
set_source_files_properties(
259+
${SOURCE_FILE}
260+
PROPERTIES
261+
COMPILE_FLAGS "-Wno-conversion")
262+
endforeach()
263+
endif()
267264
endfunction()
268265
endif()

0 commit comments

Comments
 (0)