diff options
| author | hathach <[email protected]> | 2021-10-15 15:54:32 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2021-10-15 15:54:32 +0700 |
| commit | 7596cb30797c625a0523e0f68ef65296740538e0 (patch) | |
| tree | b84a5e9ab74caf759a69b95d7f963f518be1a571 | |
| parent | 9da234cd7c73786624970206d7b7b7361275a6b7 (diff) | |
update some sense warning from -Wconversion
| -rw-r--r-- | examples/device/cdc_msc/src/msc_disk.c | 8 | ||||
| -rw-r--r-- | examples/device/cdc_msc/src/usb_descriptors.c | 2 | ||||
| -rw-r--r-- | hw/bsp/board.c | 4 | ||||
| -rw-r--r-- | src/class/cdc/cdc_device.c | 2 | ||||
| -rw-r--r-- | src/class/msc/msc_device.c | 2 | ||||
| -rw-r--r-- | src/tusb.c | 5 |
6 files changed, 11 insertions, 12 deletions
diff --git a/examples/device/cdc_msc/src/msc_disk.c b/examples/device/cdc_msc/src/msc_disk.c index cad2602a2..134bda392 100644 --- a/examples/device/cdc_msc/src/msc_disk.c +++ b/examples/device/cdc_msc/src/msc_disk.c @@ -194,7 +194,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff uint8_t const* addr = msc_disk[lba] + offset; memcpy(buffer, addr, bufsize); - return bufsize; + return (int32_t) bufsize; } bool tud_msc_is_writable_cb (uint8_t lun) @@ -224,7 +224,7 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* (void) lba; (void) offset; (void) buffer; #endif - return bufsize; + return (int32_t) bufsize; } // Callback invoked when received an SCSI command not in built-in list below @@ -263,14 +263,14 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, { if(in_xfer) { - memcpy(buffer, response, resplen); + memcpy(buffer, response, (size_t) resplen); }else { // SCSI output } } - return resplen; + return (int32_t) resplen; } #endif diff --git a/examples/device/cdc_msc/src/usb_descriptors.c b/examples/device/cdc_msc/src/usb_descriptors.c index 34537b8f0..5e397d15a 100644 --- a/examples/device/cdc_msc/src/usb_descriptors.c +++ b/examples/device/cdc_msc/src/usb_descriptors.c @@ -261,7 +261,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) const char* str = string_desc_arr[index]; // Cap at max char - chr_count = strlen(str); + chr_count = (uint8_t) strlen(str); if ( chr_count > 31 ) chr_count = 31; // Convert ASCII string into UTF-16 diff --git a/hw/bsp/board.c b/hw/bsp/board.c index 6a26f55b7..2c18b61b4 100644 --- a/hw/bsp/board.c +++ b/hw/bsp/board.c @@ -135,13 +135,13 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count) { (void) fhdl; - return board_uart_write(buf, count); + return board_uart_write(buf, (int) count); } TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) { (void) fhdl; - return board_uart_read((uint8_t*) buf, count); + return board_uart_read((uint8_t*) buf, (int) count); } #endif diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index e622bd616..74c116192 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -229,7 +229,7 @@ void cdcd_init(void) { cdcd_interface_t* p_cdc = &_cdcd_itf[i]; - p_cdc->wanted_char = -1; + p_cdc->wanted_char = (char) -1; // default line coding is : stop bit = 1, parity = none, data bits = 8 p_cdc->line_coding.bit_rate = 115200; diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index c54c4c189..81522be46 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -152,7 +152,7 @@ static inline uint16_t rdwr10_get_blocksize(msc_cbw_t const* cbw) // invalid block count if (block_count == 0) return 0; - return cbw->total_bytes / block_count; + return (uint16_t) (cbw->total_bytes / block_count); } uint8_t rdwr10_validate_cmd(msc_cbw_t const* cbw) diff --git a/src/tusb.c b/src/tusb.c index 5c6adad24..fc1936c3d 100644 --- a/src/tusb.c +++ b/src/tusb.c @@ -109,9 +109,9 @@ bool tu_edpt_validate(tusb_desc_endpoint_t const * desc_ep, tusb_speed_t speed) void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* desc_itf, uint16_t desc_len, uint8_t driver_id) { uint8_t const* p_desc = (uint8_t const*) desc_itf; - uint16_t len = 0; + uint8_t const* desc_end = p_desc + desc_len; - while( len < desc_len ) + while( p_desc < desc_end ) { if ( TUSB_DESC_ENDPOINT == tu_desc_type(p_desc) ) { @@ -121,7 +121,6 @@ void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* desc_ ep2drv[tu_edpt_number(ep_addr)][tu_edpt_dir(ep_addr)] = driver_id; } - len += (uint16_t) tu_desc_len(p_desc); p_desc = tu_desc_next(p_desc); } } |
