Blame SOURCES/0001-testutils-fix-range_is_mapped.patch

39b936
From 192ac21a3c057c5dedca4cdd1bf700f38992030c Mon Sep 17 00:00:00 2001
39b936
Message-Id: <192ac21a3c057c5dedca4cdd1bf700f38992030c.1496667760.git.jstancek@redhat.com>
39b936
From: Jan Stancek <jstancek@redhat.com>
39b936
Date: Thu, 1 Jun 2017 09:48:41 +0200
39b936
Subject: [PATCH v2 1/2] testutils: fix range_is_mapped()
39b936
39b936
It doesn't return correct value when tested region is
39b936
completely inside existing mapping:
39b936
39b936
  +--------------------------------------+
39b936
  ^ start                                ^ end
39b936
           +----------------+
39b936
           ^ low            ^ high
39b936
39b936
Rather than testing for all combinations of 2 regions overlapping,
39b936
flip the condition and test if they don't overlap.
39b936
39b936
Signed-off-by: Jan Stancek <jstancek@redhat.com>
39b936
---
39b936
 tests/testutils.c | 22 ++++++++++++++++------
39b936
 1 file changed, 16 insertions(+), 6 deletions(-)
39b936
39b936
This is a v2 series for:
39b936
  https://groups.google.com/forum/#!topic/libhugetlbfs/tAsWjuJ7x8k
39b936
39b936
diff --git a/tests/testutils.c b/tests/testutils.c
39b936
index 629837045465..f42852e1938b 100644
39b936
--- a/tests/testutils.c
39b936
+++ b/tests/testutils.c
39b936
@@ -190,19 +190,29 @@ int range_is_mapped(unsigned long low, unsigned long high)
39b936
 			return -1;
39b936
 		}
39b936
 
39b936
-		if ((start >= low) && (start < high)) {
39b936
+		/*
39b936
+		 * (existing mapping)    (tested region)
39b936
+		 * +----------------+      +.......+
39b936
+		 * ^start           ^end   ^ low   ^high
39b936
+		 */
39b936
+		if (low >= end) {
39b936
 			fclose(f);
39b936
-			return 1;
39b936
+			return 0;
39b936
 		}
39b936
-		if ((end >= low) && (end < high)) {
39b936
+
39b936
+		/*
39b936
+		 * (tested region)  (existing mapping)
39b936
+		 *     +.....+      +----------------+
39b936
+		 *     ^low  ^high  ^ start          ^end
39b936
+		 */
39b936
+		if (high <= start) {
39b936
 			fclose(f);
39b936
-			return 1;
39b936
+			return 0;
39b936
 		}
39b936
-
39b936
 	}
39b936
 
39b936
 	fclose(f);
39b936
-	return 0;
39b936
+	return 1;
39b936
 }
39b936
 
39b936
 /*
39b936
-- 
39b936
1.8.3.1
39b936