[LTP] [PATCH v3 2/2] tee01, vmsplice01, af_alg08: Use SAFE_SPLICE()

Andrea Cervesato andrea.cervesato@suse.de
Mon May 4 11:51:01 CEST 2026


From: Andrea Cervesato <andrea.cervesato@suse.com>

Replace raw splice() calls with SAFE_SPLICE() in tests where splice is
utility plumbing, not the subject of testing.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/crypto/af_alg08.c              | 9 ++-------
 testcases/kernel/syscalls/tee/tee01.c           | 8 ++------
 testcases/kernel/syscalls/vmsplice/vmsplice01.c | 5 +----
 3 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/testcases/kernel/crypto/af_alg08.c b/testcases/kernel/crypto/af_alg08.c
index 7b95984448bdc5afd3b995a98c3d81ef12e37067..5e04b579c1db464fc5b4f33fd4e13a29709bba79 100644
--- a/testcases/kernel/crypto/af_alg08.c
+++ b/testcases/kernel/crypto/af_alg08.c
@@ -96,13 +96,8 @@ static void try_corrupt(void)
 
 	SAFE_PIPE(pipefd);
 
-	TEST(splice(file_fd, &off_in, pipefd[1], NULL, OVERWRITE_SIZE, 0));
-	if (TST_RET < 0)
-		tst_brk(TBROK | TTERRNO, "splice(file -> pipe)");
-
-	TEST(splice(pipefd[0], NULL, reqfd, NULL, OVERWRITE_SIZE, 0));
-	if (TST_RET < 0)
-		tst_brk(TBROK | TTERRNO, "splice(pipe -> AF_ALG)");
+	SAFE_SPLICE(file_fd, &off_in, pipefd[1], NULL, OVERWRITE_SIZE, 0);
+	SAFE_SPLICE(pipefd[0], NULL, reqfd, NULL, OVERWRITE_SIZE, 0);
 
 	/* Expected to fail (invalid ciphertext); triggers the scratch write */
 	TST_EXP_FAIL_SILENT(recv(reqfd, recvbuf, sizeof(recvbuf), 0), EBADMSG);
diff --git a/testcases/kernel/syscalls/tee/tee01.c b/testcases/kernel/syscalls/tee/tee01.c
index d1489d0453f11faab41ab6e8e2dabbb372566f60..436c52a201689e4ffa97f217fd3b1d14e6b6ec36 100644
--- a/testcases/kernel/syscalls/tee/tee01.c
+++ b/testcases/kernel/syscalls/tee/tee01.c
@@ -58,17 +58,13 @@ static void tee_test(void)
 	SAFE_PIPE(pipe1);
 	SAFE_PIPE(pipe2);
 
-	ret = splice(fd_in, NULL, pipe1[1], NULL, TEST_BLOCK_SIZE, 0);
-	if (ret < 0)
-		tst_brk(TBROK | TERRNO, "splice(fd_in, pipe1) failed");
+	SAFE_SPLICE(fd_in, NULL, pipe1[1], NULL, TEST_BLOCK_SIZE, 0);
 
 	ret = tee(pipe1[0], pipe2[1], TEST_BLOCK_SIZE, SPLICE_F_NONBLOCK);
 	if (ret < 0)
 		tst_brk(TBROK | TERRNO, "tee() failed");
 
-	ret = splice(pipe2[0], NULL, fd_out, NULL, TEST_BLOCK_SIZE, 0);
-	if (ret < 0)
-		tst_brk(TBROK | TERRNO, "splice(pipe2, fd_out) failed");
+	SAFE_SPLICE(pipe2[0], NULL, fd_out, NULL, TEST_BLOCK_SIZE, 0);
 
 	SAFE_CLOSE(pipe2[0]);
 	SAFE_CLOSE(pipe2[1]);
diff --git a/testcases/kernel/syscalls/vmsplice/vmsplice01.c b/testcases/kernel/syscalls/vmsplice/vmsplice01.c
index 17486179baa2a897c2efbf0d2b4d39273788aadc..64eed8391797fb01b14c548ebcfe390a403da5ec 100644
--- a/testcases/kernel/syscalls/vmsplice/vmsplice01.c
+++ b/testcases/kernel/syscalls/vmsplice/vmsplice01.c
@@ -50,7 +50,6 @@ static void vmsplice_test(void)
 {
 	int pipes[2];
 	long written;
-	int ret;
 	int fd_out;
 	struct iovec v;
 	loff_t offset;
@@ -85,9 +84,7 @@ static void vmsplice_test(void)
 			}
 		}
 
-		ret = splice(pipes[0], NULL, fd_out, &offset, written, 0);
-		if (ret < 0)
-			tst_brk(TBROK | TERRNO, "splice() failed");
+		SAFE_SPLICE(pipes[0], NULL, fd_out, &offset, written, 0);
 		//printf("offset = %lld\n", (long long)offset);
 	}
 

-- 
2.51.0



More information about the ltp mailing list