Skip to content

Commit 1a8c3a8

Browse files
authored
Merge pull request #1552 from hathach/fix-old-gcc
Fix warnings when compiling rp2040 with older version of gcc
2 parents 0bfb9d6 + 4ea27ac commit 1a8c3a8

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

examples/device/webusb_serial/src/main.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ enum {
7171

7272
static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;
7373

74-
#define URL "example.tinyusb.org/webusb-serial/"
74+
#define URL "example.tinyusb.org/webusb-serial/index.html"
7575

7676
const tusb_desc_webusb_url_t desc_url =
7777
{
@@ -114,6 +114,7 @@ void echo_all(uint8_t buf[], uint32_t count)
114114
if ( web_serial_connected )
115115
{
116116
tud_vendor_write(buf, count);
117+
tud_vendor_flush();
117118
}
118119

119120
// echo to cdc
@@ -211,7 +212,8 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
211212
board_led_write(true);
212213
blink_interval_ms = BLINK_ALWAYS_ON;
213214

214-
tud_vendor_write_str("\r\nTinyUSB WebUSB device example\r\n");
215+
tud_vendor_write_str("\r\nWebUSB interface connected\r\n");
216+
tud_vendor_flush();
215217
}else
216218
{
217219
blink_interval_ms = BLINK_MOUNTED;

examples/example.cmake

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,29 @@ target_compile_options(${PROJECT} PUBLIC
44
-Werror
55
-Wfatal-errors
66
-Wdouble-promotion
7-
#-Wstrict-prototypes
8-
-Wstrict-overflow
9-
#-Werror-implicit-function-declaration
107
-Wfloat-equal
11-
#-Wundef
128
-Wshadow
139
-Wwrite-strings
1410
-Wsign-compare
1511
-Wmissing-format-attribute
1612
-Wunreachable-code
1713
-Wcast-align
18-
-Wcast-function-type
1914
-Wcast-qual
2015
-Wnull-dereference
2116
-Wuninitialized
2217
-Wunused
2318
-Wredundant-decls
19+
#-Wstrict-prototypes
20+
#-Werror-implicit-function-declaration
21+
#-Wundef
2422
)
2523

26-
# GCC version 9 or prior has a bug with incorrect Wconversion warnings
24+
# GCC 10
2725
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
28-
target_compile_options(${PROJECT} PUBLIC
29-
-Wconversion
30-
)
26+
target_compile_options(${PROJECT} PUBLIC -Wconversion)
27+
endif()
28+
29+
# GCC 8
30+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
31+
target_compile_options(${PROJECT} PUBLIC -Wcast-function-type -Wstrict-overflow)
3132
endif()

src/host/usbh.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ typedef struct {
123123

124124
// Invalid driver ID in itf2drv[] ep2drv[][] mapping
125125
enum { DRVID_INVALID = 0xFFu };
126-
enum { ADDR_INVALID = 0xFFu };
127126
enum { CONTROLLER_INVALID = 0xFFu };
128127

129128
#if CFG_TUSB_DEBUG >= 2
@@ -1434,7 +1433,8 @@ static uint8_t get_new_address(bool is_hub)
14341433
{
14351434
if (!_usbh_devices[idx].connected) return (idx+1);
14361435
}
1437-
return ADDR_INVALID;
1436+
1437+
return 0; // invalid address
14381438
}
14391439

14401440
static bool enum_request_set_addr(void)
@@ -1443,7 +1443,7 @@ static bool enum_request_set_addr(void)
14431443

14441444
// Get new address
14451445
uint8_t const new_addr = get_new_address(desc_device->bDeviceClass == TUSB_CLASS_HUB);
1446-
TU_ASSERT(new_addr != ADDR_INVALID);
1446+
TU_ASSERT(new_addr != 0);
14471447

14481448
TU_LOG2("Set Address = %d\r\n", new_addr);
14491449

0 commit comments

Comments
 (0)