From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202502 header.b=XKEl/kB7; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 609505A061C for ; Mon, 03 Feb 2025 10:26:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1738574768; bh=S4NGMM8t9MD83JnKFKWzP7fd81+z/vGPAXWojt+0dQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XKEl/kB7v789g9cIeE97y3huRjO4wnPylrO4QTw369JNnZOS28T7IcgK1RFgKkwZY XmFXCYx2bsZG05PnP7UUXQeE461+QIa2F9cYahNBqsVlKfKdCpc3U3v41CKr+RzvrB DZfMQNEPYRFSTw2yo8HwhK75tc+Cl7uQ72rfp78ZONZeHa3bombBVVliJOWNRKnX3o MvGbZOHixCdMFM51+Y5xfj2j7+V7K/2ruYhdHrysDTFj2ySPTjJdBxim4q35Pktj1l Rzmp/80cOk4/VZsJfxqDjfZxQWDU0GTrubg1YIVTHqdePPsankXpHyluDGaNVRcb8d nBa/cGBV+Tqew== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Ymh282h0nz4wyk; Mon, 3 Feb 2025 20:26:08 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 5/6] util: read_remainder should take const pointer to iovec Date: Mon, 3 Feb 2025 20:26:14 +1100 Message-ID: <20250203092615.500163-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250203092615.500163-1-david@gibson.dropbear.id.au> References: <20250203092615.500163-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: T6Z6AFW6BTTT3MWRO7LNNFXZUL4UDLUA X-Message-ID-Hash: T6Z6AFW6BTTT3MWRO7LNNFXZUL4UDLUA X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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, ...); -- 2.48.1