From: Jarkko Sakkinen <jarkko@kernel.org>
To: longlong yan <yanlonglong@kylinos.cn>
Cc: dave.hansen@linux.intel.com, shuah@kernel.org,
linux-sgx@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/sgx: use MAP_FAILED for mmap error check
Date: Wed, 22 Jul 2026 18:33:55 +0300 [thread overview]
Message-ID: <amDi4-eN3zGXExOy@kernel.org> (raw)
In-Reply-To: <20260720025443.506-1-yanlonglong@kylinos.cn>
On Mon, Jul 20, 2026 at 10:54:43AM +0800, longlong yan wrote:
> Replace the direct comparison with (void *)-1 with the standard
> MAP_FAILED macro when checking mmap()
>
> Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
> ---
> 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
>
Yeah, why not:
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
It does document test cases better.
BR, Jarkko
prev parent reply other threads:[~2026-07-22 15:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 2:54 [PATCH] selftests/sgx: use MAP_FAILED for mmap error check longlong yan
2026-07-22 2:17 ` Huang, Kai
2026-07-22 15:33 ` Jarkko Sakkinen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=amDi4-eN3zGXExOy@kernel.org \
--to=jarkko@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=yanlonglong@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox