|
From: Alexander G. <de...@ma...> - 2021-03-05 05:10:03
|
I’m working on API.
By the way. I think there is a bug(jlink.c:2032):
unsigned available_length = JLINK_TAP_BUFFER_SIZE - tap_length / 8;
if (!available_length ||
(in && pending_scan_results_length == MAX_PENDING_SCAN_RESULTS)) {
if (jlink_flush() != ERROR_OK)
return;
available_length = JLINK_TAP_BUFFER_SIZE;
}
struct pending_scan_result *pending_scan_result =
&pending_scan_results_buffer[pending_scan_results_length];
unsigned scan_length = length > available_length ?
available_length : length;
Here length is amount of bits, but available_length is amount of bytes! So this expression seems to be wrong.
Also during debug i found that first condition becomes true only when second clause is true — pending_scan_results_length == MAX_PENDING_SCAN_RESULTS.
And more over condition "!available_length" — looks very strange due to formula which calculates it.
I would correct it all like that:
int available_length = (JLINK_TAP_BUFFER_SIZE * 8) - tap_length;
if (available_length < length ||
(in && pending_scan_results_length == MAX_PENDING_SCAN_RESULTS)) {
if (jlink_flush() != ERROR_OK)
return;
available_length = JLINK_TAP_BUFFER_SIZE * 8;
}
struct pending_scan_result *pending_scan_result =
&pending_scan_results_buffer[pending_scan_results_length];
unsigned scan_length = length > available_length ?
available_length : length;
--
Alexander Gabitov
|