From 1fe299166dce79394838e2eca21e6e9d417b60f4 Mon Sep 17 00:00:00 2001 From: bz Date: Fri, 19 Apr 2019 17:29:20 +0000 Subject: [PATCH] MFC 344740: Fix compilation of world with WITHOUT_{INET,INET6}_SUPPORT or both set. Buildworld failed when both WITHOUT_INET6_SUPPORT and INET equivalent were set. Fix netstat and syslogd by applying appropriate #ifdef INET/INET6 to make world compile again. --- usr.bin/netstat/inet.c | 29 ++++++++++++++++++++++++----- usr.sbin/syslogd/syslogd.c | 8 +++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index bf995d282bb..7b3ce0ce521 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -84,8 +84,10 @@ __FBSDID("$FreeBSD$"); #include "netstat.h" #include "nl_defs.h" -void inetprint(const char *, struct in_addr *, int, const char *, int, +#ifdef INET +static void inetprint(const char *, struct in_addr *, int, const char *, int, const int); +#endif #ifdef INET6 static int udp_done, tcp_done, sdp_done; #endif /* INET6 */ @@ -506,6 +508,7 @@ protopr(u_long off, const char *name, int af1, int proto) so->so_rcv.sb_cc, so->so_snd.sb_cc); } if (numeric_port) { +#ifdef INET if (inp->inp_vflag & INP_IPV4) { inetprint("local", &inp->inp_laddr, (int)inp->inp_lport, name, 1, af1); @@ -513,8 +516,12 @@ protopr(u_long off, const char *name, int af1, int proto) inetprint("remote", &inp->inp_faddr, (int)inp->inp_fport, name, 1, af1); } +#endif +#if defined(INET) && defined(INET6) + else +#endif #ifdef INET6 - else if (inp->inp_vflag & INP_IPV6) { + if (inp->inp_vflag & INP_IPV6) { inet6print("local", &inp->in6p_laddr, (int)inp->inp_lport, name, 1); if (!Lflag) @@ -523,6 +530,7 @@ protopr(u_long off, const char *name, int af1, int proto) } /* else nothing printed now */ #endif /* INET6 */ } else if (inp->inp_flags & INP_ANONPORT) { +#ifdef INET if (inp->inp_vflag & INP_IPV4) { inetprint("local", &inp->inp_laddr, (int)inp->inp_lport, name, 1, af1); @@ -530,8 +538,12 @@ protopr(u_long off, const char *name, int af1, int proto) inetprint("remote", &inp->inp_faddr, (int)inp->inp_fport, name, 0, af1); } +#endif +#if defined(INET) && defined(INET6) + else +#endif #ifdef INET6 - else if (inp->inp_vflag & INP_IPV6) { + if (inp->inp_vflag & INP_IPV6) { inet6print("local", &inp->in6p_laddr, (int)inp->inp_lport, name, 1); if (!Lflag) @@ -540,6 +552,7 @@ protopr(u_long off, const char *name, int af1, int proto) } /* else nothing printed now */ #endif /* INET6 */ } else { +#ifdef INET if (inp->inp_vflag & INP_IPV4) { inetprint("local", &inp->inp_laddr, (int)inp->inp_lport, name, 0, af1); @@ -549,8 +562,12 @@ protopr(u_long off, const char *name, int af1, int proto) inp->inp_lport != inp->inp_fport, af1); } +#endif +#if defined(INET) && defined(INET6) + else +#endif #ifdef INET6 - else if (inp->inp_vflag & INP_IPV6) { + if (inp->inp_vflag & INP_IPV6) { inet6print("local", &inp->in6p_laddr, (int)inp->inp_lport, name, 0); if (!Lflag) @@ -1415,10 +1432,11 @@ pim_stats(u_long off __unused, const char *name, int af1 __unused, xo_close_container(name); } +#ifdef INET /* * Pretty print an Internet address (net address + port). */ -void +static void inetprint(const char *container, struct in_addr *in, int port, const char *proto, int num_port, const int af1) { @@ -1505,3 +1523,4 @@ inetname(struct in_addr *inp) } return (line); } +#endif diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index d9fc86ef059..ccd1ed554ce 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1607,6 +1607,7 @@ iovlist_append(struct iovlist *il, const char *str) } } +#if defined(INET) || defined(INET6) static void iovlist_truncate(struct iovlist *il, size_t size) { @@ -1627,6 +1628,7 @@ iovlist_truncate(struct iovlist *il, size_t size) } } } +#endif static void fprintlog_write(struct filed *f, struct iovlist *il, int flags) @@ -2945,7 +2947,11 @@ timedout(int sig __unused) * Returns -1 on error, 0 if the argument was valid. */ static int +#if defined(INET) || defined(INET6) allowaddr(char *s) +#else +allowaddr(char *s __unused) +#endif { #if defined(INET) || defined(INET6) char *cp1, *cp2; @@ -3107,13 +3113,13 @@ allowaddr(char *s) } printf("port = %d\n", ap->port); } -#endif return (0); err: if (res != NULL) freeaddrinfo(res); free(ap); +#endif return (-1); } -- 2.45.0