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

(cherry picked from commit b36b14beda4ff7ecbb906ada756141f76fcb81aa)

Details

Provenance
jhbAuthored on Jan 19 2023, 6:21 PM
Reviewer
corvink
Differential Revision
D36829: bhyve: Avoid triggering false -Wfree-nonheap-object warnings.
Parents
rG622e092eeca4: bhyve: Simplify spinup_ap_realmode slightly.
Branches
Unknown
Tags
Unknown