]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bhyve: Appease warning about a potentially unaligned pointer.
authorJohn Baldwin <jhb@FreeBSD.org>
Tue, 29 Nov 2022 01:10:07 +0000 (17:10 -0800)
committerJohn Baldwin <jhb@FreeBSD.org>
Tue, 29 Nov 2022 01:10:07 +0000 (17:10 -0800)
commit32b21dd2719f87811b66deeeb513acf7067f8fac
tree8ebe0ac9f35a7df738ccbe22f25f4ff95aa6d07b
parent15cebe3d637f70abd1ee95e2745d6676d9b1e7dd
bhyve: Appease warning about a potentially unaligned pointer.

When initializing the device model for a PCI pass through device that
uses MSI-X, bhyve reads the MSI-X capability from the real device to
save a copy in the emulated PCI config space.  It also saves a copy in
a local struct msixcap on the stack.  Since struct msixcap is packed,
GCC complains that casting a pointer to the struct to a uint32_t
pointer may result in an unaligned pointer.

This path is not performance critical, so to appease the compiler,
simply change the pointer to a char * and use memcpy to copy the 4
bytes read in each iteration of the loop.

Reviewed by: corvink, bz, markj
Differential Revision: https://reviews.freebsd.org/D37490
usr.sbin/bhyve/pci_passthru.c