Skip to content

Commit

Permalink
add and fix -Wmissing-prototypes warnings for cmake (skip make)
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Nov 27, 2024
1 parent 13a2c50 commit b77ccda
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 43 deletions.
8 changes: 4 additions & 4 deletions .idea/cmake.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/build_system/make/toolchain/gcc_common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ CFLAGS += \
-Wreturn-type \
-Wredundant-decls \

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

Expand Down
19 changes: 11 additions & 8 deletions hw/bsp/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@
#define sys_read _read
#endif

int sys_write(int fhdl, const char *buf, size_t count) TU_ATTR_USED;
int sys_read(int fhdl, char *buf, size_t count) TU_ATTR_USED;

#if defined(LOGGER_RTT)
// Logging with RTT

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

TU_ATTR_USED int sys_write(int fhdl, const char *buf, size_t count) {
int sys_write(int fhdl, const char *buf, size_t count) {
(void) fhdl;
SEGGER_RTT_Write(0, (const char *) buf, (int) count);
return (int) count;
}

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

TU_ATTR_USED int sys_write (int fhdl, const char *buf, size_t count) {
int sys_write (int fhdl, const char *buf, size_t count) {
(void) fhdl;
uint8_t const* buf8 = (uint8_t const*) buf;

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

TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
int sys_read (int fhdl, char *buf, size_t count) {
(void) fhdl;
(void) buf;
(void) count;
Expand All @@ -85,25 +88,25 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
#else

// Default logging with on-board UART
TU_ATTR_USED int sys_write (int fhdl, const char *buf, size_t count) {
int sys_write (int fhdl, const char *buf, size_t count) {
(void) fhdl;
return board_uart_write(buf, (int) count);
}

TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
int sys_read (int fhdl, char *buf, size_t count) {
(void) fhdl;
int rd = board_uart_read((uint8_t*) buf, (int) count);
return (rd > 0) ? rd : -1;
}

#endif

//TU_ATTR_USED int _close(int fhdl) {
//int _close(int fhdl) {
// (void) fhdl;
// return 0;
//}

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

//TU_ATTR_USED int _fstat(int file, struct stat *st) {
//int _fstat(int file, struct stat *st) {
// memset(st, 0, sizeof(*st));
// st->st_mode = S_IFCHR;
//}

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function(add_tinyusb TARGET)
-Wunused-function
-Wreturn-type
-Wredundant-decls
-Wmissing-prototypes
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")

Expand Down
2 changes: 1 addition & 1 deletion src/class/audio/audio_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,13 @@ TU_ATTR_WEAK bool tud_audio_feedback_format_correction_cb(uint8_t func_id) {
(void) func_id;
return CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION;
}
#endif

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) {
(void) func_id;
(void) frame_number;
(void) interval_shift;
}
#endif

#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
TU_ATTR_WEAK void tud_audio_int_done_cb(uint8_t rhport) {
Expand Down
2 changes: 1 addition & 1 deletion src/class/net/ncm_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ void tud_network_recv_renew(void) {
/**
* Same as tud_network_recv_renew() but knows \a rhport
*/
void tud_network_recv_renew_r(uint8_t rhport) {
static void tud_network_recv_renew_r(uint8_t rhport) {
TU_LOG_DRV("tud_network_recv_renew_r(%d)\n", rhport);

ncm_interface.rhport = rhport;
Expand Down
2 changes: 1 addition & 1 deletion src/class/usbtmc/usbtmc_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ osal_mutex_t usbtmcLock;
#define criticalEnter() do { (void) osal_mutex_lock(usbtmcLock,OSAL_TIMEOUT_WAIT_FOREVER); } while (0)
#define criticalLeave() do { (void) osal_mutex_unlock(usbtmcLock); } while (0)

bool atomicChangeState(usbtmcd_state_enum expectedState, usbtmcd_state_enum newState)
static bool atomicChangeState(usbtmcd_state_enum expectedState, usbtmcd_state_enum newState)
{
bool ret = true;
criticalEnter();
Expand Down
2 changes: 2 additions & 0 deletions src/class/video/video_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ extern "C" {
// CFG_TUD_VIDEO > 1
//--------------------------------------------------------------------+

bool tud_video_n_connected(uint_fast8_t ctl_idx);

/** Return true if streaming
*
* @param[in] ctl_idx Destination control interface index
Expand Down
1 change: 1 addition & 0 deletions src/portable/dialog/da146xx/dcd_da146xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool is_in_isr(void)
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
}

void tusb_vbus_changed(bool present);
void tusb_vbus_changed(bool present)
{
if (present && !_dcd.vbus_present)
Expand Down
2 changes: 1 addition & 1 deletion src/portable/microchip/samd/dcd_samd.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
//--------------------------------------------------------------------+
// Interrupt Handler
//--------------------------------------------------------------------+
void maybe_transfer_complete(void) {
static void maybe_transfer_complete(void) {
uint32_t epints = USB->DEVICE.EPINTSMRY.reg;

for (uint8_t epnum = 0; epnum < USB_EPT_NUM; epnum++) {
Expand Down
40 changes: 15 additions & 25 deletions src/portable/microchip/samg/dcd_samg.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,57 +52,47 @@ typedef struct
// Endpoint 0-5, each can only be either OUT or In
xfer_desc_t _dcd_xfer[EP_COUNT];

void xfer_epsize_set(xfer_desc_t* xfer, uint16_t epsize)
{
TU_ATTR_ALWAYS_INLINE static inline void xfer_epsize_set(xfer_desc_t* xfer, uint16_t epsize) {
xfer->epsize = epsize;
}

void xfer_begin(xfer_desc_t* xfer, uint8_t * buffer, uint16_t total_bytes)
{
TU_ATTR_ALWAYS_INLINE static inline void xfer_begin(xfer_desc_t* xfer, uint8_t * buffer, uint16_t total_bytes) {
xfer->buffer = buffer;
// xfer->ff = NULL; // TODO support dcd_edpt_xfer_fifo API
xfer->total_len = total_bytes;
xfer->actual_len = 0;
}

void xfer_end(xfer_desc_t* xfer)
{
TU_ATTR_ALWAYS_INLINE static inline void xfer_end(xfer_desc_t* xfer) {
xfer->buffer = NULL;
// xfer->ff = NULL; // TODO support dcd_edpt_xfer_fifo API
xfer->total_len = 0;
xfer->actual_len = 0;
}

uint16_t xfer_packet_len(xfer_desc_t* xfer)
{
TU_ATTR_ALWAYS_INLINE static inline uint16_t xfer_packet_len(xfer_desc_t* xfer) {
// also cover zero-length packet
return tu_min16(xfer->total_len - xfer->actual_len, xfer->epsize);
}

void xfer_packet_done(xfer_desc_t* xfer)
{
TU_ATTR_ALWAYS_INLINE static inline void xfer_packet_done(xfer_desc_t* xfer) {
uint16_t const xact_len = xfer_packet_len(xfer);

xfer->buffer += xact_len;
xfer->actual_len += xact_len;
}

//------------- Transaction helpers -------------//

// Write data to EP FIFO, return number of written bytes
static void xact_ep_write(uint8_t epnum, uint8_t* buffer, uint16_t xact_len)
{
for(uint16_t i=0; i<xact_len; i++)
{
static void xact_ep_write(uint8_t epnum, uint8_t* buffer, uint16_t xact_len) {
for(uint16_t i=0; i<xact_len; i++) {
UDP->UDP_FDR[epnum] = (uint32_t) buffer[i];
}
}

// Read data from EP FIFO
static void xact_ep_read(uint8_t epnum, uint8_t* buffer, uint16_t xact_len)
{
for(uint16_t i=0; i<xact_len; i++)
{
static void xact_ep_read(uint8_t epnum, uint8_t* buffer, uint16_t xact_len) {
for(uint16_t i=0; i<xact_len; i++) {
buffer[i] = (uint8_t) UDP->UDP_FDR[epnum];
}
}
Expand All @@ -112,24 +102,24 @@ static void xact_ep_read(uint8_t epnum, uint8_t* buffer, uint16_t xact_len)
#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)

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

volatile uint32_t nop_count;
for (nop_count = 0; nop_count < 20; nop_count ++) __NOP();
for (nop_count = 0; nop_count < 20; nop_count ++) {
__NOP();
}
}

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

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

Expand Down
3 changes: 2 additions & 1 deletion src/portable/nordic/nrf5x/dcd_nrf5x.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) {
/*------------------------------------------------------------------*/
/* Interrupt Handler
*------------------------------------------------------------------*/
void bus_reset(void) {
static void bus_reset(void) {
// 6.35.6 USB controller automatically disabled all endpoints (except control)
NRF_USBD->EPOUTEN = 1UL;
NRF_USBD->EPINEN = 1UL;
Expand Down Expand Up @@ -901,6 +901,7 @@ static void hfclk_disable(void) {
// Therefore this function must be called to handle USB power event by
// - nrfx_power_usbevt_init() : if Softdevice is not used or enabled
// - SoftDevice SOC event : if SD is used and enabled
void tusb_hal_nrf_power_event(uint32_t event);
void tusb_hal_nrf_power_event(uint32_t event) {
// Value is chosen to be as same as NRFX_POWER_USB_EVT_* in nrfx_power.h
enum {
Expand Down
2 changes: 1 addition & 1 deletion src/portable/nxp/khci/hcd_khci.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ typedef struct
CFG_TUH_MEM_SECTION TU_ATTR_ALIGNED(512) static hcd_data_t _hcd;
//CFG_TUH_MEM_SECTION TU_ATTR_ALIGNED(4) static uint8_t _rx_buf[1024];

int find_pipe(uint8_t dev_addr, uint8_t ep_addr)
static int find_pipe(uint8_t dev_addr, uint8_t ep_addr)
{
/* Find the target pipe */
int num;
Expand Down
1 change: 1 addition & 0 deletions src/portable/nxp/lpc17_40/hcd_lpc17_40.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
(CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX)

#include "chip.h"
#include "host/hcd.h"

void hcd_int_enable(uint8_t rhport)
{
Expand Down
1 change: 1 addition & 0 deletions src/portable/renesas/rusb2/rusb2_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ rusb2_controller_t rusb2_controller[] = {
};

// Application API for setting IRQ number. May throw warnings for missing prototypes.
void tusb_rusb2_set_irqnum(uint8_t rhport, int32_t irqnum);
void tusb_rusb2_set_irqnum(uint8_t rhport, int32_t irqnum) {
rusb2_controller[rhport].irqnum = irqnum;
}
Expand Down

0 comments on commit b77ccda

Please sign in to comment.