Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/2] Introduce SAFE_SPLICE()
@ 2026-05-04  8:04 Andrea Cervesato
  2026-05-04  8:04 ` [LTP] [PATCH v2 1/2] lib: Add SAFE_SPLICE() macro Andrea Cervesato
  2026-05-04  8:04 ` [LTP] [PATCH v2 2/2] tee01, vmsplice01, af_alg08: Use SAFE_SPLICE() Andrea Cervesato
  0 siblings, 2 replies; 5+ messages in thread
From: Andrea Cervesato @ 2026-05-04  8:04 UTC (permalink / raw)
  To: Linux Test Project

- add SAFE_SPLICE()
- update tests to use the new macro

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Changes in v2:
- fix compile issues by moving SAFE_SPLICE in lapi/splice.h
- Link to v1: https://lore.kernel.org/r/20260430-safe_splice-v1-0-d1d919ff2a3a@suse.com

---
Andrea Cervesato (2):
      lib: Add SAFE_SPLICE() macro
      tee01, vmsplice01, af_alg08: Use SAFE_SPLICE()

 include/lapi/splice.h                           | 28 +++++++++++++++++++++++++
 testcases/kernel/crypto/af_alg08.c              |  9 ++------
 testcases/kernel/syscalls/tee/tee01.c           | 10 +++------
 testcases/kernel/syscalls/vmsplice/vmsplice01.c |  5 +----
 4 files changed, 34 insertions(+), 18 deletions(-)
---
base-commit: 72ca484cca53710b956ba2fcc1ff203fe9c9b73b
change-id: 20260430-safe_splice-a3d6403f99cd

Best regards,
-- 
Andrea Cervesato <andrea.cervesato@suse.com>


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

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [LTP] [PATCH 1/2] lib: Add SAFE_SPLICE() macro
@ 2026-04-30 17:25 Andrea Cervesato
  2026-04-30 19:29 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Cervesato @ 2026-04-30 17:25 UTC (permalink / raw)
  To: Linux Test Project

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

splice() is used as utility plumbing in several tests (tee01,
vmsplice01, af_alg08) but lacks a SAFE_* wrapper, forcing each
caller to manually check the return value. Add SAFE_SPLICE()
following the existing safe_pipe2() pattern.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 include/tst_safe_macros.h |  8 ++++++++
 lib/tst_safe_macros.c     | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index c73c1acb1cbd671d4d22b740647d3e7491f7baf2..53caf845d1172cccf23d631d97e1f5086f98f547 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -114,6 +114,14 @@ int safe_pipe2(const char *file, const int lineno, int fildes[2], int flags);
 #define SAFE_PIPE2(fildes, flags) \
 	safe_pipe2(__FILE__, __LINE__, (fildes), (flags))
 
+ssize_t safe_splice(const char *file, const int lineno,
+		    int fd_in, loff_t *off_in, int fd_out, loff_t *off_out,
+		    size_t len, unsigned int flags);
+
+#define SAFE_SPLICE(fd_in, off_in, fd_out, off_out, len, flags) \
+	safe_splice(__FILE__, __LINE__, (fd_in), (off_in), (fd_out), \
+		    (off_out), (len), (flags))
+
 #define SAFE_READ(len_strict, fildes, buf, nbyte) \
 	safe_read(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
 
diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
index cdc8c7dd33cb0f805d40095b732d723497b2adeb..8f3dbbd1d2f371f2986356187c41007993f1589e 100644
--- a/lib/tst_safe_macros.c
+++ b/lib/tst_safe_macros.c
@@ -21,6 +21,7 @@
 #include "tst_safe_macros.h"
 #include "lapi/personality.h"
 #include "lapi/pidfd.h"
+#include "lapi/splice.h"
 
 int safe_access(const char *file, const int lineno,
 	    const char *pathname, int mode)
@@ -512,6 +513,22 @@ int safe_pipe2(const char *file, const int lineno, int fildes[2], int flags)
 	return ret;
 }
 
+ssize_t safe_splice(const char *file, const int lineno,
+		    int fd_in, loff_t *off_in, int fd_out, loff_t *off_out,
+		    size_t len, unsigned int flags)
+{
+	ssize_t ret;
+
+	ret = splice(fd_in, off_in, fd_out, off_out, len, flags);
+
+	if (ret < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"splice(%d, %d, %zu) failed", fd_in, fd_out, len);
+	}
+
+	return ret;
+}
+
 int safe_dup(const char *file, const int lineno, int oldfd)
 {
 	int rval;

-- 
2.51.0


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-04  9:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04  8:04 [LTP] [PATCH v2 0/2] Introduce SAFE_SPLICE() Andrea Cervesato
2026-05-04  8:04 ` [LTP] [PATCH v2 1/2] lib: Add SAFE_SPLICE() macro Andrea Cervesato
2026-05-04  9:28   ` [LTP] " linuxtestproject.agent
2026-05-04  8:04 ` [LTP] [PATCH v2 2/2] tee01, vmsplice01, af_alg08: Use SAFE_SPLICE() Andrea Cervesato
  -- strict thread matches above, loose matches on Subject: below --
2026-04-30 17:25 [LTP] [PATCH 1/2] lib: Add SAFE_SPLICE() macro Andrea Cervesato
2026-04-30 19:29 ` [LTP] " linuxtestproject.agent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox