From ff036dcc7df8d27aa087d71c7e024ab81d550962 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 20 Nov 2010 13:52:41 +0800 Subject: [PATCH] Fixed memcmp error (checks 1 more byte than it should) --- Kernel/arch/x86/lib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Kernel/arch/x86/lib.c b/Kernel/arch/x86/lib.c index 9287d9c3..1f563948 100644 --- a/Kernel/arch/x86/lib.c +++ b/Kernel/arch/x86/lib.c @@ -189,15 +189,16 @@ void *memsetd(void *Dest, Uint32 Val, size_t Num) */ int memcmp(const void *m1, const void *m2, size_t Num) { - if( Num == 0 ) return 1; // No bytes are always identical + if( Num == 0 ) return 0; // No bytes are always identical while(Num--) { - if(*(Uint8*)m1 != *(Uint8*)m2) break; + if(*(Uint8*)m1 != *(Uint8*)m2) + return *(Uint8*)m1 - *(Uint8*)m2; m1 ++; m2 ++; } - return *(Uint8*)m1 - *(Uint8*)m2; + return 0; } /** -- 2.20.1