screen-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[screen-devel] [PATCH 6/8] Display: Unsigned comparison causes unreachab


From: Kieran Bingham
Subject: [screen-devel] [PATCH 6/8] Display: Unsigned comparison causes unreachable code
Date: Sun, 4 Oct 2015 16:52:31 +0100

The number of bytes read by read is returned in a ssize_t so that
errors can be propogated through the return code. Previously we
were storing this return value in an unsigned size_t and then checking
this value against if (size < 0) (Which can never be true)

Simple fix here is to change the size storage to a signed ssize_t

Now that the size is signed, the parameter passed to LayProcess
should be unsigned, so we cast there instead. It's more important
to keep the read calls using a signed value here.

Signed-off-by: Kieran Bingham <address@hidden>
---
 src/display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/display.c b/src/display.c
index f8f6bea..db7b0d5 100644
--- a/src/display.c
+++ b/src/display.c
@@ -2502,7 +2502,7 @@ static void disp_writeev_fn(Event *event, void *data)
 
 static void disp_readev_fn(Event *event, void *data)
 {
-       size_t size;
+       ssize_t size;
        char buf[IOSIZE];
        Canvas *cv;
 
@@ -2566,7 +2566,7 @@ static void disp_readev_fn(Event *event, void *data)
                                flayer = &p->w_layer;
                                bufp = buf;
                                while (size > 0)
-                                       LayProcess(&bufp, &size);
+                                       LayProcess(&bufp, (size_t*)&size);
                                return;
                        }
                zmodem_abort(0, display);
-- 
2.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]