[OpenWrt-Devel] [PATCH v1] umdns: suppress address-of-packed-member warning

Paul Fertser fercerpav at gmail.com
Sat Apr 4 04:50:31 EDT 2020


Hello,

On Sat, Apr 04, 2020 at 09:27:34AM +0100, Kevin Darbyshire-Bryant wrote:
> dns.c:261:2: error: converting a packed ‘struct dns_question’ pointer
> (alignment 1) to a ‘uint16_t’ {aka ‘short unsigned int’} pointer
> (alignment 2) may result in an unaligned pointer value
> [-Werror=address-of-packed-member]
> 
> 261 |  uint16_t *swap = (uint16_t *) q;
> 
> Work around what I think is a false positive by turning the warning off.

It seems that packed structures have no alignment guarantees at all
(beyond the size they're packed for), so even the first member can't
be used like that. So the warning looks legit?

-- 
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:fercerpav at gmail.com

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list