aboutsummaryrefslogtreecommitdiff
path: root/src/jtag
diff options
context:
space:
mode:
authorMarc Schink <openocd-dev@marcschink.de>2016-05-22 20:35:34 +0200
committerPaul Fertser <fercerpav@gmail.com>2016-12-08 12:34:53 +0000
commit69ff7354d9c9accf09374772310098f1f00e8ccb (patch)
tree94a7803244c884ec26965101d45e10f6c53d8477 /src/jtag
parent1461237073e377d315799999b8e29f1605084449 (diff)
downloadriscv-openocd-69ff7354d9c9accf09374772310098f1f00e8ccb.zip
riscv-openocd-69ff7354d9c9accf09374772310098f1f00e8ccb.tar.gz
riscv-openocd-69ff7354d9c9accf09374772310098f1f00e8ccb.tar.bz2
helper: Code cleanup for hexify()
Simplify hexify() and do not longer use 0 as special case for the parameter 'count' to determine the string length of the binary input. Instead, use strlen() outside of the function if needed. Additionally, fix the return value and return the length of the converted string. The old function always returned 2 * count. Also, use more appropriate data types for the function parameters and add a small documentation. Change-Id: I133a8ab786b8f7c1296afcaf9c0a0b43881e5112 Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/3793 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Diffstat (limited to 'src/jtag')
-rw-r--r--src/jtag/drivers/ti_icdi_usb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/jtag/drivers/ti_icdi_usb.c b/src/jtag/drivers/ti_icdi_usb.c
index 7a6272f..171ac66 100644
--- a/src/jtag/drivers/ti_icdi_usb.c
+++ b/src/jtag/drivers/ti_icdi_usb.c
@@ -242,7 +242,8 @@ static int icdi_send_remote_cmd(void *handle, const char *data)
struct icdi_usb_handle_s *h = handle;
size_t cmd_len = sprintf(h->write_buffer, PACKET_START "qRcmd,");
- cmd_len += hexify(h->write_buffer + cmd_len, data, 0, h->max_packet - cmd_len);
+ cmd_len += hexify(h->write_buffer + cmd_len, (const uint8_t *)data,
+ strlen(data), h->max_packet - cmd_len);
return icdi_send_packet(handle, cmd_len);
}
@@ -512,7 +513,7 @@ static int icdi_usb_write_reg(void *handle, int num, uint32_t val)
h_u32_to_le(buf, val);
int cmd_len = snprintf(cmd, sizeof(cmd), "P%x=", num);
- hexify(cmd + cmd_len, (const char *)buf, 4, sizeof(cmd));
+ hexify(cmd + cmd_len, buf, 4, sizeof(cmd));
result = icdi_send_cmd(handle, cmd);
if (result != ERROR_OK)