summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraham sanderson <[email protected]>2022-06-27 22:39:10 +0100
committergraham sanderson <[email protected]>2022-06-27 22:43:41 +0100
commit4057c2d8d96a364329d14d3a4b2c237f388cfdc2 (patch)
treee95dadbcb70b02ff461738395b80cfa32a3c5b8f
parent2f7f3e604eb2641dd87a524ab282939bda6b3348 (diff)
rework suppress_tinyusb_warnings
* gcc 9.2.1 has some spurious -Wconversion warnings * cmake 3.18 and above require set_target_properties to be added from the target directory (so added it to all examples) * fixed a few warnings in a couple of examples
-rw-r--r--examples/device/cdc_dual_ports/src/main.c4
-rw-r--r--examples/device/hid_composite/src/main.c2
-rw-r--r--hw/bsp/rp2040/family.cmake46
3 files changed, 32 insertions, 20 deletions
diff --git a/examples/device/cdc_dual_ports/src/main.c b/examples/device/cdc_dual_ports/src/main.c
index 6053a3b81..d4d07dcd6 100644
--- a/examples/device/cdc_dual_ports/src/main.c
+++ b/examples/device/cdc_dual_ports/src/main.c
@@ -60,12 +60,12 @@ static void echo_serial_port(uint8_t itf, uint8_t buf[], uint32_t count)
if (itf == 0)
{
// echo back 1st port as lower case
- if (isupper(buf[i])) buf[i] += 'a' - 'A';
+ if (isupper(buf[i])) buf[i] = (uint8_t) (buf[i] + 'a' - 'A');
}
else
{
// echo back 2nd port as upper case
- if (islower(buf[i])) buf[i] -= 'a' - 'A';
+ if (islower(buf[i])) buf[i] = (uint8_t) (buf[i] - 'a' - 'A');
}
tud_cdc_n_write_char(itf, buf[i]);
diff --git a/examples/device/hid_composite/src/main.c b/examples/device/hid_composite/src/main.c
index bc2347ab8..cc3566ac1 100644
--- a/examples/device/hid_composite/src/main.c
+++ b/examples/device/hid_composite/src/main.c
@@ -230,7 +230,7 @@ void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t
(void) instance;
(void) len;
- uint8_t next_report_id = report[0] + 1;
+ uint8_t next_report_id = (uint8_t)(report[0] + 1);
if (next_report_id < REPORT_ID_COUNT)
{
diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake
index ed7041e4e..794d02325 100644
--- a/hw/bsp/rp2040/family.cmake
+++ b/hw/bsp/rp2040/family.cmake
@@ -150,11 +150,13 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
function(family_configure_device_example TARGET)
family_configure_target(${TARGET})
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_device)
+ suppress_tinyusb_warnings()
endfunction()
function(family_configure_host_example TARGET)
family_configure_target(${TARGET})
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_host)
+ suppress_tinyusb_warnings()
endfunction()
function(family_add_pico_pio_usb TARGET)
@@ -165,6 +167,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
family_configure_target(${TARGET})
# require tinyusb_pico_pio_usb
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_device tinyusb_host tinyusb_pico_pio_usb )
+ suppress_tinyusb_warnings()
endfunction()
function(check_and_add_pico_pio_usb_support)
@@ -232,25 +235,34 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
# This method must be called from the project scope to suppress known warnings in TinyUSB source files
function(suppress_tinyusb_warnings)
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/src/device/usbd.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion")
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/src/device/usbd_control.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion")
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
+ # some of these are pretty silly warnings only occurring in some older GCC versions
+ set(CONVERSION_WARNING_FILES
+ ${PICO_TINYUSB_PATH}/src/tusb.c
+ ${PICO_TINYUSB_PATH}/src/common/tusb_fifo.c
+ ${PICO_TINYUSB_PATH}/src/device/usbd.c
+ ${PICO_TINYUSB_PATH}/src/device/usbd_control.c
+ ${PICO_TINYUSB_PATH}/src/host/usbh.c
+ ${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
+ ${PICO_TINYUSB_PATH}/src/class/cdc/cdc_host.c
+ ${PICO_TINYUSB_PATH}/src/class/hid/hid_device.c
+ ${PICO_TINYUSB_PATH}/src/class/hid/hid_host.c
+ ${PICO_TINYUSB_PATH}/src/class/audio/audio_device.c
+ ${PICO_TINYUSB_PATH}/src/class/dfu/dfu_device.c
+ ${PICO_TINYUSB_PATH}/src/class/dfu/dfu_rt_device.c
+ ${PICO_TINYUSB_PATH}/src/class/midi/midi_device.c
+ ${PICO_TINYUSB_PATH}/src/class/usbtmc/usbtmc_device.c
+ ${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
+ )
+ foreach(SOURCE_FILE IN LISTS CONVERSION_WARNING_FILES)
+ set_source_files_properties(
+ ${SOURCE_FILE}
PROPERTIES
COMPILE_FLAGS "-Wno-conversion")
+ endforeach()
set_source_files_properties(
- ${PICO_TINYUSB_PATH}/src/common/tusb_fifo.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion")
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/src/tusb.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion")
+ ${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/rp2040_usb.c
+ PROPERTIES
+ COMPILE_FLAGS "-Wno-stringop-overflow -Wno-array-bounds"
+ )
endfunction()
endif()