[igt-dev] [PATCH i-g-t] lib: Fix strcmp() direction for bsearch.

Chris Wilson chris at chris-wilson.co.uk
Mon Sep 3 09:46:29 UTC 2018


I fluked out as vgem was the initial mid value, hidding the worst of the
errors as i915 matched with DRIVER_ANY.

Fixes: 20087bf22698 ("lib: Use a bsearch to find the module name")
Reported-by: Petri Latvala <petri.latvala at intel.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala at intel.com>
---
 lib/drmtest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index bfb38f1e9..adff1a81f 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -226,9 +226,9 @@ static int open_device(const char *name, unsigned int chipset)
 		int mid = start + (end - start) / 2;
 		int ret = strcmp(modules[mid].module, dev_name);
 		if (ret < 0) {
-			end = mid;
-		} else if (ret > 0) {
 			start = mid + 1;
+		} else if (ret > 0) {
+			end = mid;
 		} else {
 			chip = modules[mid].bit;
 			break;
-- 
2.19.0.rc1



More information about the igt-dev mailing list