Hi More cleanups.
- Lauri
>From ffe2ba1908b8f0855163f750d269f56b040c2ac4 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <[email protected]> Date: Mon, 30 Jul 2012 19:35:50 +0300 Subject: [PATCH] string: Fix some signed-unsigned warnings, plus one wrongly declared variable (static > const) Signed-off-by: Lauri Kasanen <[email protected]> --- src/mk_string.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mk_string.c b/src/mk_string.c index 48eac2a..142695b 100644 --- a/src/mk_string.c +++ b/src/mk_string.c @@ -177,7 +177,7 @@ struct mk_list *mk_string_split_line(const char *line) if (end >= 0 && end + i < len) { end += i; - if (i == end) { + if (i == (unsigned int) end) { i++; continue; } @@ -225,7 +225,7 @@ char *mk_string_build(char **buffer, unsigned long *len, va_list ap; int length; char *ptr; - static size_t _mem_alloc = 64; + const size_t _mem_alloc = 64; size_t alloc = 0; /* *buffer *must* be an empty/NULL buffer */ @@ -241,7 +241,11 @@ char *mk_string_build(char **buffer, unsigned long *len, length = vsnprintf(*buffer, alloc, format, ap); va_end(ap); - if (length >= alloc) { + if (length < 0) { + return NULL; + } + + if ((unsigned int) length >= alloc) { ptr = realloc(*buffer, length + 1); if (!ptr) { return NULL; @@ -254,10 +258,6 @@ char *mk_string_build(char **buffer, unsigned long *len, va_end(ap); } - if (length < 0) { - return NULL; - } - ptr = *buffer; ptr[length] = '\0'; *len = length; -- 1.7.2.1
_______________________________________________ Monkey mailing list [email protected] http://lists.monkey-project.com/listinfo/monkey
