Merge pull request #1552 from hathach/fix-old-gcc

Fix warnings when compiling rp2040 with older version of gcc
This commit is contained in:
Ha Thach 2022-07-12 11:08:19 +07:00 committed by GitHub
commit 1a8c3a863b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 14 deletions

View File

@ -71,7 +71,7 @@ enum {
static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED; static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;
#define URL "example.tinyusb.org/webusb-serial/" #define URL "example.tinyusb.org/webusb-serial/index.html"
const tusb_desc_webusb_url_t desc_url = const tusb_desc_webusb_url_t desc_url =
{ {
@ -114,6 +114,7 @@ void echo_all(uint8_t buf[], uint32_t count)
if ( web_serial_connected ) if ( web_serial_connected )
{ {
tud_vendor_write(buf, count); tud_vendor_write(buf, count);
tud_vendor_flush();
} }
// echo to cdc // echo to cdc
@ -211,7 +212,8 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
board_led_write(true); board_led_write(true);
blink_interval_ms = BLINK_ALWAYS_ON; blink_interval_ms = BLINK_ALWAYS_ON;
tud_vendor_write_str("\r\nTinyUSB WebUSB device example\r\n"); tud_vendor_write_str("\r\nWebUSB interface connected\r\n");
tud_vendor_flush();
}else }else
{ {
blink_interval_ms = BLINK_MOUNTED; blink_interval_ms = BLINK_MOUNTED;

View File

@ -4,28 +4,29 @@ target_compile_options(${PROJECT} PUBLIC
-Werror -Werror
-Wfatal-errors -Wfatal-errors
-Wdouble-promotion -Wdouble-promotion
#-Wstrict-prototypes
-Wstrict-overflow
#-Werror-implicit-function-declaration
-Wfloat-equal -Wfloat-equal
#-Wundef
-Wshadow -Wshadow
-Wwrite-strings -Wwrite-strings
-Wsign-compare -Wsign-compare
-Wmissing-format-attribute -Wmissing-format-attribute
-Wunreachable-code -Wunreachable-code
-Wcast-align -Wcast-align
-Wcast-function-type
-Wcast-qual -Wcast-qual
-Wnull-dereference -Wnull-dereference
-Wuninitialized -Wuninitialized
-Wunused -Wunused
-Wredundant-decls -Wredundant-decls
#-Wstrict-prototypes
#-Werror-implicit-function-declaration
#-Wundef
) )
# GCC version 9 or prior has a bug with incorrect Wconversion warnings # GCC 10
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
target_compile_options(${PROJECT} PUBLIC target_compile_options(${PROJECT} PUBLIC -Wconversion)
-Wconversion endif()
)
# GCC 8
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
target_compile_options(${PROJECT} PUBLIC -Wcast-function-type -Wstrict-overflow)
endif() endif()

View File

@ -123,7 +123,6 @@ typedef struct {
// Invalid driver ID in itf2drv[] ep2drv[][] mapping // Invalid driver ID in itf2drv[] ep2drv[][] mapping
enum { DRVID_INVALID = 0xFFu }; enum { DRVID_INVALID = 0xFFu };
enum { ADDR_INVALID = 0xFFu };
enum { CONTROLLER_INVALID = 0xFFu }; enum { CONTROLLER_INVALID = 0xFFu };
#if CFG_TUSB_DEBUG >= 2 #if CFG_TUSB_DEBUG >= 2
@ -1434,7 +1433,8 @@ static uint8_t get_new_address(bool is_hub)
{ {
if (!_usbh_devices[idx].connected) return (idx+1); if (!_usbh_devices[idx].connected) return (idx+1);
} }
return ADDR_INVALID;
return 0; // invalid address
} }
static bool enum_request_set_addr(void) static bool enum_request_set_addr(void)
@ -1443,7 +1443,7 @@ static bool enum_request_set_addr(void)
// Get new address // Get new address
uint8_t const new_addr = get_new_address(desc_device->bDeviceClass == TUSB_CLASS_HUB); uint8_t const new_addr = get_new_address(desc_device->bDeviceClass == TUSB_CLASS_HUB);
TU_ASSERT(new_addr != ADDR_INVALID); TU_ASSERT(new_addr != 0);
TU_LOG2("Set Address = %d\r\n", new_addr); TU_LOG2("Set Address = %d\r\n", new_addr);