public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] pkey: remove the ltp_ prefix from pkey functions
Date: Tue,  6 Aug 2024 10:31:05 +0800	[thread overview]
Message-ID: <20240806023105.20509-1-liwang@redhat.com> (raw)
In-Reply-To: <CAEemH2eF3B41E2nv1+-oMrCUTw7zfVrgCULRBaBe=Pk9roBUiQ@mail.gmail.com>

Suggested-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Li Wang <liwang@redhat.com>
---
 include/lapi/pkey.h                       | 14 +++++---------
 testcases/kernel/syscalls/mseal/mseal01.c |  6 +++---
 testcases/kernel/syscalls/pkeys/pkey01.c  |  8 ++++----
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/include/lapi/pkey.h b/include/lapi/pkey.h
index e0dc20dce..933dff34a 100644
--- a/include/lapi/pkey.h
+++ b/include/lapi/pkey.h
@@ -17,29 +17,25 @@
 #endif
 
 #ifndef HAVE_PKEY_MPROTECT
-inline int ltp_pkey_mprotect(void *addr, size_t len, int prot, int pkey)
+inline int pkey_mprotect(void *addr, size_t len, int prot, int pkey)
 {
 	return tst_syscall(__NR_pkey_mprotect, addr, len, prot, pkey);
 }
 
-inline int ltp_pkey_alloc(unsigned int flags, unsigned int access_rights)
+inline int pkey_alloc(unsigned int flags, unsigned int access_rights)
 {
 	return tst_syscall(__NR_pkey_alloc, flags, access_rights);
 }
 
-inline int ltp_pkey_free(int pkey)
+inline int pkey_free(int pkey)
 {
 	return tst_syscall(__NR_pkey_free, pkey);
 }
-#else
-#define ltp_pkey_alloc pkey_alloc
-#define ltp_pkey_free pkey_free
-#define ltp_pkey_mprotect pkey_mprotect
 #endif /* HAVE_PKEY_MPROTECT */
 
 static inline void check_pkey_support(void)
 {
-	int pkey = ltp_pkey_alloc(0, 0);
+	int pkey = tst_syscall(__NR_pkey_alloc, 0, 0);
 
 	if (pkey == -1) {
 		if (errno == ENOSYS)
@@ -50,7 +46,7 @@ static inline void check_pkey_support(void)
 			tst_brk(TCONF, "pkeys are not available for test");
 	}
 
-	ltp_pkey_free(pkey);
+	tst_syscall(__NR_pkey_free, pkey);
 }
 
 #endif /* PKEYS_H__ */
diff --git a/testcases/kernel/syscalls/mseal/mseal01.c b/testcases/kernel/syscalls/mseal/mseal01.c
index 1de9fb723..94e3e4b23 100644
--- a/testcases/kernel/syscalls/mseal/mseal01.c
+++ b/testcases/kernel/syscalls/mseal/mseal01.c
@@ -51,17 +51,17 @@ static void test_pkey_mprotect(void)
 
 	check_pkey_support();
 
-	pkey = ltp_pkey_alloc(0, 0);
+	pkey = pkey_alloc(0, 0);
 	if (pkey == -1)
 		tst_brk(TBROK | TERRNO, "pkey_alloc failed");
 
-	TST_EXP_FAIL(ltp_pkey_mprotect(
+	TST_EXP_FAIL(pkey_mprotect(
 		mem_addr, mem_size,
 		PROT_NONE,
 		pkey),
 		EPERM);
 
-	if (ltp_pkey_free(pkey) == -1)
+	if (pkey_free(pkey) == -1)
 		tst_brk(TBROK | TERRNO, "pkey_free() error");
 }
 
diff --git a/testcases/kernel/syscalls/pkeys/pkey01.c b/testcases/kernel/syscalls/pkeys/pkey01.c
index a6a739668..60f36706c 100644
--- a/testcases/kernel/syscalls/pkeys/pkey01.c
+++ b/testcases/kernel/syscalls/pkeys/pkey01.c
@@ -142,12 +142,12 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
 
 	buffer = SAFE_MMAP(NULL, size, mpa->prot, mpa->flags, fd, 0);
 
-	pkey = ltp_pkey_alloc(tc->flags, tc->access_rights);
+	pkey = pkey_alloc(tc->flags, tc->access_rights);
 	if (pkey == -1)
 		tst_brk(TBROK | TERRNO, "pkey_alloc failed");
 
 	tst_res(TINFO, "Set %s on (%s) buffer", tc->name, flag_to_str(mpa->flags));
-	if (ltp_pkey_mprotect(buffer, size, mpa->prot, pkey) == -1)
+	if (pkey_mprotect(buffer, size, mpa->prot, pkey) == -1)
 		tst_brk(TBROK | TERRNO, "pkey_mprotect failed");
 
 	pid = SAFE_FORK();
@@ -176,7 +176,7 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
                 tst_res(TFAIL, "Child: %s", tst_strstatus(status));
 
 	tst_res(TINFO, "Remove %s from the buffer", tc->name);
-	if (ltp_pkey_mprotect(buffer, size, mpa->prot, 0x0) == -1)
+	if (pkey_mprotect(buffer, size, mpa->prot, 0x0) == -1)
 		tst_brk(TBROK | TERRNO, "pkey_mprotect failed");
 
 	switch (mpa->prot) {
@@ -199,7 +199,7 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
 
 	SAFE_MUNMAP(buffer, size);
 
-	if (ltp_pkey_free(pkey) == -1)
+	if (pkey_free(pkey) == -1)
 		tst_brk(TBROK | TERRNO, "pkey_free failed");
 }
 
-- 
2.45.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-08-06  2:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05  6:52 [LTP] [PATCH v2 1/2] lapi: move pkey.h declarations inside the lapi/ folder Li Wang
2024-08-05  6:52 ` [LTP] [PATCH v2 2/2] mseal01: handle more possible errnos when pkey_alloc gets fail Li Wang
2024-08-05 13:59   ` Petr Vorel
2024-08-06  1:30     ` Li Wang
2024-08-06  2:31       ` Li Wang [this message]
2024-08-06  6:19         ` [LTP] [PATCH] pkey: remove the ltp_ prefix from pkey functions Petr Vorel
2024-08-06  7:37           ` Li Wang
2024-08-06  9:04             ` Li Wang
2024-08-06  9:21               ` Petr Vorel
2024-08-05 13:55 ` [LTP] [PATCH v2 1/2] lapi: move pkey.h declarations inside the lapi/ folder Petr Vorel
2024-08-06  0:58   ` Li Wang

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=20240806023105.20509-1-liwang@redhat.com \
    --to=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /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