From 3d2d5dcc9c27b84dc2e5e9ed53be0f784a450042 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Tue, 2 Feb 2010 00:05:42 -0500 Subject: ARM semihosting: fix EOF handling with SYS_READ 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 --- src/target/arm_semihosting.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/target/arm_semihosting.c b/src/target/arm_semihosting.c index c41c5a00..9b853d9f 100644 --- a/src/target/arm_semihosting.c +++ b/src/target/arm_semihosting.c @@ -190,7 +190,7 @@ static int do_semihosting(struct target *target) } else { result = read(fd, buf, l); armv4_5->semihosting_errno = errno; - if (result > 0) { + if (result >= 0) { retval = target_write_buffer(target, a, result, buf); if (retval != ERROR_OK) { free(buf); -- cgit v1.2.3