The semihosting interface has a strange convention for read/write where
the unused amount of buffer must be returned. We failed to return the
total buffer size when the local read() call returned 0.
Signed-off-by: Nicolas Pitre <nico@marvell.com>
} else {
result = read(fd, buf, l);
armv4_5->semihosting_errno = errno;
} else {
result = read(fd, buf, l);
armv4_5->semihosting_errno = errno;
retval = target_write_buffer(target, a, result, buf);
if (retval != ERROR_OK) {
free(buf);
retval = target_write_buffer(target, a, result, buf);
if (retval != ERROR_OK) {
free(buf);