[LTP] [PATCH] pkey: remove the ltp_ prefix from pkey functions

Li Wang liwang@redhat.com
Tue Aug 6 04:31:05 CEST 2024


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



More information about the ltp mailing list