Skip to content
Permalink
Browse files

libc: fix memchr() prototype

The standard memchr() uses an int for its second argument.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
  • Loading branch information...
Nicolas Pitre authored and andrewboie committed Jul 9, 2019
1 parent 55dc481 commit ffab1979286cfaf05cfe8ecdfa3dfe93349e86b9
Showing with 3 additions and 3 deletions.
  1. +1 −1 lib/libc/minimal/include/string.h
  2. +2 −2 lib/libc/minimal/source/string/string.c
@@ -36,7 +36,7 @@ extern void *memmove(void *d, const void *s, size_t n);
extern void *memcpy(void *_MLIBC_RESTRICT d, const void *_MLIBC_RESTRICT s,
size_t n);
extern void *memset(void *buf, int c, size_t n);
extern void *memchr(const void *s, unsigned char c, size_t n);
extern void *memchr(const void *s, int c, size_t n);

#ifdef __cplusplus
}
@@ -357,13 +357,13 @@ void *memset(void *buf, int c, size_t n)
* @return pointer to start of found byte
*/

void *memchr(const void *s, unsigned char c, size_t n)
void *memchr(const void *s, int c, size_t n)
{
if (n != 0) {
const unsigned char *p = s;

do {
if (*p++ == c) {
if (*p++ == (unsigned char)c) {
return ((void *)(p - 1));
}

0 comments on commit ffab197

Please sign in to comment.
You can’t perform that action at this time.