diff mbox series

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

Message ID 20200404082734.79321-1-ldir@darbyshire-bryant.me.uk
State Superseded
Headers show
Series [OpenWrt-Devel,v1] umdns: suppress address-of-packed-member warning | expand

Commit Message

Kevin 'ldir' Darbyshire-Bryant April 4, 2020, 8:27 a.m. UTC
gcc 8 & 9 appear to be more picky with regards access alignment to
packed structures, leading to this warning in dns.c:

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.
Not ideal, but not quite as not ideal as build failure.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
---
 package/network/services/umdns/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paul Fertser April 4, 2020, 8:50 a.m. UTC | #1
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?
diff mbox series

Patch

diff --git a/package/network/services/umdns/Makefile b/package/network/services/umdns/Makefile
index ffbc3fed35..7dbbea322a 100644
--- a/package/network/services/umdns/Makefile
+++ b/package/network/services/umdns/Makefile
@@ -8,7 +8,7 @@ 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=umdns
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/mdnsd.git
 PKG_SOURCE_PROTO:=git
@@ -30,7 +30,7 @@  define Package/umdns
   DEPENDS:=+libubox +libubus +libblobmsg-json
 endef
 
-TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include -Wno-address-of-packed-member
 
 define Package/umdns/conffiles
 /etc/config/umdns