summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGergely Nagy <algernon@balabit.hu>2012-03-24 15:52:25 +0100
committerGergely Nagy <algernon@balabit.hu>2012-03-24 15:52:25 +0100
commitc515ced437047b459cfce6b6a34eb572558566f9 (patch)
tree8edac49a71c8c4b62bf10f20e8b33d699ff078c0
parent99dd3a3f8dc881c0f4939205dc4c04bb6ea0c149 (diff)
downloadlibumberlog-c515ced437047b459cfce6b6a34eb572558566f9.tar.gz
libumberlog-c515ced437047b459cfce6b6a34eb572558566f9.tar.xz
libumberlog-c515ced437047b459cfce6b6a34eb572558566f9.zip
Portability fixes
Use _POSIX_HOST_NAME_MAX instead of HOST_NAME_MAX: both Linux and FreeBSD have the former, but FreeBSD does not have HOST_NAME_MAX in limits.h Signed-off-by: Gergely Nagy <algernon@balabit.hu>
-rw-r--r--lib/umberlog.c6
-rw-r--r--t/test_umberlog.c4
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/umberlog.c b/lib/umberlog.c
index 516f41c..e2d72de 100644
--- a/lib/umberlog.c
+++ b/lib/umberlog.c
@@ -64,7 +64,7 @@ static __thread struct
uid_t uid;
gid_t gid;
const char *ident;
- char hostname[HOST_NAME_MAX + 1];
+ char hostname[_POSIX_HOST_NAME_MAX + 1];
} ul_sys_settings;
static void
@@ -91,7 +91,7 @@ ul_openlog (const char *ident, int option, int facility)
ul_sys_settings.uid = getuid ();
ul_sys_settings.ident = ident;
- gethostname (ul_sys_settings.hostname, HOST_NAME_MAX);
+ gethostname (ul_sys_settings.hostname, _POSIX_HOST_NAME_MAX);
}
/** HELPERS **/
@@ -156,7 +156,7 @@ static inline const char *
_get_hostname (void)
{
if (ul_sys_settings.flags & LOG_UL_NOCACHE)
- gethostname (ul_sys_settings.hostname, HOST_NAME_MAX);
+ gethostname (ul_sys_settings.hostname, _POSIX_HOST_NAME_MAX);
return ul_sys_settings.hostname;
}
diff --git a/t/test_umberlog.c b/t/test_umberlog.c
index d1c2911..f20d28b 100644
--- a/t/test_umberlog.c
+++ b/t/test_umberlog.c
@@ -61,7 +61,7 @@ test_simple (void)
{
char *msg;
struct json_object *jo;
- char host[HOST_NAME_MAX + 1];
+ char host[_POSIX_HOST_NAME_MAX + 1];
openlog ("umberlog/test_simple", 0, LOG_LOCAL0);
@@ -69,7 +69,7 @@ test_simple (void)
jo = parse_msg (msg);
free (msg);
- gethostname (host, HOST_NAME_MAX);
+ gethostname (host, _POSIX_HOST_NAME_MAX);
verify_value (jo, "msg", "hello, I'm test_simple!");
verify_value (jo, "facility", "local0");