commit b3b28414fd4050514ac583ba72060574d74a1bab
Author:     Quentin Rameau <[email protected]>
AuthorDate: Fri Feb 17 12:26:07 2017 +0100
Commit:     Quentin Rameau <[email protected]>
CommitDate: Fri Feb 17 23:04:55 2017 +0100

    [libc] Fix memcmp return value

diff --git a/libc/src/memcmp.c b/libc/src/memcmp.c
index 737e0e8..8cf35f0 100644
--- 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;
 }

Reply via email to