[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg-devel
Subject:    [PATCH xserver] xfree86: Fix X -configure driver sort yet again
From:       Adam Jackson <ajax () redhat ! com>
Date:       2017-06-27 15:18:48
Message-ID: 20170627151848.13480-1-ajax () redhat ! com
[Download RAW message or body]

There were two bugs here: The comparison function was not stable when
one or more of the drivers being compared is a fallback, and the last
driver in the list would never be moved.

Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 hw/xfree86/common/xf86Configure.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 5f9643a52..07d3c6319 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -554,15 +554,15 @@ driver_sort(const void *_l, const void *_r)
     if (left == -1 && right == -1)
 	return strcmp(l, r);
 
-    /* left is a fallback */
-    if (left >= 0)
+    /* left is a fallback, right is not */
+    if (left >= 0 && right == -1)
 	return 1;
 
-    /* right is a fallback */
-    if (right >= 0)
+    /* right is a fallback, left is not */
+    if (right >= 0 && left == -1)
 	return -1;
 
-    /* both are fallbacks, which is worse */
+    /* both are fallbacks, decide which is worse */
     return left - right;
 }
 
@@ -573,7 +573,6 @@ fixup_video_driver_list(const char **drivers)
 
     /* walk to the end of the list */
     for (end = drivers; *end && **end; end++);
-    end--;
 
     qsort(drivers, end - drivers, sizeof(const char *), driver_sort);
 }
-- 
2.13.0

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic