On 5/14/21 3:11 PM, Alejandro Colomar wrote:
- Remove unnecessary includes
- Add a comment about why each include is needed
- Sort alphabetically
All this has been done using iwyu(1):
$ iwyu getaddrinfo_server.c 2>&1 \
| sed -e '\,^#,s,//,/*,' -e '\,^#,s,$, */,' \
| sed '/^#/s/\w*\.\.\./.../';
getaddrinfo_client.c should add these lines:
getaddrinfo_client.c should remove these lines:
- #include <sys/types.h> // lines 1-1
The full include-list for getaddrinfo_client.c:
#include <netdb.h> /* for addrinfo, freeaddrinfo, gai_strerror, ... */
#include <stdio.h> /* for fprintf, stderr, perror, printf, NULL, size_t */
#include <stdlib.h> /* for exit, EXIT_FAILURE, EXIT_SUCCESS */
#include <string.h> /* for memset, strlen */
#include <sys/socket.h> /* for connect, socket, AF_UNSPEC, SOCK_DGRAM */
#include <unistd.h> /* for close, read, write, ssize_t */
Oops, the above should be:
getaddrinfo_server.c should add these lines:
getaddrinfo_server.c should remove these lines:
- #include <sys/types.h> // lines 1-1
The full include-list for getaddrinfo_server.c:
#include <netdb.h> /* for addrinfo, gai_strerror, freeaddrinfo,
... */
#include <stdio.h> /* for fprintf, NULL, stderr, printf */
#include <stdlib.h> /* for exit, EXIT_FAILURE */
#include <string.h> /* for memset */
#include <sys/socket.h> /* for bind, recvfrom, sendto, socket, ... */
#include <unistd.h> /* for close, ssize_t */
The code contents are correct.
$ iwyu getaddrinfo_client.c 2>&1 \
| sed -e '\,^#,s,//,/*,' -e '\,^#,s,$, */,' \
| sed '/^#/s/\w*\.\.\./.../';
getaddrinfo_client.c should add these lines:
getaddrinfo_client.c should remove these lines:
- #include <sys/types.h> // lines 1-1
The full include-list for getaddrinfo_client.c:
#include <netdb.h> /* for addrinfo, freeaddrinfo, gai_strerror, ... */
#include <stdio.h> /* for fprintf, stderr, perror, printf, NULL, size_t */
#include <stdlib.h> /* for exit, EXIT_FAILURE, EXIT_SUCCESS */
#include <string.h> /* for memset, strlen */
#include <sys/socket.h> /* for connect, socket, AF_UNSPEC, SOCK_DGRAM */
#include <unistd.h> /* for close, read, write, ssize_t */
$
--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/