[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
- [screen-devel] [Trivial] Bugfixes and compiler warnings, Kieran Bingham, 2015/10/08
- [screen-devel] [PATCH 1/8] Makefile.in: Fix out of tree build, Kieran Bingham, 2015/10/08
- [screen-devel] [PATCH 2/8] Process: Fix sign-compare errors, Kieran Bingham, 2015/10/08
- [screen-devel] [PATCH 3/8] Process: Fix const qualifer loss in ShowWindows, Kieran Bingham, 2015/10/08
- [screen-devel] [PATCH 5/8] Process: Fix printf modifier warning, Kieran Bingham, 2015/10/08
- [screen-devel] [PATCH 6/8] Display: Unsigned comparison causes unreachable code,
Kieran Bingham <=
- [screen-devel] [PATCH 4/8] Process: Pointer arithmetic comparison with unsigned size_t, Kieran Bingham, 2015/10/08
- [screen-devel] [PATCH 7/8] Display: Convert strlen_onscreen to be unsigned like strlen, Kieran Bingham, 2015/10/08
- [screen-devel] [PATCH 8/8] WinMsgBuf: Fix const qualifier in wmbc_mergewmb, Kieran Bingham, 2015/10/08