diff options
| author | Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> | 2026-03-09 18:10:54 +0000 |
|---|---|---|
| committer | Ed Maste <emaste@FreeBSD.org> | 2026-04-01 19:05:26 +0000 |
| commit | 970e0db1c38b8b5f873e7c9797bb9abcad76a1d7 (patch) | |
| tree | b9f5ce308648d219aa933d64c6a9eea9119b6e42 | |
| parent | d0afead876076f605c363f03d92304d1bd75be1c (diff) | |
bhyve/virtio: Fix comparison of integer expressions of different signedness
It's a bit silly to have iov_to_buf() and buf_to_iov() return a ssize_t
to begin with, just to be able to return -1 for error. Change this to
size_t and use 0 as an error indicator, which won't require any changes
to the code using these functions.
While here, switch iov_to_buf() to use reallocf() instead of realloc().
Reviewed by: jhb
Fixes: 2a514d377b37 ("bhyve/virtio-scsi: Preallocate all I/O requests")
Differential Revision: https://reviews.freebsd.org/D55800
| -rw-r--r-- | usr.sbin/bhyve/iov.c | 10 | ||||
| -rw-r--r-- | usr.sbin/bhyve/iov.h | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/usr.sbin/bhyve/iov.c b/usr.sbin/bhyve/iov.c index 16d7765b437b..aadea1d67933 100644 --- a/usr.sbin/bhyve/iov.c +++ b/usr.sbin/bhyve/iov.c @@ -110,16 +110,16 @@ check_iov_len(const struct iovec *iov, size_t niov, size_t len) return (false); } -ssize_t +size_t iov_to_buf(const struct iovec *iov, size_t niov, void **buf) { size_t ptr, total; size_t i; total = count_iov(iov, niov); - *buf = realloc(*buf, total); + *buf = reallocf(*buf, total); if (*buf == NULL) - return (-1); + return (0); for (i = 0, ptr = 0; i < niov; i++) { memcpy((uint8_t *)*buf + ptr, iov[i].iov_base, iov[i].iov_len); @@ -129,7 +129,7 @@ iov_to_buf(const struct iovec *iov, size_t niov, void **buf) return (total); } -ssize_t +size_t buf_to_iov(const void *buf, size_t buflen, const struct iovec *iov, size_t niov) { size_t off = 0, len; @@ -141,5 +141,5 @@ buf_to_iov(const void *buf, size_t buflen, const struct iovec *iov, size_t niov) off += len; } - return ((ssize_t)off); + return (off); } diff --git a/usr.sbin/bhyve/iov.h b/usr.sbin/bhyve/iov.h index e14a9bc7e019..788e8da84b8b 100644 --- a/usr.sbin/bhyve/iov.h +++ b/usr.sbin/bhyve/iov.h @@ -40,7 +40,7 @@ struct iovec *split_iov(struct iovec *, size_t *, size_t, size_t *); size_t count_iov(const struct iovec *, size_t); bool check_iov_len(const struct iovec *, size_t, size_t); -ssize_t iov_to_buf(const struct iovec *, size_t, void **); -ssize_t buf_to_iov(const void *, size_t, const struct iovec *, size_t); +size_t iov_to_buf(const struct iovec *, size_t, void **); +size_t buf_to_iov(const void *, size_t, const struct iovec *, size_t); #endif /* _IOV_H_ */ |
