Skip to content

Commit 3681ad2

Browse files
authored
Merge pull request hathach#1521 from kilograham/rp2040_warning
Re-add some warning suppression for rp2040
2 parents c7fce32 + 898b52b commit 3681ad2

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
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] += '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] -= '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 = 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: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,13 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
150150
function(family_configure_device_example TARGET)
151151
family_configure_target(${TARGET})
152152
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_device)
153+
suppress_tinyusb_warnings()
153154
endfunction()
154155

155156
function(family_configure_host_example TARGET)
156157
family_configure_target(${TARGET})
157158
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_host)
159+
suppress_tinyusb_warnings()
158160
endfunction()
159161

160162
function(family_add_pico_pio_usb TARGET)
@@ -165,6 +167,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
165167
family_configure_target(${TARGET})
166168
# require tinyusb_pico_pio_usb
167169
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_device tinyusb_host tinyusb_pico_pio_usb )
170+
suppress_tinyusb_warnings()
168171
endfunction()
169172

170173
function(check_and_add_pico_pio_usb_support)
@@ -232,6 +235,31 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
232235

233236
# This method must be called from the project scope to suppress known warnings in TinyUSB source files
234237
function(suppress_tinyusb_warnings)
235-
# there are currently no warnings to suppress, however this function must still exist
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()
236264
endfunction()
237265
endif()

0 commit comments

Comments
 (0)