|
|
Message-ID: <20250527140619.GN1827@brightrain.aerifal.cx>
Date: Tue, 27 May 2025 10:06:19 -0400
From: Rich Felker <dalias@...c.org>
To: Casey Connolly <kcxt@...tmarketos.org>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH v2] stdio: skip empty iovec when buffering is
disabled
On Wed, Apr 23, 2025 at 03:06:48PM +0200, Casey Connolly wrote:
> When buffering on a FILE is disabled we still send both iovecs, even
> though the first one is always empty. Clean things up by skipping the
> empty iovec instead.
> ---
>
> Changes since v1:
> - reword to better reflect the change
> - V1: https://www.openwall.com/lists/musl/2025/04/23/1
>
> ---
> src/stdio/__stdio_write.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c
> index d2d89475b0f9..b08913266269 100644
> --- a/src/stdio/__stdio_write.c
> +++ b/src/stdio/__stdio_write.c
> @@ -9,8 +9,13 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
> };
> struct iovec *iov = iovs;
> size_t rem = iov[0].iov_len + iov[1].iov_len;
> int iovcnt = 2;
> +
> + if (!iov->iov_len) {
> + iov++;
> + iovcnt--;
> + }
> ssize_t cnt;
> for (;;) {
> cnt = syscall(SYS_writev, f->fd, iov, iovcnt);
> if (cnt == rem) {
> --
> 2.49.0
Thanks. Merging now, with the lines reordered so decl of cnt isn't
separated from the rest, which looks unintentional.
Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.