tests/xe_madvise: fix cross-compilation error on ARM
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
@@ -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
Quoted 27 lines · Arvind Yadav
Casting a pointer to
uint64_ttriggers -Werror=pointer-to-int-cast on 32-bit ARM wheresizeof(void *)is 4 butsizeof(uint64_t)is 8.Use
igt_assert(ptr == MAP_FAILED)instead ofigt_assert_eq_u64()which avoids the cast entirely.Suggested-by Nishit Sharma <[email protected]>Signed-off-by Varun Gupta <[email protected]>Signed-off-by Arvind Yadav <[email protected]>--- tests/intel/xe_madvise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tests/intel/xe_madvise.c +1
-1@@ -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:
Hi Arvind,
Quoted 9 lines · Arvind Yadav
Casting a pointer to
uint64_ttriggers -Werror=pointer-to-int-cast on 32-bit ARM wheresizeof(void *)is 4 butsizeof(uint64_t)is 8.Use
igt_assert(ptr == MAP_FAILED)instead ofigt_assert_eq_u64()which avoids the cast entirely.Suggested-by Nishit Sharma <[email protected]>Signed-off-by Varun Gupta <[email protected]>Signed-off-by Arvind Yadav <[email protected]>
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@@ -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