From ac044784a6ce64ff15610d4b70750065a7f01b80 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 1 Sep 2015 21:07:54 +0200 Subject: start on makefile and fixing warnings and errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/string/strchr.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/string/strchr.c') diff --git a/src/string/strchr.c b/src/string/strchr.c index 21345d4..2b49c2e 100644 --- a/src/string/strchr.c +++ b/src/string/strchr.c @@ -16,7 +16,9 @@ * along with this program. If not, see . */ #include -#include + + +# pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" @@ -31,9 +33,10 @@ */ void* memchr(const void* segment, int c, size_t size) { + char* s = segment; while (size--) - if (*segment++ == c) - return segment - 1; + if (*s++ == c) + return s - 1; return NULL; } @@ -50,9 +53,10 @@ void* memchr(const void* segment, int c, size_t size) */ void* rawmemchr(const void* segment, int c) { + char* s = segment; for (;;) - if (*segment++ == c) - return segment - 1; + if (*s++ == c) + return s - 1; } @@ -71,9 +75,10 @@ void* rawmemchr(const void* segment, int c) */ void* memrchr(const void* segment, int c, size_t size) { + char* s = segment; while (size--) - if (segment[size] == c) - return segment + size; + if (s[size] == c) + return s + size; return NULL; } -- cgit v1.2.3-70-g09d2