mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
socket: Use may_alias on sockaddr structs (bug 19622)
This supports common coding patterns. The GCC C front end before version 7 rejects the may_alias attribute on a struct definition if it was not present in a previous forward declaration, so this attribute can only be conditionally applied. This implements the spirit of the change in Austin Group issue 1641. Suggested-by: Marek Polacek <polacek@redhat.com> Suggested-by: Jakub Jelinek <jakub@redhat.com> Reviewed-by: Sam James <sam@gentoo.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
@ -181,7 +181,7 @@ typedef __socklen_t socklen_t;
|
||||
#include <bits/sockaddr.h>
|
||||
|
||||
/* Structure describing a generic socket address. */
|
||||
struct sockaddr
|
||||
struct __attribute_struct_may_alias__ sockaddr
|
||||
{
|
||||
__SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
|
||||
char sa_data[14]; /* Address data. */
|
||||
@ -194,7 +194,7 @@ struct sockaddr
|
||||
#define _SS_PADSIZE \
|
||||
(_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))
|
||||
|
||||
struct sockaddr_storage
|
||||
struct __attribute_struct_may_alias__ sockaddr_storage
|
||||
{
|
||||
__SOCKADDR_COMMON (ss_); /* Address family, etc. */
|
||||
char __ss_padding[_SS_PADSIZE];
|
||||
|
Reference in New Issue
Block a user