"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
portability: HOST_NAME_MAX
To:
gameoftrees@openbsd.org
Date:
Sat, 24 Jun 2023 22:32:52 +0200

Download raw body.

Thread
On FreeBSD, HOST_NAME_MAX is not defined.  Use _POSIX_HOST_NAME_MAX
instead, which is guaranteed to exist.

OK?

The POSIX logic is convoluted.  Basically, if I understand correctly:
If sysconf(_SC_HOST_NAME_MAX) >= _POSIX_HOST_NAME_MAX, then
HOST_NAME_MAX should not be defined in <limits.h>.

-----------------------------------------------
commit 1f948a3aee6f3f9bff26b7f39fe2c4e63ddf8ff6 (main)
from: Christian Weisgerber <naddy@mips.inka.de>
date: Sat Jun 24 20:25:37 2023 UTC
 
 use _POSIX_HOST_NAME_MAX for portability
 
 M  lib/repository_admin.c

diff 294fdcae50063512dd68a933836696c9eb0ea0ff 1f948a3aee6f3f9bff26b7f39fe2c4e63ddf8ff6
commit - 294fdcae50063512dd68a933836696c9eb0ea0ff
commit + 1f948a3aee6f3f9bff26b7f39fe2c4e63ddf8ff6
blob - 31425fb8310125b7f7fe7389432f6a005df42136
blob + b3f6f17b931df0ad083fed1158a332673f844866
--- lib/repository_admin.c
+++ lib/repository_admin.c
@@ -618,7 +618,7 @@ got_repo_cleanup_prepare(struct got_repository *repo,
     struct got_lockfile **lk)
 {
 	const struct got_error *err;
-	char myname[HOST_NAME_MAX + 1];
+	char myname[_POSIX_HOST_NAME_MAX + 1];
 
 	if (gethostname(myname, sizeof(myname)) == -1)
 		return got_error_from_errno("gethostname");

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de