[PATCH] selftests/sgx: use MAP_FAILED for mmap error check
From: longlong yan
Date: Sun Jul 19 2026 - 22:56:30 EST
Replace the direct comparison with (void *)-1 with the standard
MAP_FAILED macro when checking mmap()
Signed-off-by: longlong yan <yanlonglong@xxxxxxxxxx>
---
tools/testing/selftests/sgx/load.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/sgx/load.c b/tools/testing/selftests/sgx/load.c
index c9f658e44de6..6204ab0bae19 100644
--- a/tools/testing/selftests/sgx/load.c
+++ b/tools/testing/selftests/sgx/load.c
@@ -202,7 +202,7 @@ bool encl_load(const char *path, struct encl *encl, unsigned long heap_size)
}
ptr = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0);
- if (ptr == (void *)-1) {
+ if (ptr == MAP_FAILED) {
perror("mmap for read");
goto err;
}
@@ -215,7 +215,7 @@ bool encl_load(const char *path, struct encl *encl, unsigned long heap_size)
" If so, remount it executable: mount -o remount,exec /dev\n\n"
ptr = mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_SHARED, fd, 0);
- if (ptr == (void *)-1) {
+ if (ptr == MAP_FAILED) {
fprintf(stderr, ERR_MSG);
goto err;
}
--
2.43.0