public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 5/6] util: read_remainder should take const pointer to iovec
Date: Mon,  3 Feb 2025 20:26:14 +1100	[thread overview]
Message-ID: <20250203092615.500163-6-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20250203092615.500163-1-david@gibson.dropbear.id.au>

read_remainder() takes a struct iovec * to describe where it will read its
data, unlike write_remainder() which takes a const struct iovec *.  At
first this seems like it makes sense, since read_remainder() will alter
data within the iovec.

However, what it actually alters is data within the buffers described by
the iovec, not the iovec entries itself.  So, like write it should take
a const struct iovec *.

[This is a candidate for folding into the earlier patch]

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 util.c | 2 +-
 util.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/util.c b/util.c
index 0e0f8a4b..a9ea90a0 100644
--- a/util.c
+++ b/util.c
@@ -717,7 +717,7 @@ int read_all_buf(int fd, void *buf, size_t len)
  *
  * Note: mode-specific seccomp profiles need to enable readv() to use this.
  */
-int read_remainder(int fd, struct iovec *iov, size_t cnt, size_t skip)
+int read_remainder(int fd, const struct iovec *iov, size_t cnt, size_t skip)
 {
 	size_t i = 0, offset;
 
diff --git a/util.h b/util.h
index 6924d08d..dfac63b1 100644
--- a/util.h
+++ b/util.h
@@ -205,7 +205,7 @@ int write_file(const char *path, const char *buf);
 int write_all_buf(int fd, const void *buf, size_t len);
 int write_remainder(int fd, const struct iovec *iov, size_t iovcnt, size_t skip);
 int read_all_buf(int fd, void *buf, size_t len);
-int read_remainder(int fd, struct iovec *iov, size_t cnt, size_t skip);
+int read_remainder(int fd, const struct iovec *iov, size_t cnt, size_t skip);
 void close_open_files(int argc, char **argv);
 bool snprintf_check(char *str, size_t size, const char *format, ...);
 
-- 
@@ -205,7 +205,7 @@ int write_file(const char *path, const char *buf);
 int write_all_buf(int fd, const void *buf, size_t len);
 int write_remainder(int fd, const struct iovec *iov, size_t iovcnt, size_t skip);
 int read_all_buf(int fd, void *buf, size_t len);
-int read_remainder(int fd, struct iovec *iov, size_t cnt, size_t skip);
+int read_remainder(int fd, const struct iovec *iov, size_t cnt, size_t skip);
 void close_open_files(int argc, char **argv);
 bool snprintf_check(char *str, size_t size, const char *format, ...);
 
-- 
2.48.1


  parent reply	other threads:[~2025-02-03  9:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-03  9:26 [PATCH 0/6] More migration improvements David Gibson
2025-02-03  9:26 ` [PATCH 1/6] vhost-user: Change different vhost-user messages to trace() level David Gibson
2025-02-04  0:42   ` Stefano Brivio
2025-02-03  9:26 ` [PATCH 2/6] migrate, flow: Abort migration on repair_flush() failure David Gibson
2025-02-03  9:26 ` [PATCH 3/6] migrate: Clearer debug message in migrate_request() David Gibson
2025-02-03  9:26 ` [PATCH 4/6] migrate: Handle sending header section from data sections David Gibson
2025-02-03  9:26 ` David Gibson [this message]
2025-02-04  0:42   ` [PATCH 5/6] util: read_remainder should take const pointer to iovec Stefano Brivio
2025-02-03  9:26 ` [PATCH 6/6] migrate: Make migration handlers simpler and more flexible David Gibson
2025-02-03 10:20   ` Stefano Brivio
2025-02-03 23:55     ` David Gibson
2025-02-04  0:12       ` Stefano Brivio
2025-02-04  3:36         ` David Gibson

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=20250203092615.500163-6-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).