Skip to content

Commit 38f02f0

Browse files
authored
Merge pull request #1145 from kilograham/release-0.12.0
Address compiler warnings
2 parents d94a5aa + 06d9555 commit 38f02f0

File tree

5 files changed

+53
-16
lines changed

5 files changed

+53
-16
lines changed

hw/bsp/rp2040/family.cmake

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
7777
${TOP}/src/class/video/video_device.c
7878
)
7979

80-
8180
# Base config for host mode; wrapped by SDK's tinyusb_host
8281
add_library(tinyusb_host_base INTERFACE)
8382
target_sources(tinyusb_host_base INTERFACE
@@ -153,4 +152,28 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
153152
enable_language(C CXX ASM)
154153
pico_sdk_init()
155154
endfunction()
155+
156+
# This method must be called from the project scope to suppress known warnings in TinyUSB source files
157+
function(suppress_tinyusb_warnings)
158+
set_source_files_properties(
159+
${PICO_TINYUSB_PATH}/src/tusb.c
160+
PROPERTIES
161+
COMPILE_FLAGS "-Wno-conversion")
162+
set_source_files_properties(
163+
${PICO_TINYUSB_PATH}/src/common/tusb_fifo.c
164+
PROPERTIES
165+
COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual")
166+
set_source_files_properties(
167+
${PICO_TINYUSB_PATH}/src/device/usbd.c
168+
PROPERTIES
169+
COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual -Wno-null-dereference")
170+
set_source_files_properties(
171+
${PICO_TINYUSB_PATH}/src/device/usbd_control.c
172+
PROPERTIES
173+
COMPILE_FLAGS "-Wno-conversion")
174+
set_source_files_properties(
175+
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
176+
PROPERTIES
177+
COMPILE_FLAGS "-Wno-conversion")
178+
endfunction()
156179
endif()

src/device/dcd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,14 @@ typedef struct TU_ATTR_ALIGNED(4)
106106
void dcd_init (uint8_t rhport);
107107

108108
// Interrupt Handler
109+
#if __GNUC__
110+
#pragma GCC diagnostic push
111+
#pragma GCC diagnostic ignored "-Wredundant-decls"
112+
#endif
109113
void dcd_int_handler(uint8_t rhport);
114+
#if __GNUC__
115+
#pragma GCC diagnostic pop
116+
#endif
110117

111118
// Enable device interrupt
112119
void dcd_int_enable (uint8_t rhport);

src/osal/osal.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ typedef void (*osal_task_func_t)( void * );
6767
// OSAL Porting API
6868
//--------------------------------------------------------------------+
6969

70+
#if __GNUC__
71+
#pragma GCC diagnostic push
72+
#pragma GCC diagnostic ignored "-Wredundant-decls"
73+
#endif
7074
//------------- Semaphore -------------//
7175
static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef);
7276
static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr);
@@ -84,6 +88,9 @@ static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef);
8488
static inline bool osal_queue_receive(osal_queue_t qhdl, void* data);
8589
static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr);
8690
static inline bool osal_queue_empty(osal_queue_t qhdl);
91+
#if __GNUC__
92+
#pragma GCC diagnostic pop
93+
#endif
8794

8895
#if 0 // TODO remove subtask related macros later
8996
// Sub Task

src/portable/raspberrypi/rp2040/dcd_rp2040.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static struct hw_endpoint *hw_endpoint_get_by_addr(uint8_t ep_addr)
7070
static void _hw_endpoint_alloc(struct hw_endpoint *ep, uint8_t transfer_type)
7171
{
7272
// size must be multiple of 64
73-
uint16_t size = tu_div_ceil(ep->wMaxPacketSize, 64) * 64u;
73+
uint size = tu_div_ceil(ep->wMaxPacketSize, 64) * 64u;
7474

7575
// double buffered Bulk endpoint
7676
if ( transfer_type == TUSB_XFER_BULK )
@@ -88,7 +88,7 @@ static void _hw_endpoint_alloc(struct hw_endpoint *ep, uint8_t transfer_type)
8888
pico_info(" Alloced %d bytes at offset 0x%x (0x%p)\r\n", size, dpram_offset, ep->hw_data_buf);
8989

9090
// Fill in endpoint control register with buffer offset
91-
uint32_t const reg = EP_CTRL_ENABLE_BITS | (transfer_type << EP_CTRL_BUFFER_TYPE_LSB) | dpram_offset;
91+
uint32_t const reg = EP_CTRL_ENABLE_BITS | ((uint)transfer_type << EP_CTRL_BUFFER_TYPE_LSB) | dpram_offset;
9292

9393
*ep->endpoint_control = reg;
9494
}
@@ -177,7 +177,7 @@ static void hw_handle_buff_status(void)
177177
uint32_t remaining_buffers = usb_hw->buf_status;
178178
pico_trace("buf_status = 0x%08x\n", remaining_buffers);
179179
uint bit = 1u;
180-
for (uint i = 0; remaining_buffers && i < USB_MAX_ENDPOINTS * 2; i++)
180+
for (uint8_t i = 0; remaining_buffers && i < USB_MAX_ENDPOINTS * 2; i++)
181181
{
182182
if (remaining_buffers & bit)
183183
{
@@ -365,19 +365,19 @@ void dcd_init (uint8_t rhport)
365365
dcd_connect(rhport);
366366
}
367367

368-
void dcd_int_enable(uint8_t rhport)
368+
void dcd_int_enable(__unused uint8_t rhport)
369369
{
370370
assert(rhport == 0);
371371
irq_set_enabled(USBCTRL_IRQ, true);
372372
}
373373

374-
void dcd_int_disable(uint8_t rhport)
374+
void dcd_int_disable(__unused uint8_t rhport)
375375
{
376376
assert(rhport == 0);
377377
irq_set_enabled(USBCTRL_IRQ, false);
378378
}
379379

380-
void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
380+
void dcd_set_address (__unused uint8_t rhport, __unused uint8_t dev_addr)
381381
{
382382
assert(rhport == 0);
383383

@@ -386,22 +386,22 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
386386
hw_endpoint_xfer(0x80, NULL, 0);
387387
}
388388

389-
void dcd_remote_wakeup(uint8_t rhport)
389+
void dcd_remote_wakeup(__unused uint8_t rhport)
390390
{
391391
pico_info("dcd_remote_wakeup %d\n", rhport);
392392
assert(rhport == 0);
393393
usb_hw_set->sie_ctrl = USB_SIE_CTRL_RESUME_BITS;
394394
}
395395

396396
// disconnect by disabling internal pull-up resistor on D+/D-
397-
void dcd_disconnect(uint8_t rhport)
397+
void dcd_disconnect(__unused uint8_t rhport)
398398
{
399399
(void) rhport;
400400
usb_hw_clear->sie_ctrl = USB_SIE_CTRL_PULLUP_EN_BITS;
401401
}
402402

403403
// connect by enabling internal pull-up resistor on D+/D-
404-
void dcd_connect(uint8_t rhport)
404+
void dcd_connect(__unused uint8_t rhport)
405405
{
406406
(void) rhport;
407407
usb_hw_set->sie_ctrl = USB_SIE_CTRL_PULLUP_EN_BITS;
@@ -423,7 +423,7 @@ void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const * re
423423
}
424424
}
425425

426-
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt)
426+
bool dcd_edpt_open (__unused uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt)
427427
{
428428
assert(rhport == 0);
429429
hw_endpoint_init(desc_edpt->bEndpointAddress, desc_edpt->wMaxPacketSize.size, desc_edpt->bmAttributes.xfer);
@@ -438,7 +438,7 @@ void dcd_edpt_close_all (uint8_t rhport)
438438
reset_non_control_endpoints();
439439
}
440440

441-
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
441+
bool dcd_edpt_xfer(__unused uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
442442
{
443443
assert(rhport == 0);
444444
hw_endpoint_xfer(ep_addr, buffer, total_bytes);

src/portable/raspberrypi/rp2040/rp2040_usb.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const char *ep_dir_string[] = {
3838
"in",
3939
};
4040

41-
static inline void _hw_endpoint_lock_update(struct hw_endpoint *ep, int delta) {
41+
static inline void _hw_endpoint_lock_update(__unused struct hw_endpoint * ep, __unused int delta) {
4242
// todo add critsec as necessary to prevent issues between worker and IRQ...
4343
// note that this is perhaps as simple as disabling IRQs because it would make
4444
// sense to have worker and IRQ on same core, however I think using critsec is about equivalent.
@@ -107,7 +107,7 @@ void _hw_endpoint_buffer_control_update32(struct hw_endpoint *ep, uint32_t and_m
107107
static uint32_t prepare_ep_buffer(struct hw_endpoint *ep, uint8_t buf_id)
108108
{
109109
uint16_t const buflen = tu_min16(ep->remaining_len, ep->wMaxPacketSize);
110-
ep->remaining_len -= buflen;
110+
ep->remaining_len = (uint16_t)(ep->remaining_len - buflen);
111111

112112
uint32_t buf_ctrl = buflen | USB_BUF_CTRL_AVAIL;
113113

@@ -214,15 +214,15 @@ static uint16_t sync_ep_buffer(struct hw_endpoint *ep, uint8_t buf_id)
214214
// sent some data can increase the length we have sent
215215
assert(!(buf_ctrl & USB_BUF_CTRL_FULL));
216216

217-
ep->xferred_len += xferred_bytes;
217+
ep->xferred_len = (uint16_t)(ep->xferred_len + xferred_bytes);
218218
}else
219219
{
220220
// If we have received some data, so can increase the length
221221
// we have received AFTER we have copied it to the user buffer at the appropriate offset
222222
assert(buf_ctrl & USB_BUF_CTRL_FULL);
223223

224224
memcpy(ep->user_buf, ep->hw_data_buf + buf_id*64, xferred_bytes);
225-
ep->xferred_len += xferred_bytes;
225+
ep->xferred_len = (uint16_t)(ep->xferred_len + xferred_bytes);
226226
ep->user_buf += xferred_bytes;
227227
}
228228

0 commit comments

Comments
 (0)