The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=bc9f667eb11d9b47541f834faefbc6aac077cee2
commit bc9f667eb11d9b47541f834faefbc6aac077cee2 Author: Hans Rosenfeld <[email protected]> AuthorDate: 2026-03-10 19:14:10 +0000 Commit: Ed Maste <[email protected]> CommitDate: 2026-05-06 17:36:48 +0000 bhyve/virtio-scsi: Don't invoke iov_to_buf() in an assert() expression If anyone would build bhyve with -DNDEBUG, any code in the expression in assert() won't be executed. Instead put the return value in a temporary variable to assert that it has the expected value. Reviewed by: emaste, markj (earlier version) Fixes: 2a514d377b37 ("bhyve/virtio-scsi: Preallocate all I/O requests") Differential Revision: https://reviews.freebsd.org/D55803 --- usr.sbin/bhyve/pci_virtio_scsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index dafff50fa531..5fb867e5eae7 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -669,6 +669,7 @@ pci_vtscsi_queue_request(struct pci_vtscsi_softc *sc, struct vqueue_info *vq) struct pci_vtscsi_queue *q = &sc->vss_queues[vq->vq_num - 2]; struct pci_vtscsi_request *req; struct vi_req vireq; + size_t res __maybe_unused; int n; pthread_mutex_lock(&q->vsq_fmtx); @@ -747,8 +748,9 @@ pci_vtscsi_queue_request(struct pci_vtscsi_softc *sc, struct vqueue_info *vq) * This will have to change if we begin allowing config space writes * to change sense size. */ - assert(iov_to_buf(req->vsr_iov_in, req->vsr_niov_in, - (void **)&req->vsr_cmd_rd) == VTSCSI_IN_HEADER_LEN(q->vsq_sc)); + res = iov_to_buf(req->vsr_iov_in, req->vsr_niov_in, + (void **)&req->vsr_cmd_rd); + assert(res == VTSCSI_IN_HEADER_LEN(q->vsq_sc)); /* Make sure this request addresses a valid LUN. */ if (pci_vtscsi_check_lun(req->vsr_cmd_rd->lun) == false) {
