ARM semihosting: fix EOF handling with SYS_READ
authorNicolas Pitre <nico@fluxnic.net>
Tue, 2 Feb 2010 05:05:42 +0000 (00:05 -0500)
committerNicolas Pitre <nico@fluxnic.net>
Tue, 2 Feb 2010 05:05:42 +0000 (00:05 -0500)
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>
src/target/arm_semihosting.c

index c41c5a0087f6fc5350b8ed1402a448c7f8836219..9b853d9f942d08da4fc29412238948ca6a09eaaa 100644 (file)
@@ -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);