qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] slirp: Fix build with gcc 9
@ 2019-03-01  9:39 Greg Kurz
  2019-03-01  9:49 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kurz @ 2019-03-01  9:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz, samuel.thibault, jan.kiszka, Peter Maydell

Build fails with gcc 9:

  CC      slirp/ndp_table.o
slirp/ndp_table.c: In function ‘ndp_table_add’:
slirp/ndp_table.c:31:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
   31 |         if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) {
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
slirp/ndp_table.c: In function ‘ndp_table_search’:
slirp/ndp_table.c:75:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
   75 |         if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) {
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

The ndpentry structure isn't used to model on-the-wire data or anything
else that would care for the struct layout. It doesn't need to be packed
actually. Just drop SLIRP_PACKED.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
v2: - don't check the struct size at compile time
---
 slirp/slirp.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index 752a4cd8c81c..8068ba1d1e9e 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -106,7 +106,7 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,
 struct ndpentry {
     unsigned char   eth_addr[ETH_ALEN];     /* sender hardware address */
     struct in6_addr ip_addr;                /* sender IP address       */
-} SLIRP_PACKED;
+};
 
 #define NDP_TABLE_SIZE 16
 

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

* Re: [Qemu-devel] [PATCH v2] slirp: Fix build with gcc 9
  2019-03-01  9:39 [Qemu-devel] [PATCH v2] slirp: Fix build with gcc 9 Greg Kurz
@ 2019-03-01  9:49 ` Peter Maydell
  2019-03-02  1:33   ` Samuel Thibault
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2019-03-01  9:49 UTC (permalink / raw)
  To: Greg Kurz; +Cc: QEMU Developers, Samuel Thibault, Jan Kiszka

On Fri, 1 Mar 2019 at 09:39, Greg Kurz <groug@kaod.org> wrote:
>
> Build fails with gcc 9:
>
>   CC      slirp/ndp_table.o
> slirp/ndp_table.c: In function ‘ndp_table_add’:
> slirp/ndp_table.c:31:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
>    31 |         if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) {
>       |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> slirp/ndp_table.c: In function ‘ndp_table_search’:
> slirp/ndp_table.c:75:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
>    75 |         if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) {
>       |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> The ndpentry structure isn't used to model on-the-wire data or anything
> else that would care for the struct layout. It doesn't need to be packed
> actually. Just drop SLIRP_PACKED.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
> v2: - don't check the struct size at compile time
> ---
>  slirp/slirp.h |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/slirp/slirp.h b/slirp/slirp.h
> index 752a4cd8c81c..8068ba1d1e9e 100644
> --- a/slirp/slirp.h
> +++ b/slirp/slirp.h
> @@ -106,7 +106,7 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,
>  struct ndpentry {
>      unsigned char   eth_addr[ETH_ALEN];     /* sender hardware address */
>      struct in6_addr ip_addr;                /* sender IP address       */
> -} SLIRP_PACKED;
> +};
>
>  #define NDP_TABLE_SIZE 16

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH v2] slirp: Fix build with gcc 9
  2019-03-01  9:49 ` Peter Maydell
@ 2019-03-02  1:33   ` Samuel Thibault
  0 siblings, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2019-03-02  1:33 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Greg Kurz, QEMU Developers, Jan Kiszka

Peter Maydell, le ven. 01 mars 2019 09:49:26 +0000, a ecrit:
> On Fri, 1 Mar 2019 at 09:39, Greg Kurz <groug@kaod.org> wrote:
> >
> > Build fails with gcc 9:
> >
> >   CC      slirp/ndp_table.o
> > slirp/ndp_table.c: In function ‘ndp_table_add’:
> > slirp/ndp_table.c:31:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
> >    31 |         if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) {
> >       |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > slirp/ndp_table.c: In function ‘ndp_table_search’:
> > slirp/ndp_table.c:75:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
> >    75 |         if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) {
> >       |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> >
> > The ndpentry structure isn't used to model on-the-wire data or anything
> > else that would care for the struct layout. It doesn't need to be packed
> > actually. Just drop SLIRP_PACKED.
> >
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> > v2: - don't check the struct size at compile time
> > ---
> >  slirp/slirp.h |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/slirp/slirp.h b/slirp/slirp.h
> > index 752a4cd8c81c..8068ba1d1e9e 100644
> > --- a/slirp/slirp.h
> > +++ b/slirp/slirp.h
> > @@ -106,7 +106,7 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,
> >  struct ndpentry {
> >      unsigned char   eth_addr[ETH_ALEN];     /* sender hardware address */
> >      struct in6_addr ip_addr;                /* sender IP address       */
> > -} SLIRP_PACKED;
> > +};
> >
> >  #define NDP_TABLE_SIZE 16
> 
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Applied to my tree, thanks!

Samuel

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

end of thread, other threads:[~2019-03-02  1:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-01  9:39 [Qemu-devel] [PATCH v2] slirp: Fix build with gcc 9 Greg Kurz
2019-03-01  9:49 ` Peter Maydell
2019-03-02  1:33   ` Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).