update some sense warning from -Wconversion

This commit is contained in:
hathach 2021-10-15 15:54:32 +07:00
parent 9da234cd7c
commit 7596cb3079
6 changed files with 11 additions and 12 deletions

View File

@ -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; uint8_t const* addr = msc_disk[lba] + offset;
memcpy(buffer, addr, bufsize); memcpy(buffer, addr, bufsize);
return bufsize; return (int32_t) bufsize;
} }
bool tud_msc_is_writable_cb (uint8_t lun) 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; (void) lba; (void) offset; (void) buffer;
#endif #endif
return bufsize; return (int32_t) bufsize;
} }
// Callback invoked when received an SCSI command not in built-in list below // 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) if(in_xfer)
{ {
memcpy(buffer, response, resplen); memcpy(buffer, response, (size_t) resplen);
}else }else
{ {
// SCSI output // SCSI output
} }
} }
return resplen; return (int32_t) resplen;
} }
#endif #endif

View File

@ -261,7 +261,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
const char* str = string_desc_arr[index]; const char* str = string_desc_arr[index];
// Cap at max char // Cap at max char
chr_count = strlen(str); chr_count = (uint8_t) strlen(str);
if ( chr_count > 31 ) chr_count = 31; if ( chr_count > 31 ) chr_count = 31;
// Convert ASCII string into UTF-16 // Convert ASCII string into UTF-16

View File

@ -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) TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
{ {
(void) fhdl; (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) TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
{ {
(void) fhdl; (void) fhdl;
return board_uart_read((uint8_t*) buf, count); return board_uart_read((uint8_t*) buf, (int) count);
} }
#endif #endif

View File

@ -229,7 +229,7 @@ void cdcd_init(void)
{ {
cdcd_interface_t* p_cdc = &_cdcd_itf[i]; 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 // default line coding is : stop bit = 1, parity = none, data bits = 8
p_cdc->line_coding.bit_rate = 115200; p_cdc->line_coding.bit_rate = 115200;

View File

@ -152,7 +152,7 @@ static inline uint16_t rdwr10_get_blocksize(msc_cbw_t const* cbw)
// invalid block count // invalid block count
if (block_count == 0) return 0; 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) uint8_t rdwr10_validate_cmd(msc_cbw_t const* cbw)

View File

@ -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) 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; 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) ) 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; 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); p_desc = tu_desc_next(p_desc);
} }
} }