lkml.org 
[lkml]   [2019]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2] net/socket: fix GCC8+ Wpacked-not-aligned warnings
Date
From: Qian Cai
> Sent: 30 July 2019 15:38
...
> Use an implicit alignment for "struct __kernel_sockaddr_storage" so it
> can keep the same alignments as a member in both packed and un-packed
> structures without breaking UAPI.
>
> Suggested-by: David Laight <David.Laight@ACULAB.COM>
...

Although I suggested it needs a bit of tidy up.

Add a comment maybe:

/* The definition uses anonymous union and struct in order to
* control the default alignment. */

> struct __kernel_sockaddr_storage {
> - __kernel_sa_family_t ss_family; /* address family */
> - /* Following field(s) are implementation specific */
> - char __data[_K_SS_MAXSIZE - sizeof(unsigned short)];
> + union {
> + void *__align; /* implementation specific desired alignment */

Move the 'void *' below the struct so the first member is the 'public one.

> + struct {
> + __kernel_sa_family_t ss_family; /* address family */
> + /* Following field(s) are implementation specific */
> + char __data[_K_SS_MAXSIZE - sizeof(unsigned short)];
> /* space to achieve desired size, */
> /* _SS_MAXSIZE value minus size of ss_family */
> -} __attribute__ ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */
> + };
> + };
> +};
>
> #endif /* _UAPI_LINUX_SOCKET_H */
> --
> 1.8.3.1

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

\
 
 \ /
  Last update: 2019-07-30 17:00    [W:0.043 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site