diff options
author | Zack Weinberg <zackw@panix.com> | 2019-06-06 09:49:54 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2020-01-08 14:15:42 -0500 |
commit | 94ab7b6b7f5b7f424554e325c20f60f706efc207 (patch) | |
tree | edfbeab9619c7ecdc74f25326c8b4fcc428b53bb /resolv | |
parent | 0e8caaf081a844893aa5bbf67010c3e34ca47f34 (diff) | |
download | glibc-94ab7b6b7f5b7f424554e325c20f60f706efc207.zip glibc-94ab7b6b7f5b7f424554e325c20f60f706efc207.tar.gz glibc-94ab7b6b7f5b7f424554e325c20f60f706efc207.tar.bz2 |
Don’t include sys/socket.h from public headers.
No standard public header is required to include sys/socket.h,
although some are allowed to. Several public headers need the
definitions of socklen_t, struct sockaddr, and/or struct
sockaddr_storage, but nothing else from sys/socket.h. We already have
a single-type header for socklen_t, so this patch adds single-type
headers for struct sockaddr and struct sockaddr_storage.
The definition of struct sockaddr_storage is subtly different on Linux
than on the Hurd; in order to not need two copies of
bits/types/struct_sockaddr_storage.h, bits/sockaddr.h is now
responsible for defining __ss_aligntype if ‘unsigned long int’ is not
the correct definition.
I also added a single-type header for struct linger, even though only
sys/socket.h is expected to define that, just because all three copies
of bits/socket.h were defining it exactly the same way. There would
also be a case for defining it directly in sys/socket.h but this
seemed tidier.
I did *not* create single-type headers for struct msghdr and struct
cmsghdr, because those and their helper macros are not consistent
among the three copies of bits/socket.h, and, again, only sys/socket.h
is expected to define them.
The large number of .c files that add an `#include <sys/socket.h>`
might make this look like it’s not worth doing. However, after this
change, only half of the files in the glibc source tree that include
netinet/in.h also need to include sys/socket.h, and only a third of
the files that include netdb.h need to include sys/socket.h. Before,
all of the files in both groups were getting sys/socket.h. That seems
like enough justification to me.
While I was at it I noticed that sys/socketvar.h is yet another
backward compatibility header that does nothing but include some other
header (sys/socket.h, in this case) and also doesn’t need to be
system-dependent.
* socket/bits/types/struct_linger.h
* socket/bits/types/struct_sockaddr.h
* socket/bits/types/struct_sockaddr_storage.h:
New single-type headers, factored out of the various bits/socket.h
headers.
* include/bits/types/struct_linger.h
* include/bits/types/struct_sockaddr.h
* include/bits/types/struct_sockaddr_storage.h:
New wrappers.
* socket/Makefile (headers): Add bits/types/struct_linger.h,
bits/types/struct_sockaddr.h, and bits/types/struct_sockaddr_storage.h.
Alphabetize the list.
* bits/socket.h, sysdeps/mach/hurd/bits/socket.h
* sysdeps/unix/sysv/linux/bits/socket.h:
Don’t define struct sockaddr, struct sockaddr_storage,
__ss_aligntype, or struct linger here. Minimize inclusions.
* sysdeps/unix/bsd/bits/sockaddr.h: Define __ss_aligntype here.
* socket/sys/socket.h: Include bits/types/struct_linger.h,
bits/sockaddr.h, bits/types/struct_sockaddr.h, and
bits/types/struct_sockaddr_storage.h. Move inclusion of
bits/socket.h below forward declaration of struct timespec,
and update commentary.
* inet/ifaddrs.h, socket/net/if.h
* sysdeps/mach/hurd/net/if_arp.h
* sysdeps/mach/hurd/net/route.h
* sysdeps/unix/sysv/linux/errqueue.h
* sysdeps/unix/sysv/linux/net/if_arp.h
* sysdeps/unix/sysv/linux/net/route.h:
Include bits/types/struct_sockaddr.h and possibly also bits/types.h,
not sys/socket.h or sys/types.h.
* sysdeps/unix/sysv/linux/errqueue.h:
* sysdeps/unix/sysv/linux/net/route.h:
Use __uint8_t and __uint32_t instead of uint8_t and uint32_t.
* inet/arpa/inet.h: Include bits/types/size_t.h.
* inet/netinet/in.h: Include bits/sockaddr.h,
bits/types/struct_sockaddr.h, and
bits/types/struct_sockaddr_storage.h,
not sys/socket.h. Use __socklen_t instead of socklen_t.
* inet/netinet/tcp.h: Include bits/types.h and
bits/types/struct_sockaddr_storage.h, not sys/socket.h or
bits/stdint-uintn.h. Use __uint8_t, __uint16_t, and __uint32_t
instead of uint8_t, uint16_t and uint32_t.
* inet/protocols/routed.h: Include features.h and
bits/types/struct_sockaddr.h, not sys/socket.h.
* resolv/netdb.h: Include bits/types/socklen_t.h.
* sysdeps/unix/sysv/linux/netatalk/at.h: Don’t include sys/socket.h.
* include/ifaddrs.h: Include stddef.h for size_t.
* include/netdb.h: Use __socklen_t instead of socklen_t.
* inet/check_pf.c, inet/gethstbynm.c, inet/gethstbynm_r.c
* inet/getsourcefilter.c, inet/inet6_opt.c, inet/inet6_option.c
* inet/inet6_rth.c, inet/setsourcefilter.c, inet/test-ifaddrs.c
* inet/test-inet6_opt.c, inet/tst-inet6_rth.c
* inet/tst-inet6_scopeid_pton.c, nis/nss_nis/nis-hosts.c
* nis/nss_nisplus/nisplus-hosts.c, nscd/aicache.c, nscd/cache.c
* nscd/hstcache.c, nscd/initgrcache.c, nscd/netgroupcache.c
* nscd/nscd_gethst_r.c, nscd/servicescache.c, nss/digits_dots.c
* nss/nss_files/files-hosts.c, nss/nss_files/files-network.c
* nss/tst-nss-files-hosts-erange.c, nss/tst-nss-files-hosts-getent.c
* nss/tst-nss-files-hosts-multi.c, posix/tst-getaddrinfo3.c
* resolv/nss_dns/dns-network.c, resolv/resolv_conf.c
* resolv/tst-bug18665-tcp.c, resolv/tst-bug18665.c
* resolv/tst-inet_ntop.c, resolv/tst-inet_pton.c
* resolv/tst-resolv-ai_idn-common.c, resolv/tst-resolv-basic.c
* resolv/tst-resolv-edns.c, resolv/tst-resolv-network.c
* resolv/tst-resolv-nondecimal.c, resolv/tst-resolv-search.c
* resolv/tst-resolv-threads.c, resolv/tst-resolv-trailing.c
* sunrpc/rpc_gethostbyname.c
* support/support_format_address_family.c
* support/support_format_addrinfo.c
* support/support_format_dns_packet.c
* support/support_format_hostent.c, support/support_format_netent.c
* sysdeps/mach/hurd/if_index.c
* sysdeps/unix/sysv/linux/check_native.c: Include sys/socket.h.
* resolv/tst-resolv-binary.c: Include sys/types.h.
* sysdeps/generic/sys/socketvar.h: Move to socket/sys/socketvar.h.
* include/sys/socketvar.h: New wrapper.
* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
Update.
Diffstat (limited to 'resolv')
-rw-r--r-- | resolv/netdb.h | 1 | ||||
-rw-r--r-- | resolv/nss_dns/dns-network.c | 1 | ||||
-rw-r--r-- | resolv/resolv_conf.c | 1 | ||||
-rw-r--r-- | resolv/tst-bug18665-tcp.c | 1 | ||||
-rw-r--r-- | resolv/tst-bug18665.c | 1 | ||||
-rw-r--r-- | resolv/tst-inet_ntop.c | 1 | ||||
-rw-r--r-- | resolv/tst-inet_pton.c | 1 | ||||
-rw-r--r-- | resolv/tst-resolv-ai_idn-common.c | 1 | ||||
-rw-r--r-- | resolv/tst-resolv-basic.c | 1 | ||||
-rw-r--r-- | resolv/tst-resolv-binary.c | 1 | ||||
-rw-r--r-- | resolv/tst-resolv-edns.c | 1 | ||||
-rw-r--r-- | resolv/tst-resolv-network.c | 1 | ||||
-rw-r--r-- | resolv/tst-resolv-nondecimal.c | 1 | ||||
-rw-r--r-- | resolv/tst-resolv-search.c | 1 | ||||
-rw-r--r-- | resolv/tst-resolv-threads.c | 1 | ||||
-rw-r--r-- | resolv/tst-resolv-trailing.c | 1 |
16 files changed, 16 insertions, 0 deletions
diff --git a/resolv/netdb.h b/resolv/netdb.h index 575e416..91277fc 100644 --- a/resolv/netdb.h +++ b/resolv/netdb.h @@ -25,6 +25,7 @@ #include <features.h> #include <netinet/in.h> +#include <bits/types/socklen_t.h> #include <bits/stdint-uintn.h> #ifdef __USE_MISC /* This is necessary to make this include file properly replace the diff --git a/resolv/nss_dns/dns-network.c b/resolv/nss_dns/dns-network.c index 906a3a6..06f187f 100644 --- a/resolv/nss_dns/dns-network.c +++ b/resolv/nss_dns/dns-network.c @@ -65,6 +65,7 @@ #include <stddef.h> #include "nsswitch.h" +#include <sys/socket.h> #include <arpa/inet.h> #include <arpa/nameser.h> #include <resolv/resolv-internal.h> diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c index 08c50ef..316d27f 100644 --- a/resolv/resolv_conf.c +++ b/resolv/resolv_conf.c @@ -23,6 +23,7 @@ #include <libc-lock.h> #include <resolv-internal.h> #include <sys/stat.h> +#include <sys/socket.h> #include <libc-symbols.h> /* _res._u._ext.__glibc_extension_index is used as an index into a diff --git a/resolv/tst-bug18665-tcp.c b/resolv/tst-bug18665-tcp.c index 3717067..539b5eb 100644 --- a/resolv/tst-bug18665-tcp.c +++ b/resolv/tst-bug18665-tcp.c @@ -22,6 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> #include <support/check.h> #include <support/check_nss.h> #include <support/resolv_test.h> diff --git a/resolv/tst-bug18665.c b/resolv/tst-bug18665.c index 37e2828..c1e29cf 100644 --- a/resolv/tst-bug18665.c +++ b/resolv/tst-bug18665.c @@ -21,6 +21,7 @@ #include <resolv.h> #include <stdio.h> #include <string.h> +#include <sys/socket.h> #include <support/check.h> #include <support/resolv_test.h> #include <support/xthread.h> diff --git a/resolv/tst-inet_ntop.c b/resolv/tst-inet_ntop.c index f0de063..728fd25 100644 --- a/resolv/tst-inet_ntop.c +++ b/resolv/tst-inet_ntop.c @@ -3,6 +3,7 @@ #include <netinet/in.h> #include <stdio.h> #include <string.h> +#include <sys/socket.h> static int do_test (void) diff --git a/resolv/tst-inet_pton.c b/resolv/tst-inet_pton.c index 71c6794..7092143 100644 --- a/resolv/tst-inet_pton.c +++ b/resolv/tst-inet_pton.c @@ -21,6 +21,7 @@ #include <stdbool.h> #include <stdio.h> #include <string.h> +#include <sys/socket.h> #include <support/check.h> #include <support/next_to_fault.h> #include <support/xunistd.h> diff --git a/resolv/tst-resolv-ai_idn-common.c b/resolv/tst-resolv-ai_idn-common.c index 9e8ed76..ff6ff13 100644 --- a/resolv/tst-resolv-ai_idn-common.c +++ b/resolv/tst-resolv-ai_idn-common.c @@ -23,6 +23,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> #include <support/check.h> #include <support/check_nss.h> #include <support/resolv_test.h> diff --git a/resolv/tst-resolv-basic.c b/resolv/tst-resolv-basic.c index 2ad9ee3..deb1e3c 100644 --- a/resolv/tst-resolv-basic.c +++ b/resolv/tst-resolv-basic.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> #include <support/check.h> #include <support/check_nss.h> #include <support/format_nss.h> diff --git a/resolv/tst-resolv-binary.c b/resolv/tst-resolv-binary.c index 90a94a5..c7ad3bd 100644 --- a/resolv/tst-resolv-binary.c +++ b/resolv/tst-resolv-binary.c @@ -18,6 +18,7 @@ #include <resolv.h> #include <string.h> +#include <sys/types.h> #include <support/check.h> #include <support/resolv_test.h> diff --git a/resolv/tst-resolv-edns.c b/resolv/tst-resolv-edns.c index 4fbb3a0..5975203 100644 --- a/resolv/tst-resolv-edns.c +++ b/resolv/tst-resolv-edns.c @@ -22,6 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> #include <support/check.h> #include <support/resolv_test.h> #include <support/support.h> diff --git a/resolv/tst-resolv-network.c b/resolv/tst-resolv-network.c index a91699c..2bb5266 100644 --- a/resolv/tst-resolv-network.c +++ b/resolv/tst-resolv-network.c @@ -19,6 +19,7 @@ #include <netdb.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> #include <support/check.h> #include <support/check_nss.h> #include <support/resolv_test.h> diff --git a/resolv/tst-resolv-nondecimal.c b/resolv/tst-resolv-nondecimal.c index 5d161a4..8b1b162 100644 --- a/resolv/tst-resolv-nondecimal.c +++ b/resolv/tst-resolv-nondecimal.c @@ -18,6 +18,7 @@ #include <netdb.h> #include <stdlib.h> +#include <sys/socket.h> #include <support/check.h> #include <support/check_nss.h> #include <support/resolv_test.h> diff --git a/resolv/tst-resolv-search.c b/resolv/tst-resolv-search.c index 6379147..545a0a2 100644 --- a/resolv/tst-resolv-search.c +++ b/resolv/tst-resolv-search.c @@ -19,6 +19,7 @@ #include <resolv.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> #include <support/check.h> #include <support/check_nss.h> #include <support/resolv_test.h> diff --git a/resolv/tst-resolv-threads.c b/resolv/tst-resolv-threads.c index a3a874e..0b4c198 100644 --- a/resolv/tst-resolv-threads.c +++ b/resolv/tst-resolv-threads.c @@ -29,6 +29,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> #include <support/check.h> #include <support/namespace.h> #include <support/resolv_test.h> diff --git a/resolv/tst-resolv-trailing.c b/resolv/tst-resolv-trailing.c index f27e110..b2ec1df 100644 --- a/resolv/tst-resolv-trailing.c +++ b/resolv/tst-resolv-trailing.c @@ -18,6 +18,7 @@ #include <array_length.h> #include <netdb.h> +#include <sys/socket.h> #include <support/check.h> #include <support/check_nss.h> #include <support/resolv_test.h> |