WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] tmem: two wrongs (or three lefts and a wrong) make a

To: xen-devel@xxxxxxxxxxxxxxxxxxx, Keir Fraser <keir@xxxxxxx>
Subject: [Xen-devel] [PATCH] tmem: two wrongs (or three lefts and a wrong) make a right
From: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
Date: Mon, 13 Dec 2010 10:45:25 -0800 (PST)
Cc:
Delivery-date: Mon, 13 Dec 2010 10:48:39 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
(Please apply for 4.0.x and xen-unstable.)

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@xxxxxxxxxx>

diff -r 5393151a737b xen/common/tmem.c
--- a/xen/common/tmem.c Tue Sep 14 18:26:10 2010 +0100
+++ b/xen/common/tmem.c Mon Dec 13 11:37:57 2010 -0700
@@ -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
     {
         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;

Attachment: tmem-oidbugs.patch
Description: Binary data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] tmem: two wrongs (or three lefts and a wrong) make a right, Dan Magenheimer <=