dirtyJtag: cpplint/cppcheck

This commit is contained in:
Gwenhael Goavec-Merou 2021-06-20 16:39:19 +02:00
parent 0a7fd93a08
commit 40d9bc3ea7
1 changed files with 22 additions and 21 deletions

View File

@ -60,7 +60,8 @@ struct version_specific
uint16_t max_bits; // max bit count that can be transferred
};
static version_specific v_options[4] ={{0, 240}, {0, 240}, {NO_READ, 496}, {NO_READ, 4000}};
static version_specific v_options[4] ={{0, 240}, {0, 240}, {NO_READ, 496},
{NO_READ, 4000}};
enum dirtyJtagSig {
@ -255,7 +256,7 @@ int DirtyJtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
uint8_t tx_cpy[real_byte_len];
uint8_t tx_buf[512], rx_buf[512];
uint8_t *tx_ptr = tx, *rx_ptr = rx;
uint8_t *tx_ptr, *rx_ptr = rx;
if (tx)
memcpy(tx_cpy, tx, real_byte_len);
@ -265,9 +266,11 @@ int DirtyJtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
tx_buf[0] = CMD_XFER | (rx ? 0 : v_options[_version].no_read);
uint16_t max_bit_transfer_length = v_options[_version].max_bits;
assert(max_bit_transfer_length %8 == 0);//need to cut the bits on byte size.
// need to cut the bits on byte size.
assert(max_bit_transfer_length % 8 == 0);
while (real_bit_len != 0) {
uint16_t bit_to_send = (real_bit_len > max_bit_transfer_length) ? max_bit_transfer_length : real_bit_len;
uint16_t bit_to_send = (real_bit_len > max_bit_transfer_length) ?
max_bit_transfer_length : real_bit_len;
size_t byte_to_send = (bit_to_send + 7) / 8;
size_t header_offset = 0;
if (_version == 3) {
@ -290,9 +293,11 @@ int DirtyJtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
actual_length = 0;
int ret = libusb_bulk_transfer(dev_handle, DIRTYJTAG_WRITE_EP,
(unsigned char *)tx_buf, (byte_to_send + header_offset), &actual_length, 1000);
(unsigned char *)tx_buf, (byte_to_send + header_offset),
&actual_length, 1000);
if ((ret < 0) || (actual_length != (int)(byte_to_send + header_offset))) {
cerr << "writeTDI: fill: usb bulk write failed " << ret << "actual length: " << actual_length << endl;
cerr << "writeTDI: fill: usb bulk write failed " << ret <<
"actual length: " << actual_length << endl;
return EXIT_FAILURE;
}
// cerr << actual_length << ", " << bit_to_send << endl;
@ -333,7 +338,6 @@ int DirtyJtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
if (rx)
{
int actual_length;
mask |= SIG_TCK;
uint8_t buf[] = {
CMD_SETSIG,
@ -374,11 +378,8 @@ int DirtyJtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
return -EXIT_FAILURE;
}
}
else
{
if (toggleClk(SIG_TMS, last_bit, 1))
{
} else {
if (toggleClk(SIG_TMS, last_bit, 1)) {
cerr << "writeTDI: last bit error" << endl;
return -EXIT_FAILURE;
}