mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/4] ratp: Mark struct ratp_bb as packed
@ 2019-09-07 23:54 Andrey Smirnov
  2019-09-07 23:54 ` [PATCH 2/4] net: Adjust net_copy_uint32's signature Andrey Smirnov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-09-07 23:54 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Mark struct ratp_bb as packed to make sure that it has the same
alignment as struct ratp_bb_md_response and struct ratp_bb_mw_response
where it's used. GCC9 catches this mismatch and generates a
-Waddress-of-packed-member warning

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 include/ratp_bb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/ratp_bb.h b/include/ratp_bb.h
index b6699979b6..9162e7cbe5 100644
--- a/include/ratp_bb.h
+++ b/include/ratp_bb.h
@@ -32,7 +32,7 @@ struct ratp_bb {
 	uint16_t type;
 	uint16_t flags;
 	uint8_t data[];
-};
+} __packed;
 
 struct ratp_bb_pkt {
 	unsigned int len;
-- 
2.21.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/4] net: Adjust net_copy_uint32's signature
  2019-09-07 23:54 [PATCH 1/4] ratp: Mark struct ratp_bb as packed Andrey Smirnov
@ 2019-09-07 23:54 ` Andrey Smirnov
  2019-09-07 23:54 ` [PATCH 3/4] mtd: ubi: Compile fastmap.c with -Wno-address-of-packed-member Andrey Smirnov
  2019-09-07 23:54 ` [PATCH 4/4] USB: gadget: Compile composite.c " Andrey Smirnov
  2 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-09-07 23:54 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Net_copy_uint32() uses memcpy() under the hood, so there's no need to
specify "to" and "from" parameters as uint32_t * and place stricter
alignment requirements than necessary.

GCC9 generates a couple of -Waddress-of-packed-member warnings here
otherwise.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 include/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net.h b/include/net.h
index 6912a557b5..3491425e09 100644
--- a/include/net.h
+++ b/include/net.h
@@ -315,7 +315,7 @@ static inline void net_copy_ip(void *to, void *from)
 }
 
 /* copy ulong */
-static inline void net_copy_uint32(uint32_t *to, uint32_t *from)
+static inline void net_copy_uint32(void *to, void *from)
 {
 	memcpy(to, from, sizeof(uint32_t));
 }
-- 
2.21.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/4] mtd: ubi: Compile fastmap.c with -Wno-address-of-packed-member
  2019-09-07 23:54 [PATCH 1/4] ratp: Mark struct ratp_bb as packed Andrey Smirnov
  2019-09-07 23:54 ` [PATCH 2/4] net: Adjust net_copy_uint32's signature Andrey Smirnov
@ 2019-09-07 23:54 ` Andrey Smirnov
  2019-09-09 10:23   ` Sascha Hauer
  2019-09-07 23:54 ` [PATCH 4/4] USB: gadget: Compile composite.c " Andrey Smirnov
  2 siblings, 1 reply; 7+ messages in thread
From: Andrey Smirnov @ 2019-09-07 23:54 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

GCC9 for ARM produces the following warnings:

fastmap.c: In function 'ubi_attach_fastmap':
fastmap.c:700:31: warning: taking address of packed member of 'struct ubi_fm_scan_pool' may result in an unaligned pointer value [-Waddress-of-packed-member]
  700 |  ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &lfree);
      |                           ~~~~^~~~~~
fastmap.c:704:34: warning: taking address of packed member of 'struct ubi_fm_scan_pool' may result in an unaligned pointer value [-Waddress-of-packed-member]
  704 |  ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &lfree);
      |                           ~~~~~~~^~~~~~

the offending code seems OK and there doesn't seem to be a way to fix
this in code, so disable the warning for that file.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mtd/ubi/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/ubi/Makefile b/drivers/mtd/ubi/Makefile
index 33ac39026c..6ffb4ae2bc 100644
--- a/drivers/mtd/ubi/Makefile
+++ b/drivers/mtd/ubi/Makefile
@@ -2,4 +2,5 @@ obj-$(CONFIG_MTD_UBI) += ubi.o
 
 ubi-y += vtbl.o vmt.o upd.o build.o barebox.o kapi.o eba.o io.o wl.o attach.o
 ubi-y += misc.o debug.o
+CFLAGS_fastmap.o := -Wno-address-of-packed-member
 ubi-$(CONFIG_MTD_UBI_FASTMAP) += fastmap.o
-- 
2.21.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/4] USB: gadget: Compile composite.c with -Wno-address-of-packed-member
  2019-09-07 23:54 [PATCH 1/4] ratp: Mark struct ratp_bb as packed Andrey Smirnov
  2019-09-07 23:54 ` [PATCH 2/4] net: Adjust net_copy_uint32's signature Andrey Smirnov
  2019-09-07 23:54 ` [PATCH 3/4] mtd: ubi: Compile fastmap.c with -Wno-address-of-packed-member Andrey Smirnov
@ 2019-09-07 23:54 ` Andrey Smirnov
  2 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-09-07 23:54 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

GCC9 for ARM produces the following warnings:

drivers/usb/gadget/composite.c: In function 'bos_desc':
drivers/usb/gadget/composite.c:522:15: warning: taking address of packed member of 'struct usb_bos_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
  522 |  le16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE);
      |               ^~~~~~~~~~~~~~~~~~
drivers/usb/gadget/composite.c:534:15: warning: taking address of packed member of 'struct usb_bos_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
  534 |  le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE);
      |               ^~~~~~~~~~~~~~~~~~
drivers/usb/gadget/composite.c: In function 'get_string':
drivers/usb/gadget/composite.c:928:23: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
  928 |    collect_langs(sp, s->wData);
      |                      ~^~~~~~~
drivers/usb/gadget/composite.c:933:24: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
  933 |     collect_langs(sp, s->wData);
      |                       ~^~~~~~~
drivers/usb/gadget/composite.c:938:25: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
  938 |      collect_langs(sp, s->wData);
      |                        ~^~~~~~~
drivers/usb/gadget/composite.c:945:23: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
  945 |    collect_langs(sp, s->wData);
      |                      ~^~~~~~~

the offending code seems OK and there doesn't seem to be a way to fix
this in code, so disable the warning for that file.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/gadget/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 9ef594575b..8d399e568f 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -1,4 +1,6 @@
 
+CFLAGS_composite.o := -Wno-address-of-packed-member
+
 obj-$(CONFIG_USB_GADGET) += composite.o config.o usbstring.o epautoconf.o udc-core.o functions.o config.o multi.o
 obj-$(CONFIG_USB_GADGET_SERIAL) += u_serial.o serial.o f_serial.o f_acm.o
 obj-$(CONFIG_USB_GADGET_DFU) += dfu.o
-- 
2.21.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4] mtd: ubi: Compile fastmap.c with -Wno-address-of-packed-member
  2019-09-07 23:54 ` [PATCH 3/4] mtd: ubi: Compile fastmap.c with -Wno-address-of-packed-member Andrey Smirnov
@ 2019-09-09 10:23   ` Sascha Hauer
  2019-09-10  4:28     ` Andrey Smirnov
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2019-09-09 10:23 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Sat, Sep 07, 2019 at 04:54:55PM -0700, Andrey Smirnov wrote:
> GCC9 for ARM produces the following warnings:
> 
> fastmap.c: In function 'ubi_attach_fastmap':
> fastmap.c:700:31: warning: taking address of packed member of 'struct ubi_fm_scan_pool' may result in an unaligned pointer value [-Waddress-of-packed-member]
>   700 |  ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &lfree);
>       |                           ~~~~^~~~~~
> fastmap.c:704:34: warning: taking address of packed member of 'struct ubi_fm_scan_pool' may result in an unaligned pointer value [-Waddress-of-packed-member]
>   704 |  ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &lfree);
>       |                           ~~~~~~~^~~~~~
> 
> the offending code seems OK and there doesn't seem to be a way to fix
> this in code, so disable the warning for that file.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---

Linux disables this warning completely. We just burnt some developer
cycles, came to the conclusion that the world isn't perfect, that
there's no good (at least good realistic) solution to this problem and
that we should just do the same as Linux.

Disabling this warning for individual files in which it triggers
probably doesn't bring us further.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4] mtd: ubi: Compile fastmap.c with -Wno-address-of-packed-member
  2019-09-09 10:23   ` Sascha Hauer
@ 2019-09-10  4:28     ` Andrey Smirnov
  2019-09-12  6:55       ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: Andrey Smirnov @ 2019-09-10  4:28 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

On Mon, Sep 9, 2019 at 3:23 AM Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> On Sat, Sep 07, 2019 at 04:54:55PM -0700, Andrey Smirnov wrote:
> > GCC9 for ARM produces the following warnings:
> >
> > fastmap.c: In function 'ubi_attach_fastmap':
> > fastmap.c:700:31: warning: taking address of packed member of 'struct ubi_fm_scan_pool' may result in an unaligned pointer value [-Waddress-of-packed-member]
> >   700 |  ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &lfree);
> >       |                           ~~~~^~~~~~
> > fastmap.c:704:34: warning: taking address of packed member of 'struct ubi_fm_scan_pool' may result in an unaligned pointer value [-Waddress-of-packed-member]
> >   704 |  ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &lfree);
> >       |                           ~~~~~~~^~~~~~
> >
> > the offending code seems OK and there doesn't seem to be a way to fix
> > this in code, so disable the warning for that file.
> >
> > Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> > ---
>
> Linux disables this warning completely.

Yeah, I saw that. Wasn't sure if we wanted to go that direction or not.

> We just burnt some developer
> cycles, came to the conclusion that the world isn't perfect, that
> there's no good (at least good realistic) solution to this problem and
> that we should just do the same as Linux.
>
> Disabling this warning for individual files in which it triggers
> probably doesn't bring us further.
>

Sure, will do. I think "ratp: Mark struct ratp_bb as packed" might
still be worth applying though.

Thanks,
Andrey Smirnov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4] mtd: ubi: Compile fastmap.c with -Wno-address-of-packed-member
  2019-09-10  4:28     ` Andrey Smirnov
@ 2019-09-12  6:55       ` Sascha Hauer
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2019-09-12  6:55 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

On Mon, Sep 09, 2019 at 09:28:17PM -0700, Andrey Smirnov wrote:
> On Mon, Sep 9, 2019 at 3:23 AM Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >
> > On Sat, Sep 07, 2019 at 04:54:55PM -0700, Andrey Smirnov wrote:
> > > GCC9 for ARM produces the following warnings:
> > >
> > > fastmap.c: In function 'ubi_attach_fastmap':
> > > fastmap.c:700:31: warning: taking address of packed member of 'struct ubi_fm_scan_pool' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > >   700 |  ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &lfree);
> > >       |                           ~~~~^~~~~~
> > > fastmap.c:704:34: warning: taking address of packed member of 'struct ubi_fm_scan_pool' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > >   704 |  ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &lfree);
> > >       |                           ~~~~~~~^~~~~~
> > >
> > > the offending code seems OK and there doesn't seem to be a way to fix
> > > this in code, so disable the warning for that file.
> > >
> > > Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> > > ---
> >
> > Linux disables this warning completely.
> 
> Yeah, I saw that. Wasn't sure if we wanted to go that direction or not.
> 
> > We just burnt some developer
> > cycles, came to the conclusion that the world isn't perfect, that
> > there's no good (at least good realistic) solution to this problem and
> > that we should just do the same as Linux.
> >
> > Disabling this warning for individual files in which it triggers
> > probably doesn't bring us further.
> >
> 
> Sure, will do. I think "ratp: Mark struct ratp_bb as packed" might
> still be worth applying though.

Applied this and also [PATCH 2/4] net: Adjust net_copy_uint32's
signature

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-09-12  6:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-07 23:54 [PATCH 1/4] ratp: Mark struct ratp_bb as packed Andrey Smirnov
2019-09-07 23:54 ` [PATCH 2/4] net: Adjust net_copy_uint32's signature Andrey Smirnov
2019-09-07 23:54 ` [PATCH 3/4] mtd: ubi: Compile fastmap.c with -Wno-address-of-packed-member Andrey Smirnov
2019-09-09 10:23   ` Sascha Hauer
2019-09-10  4:28     ` Andrey Smirnov
2019-09-12  6:55       ` Sascha Hauer
2019-09-07 23:54 ` [PATCH 4/4] USB: gadget: Compile composite.c " Andrey Smirnov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox