HomeFreeBSD

bhyve: Avoid triggering false -Wfree-nonheap-object warnings.

Description

bhyve: Avoid triggering false -Wfree-nonheap-object warnings.

XHCI port and slot numbers are 1-based rather than 0-based. To handle
this, bhyve was subtracting one item from the pointers saved in the
softc so that index 1 accessed index 0 of the allocated array.

However, this is UB and confused GCC 12. The compiler noticed that
the calls to free() were using an offset and emitted a warning.
Rather than storing UB pointers in the softc, push the decrement
operation into the existing macros that wrap accesses to the relevant
arrays.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D36829

Details

Provenance
jhbAuthored on Jan 19 2023, 6:21 PM
Reviewer
corvink
Differential Revision
D36829: bhyve: Avoid triggering false -Wfree-nonheap-object warnings.
Parents
rG05187f2ffc79: amd64: Fix a common typo in source code comments
Branches
Unknown
Tags
Unknown