From: John Hodge Date: Sat, 20 Nov 2010 05:52:41 +0000 (+0800) Subject: Fixed memcmp error (checks 1 more byte than it should) X-Git-Tag: rel0.07~57 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ff036dcc7df8d27aa087d71c7e024ab81d550962;hp=26e66aa0a682e2f1a5d9328b6037b5779310f8f3;p=tpg%2Facess2.git Fixed memcmp error (checks 1 more byte than it should) --- 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; } /**