[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[screen-devel] [PATCH 4/8] Process: Pointer arithmetic comparison with u
From: |
Kieran Bingham |
Subject: |
[screen-devel] [PATCH 4/8] Process: Pointer arithmetic comparison with unsigned size_t |
Date: |
Sun, 4 Oct 2015 16:52:29 +0100 |
These two fixes cast the resultant pointer calculation to a
uintptr_t. This type is unsigned, (matching size_t) but specifically
set to store pointers.
I dislike simply casting to remove warnings, but in this instance
I think this may be reasonable. The aim of both of these cases is to
loop for the length of the buffer, so one alternative could be to
extract the calculation. If this is preferred by the developers,
we can drop this patch.
Signed-off-by: Kieran Bingham <address@hidden>
---
src/process.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/process.c b/src/process.c
index 86864f5..40c81f8 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4827,7 +4827,7 @@ static void ColonFin(char *buf, size_t len, void *data)
int showmessage = 0;
char *s = buf;
- while (*s && s - buf < len)
+ while (*s && (uintptr_t)(s - buf) < len)
if (*s++ == ' ')
return;
@@ -4848,7 +4848,7 @@ static void ColonFin(char *buf, size_t len, void *data)
s = mbuf;
for (l = m - 1; l >= 0 && strncmp(buf,
comms[l].name, len) == 0; l--) ;
for (m = ++l;
- m <= r && strncmp(buf, comms[m].name, len)
== 0 && s - mbuf < sizeof(mbuf); m++)
+ m <= r && strncmp(buf, comms[m].name, len)
== 0 && (uintptr_t)(s - mbuf) < sizeof(mbuf); m++)
s += snprintf(s, sizeof(mbuf) - (s -
mbuf), " %s", comms[m].name);
if (l < m - 1) {
if (showmessage)
--
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, 2015/10/08
- [screen-devel] [PATCH 4/8] Process: Pointer arithmetic comparison with unsigned size_t,
Kieran Bingham <=
- [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