[igt-dev] [PATCH i-g-t] tests/i915/gen_mmap: fix no-op loops
Simon Ser
simon.ser at intel.com
Tue May 7 12:44:41 UTC 2019
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 at intel.com>
Cc: Antonio Argenziano <antonio.argenziano at intel.com>
Cc: Chris Wilson <chris at 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
More information about the igt-dev
mailing list