Skip to contentSkip to conversation

tests/xe_madvise: fix cross-compilation error on ARM

PATCH In review Arvind Yadav 3 participants 3 messages Apr 20

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/xe_madvise: fix cross-compilation error on ARM

Casting a pointer to uint64_t triggers -Werror=pointer-to-int-cast on 32-bit ARM where sizeof(void *) is 4 but sizeof(uint64_t) is 8.

Use igt_assert(ptr == MAP_FAILED) instead of igt_assert_eq_u64() which avoids the cast entirely.

---
 tests/intel/xe_madvise.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/intel/xe_madvise.c +2 -2
index 805de793a..c728cc5c0 100644
@@ -198,7 +198,7 @@ static void test_purged_mmap_blocked(int fd)
 	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo), 0);
 
 	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
-	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
+	igt_assert(ptr == MAP_FAILED);
 	igt_assert_eq(errno, EINVAL);
 
 	gem_close(fd, bo);
@@ -340,7 +340,7 @@ static void test_dontneed_before_mmap(int fd)
 
 	/* mmap() on a DONTNEED BO must fail with EBUSY. */
 	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
-	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
+	igt_assert(ptr == MAP_FAILED);
 	igt_assert_eq(errno, EBUSY);
 
 	/* Restore to WILLNEED before cleanup */
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Arvind Yadav

Casting a pointer to uint64_t triggers -Werror=pointer-to-int-cast on 32-bit ARM where sizeof(void *) is 4 but sizeof(uint64_t) is 8.

Use igt_assert(ptr == MAP_FAILED) instead of igt_assert_eq_u64() which avoids the cast entirely.

---
  tests/intel/xe_madvise.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
tests/intel/xe_madvise.c +1 -1
index 805de793a..c728cc5c0 100644
@@ -198,7 +198,7 @@ static void test_purged_mmap_blocked(int fd)
  	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo), 0);
 
  	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
-	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
+	igt_assert(ptr == MAP_FAILED);
  	igt_assert_eq(errno, EINVAL);
 
  	gem_close(fd, bo);

tests/intel/xe_madvise.c static void test_dontneed_before_mmap(int fd) · line 346

Quoted 8 lines
tests/intel/xe_madvise.c +1 -1
@@ -340,7 +340,7 @@ static void test_dontneed_before_mmap(int fd)
 
  	/* mmap() on a DONTNEED BO must fail with EBUSY. */
  	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
-	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
+	igt_assert(ptr == MAP_FAILED);
  	igt_assert_eq(errno, EBUSY);
 
  	/* Restore to WILLNEED before cleanup */

LGTM:

#2 lore raw
In reply to Arvind Yadav

Hi Arvind,

Quoted 9 lines · Arvind Yadav

Casting a pointer to uint64_t triggers -Werror=pointer-to-int-cast on 32-bit ARM where sizeof(void *) is 4 but sizeof(uint64_t) is 8.

Use igt_assert(ptr == MAP_FAILED) instead of igt_assert_eq_u64() which avoids the cast entirely.

Thank you for fix but it was already fixed by recent commit

06dab255d tests/intel/xe_madvise: Fix armhf compilation

Regards,
Kamil

Quoted 29 lines
---
 tests/intel/xe_madvise.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/intel/xe_madvise.c +2 -2
index 805de793a..c728cc5c0 100644
@@ -198,7 +198,7 @@ static void test_purged_mmap_blocked(int fd)
 	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo), 0);
 
 	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
-	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
+	igt_assert(ptr == MAP_FAILED);
 	igt_assert_eq(errno, EINVAL);
 
 	gem_close(fd, bo);
@@ -340,7 +340,7 @@ static void test_dontneed_before_mmap(int fd)
 
 	/* mmap() on a DONTNEED BO must fail with EBUSY. */
 	ptr = mmap(NULL, bo_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mmo.offset);
-	igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
+	igt_assert(ptr == MAP_FAILED);
 	igt_assert_eq(errno, EBUSY);
 
 	/* Restore to WILLNEED before cleanup */
Signature · 1 line
2.43.0