From d880a9a797b211cb3b3b3780c37217f3d7a5424a Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 28 Apr 2014 18:35:50 +0200 Subject: [PATCH] Fix memchr(3) missing an unsigned char cast. --- libc/string/memchr.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libc/string/memchr.cpp b/libc/string/memchr.cpp index e0b9d925..1116ee93 100644 --- a/libc/string/memchr.cpp +++ b/libc/string/memchr.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2014. This file is part of the Sortix C Library. @@ -22,15 +22,13 @@ *******************************************************************************/ -#include #include extern "C" void* memchr(const void* s, int c, size_t size) { - const uint8_t* buf = (const uint8_t*) s; + const unsigned char* buf = (const unsigned char*) s; for ( size_t i = 0; i < size; i++ ) - { - if ( buf[i] == c ) { return (void*) (buf + i); } - } + if ( buf[i] == (unsigned char) c ) + return (void*) (buf + i); return NULL; }