Skip to content

Commit dbc2c8d

Browse files
authored
Fix missing protoype warning, change TUD_EPBUF_TYPE_DEF order (#2889)
* change TUD_EPBUF_TYPE_DEF order * add and fix -Wmissing-prototypes warnings for cmake (skip make)
1 parent 2732aff commit dbc2c8d

File tree

18 files changed

+54
-48
lines changed

18 files changed

+54
-48
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,18 @@ jobs:
118118
runs-on: [self-hosted, Linux, X64, hifiphile]
119119
env:
120120
BUILD_ARGS: ${{ join(fromJSON(needs.set-matrix.outputs.json)['arm-iar'], ' ') }}
121+
IAR_LMS_CLOUD_URL: https://license.cloud.iar.com
122+
IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }}
121123
steps:
122124
- name: Clean workspace
123125
run: |
124126
echo "Cleaning up previous run"
125127
rm -rf "${{ github.workspace }}"
126128
mkdir -p "${{ github.workspace }}"
127129
130+
- name: Toolchain version
131+
run: iccarm --version
132+
128133
- name: Checkout TinyUSB
129134
uses: actions/checkout@v4
130135

.idea/cmake.xml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/build_system/make/toolchain/gcc_common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ CFLAGS += \
3131
-Wreturn-type \
3232
-Wredundant-decls \
3333

34+
# -Wmissing-prototypes \
3435
# conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
3536
# -Wconversion
3637

hw/bsp/board.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,23 @@
3939
#define sys_read _read
4040
#endif
4141

42+
int sys_write(int fhdl, const char *buf, size_t count) TU_ATTR_USED;
43+
int sys_read(int fhdl, char *buf, size_t count) TU_ATTR_USED;
44+
4245
#if defined(LOGGER_RTT)
4346
// Logging with RTT
4447

4548
// If using SES IDE, use the Syscalls/SEGGER_RTT_Syscalls_SES.c instead
4649
#if !(defined __SES_ARM) && !(defined __SES_RISCV) && !(defined __CROSSWORKS_ARM)
4750
#include "SEGGER_RTT.h"
4851

49-
TU_ATTR_USED int sys_write(int fhdl, const char *buf, size_t count) {
52+
int sys_write(int fhdl, const char *buf, size_t count) {
5053
(void) fhdl;
5154
SEGGER_RTT_Write(0, (const char *) buf, (int) count);
5255
return (int) count;
5356
}
5457

55-
TU_ATTR_USED int sys_read(int fhdl, char *buf, size_t count) {
58+
int sys_read(int fhdl, char *buf, size_t count) {
5659
(void) fhdl;
5760
int rd = (int) SEGGER_RTT_Read(0, buf, count);
5861
return (rd > 0) ? rd : -1;
@@ -64,7 +67,7 @@ TU_ATTR_USED int sys_read(int fhdl, char *buf, size_t count) {
6467
// Logging with SWO for ARM Cortex
6568
#include "board_mcu.h"
6669

67-
TU_ATTR_USED int sys_write (int fhdl, const char *buf, size_t count) {
70+
int sys_write (int fhdl, const char *buf, size_t count) {
6871
(void) fhdl;
6972
uint8_t const* buf8 = (uint8_t const*) buf;
7073

@@ -75,7 +78,7 @@ TU_ATTR_USED int sys_write (int fhdl, const char *buf, size_t count) {
7578
return (int) count;
7679
}
7780

78-
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
81+
int sys_read (int fhdl, char *buf, size_t count) {
7982
(void) fhdl;
8083
(void) buf;
8184
(void) count;
@@ -85,25 +88,25 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
8588
#else
8689

8790
// Default logging with on-board UART
88-
TU_ATTR_USED int sys_write (int fhdl, const char *buf, size_t count) {
91+
int sys_write (int fhdl, const char *buf, size_t count) {
8992
(void) fhdl;
9093
return board_uart_write(buf, (int) count);
9194
}
9295

93-
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
96+
int sys_read (int fhdl, char *buf, size_t count) {
9497
(void) fhdl;
9598
int rd = board_uart_read((uint8_t*) buf, (int) count);
9699
return (rd > 0) ? rd : -1;
97100
}
98101

99102
#endif
100103

101-
//TU_ATTR_USED int _close(int fhdl) {
104+
//int _close(int fhdl) {
102105
// (void) fhdl;
103106
// return 0;
104107
//}
105108

106-
//TU_ATTR_USED int _fstat(int file, struct stat *st) {
109+
//int _fstat(int file, struct stat *st) {
107110
// memset(st, 0, sizeof(*st));
108111
// st->st_mode = S_IFCHR;
109112
//}

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function(add_tinyusb TARGET)
6767
-Wunused-function
6868
-Wreturn-type
6969
-Wredundant-decls
70+
-Wmissing-prototypes
7071
)
7172
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
7273

src/class/audio/audio_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,13 @@ TU_ATTR_WEAK bool tud_audio_feedback_format_correction_cb(uint8_t func_id) {
490490
(void) func_id;
491491
return CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION;
492492
}
493-
#endif
494493

495494
TU_ATTR_WEAK TU_ATTR_FAST_FUNC void tud_audio_feedback_interval_isr(uint8_t func_id, uint32_t frame_number, uint8_t interval_shift) {
496495
(void) func_id;
497496
(void) frame_number;
498497
(void) interval_shift;
499498
}
499+
#endif
500500

501501
#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
502502
TU_ATTR_WEAK void tud_audio_int_done_cb(uint8_t rhport) {

src/class/bth/bth_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef struct {
5252

5353
typedef struct {
5454
TUD_EPBUF_DEF(epout_buf, CFG_TUD_BTH_DATA_EPSIZE);
55-
TUD_EPBUF_TYPE_DEF(hci_cmd, bt_hci_cmd_t);
55+
TUD_EPBUF_TYPE_DEF(bt_hci_cmd_t, hci_cmd);
5656
} btd_epbuf_t;
5757

5858
//--------------------------------------------------------------------+

src/class/net/ncm_device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ typedef struct {
118118

119119
typedef struct {
120120
struct {
121-
TUD_EPBUF_TYPE_DEF(ntb, recv_ntb_t);
121+
TUD_EPBUF_TYPE_DEF(recv_ntb_t, ntb);
122122
} recv[RECV_NTB_N];
123123

124124
struct {
125-
TUD_EPBUF_TYPE_DEF(ntb, xmit_ntb_t);
125+
TUD_EPBUF_TYPE_DEF(xmit_ntb_t, ntb);
126126
} xmit[XMIT_NTB_N];
127127

128-
TUD_EPBUF_TYPE_DEF(epnotif, ncm_notify_t);
128+
TUD_EPBUF_TYPE_DEF(ncm_notify_t, epnotif);
129129
} ncm_epbuf_t;
130130

131131
static ncm_interface_t ncm_interface;
@@ -748,7 +748,7 @@ void tud_network_recv_renew(void) {
748748
/**
749749
* Same as tud_network_recv_renew() but knows \a rhport
750750
*/
751-
void tud_network_recv_renew_r(uint8_t rhport) {
751+
static void tud_network_recv_renew_r(uint8_t rhport) {
752752
TU_LOG_DRV("tud_network_recv_renew_r(%d)\n", rhport);
753753

754754
ncm_interface.rhport = rhport;

src/class/usbtmc/usbtmc_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ osal_mutex_t usbtmcLock;
180180
#define criticalEnter() do { (void) osal_mutex_lock(usbtmcLock,OSAL_TIMEOUT_WAIT_FOREVER); } while (0)
181181
#define criticalLeave() do { (void) osal_mutex_unlock(usbtmcLock); } while (0)
182182

183-
bool atomicChangeState(usbtmcd_state_enum expectedState, usbtmcd_state_enum newState)
183+
static bool atomicChangeState(usbtmcd_state_enum expectedState, usbtmcd_state_enum newState)
184184
{
185185
bool ret = true;
186186
criticalEnter();

src/class/video/video_device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ extern "C" {
4040
// CFG_TUD_VIDEO > 1
4141
//--------------------------------------------------------------------+
4242

43+
bool tud_video_n_connected(uint_fast8_t ctl_idx);
44+
4345
/** Return true if streaming
4446
*
4547
* @param[in] ctl_idx Destination control interface index

src/common/tusb_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
}
4848

4949
// Declare an endpoint buffer with a type
50-
#define TUD_EPBUF_TYPE_DEF(_name, _type) \
50+
#define TUD_EPBUF_TYPE_DEF(_type, _name) \
5151
union { \
5252
CFG_TUD_MEM_ALIGN _type _name; \
5353
uint8_t _name##_dcache_padding[TUD_EPBUF_DCACHE_SIZE(sizeof(_type))]; \

src/portable/dialog/da146xx/dcd_da146xx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool is_in_isr(void)
896896
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
897897
}
898898

899+
void tusb_vbus_changed(bool present);
899900
void tusb_vbus_changed(bool present)
900901
{
901902
if (present && !_dcd.vbus_present)

src/portable/microchip/samd/dcd_samd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
335335
//--------------------------------------------------------------------+
336336
// Interrupt Handler
337337
//--------------------------------------------------------------------+
338-
void maybe_transfer_complete(void) {
338+
static void maybe_transfer_complete(void) {
339339
uint32_t epints = USB->DEVICE.EPINTSMRY.reg;
340340

341341
for (uint8_t epnum = 0; epnum < USB_EPT_NUM; epnum++) {

src/portable/microchip/samg/dcd_samg.c

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,57 +52,47 @@ typedef struct
5252
// Endpoint 0-5, each can only be either OUT or In
5353
xfer_desc_t _dcd_xfer[EP_COUNT];
5454

55-
void xfer_epsize_set(xfer_desc_t* xfer, uint16_t epsize)
56-
{
55+
TU_ATTR_ALWAYS_INLINE static inline void xfer_epsize_set(xfer_desc_t* xfer, uint16_t epsize) {
5756
xfer->epsize = epsize;
5857
}
5958

60-
void xfer_begin(xfer_desc_t* xfer, uint8_t * buffer, uint16_t total_bytes)
61-
{
59+
TU_ATTR_ALWAYS_INLINE static inline void xfer_begin(xfer_desc_t* xfer, uint8_t * buffer, uint16_t total_bytes) {
6260
xfer->buffer = buffer;
6361
// xfer->ff = NULL; // TODO support dcd_edpt_xfer_fifo API
6462
xfer->total_len = total_bytes;
6563
xfer->actual_len = 0;
6664
}
6765

68-
void xfer_end(xfer_desc_t* xfer)
69-
{
66+
TU_ATTR_ALWAYS_INLINE static inline void xfer_end(xfer_desc_t* xfer) {
7067
xfer->buffer = NULL;
7168
// xfer->ff = NULL; // TODO support dcd_edpt_xfer_fifo API
7269
xfer->total_len = 0;
7370
xfer->actual_len = 0;
7471
}
7572

76-
uint16_t xfer_packet_len(xfer_desc_t* xfer)
77-
{
73+
TU_ATTR_ALWAYS_INLINE static inline uint16_t xfer_packet_len(xfer_desc_t* xfer) {
7874
// also cover zero-length packet
7975
return tu_min16(xfer->total_len - xfer->actual_len, xfer->epsize);
8076
}
8177

82-
void xfer_packet_done(xfer_desc_t* xfer)
83-
{
78+
TU_ATTR_ALWAYS_INLINE static inline void xfer_packet_done(xfer_desc_t* xfer) {
8479
uint16_t const xact_len = xfer_packet_len(xfer);
85-
8680
xfer->buffer += xact_len;
8781
xfer->actual_len += xact_len;
8882
}
8983

9084
//------------- Transaction helpers -------------//
9185

9286
// Write data to EP FIFO, return number of written bytes
93-
static void xact_ep_write(uint8_t epnum, uint8_t* buffer, uint16_t xact_len)
94-
{
95-
for(uint16_t i=0; i<xact_len; i++)
96-
{
87+
static void xact_ep_write(uint8_t epnum, uint8_t* buffer, uint16_t xact_len) {
88+
for(uint16_t i=0; i<xact_len; i++) {
9789
UDP->UDP_FDR[epnum] = (uint32_t) buffer[i];
9890
}
9991
}
10092

10193
// Read data from EP FIFO
102-
static void xact_ep_read(uint8_t epnum, uint8_t* buffer, uint16_t xact_len)
103-
{
104-
for(uint16_t i=0; i<xact_len; i++)
105-
{
94+
static void xact_ep_read(uint8_t epnum, uint8_t* buffer, uint16_t xact_len) {
95+
for(uint16_t i=0; i<xact_len; i++) {
10696
buffer[i] = (uint8_t) UDP->UDP_FDR[epnum];
10797
}
10898
}
@@ -112,24 +102,24 @@ static void xact_ep_read(uint8_t epnum, uint8_t* buffer, uint16_t xact_len)
112102
#define CSR_NO_EFFECT_1_ALL (UDP_CSR_RX_DATA_BK0 | UDP_CSR_RX_DATA_BK1 | UDP_CSR_STALLSENT | UDP_CSR_RXSETUP | UDP_CSR_TXCOMP)
113103

114104
// Per Specs: CSR need synchronization each write
115-
static inline void csr_write(uint8_t epnum, uint32_t value)
116-
{
105+
TU_ATTR_ALWAYS_INLINE static inline void csr_write(uint8_t epnum, uint32_t value) {
117106
uint32_t const csr = value;
118107
UDP->UDP_CSR[epnum] = csr;
119108

120109
volatile uint32_t nop_count;
121-
for (nop_count = 0; nop_count < 20; nop_count ++) __NOP();
110+
for (nop_count = 0; nop_count < 20; nop_count ++) {
111+
__NOP();
112+
}
122113
}
123114

124115
// Per Specs: CSR need synchronization each write
125-
static inline void csr_set(uint8_t epnum, uint32_t mask)
116+
TU_ATTR_ALWAYS_INLINE static inline void csr_set(uint8_t epnum, uint32_t mask)
126117
{
127118
csr_write(epnum, UDP->UDP_CSR[epnum] | CSR_NO_EFFECT_1_ALL | mask);
128119
}
129120

130121
// Per Specs: CSR need synchronization each write
131-
static inline void csr_clear(uint8_t epnum, uint32_t mask)
132-
{
122+
TU_ATTR_ALWAYS_INLINE static inline void csr_clear(uint8_t epnum, uint32_t mask) {
133123
csr_write(epnum, (UDP->UDP_CSR[epnum] | CSR_NO_EFFECT_1_ALL) & ~mask);
134124
}
135125

src/portable/nordic/nrf5x/dcd_nrf5x.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) {
530530
/*------------------------------------------------------------------*/
531531
/* Interrupt Handler
532532
*------------------------------------------------------------------*/
533-
void bus_reset(void) {
533+
static void bus_reset(void) {
534534
// 6.35.6 USB controller automatically disabled all endpoints (except control)
535535
NRF_USBD->EPOUTEN = 1UL;
536536
NRF_USBD->EPINEN = 1UL;
@@ -901,6 +901,7 @@ static void hfclk_disable(void) {
901901
// Therefore this function must be called to handle USB power event by
902902
// - nrfx_power_usbevt_init() : if Softdevice is not used or enabled
903903
// - SoftDevice SOC event : if SD is used and enabled
904+
void tusb_hal_nrf_power_event(uint32_t event);
904905
void tusb_hal_nrf_power_event(uint32_t event) {
905906
// Value is chosen to be as same as NRFX_POWER_USB_EVT_* in nrfx_power.h
906907
enum {

src/portable/nxp/khci/hcd_khci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ typedef struct
140140
CFG_TUH_MEM_SECTION TU_ATTR_ALIGNED(512) static hcd_data_t _hcd;
141141
//CFG_TUH_MEM_SECTION TU_ATTR_ALIGNED(4) static uint8_t _rx_buf[1024];
142142

143-
int find_pipe(uint8_t dev_addr, uint8_t ep_addr)
143+
static int find_pipe(uint8_t dev_addr, uint8_t ep_addr)
144144
{
145145
/* Find the target pipe */
146146
int num;

src/portable/nxp/lpc17_40/hcd_lpc17_40.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
(CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX)
3131

3232
#include "chip.h"
33+
#include "host/hcd.h"
3334

3435
void hcd_int_enable(uint8_t rhport)
3536
{

src/portable/renesas/rusb2/rusb2_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ rusb2_controller_t rusb2_controller[] = {
4545
};
4646

4747
// Application API for setting IRQ number. May throw warnings for missing prototypes.
48+
void tusb_rusb2_set_irqnum(uint8_t rhport, int32_t irqnum);
4849
void tusb_rusb2_set_irqnum(uint8_t rhport, int32_t irqnum) {
4950
rusb2_controller[rhport].irqnum = irqnum;
5051
}

0 commit comments

Comments
 (0)