From 031df332e98d507ad153fc54ea8c4b7109b7dabf Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 6 Aug 2024 11:21:49 +1000 Subject: util: Use unsigned (size_t) value for iov length The "correct" type for the length of an IOV is unclear: writev() and readv() use an int, but sendmsg() and recvmsg() use a size_t. Using the unsigned size_t has some advantages, though, and it makes more sense for the case of write_remainder. Using size_t throughout here means we don't have a signed vs. unsigned comparison, and we don't have to deal with the case of iov_skip_bytes() returning a value which becomes negative when assigned to an integer. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index f2e26a7..54a9f58 100644 --- a/util.c +++ b/util.c @@ -592,10 +592,9 @@ int do_clone(int (*fn)(void *), char *stack_area, size_t stack_size, int flags, * * #syscalls write writev */ -int write_remainder(int fd, const struct iovec *iov, int iovcnt, size_t skip) +int write_remainder(int fd, const struct iovec *iov, size_t iovcnt, size_t skip) { - int i; - size_t offset; + size_t offset, i; while ((i = iov_skip_bytes(iov, iovcnt, skip, &offset)) < iovcnt) { ssize_t rc; -- cgit v1.2.3