[hackers] [scc] [libc] Fix memcmp return value || Quentin Rameau

From: <git_AT_suckless.org>
Date: Fri, 17 Feb 2017 23:06:58 +0100 (CET)

commit b3b28414fd4050514ac583ba72060574d74a1bab
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Fri Feb 17 12:26:07 2017 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
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
_AT_@ -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;
 }
Received on Fri Feb 17 2017 - 23:06:58 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 17 2017 - 23:12:43 CET