[SerialICE] Patch set updated for serialice: qemu-0.15.x/serialice-com: Return I/O errors

Patrick Rudolph (siro@das-labor.org) gerrit at coreboot.org
Thu Apr 28 14:19:59 CEST 2016


Patrick Rudolph (siro at das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14508

-gerrit

commit b7996cdb2291af87a0b72de3a13afb924e152a67
Author: Patrick Rudolph <siro at das-labor.org>
Date:   Mon Apr 25 12:19:39 2016 +0200

    qemu-0.15.x/serialice-com: Return I/O errors
    
    Return I/O erros to calling function.
    Return -1 in serialice_write and serialice_read.
    
    Change-Id: I168093eaad897f2998c055e46acd88fe6a263947
    Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
 qemu-0.15.x/serialice-com.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/qemu-0.15.x/serialice-com.c b/qemu-0.15.x/serialice-com.c
index ee539f4..c9a8e8b 100644
--- a/qemu-0.15.x/serialice-com.c
+++ b/qemu-0.15.x/serialice-com.c
@@ -79,7 +79,8 @@ static int serialice_read(SerialICEState * state, void *buf, size_t nbyte)
     while (1) {
 #ifdef WIN32
         int ret = 0;
-        ReadFile(state->fd, buf, nbyte - bytes_read, &ret, NULL);
+        if (!ReadFile(state->fd, buf, nbyte - bytes_read, &ret, NULL))
+            return -1;
         if (!ret) {
             break;
         }
@@ -91,7 +92,7 @@ static int serialice_read(SerialICEState * state, void *buf, size_t nbyte)
         }
 
         if (ret == -1) {
-            break;
+            return -1;
         }
 #endif
 
@@ -116,16 +117,17 @@ static int serialice_write(SerialICEState * state, const void *buf,
     for (i = 0; i < (int)nbyte; i++) {
 #ifdef WIN32
         int ret = 0;
-        while (ret == 0) {
-            WriteFile(state->fd, buffer + i, 1, &ret, NULL);
-        }
+        if (!WriteFile(state->fd, buffer + i, 1, &ret, NULL))
+            return -1;
+
         ret = 0;
-        while (ret == 0) {
-            ReadFile(state->fd, &c, 1, &ret, NULL);
-        }
+        if (!ReadFile(state->fd, &c, 1, &ret, NULL))
+            return -1;
 #else
-        while (write(state->fd, buffer + i, 1) != 1) ;
-        while (read(state->fd, &c, 1) != 1) ;
+        if (write(state->fd, buffer + i, 1) != 1)
+            return -1;
+        if (read(state->fd, &c, 1) != 1)
+            return -1;
 #endif
         if (c != buffer[i] && !handshake_mode) {
             printf("Readback error! %x/%x\n", c, buffer[i]);



More information about the SerialICE mailing list