From ee7952c5112a2b08c1b196cabd946e0b3c3dc74a Mon Sep 17 00:00:00 2001
From: Antony Antony <antony@phenome.org>
Date: Mon, 14 Aug 2017 20:52:18 +0200
Subject: [PATCH] posix: use HOST_NAME_MAX consitently from limits.h

---
 lib/libswan/id.c                | 5 +----
 ports/linux/include/sysdep.h    | 2 +-
 programs/pluto/ikev2_ipseckey.c | 2 +-
 programs/pluto/rcv_whack.c      | 4 ----
 4 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/lib/libswan/id.c b/lib/libswan/id.c
index 06cc751..b89650a 100644
--- a/lib/libswan/id.c
+++ b/lib/libswan/id.c
@@ -22,10 +22,6 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <unistd.h>
-#ifndef HOST_NAME_MAX	/* POSIX 1003.1-2001 says <unistd.h> defines this */
-#define HOST_NAME_MAX 255	/* upper bound, according to SUSv2 */
-#endif
 
 #include <libreswan.h>
 
@@ -34,6 +30,7 @@
 #include "libreswan/passert.h"
 #include "lswalloc.h"
 #include "lswlog.h"
+#include "sysdep.h"
 #include "id.h"
 #include "x509.h"
 #include <cert.h>
diff --git a/ports/linux/include/sysdep.h b/ports/linux/include/sysdep.h
index deb2ac1..b782b2c 100644
--- a/ports/linux/include/sysdep.h
+++ b/ports/linux/include/sysdep.h
@@ -5,7 +5,7 @@
 #define TimeZoneOffset timezone
 
 #include <limits.h>
-/* POSIX 1003.1-2001 says <unistd.h> defines this */
+/* POSIX 1003.1-2001 says <limits.h> defines this */
 #ifndef HOST_NAME_MAX
 /* some don't even use _POSIX_HOST_NAME_MAX */
 # ifdef _POSIX_HOST_NAME_MAX
diff --git a/programs/pluto/ikev2_ipseckey.c b/programs/pluto/ikev2_ipseckey.c
index 45872ef..1d32d37 100644
--- a/programs/pluto/ikev2_ipseckey.c
+++ b/programs/pluto/ikev2_ipseckey.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <errno.h>
 #include <arpa/inet.h> /* for inet_ntop */
 #include <arpa/nameser.h>
@@ -31,6 +30,7 @@
 #include "unbound-event.h"
 #include "libreswan.h"
 #include "lswlog.h"
+#include "sysdep.h"
 #include "defs.h"
 #include "log.h"
 #include "constants.h" /* for demux.h */
diff --git a/programs/pluto/rcv_whack.c b/programs/pluto/rcv_whack.c
index baa9fdf..9a53ed5 100644
--- a/programs/pluto/rcv_whack.c
+++ b/programs/pluto/rcv_whack.c
@@ -28,10 +28,6 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#ifndef HOST_NAME_MAX           /* POSIX 1003.1-2001 says <unistd.h> defines this */
-# define HOST_NAME_MAX  255     /* upper bound, according to SUSv2 */
-#endif
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-- 
2.9.4

