From: Tom Rini Date: Fri, 29 Nov 2019 13:37:33 -0500 Subject: [U-Boot] [PATCH v1] gcc-9: silence 'address-of-packed-member' warning In-Reply-To: <20191129174759.20082-1-andriy.shevchenko@linux.intel.com> References: <20191129174759.20082-1-andriy.shevchenko@linux.intel.com> Message-ID: <20191129183733.GL15966@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de On Fri, Nov 29, 2019 at 07:47:59PM +0200, Andy Shevchenko wrote: > GCC 9.x starts complaining about potential misalignment of the pointer to > the array (in this case alignment=2) in the packed (alignment=1) structures. > > Repeating Linus' Torvalds commit 6f303d60534c in the Linux kernel. > > Original commit message: > > We already did this for clang, but now gcc has that warning too. > Yes, yes, the address may be unaligned. And that's kind of the point. > > This in particular hides the warnings like > > drivers/usb/gadget/composite.c:545:23: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member] > 545 | collect_langs(sp, s->wData); > > drivers/usb/gadget/composite.c:550:24: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member] > 550 | collect_langs(sp, s->wData); > > drivers/usb/gadget/composite.c:555:25: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member] > 555 | collect_langs(sp, s->wData); > > Signed-off-by: Andy Shevchenko > --- > Makefile | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index 7485bc2594..a0469f6a9c 100644 > --- a/Makefile > +++ b/Makefile > @@ -672,11 +672,12 @@ endif > endif > > KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) > +KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) > + > ifeq ($(cc-name),clang) > KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) > KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) > KBUILD_CFLAGS += $(call cc-disable-warning, gnu) > -KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) > KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) > endif Ooh, I wish I had thought to look at the kernel a while ago. I very much like this idea and need to run a test to see how much space we re-grain with this patch and reverting the handful of reworks that might not make as much long term sense to do. Thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: