xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tmem: two wrongs (or three lefts and a wrong) make a right
@ 2010-12-13 18:45 Dan Magenheimer
  0 siblings, 0 replies; only message in thread
From: Dan Magenheimer @ 2010-12-13 18:45 UTC (permalink / raw)
  To: xen-devel, Keir Fraser

[-- Attachment #1: Type: text/plain, Size: 1473 bytes --]

(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@oracle.com>

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 #2: tmem-oidbugs.patch --]
[-- Type: application/octet-stream, Size: 1114 bytes --]

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 #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-12-13 18:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-13 18:45 [PATCH] tmem: two wrongs (or three lefts and a wrong) make a right Dan Magenheimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).