[PATCH] selftests/sgx: use MAP_FAILED for mmap error check
longlong yan <[email protected]> Mon, 20 Jul 2026 10:54:43 +0800
| Newsgroups | org.kernel.vger.linux-sgx,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest |
|---|---|
| Message-ID | <[email protected]> |
Replace the direct comparison with (void *)-1 with the standard MAP_FAILED macro when checking mmap() Signed-off-by: longlong yan <[email protected]> --- 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