Skip to content

Commit

Permalink
try to fix type conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
talpachen committed Nov 26, 2023
1 parent 306782e commit f6d3119
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/jtag/drivers/cmsis_dap_usb_bulk.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,17 @@ static int cmsis_dap_usb_write(struct cmsis_dap *dap, int txlen, int timeout_ms)
{
int transferred = 0;
int err;
int tail = 0;
unsigned int tail = 0;
unsigned int size = txlen;

if ((txlen < (int)dap->packet_buffer_size) && !(txlen % dap->packet_size)) {
if ((size < dap->packet_buffer_size) && !(size % dap->packet_size)) {
tail = 1;
size += tail;
}

/* skip the first byte that is only used by the HID backend */
err = libusb_bulk_transfer(dap->bdata->dev_handle, dap->bdata->ep_out,
dap->packet_buffer, txlen + tail, &transferred, timeout_ms);
dap->packet_buffer, size, &transferred, timeout_ms);
if (err) {
if (err == LIBUSB_ERROR_TIMEOUT) {
return ERROR_TIMEOUT_REACHED;
Expand Down

0 comments on commit f6d3119

Please sign in to comment.