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

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