If anyone would build bhyve with -DNDEBUG, any code in the expression
in assert() won't be executed. Remove the assertion and check the
returned size from iov_to_buf() explicitly, exiting if it is wrong.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 72348 Build 69231: arc lint + arc unit
Event Timeline
| usr.sbin/bhyve/pci_virtio_scsi.c | ||
|---|---|---|
| 754 | ||
| usr.sbin/bhyve/pci_virtio_scsi.c | ||
|---|---|---|
| 752 | This still fails to build with gcc. | |
| usr.sbin/bhyve/pci_virtio_scsi.c | ||
|---|---|---|
| 752 | That's not surprising, given this is a fix for a different issue. Please see https://reviews.freebsd.org/D55800 for the proper fix of the build failure with gcc. | |
Or, something along the lines of:
size_t res __maybe_unused; res = iov_to_buf(...); assert (res == VTSCSI_IN_HEADER_LEN(q->vsq_sc);
There doesn't seem to be a general definition of __maybe_unused in FreeBSD, or I'm just too dense to find it. Some externals sources like ZFS seem to have it, though.
Perhaps I could use maybe_unused, but that's a C23 feature.
The commit should include a Fixes: 2a514d377b37 ("bhyve/virtio-scsi: Preallocate all I/O requests") tag.
There doesn't seem to be a general definition of __maybe_unused in FreeBSD
Ah, yes. We seem two have three copies of the #define in our tree, two under sys/, but it's not generally available. We could perhaps define it in cdefs.h, but independent of this change.