]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
tmem: two wrongs (or three lefts and a wrong) make a right
authorKeir Fraser <keir@xen.org>
Wed, 15 Dec 2010 10:32:22 +0000 (10:32 +0000)
committerKeir Fraser <keir@xen.org>
Wed, 15 Dec 2010 10:32:22 +0000 (10:32 +0000)
These two bugs apparently complement each other enough that
they escaped problems in my testing, but eventually gum
up the works and are obviously horribly wrong.

Found while developing tmem for native Linux.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
xen-unstable changeset:   22525:01f3b3509023
xen-unstable date:        Wed Dec 15 10:27:18 2010 +0000

xen/common/tmem.c

index 8a5272bf9df15f80182dc2b5483338a2faebc846..f1f93728c70ac0b287dd72064916f7521d03f9a0 100644 (file)
@@ -863,17 +863,17 @@ int oid_compare(OID *left, OID *right)
         {
             if ( left->oid[0] == right->oid[0] )
                 return 0;
-            else if ( left->oid[0] < left->oid[0] )
+            else if ( left->oid[0] < right->oid[0] )
                 return -1;
             else
                 return 1;
         }
-        else if ( left->oid[1] < left->oid[1] )
+        else if ( left->oid[1] < right->oid[1] )
             return -1;
         else
             return 1;
     }
-    else if ( left->oid[2] < left->oid[2] )
+    else if ( left->oid[2] < right->oid[2] )
         return -1;
     else
         return 1;
@@ -970,7 +970,7 @@ static NOINLINE int obj_rb_insert(struct rb_root *root, obj_t *obj)
     {
         this = container_of(*new, obj_t, rb_tree_node);
         parent = *new;
-        switch ( oid_compare(&obj->oid, &this->oid) )
+        switch ( oid_compare(&this->oid, &obj->oid) )
         {
             case 0:
                 return 0;