[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[screen-devel] [PATCH 7/8] Display: Convert strlen_onscreen to be unsign
From: |
Kieran Bingham |
Subject: |
[screen-devel] [PATCH 7/8] Display: Convert strlen_onscreen to be unsigned like strlen |
Date: |
Sun, 4 Oct 2015 16:52:32 +0100 |
Currently there are different use cases of both signed and unsigned
char arrays passed into this function.
Upon initial examination of the function, I believe that it is safe
to use an unsigned type, matching the c library strlen declaration,
and then unifying calls so that they do not have to simply cast
the array types.
The only part of the function which uses the actual (signed/unsigned)
type of the char is the call to FromUtf8() which itself converts to a
signed int.
Converting to use signed char* here seems to be a reasonable fix for the
compiler warnings. (rather than casting the warning lines to unsigned)
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 db7b0d5..72f3236 100644
--- a/src/display.c
+++ b/src/display.c
@@ -1581,7 +1581,7 @@ static void RemoveStatusMinWait()
RemoveStatus();
}
-static int strlen_onscreen(unsigned char *c, unsigned char *end)
+static int strlen_onscreen(char *c, char *end)
{
int len = 0;
while (*c && (!end || c < end)) {
@@ -1608,7 +1608,7 @@ static int PrePutWinMsg(char *s, int start, int max)
Ideally, this would not be necessary. But fixing it the Right Way
will
probably take way more time. So this will have to do for now. */
if (D_encoding == UTF8) {
- int chars = strlen_onscreen((unsigned char *)(s + start),
(unsigned char *)(s + max));
+ int chars = strlen_onscreen((s + start), (s + max));
D_encoding = 0;
PutWinMsg(s, start, max + ((max - start) - chars)); /*
Multibyte count */
D_encoding = UTF8;
--
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, 2015/10/08
- [screen-devel] [PATCH 7/8] Display: Convert strlen_onscreen to be unsigned like strlen,
Kieran Bingham <=
- [screen-devel] [PATCH 8/8] WinMsgBuf: Fix const qualifier in wmbc_mergewmb, Kieran Bingham, 2015/10/08