diff options
author | Florian Weimer <fweimer@redhat.com> | 2024-05-18 09:33:19 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2024-05-27 17:25:13 +0200 |
commit | 26e7005728f0eea2972474e6be2905c467661237 (patch) | |
tree | cc9b1d51cd6805f7f7caaf6310152cac6c43971b /sysdeps | |
parent | 9f2b100d6705b9bbb25206b53e80d7759644e06e (diff) | |
download | glibc-26e7005728f0eea2972474e6be2905c467661237.zip glibc-26e7005728f0eea2972474e6be2905c467661237.tar.gz glibc-26e7005728f0eea2972474e6be2905c467661237.tar.bz2 |
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>
(cherry picked from commit 8d7b6b4cb27d4dec1dd5f7960298c1699275f962)
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/mach/hurd/bits/socket.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/bits/socket.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/net/if_packet.h | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/netash/ash.h | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/neteconet/ec.h | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/netiucv/iucv.h | 2 |
6 files changed, 8 insertions, 8 deletions
diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h index 3e72f9f..b5eeac3 100644 --- a/sysdeps/mach/hurd/bits/socket.h +++ b/sysdeps/mach/hurd/bits/socket.h @@ -153,7 +153,7 @@ enum __socket_type #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. */ @@ -170,7 +170,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]; diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h index 0d86feb..6dab283 100644 --- a/sysdeps/unix/sysv/linux/bits/socket.h +++ b/sysdeps/unix/sysv/linux/bits/socket.h @@ -180,7 +180,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. */ @@ -193,7 +193,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]; diff --git a/sysdeps/unix/sysv/linux/net/if_packet.h b/sysdeps/unix/sysv/linux/net/if_packet.h index 9ffb69b..c17e1c2 100644 --- a/sysdeps/unix/sysv/linux/net/if_packet.h +++ b/sysdeps/unix/sysv/linux/net/if_packet.h @@ -26,7 +26,7 @@ From Linux 2.1 the AF_PACKET interface is preferred and you should consider using it in place of this one. */ -struct sockaddr_pkt +struct __attribute_struct_may_alias__ sockaddr_pkt { __SOCKADDR_COMMON (spkt_); unsigned char spkt_device[14]; diff --git a/sysdeps/unix/sysv/linux/netash/ash.h b/sysdeps/unix/sysv/linux/netash/ash.h index 7d885d1..7a6ff50 100644 --- a/sysdeps/unix/sysv/linux/netash/ash.h +++ b/sysdeps/unix/sysv/linux/netash/ash.h @@ -22,7 +22,7 @@ #include <features.h> #include <bits/sockaddr.h> -struct sockaddr_ash +struct __attribute_struct_may_alias__ sockaddr_ash { __SOCKADDR_COMMON (sash_); /* Common data: address family etc. */ int sash_ifindex; /* Interface to use. */ diff --git a/sysdeps/unix/sysv/linux/neteconet/ec.h b/sysdeps/unix/sysv/linux/neteconet/ec.h index b07a107..f3132f0 100644 --- a/sysdeps/unix/sysv/linux/neteconet/ec.h +++ b/sysdeps/unix/sysv/linux/neteconet/ec.h @@ -28,7 +28,7 @@ struct ec_addr unsigned char net; /* Network number. */ }; -struct sockaddr_ec +struct __attribute_struct_may_alias__ sockaddr_ec { __SOCKADDR_COMMON (sec_); unsigned char port; /* Port number. */ diff --git a/sysdeps/unix/sysv/linux/netiucv/iucv.h b/sysdeps/unix/sysv/linux/netiucv/iucv.h index f5fad81..27151e8 100644 --- a/sysdeps/unix/sysv/linux/netiucv/iucv.h +++ b/sysdeps/unix/sysv/linux/netiucv/iucv.h @@ -23,7 +23,7 @@ __BEGIN_DECLS -struct sockaddr_iucv +struct __attribute_struct_may_alias__ sockaddr_iucv { __SOCKADDR_COMMON (siucv_); unsigned short siucv_port; /* Reserved */ |