diff options
| author | Ha Thach <[email protected]> | 2023-08-14 22:25:44 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-14 22:25:44 +0700 |
| commit | ba40d667e1476ee4ff988c425cf0cf1b17aed17d (patch) | |
| tree | 12d6ef2f6e4379257a12953824715c8aea69e59a | |
| parent | 92457ec99f1690b772ef9fa6b348256701c7fcf7 (diff) | |
| parent | b5ba12119dccb123aa6e8798dc86d639af6703b9 (diff) | |
Merge pull request #2219 from tswan-quasi/master
min on cdc r/w
| -rw-r--r-- | src/class/cdc/cdc_device.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 70d9c2e24..c26264e60 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -150,7 +150,7 @@ uint32_t tud_cdc_n_available(uint8_t itf) uint32_t tud_cdc_n_read(uint8_t itf, void* buffer, uint32_t bufsize) { cdcd_interface_t* p_cdc = &_cdcd_itf[itf]; - uint32_t num_read = tu_fifo_read_n(&p_cdc->rx_ff, buffer, (uint16_t) bufsize); + uint32_t num_read = tu_fifo_read_n(&p_cdc->rx_ff, buffer, (uint16_t) TU_MIN(bufsize, UINT16_MAX)); _prep_out_transaction(p_cdc); return num_read; } @@ -173,7 +173,7 @@ void tud_cdc_n_read_flush (uint8_t itf) uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize) { cdcd_interface_t* p_cdc = &_cdcd_itf[itf]; - uint16_t ret = tu_fifo_write_n(&p_cdc->tx_ff, buffer, (uint16_t) bufsize); + uint16_t ret = tu_fifo_write_n(&p_cdc->tx_ff, buffer, (uint16_t) TU_MIN(bufsize, UINT16_MAX)); // flush if queue more than packet size // may need to suppress -Wunreachable-code since most of the time CFG_TUD_CDC_TX_BUFSIZE < BULK_PACKET_SIZE |
