Fixed memcmp error (checks 1 more byte than it should)
authorJohn Hodge <[email protected]>
Sat, 20 Nov 2010 05:52:41 +0000 (13:52 +0800)
committerJohn Hodge <[email protected]>
Sat, 20 Nov 2010 05:52:41 +0000 (13:52 +0800)
Kernel/arch/x86/lib.c

index 9287d9c..1f56394 100644 (file)
@@ -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;
 }
 
 /**

UCC git Repository :: git.ucc.asn.au