Sprinkle igt_assert(ptr) after gem_mmap__{cpu,gtt,wc}

Do the following
 ptr = gem_mmap__{cpu,gtt,wc}()
+igt_assert(ptr);

whenever the code doesn't handle the NULL ptr in any kind of
specific way.

Makes it easier to move the assert into gem_mmap__{cpu,gtt,wc}() itself.

Mostly done with coccinelle, with some manual cleanups:
@@
identifier I;
@@
<... when != igt_assert(I)
     when != igt_require(I)
     when != igt_require_f(I, ...)
     when != I != NULL
     when != I == NULL
(
  I = gem_mmap__gtt(...);
+ igt_assert(I);
|
  I = gem_mmap__cpu(...);
+ igt_assert(I);
|
  I = gem_mmap__wc(...);
+ igt_assert(I);
)
...>

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Ville Syrjälä
2015-10-09 18:19:34 +03:00
parent 91d295cf06
commit 7eaae3c201
23 changed files with 77 additions and 9 deletions
+6 -2
View File
@@ -89,15 +89,17 @@ static void test_streaming(int fd, int mode, int sync)
case 0: /* cpu/snoop */
gem_set_caching(fd, src, I915_CACHING_CACHED);
s = gem_mmap__cpu(fd, src, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE);
igt_assert(s);
break;
case 1: /* gtt */
s = gem_mmap__gtt(fd, src, OBJECT_SIZE, PROT_READ | PROT_WRITE);
igt_assert(s);
break;
case 2: /* wc */
s = gem_mmap__wc(fd, src, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE);
igt_assert(s);
break;
}
igt_assert(s);
*s = 0; /* fault the object into the mappable range first (for GTT) */
d = gem_mmap__cpu(fd, dst, 0, OBJECT_SIZE, PROT_READ);
@@ -284,15 +286,17 @@ static void test_batch(int fd, int mode, int reverse)
case 0: /* cpu/snoop */
igt_require(gem_has_llc(fd));
base = gem_mmap__cpu(fd, exec[BATCH].handle, 0, batch_size, PROT_READ | PROT_WRITE);
igt_assert(base);
break;
case 1: /* gtt */
base = gem_mmap__gtt(fd, exec[BATCH].handle, batch_size, PROT_READ | PROT_WRITE);
igt_assert(base);
break;
case 2: /* wc */
base = gem_mmap__wc(fd, exec[BATCH].handle, 0, batch_size, PROT_READ | PROT_WRITE);
igt_assert(base);
break;
}
igt_assert(base);
*base = 0; /* fault the object into the mappable range first */
gem_write(fd, exec[BATCH].handle, 0, tmp, sizeof(tmp));