public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] tests/i915/gen_mmap: fix no-op loops
@ 2019-05-07 12:44 Simon Ser
  2019-05-07 13:54 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Simon Ser @ 2019-05-07 12:44 UTC (permalink / raw)
  To: igt-dev

The loop condition is never satisfied, since after filling the array i > 0. For
this reason the loop is always a no-op.

Use a more conventional loop instead.

Fixes: 964e39159c64 ("tests/i915/gem_mmap: Add invalid parameters tests")
Signed-off-by: Simon Ser <simon.ser@intel.com>
Cc: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/gem_mmap.c     | 7 ++++---
 tests/i915/gem_mmap_gtt.c | 7 ++++---
 tests/i915/gem_mmap_wc.c  | 7 ++++---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/tests/i915/gem_mmap.c b/tests/i915/gem_mmap.c
index d1b10013a1b8..c96aa2c0a7a5 100644
--- a/tests/i915/gem_mmap.c
+++ b/tests/i915/gem_mmap.c
@@ -158,14 +158,15 @@ igt_main
 	igt_subtest("bad-object") {
 		uint32_t real_handle = gem_create(fd, 4096);
 		uint32_t handles[20];
-		int i = 0;
+		size_t i = 0, len;

 		handles[i++] = 0xdeadbeef;
 		for(int bit = 0; bit < 16; bit++)
 			handles[i++] = real_handle | (1 << (bit + 16));
-		handles[i] = real_handle + 1;
+		handles[i++] = real_handle + 1;
+		len = i;

-		for (; i < 0; i--) {
+		for (i = 0; i < len; ++i) {
 			struct drm_i915_gem_mmap arg = {
 				.handle = handles[i],
 				.size = 4096,
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index 9a670f030149..034658e64990 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -886,14 +886,15 @@ igt_main
 	igt_subtest("bad-object") {
 		uint32_t real_handle = gem_create(fd, 4096);
 		uint32_t handles[20];
-		int i = 0;
+		size_t i = 0, len;

 		handles[i++] = 0xdeadbeef;
 		for(int bit = 0; bit < 16; bit++)
 			handles[i++] = real_handle | (1 << (bit + 16));
-		handles[i] = real_handle + 1;
+		handles[i++] = real_handle + 1;
+		len = i;

-		for (; i < 0; i--) {
+		for (i = 0; i < len; ++i) {
 			struct drm_i915_gem_mmap_gtt arg = {
 				.handle = handles[i],
 			};
diff --git a/tests/i915/gem_mmap_wc.c b/tests/i915/gem_mmap_wc.c
index 159eedbf4cfb..63538f791aae 100644
--- a/tests/i915/gem_mmap_wc.c
+++ b/tests/i915/gem_mmap_wc.c
@@ -496,14 +496,15 @@ igt_main
 	igt_subtest("bad-object") {
 		uint32_t real_handle = gem_create(fd, 4096);
 		uint32_t handles[20];
-		int i = 0;
+		size_t i = 0, len;

 		handles[i++] = 0xdeadbeef;
 		for(int bit = 0; bit < 16; bit++)
 			handles[i++] = real_handle | (1 << (bit + 16));
-		handles[i] = real_handle + 1;
+		handles[i++] = real_handle + 1;
+		len = i;

-		for (; i < 0; i--) {
+		for (i = 0; i < len; ++i) {
 			struct drm_i915_gem_mmap arg = {
 				.handle = handles[i],
 				.size = 4096,
--
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-06-03 15:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-07 12:44 [igt-dev] [PATCH i-g-t] tests/i915/gen_mmap: fix no-op loops Simon Ser
2019-05-07 13:54 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-05-07 14:31 ` [igt-dev] [PATCH i-g-t] " Chris Wilson
2019-05-07 15:10   ` Ser, Simon
2019-05-08 11:27     ` Jani Nikula
2019-05-07 18:42 ` [igt-dev] ✗ Fi.CI.IGT: failure for " Patchwork
2019-05-08  9:54   ` Ser, Simon
2019-05-20  6:26     ` Ser, Simon
2019-05-27 15:25     ` Ser, Simon
2019-05-31 11:36     ` Ser, Simon
2019-05-31 11:41       ` Chris Wilson
2019-05-31 11:52         ` Ser, Simon
2019-06-03 15:18           ` Daniel Vetter
2019-05-10 15:39 ` [igt-dev] [PATCH i-g-t] " Antonio Argenziano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox