vq_getchain() can return -1 if some descriptor(s) are invalid and
prints a diagnostic message.
We should assert the return on variable n.
Differential D15388
assert(3) vq_getchain() on pci_vtcon_notify_tx() spotted by gcc. araujo on May 11 2018, 8:34 AM. Authored by Tags None Referenced Files
Details
vq_getchain() can return -1 if some descriptor(s) are invalid and We should assert the return on variable n.
Diff Detail
Event Timeline
Comment Actions Address @avg concern about idx becomes 0 and be passed to vq_relchain and perhaps
Comment Actions Normally if you weren't planning to do a runtime check you would just not have 'n' at all. What you really kind of want is a working version of 'assert(vq_getchain(...) >=1)' but you can't do that safely. Andriy is right that the warning will be back with a NDEBUG build (but we don't define NDEBUG in FreeBSD builds, even for releases). The current version is perhaps the least evil. Other ideas I considered: if (vq_getchain(...) < 1) abort(); if (vq_getchain(...) < 1) assert(false); |