commit b3b28414fd4050514ac583ba72060574d74a1bab
parent e44d78d4ad53b34dfe71378974a9208022a5e784
Author: Quentin Rameau <quinq@fifth.space>
Date: Fri, 17 Feb 2017 12:26:07 +0100
[libc] Fix memcmp return value
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libc/src/memcmp.c b/libc/src/memcmp.c
@@ -7,7 +7,7 @@ memcmp(const void *s1, const void *s2, size_t n)
{
char *s = (char *) s1, *t = (char *) s2;
- while (n > 0 && *s++ != *t++)
- --n;
- return n != 0;
+ while (n > 0 && *s == *t)
+ --n, ++s, ++t;
+ return n ? (*s - *t) : 0;
}