Linux Test Project
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v3 1/2] lib: Add SAFE_SPLICE() macro
Date: Mon, 4 May 2026 13:17:37 +0200	[thread overview]
Message-ID: <afiAUXp-UY52IuKz@yuki.lan> (raw)
In-Reply-To: <20260504-safe_splice-v3-1-e5acf4c9193b@suse.com>

Hi!
> Add new SAFE_SPLIT() in lapi/splice.h.
> 
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
>  include/lapi/splice.h | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/include/lapi/splice.h b/include/lapi/splice.h
> index 191b22d2d6397d1efad5e2025be5a2c4370724dc..e346e5cca9f44bd8421c6b99f84cd4646269ac1f 100644
> --- a/include/lapi/splice.h
> +++ b/include/lapi/splice.h
> @@ -7,6 +7,13 @@
>  #ifndef LAPI_SPLICE_H__
>  #define LAPI_SPLICE_H__
>  
> +#ifndef _GNU_SOURCE
> +# define _GNU_SOURCE
> +#endif
> +
> +#include <fcntl.h>
> +#include <sys/types.h>
> +
>  #include "config.h"
>  #include "lapi/syscalls.h"
>  
> @@ -19,4 +26,25 @@ static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out,
>  }
>  #endif
>  
> +static inline 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);

Why don't we print the offsets?


Otherwise:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

> +	}
> +
> +	return ret;
> +}
> +
> +#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))
> +
>  #endif /* LAPI_SPLICE_H__ */
> 
> -- 
> 2.51.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2026-05-04 11:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04  9:50 [LTP] [PATCH v3 0/2] Introduce SAFE_SPLICE() Andrea Cervesato
2026-05-04  9:51 ` [LTP] [PATCH v3 1/2] lib: Add SAFE_SPLICE() macro Andrea Cervesato
2026-05-04 11:17   ` Cyril Hrubis [this message]
2026-05-04 11:28     ` Andrea Cervesato via ltp
2026-05-04  9:51 ` [LTP] [PATCH v3 2/2] tee01, vmsplice01, af_alg08: Use SAFE_SPLICE() Andrea Cervesato
2026-05-04 11:23   ` Cyril Hrubis
2026-05-04 11:33 ` [LTP] [PATCH v3 0/2] Introduce SAFE_SPLICE() Andrea Cervesato via ltp

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=afiAUXp-UY52IuKz@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=andrea.cervesato@suse.de \
    --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