git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-compat-util.h: Provide missing netdb.h definitions

From
David Michael <fedora.dm0@gmail.com>
Date
Feb 25, 2013, 19:30 UTC
Message-ID
<CAEvUa7n_EsKnKQNuyvSiZW8s_rZv4oQrFNDX9wa_JSr_REj89w@mail.gmail.com>

Some platforms may lack the NI_MAXHOST and NI_MAXSERV values in their system headers, so ensure they are available.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
---

NI_MAXHOST is missing from my platform, and it has no compatibility definition anywhere.

    $ grep -FIR NI_MAXHOST
    imap-send.c:            char addr[NI_MAXHOST];
    connect.c:    static char addr[NI_MAXHOST];

I've been defining it in CFLAGS, but I noticed there is precedence for this type of definition in git-compat-util.h. This patch adds a definition for compatibility.

In addition, all the documentation I've seen mentions NI_MAXHOST and NI_MAXSERV together, so this also moves the NI_MAXSERV definition to git-compat-util.h for consistency.

 daemon.c          |  4 ----
 git-compat-util.h | 11 +++++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/daemon.c b/daemon.c
index 4602b46..df8c0ab 100644
--- a/daemon.c
+++ b/daemon.c
@@ -9,10 +9,6 @@
 #define HOST_NAME_MAX 256
 #endif

-#ifndef NI_MAXSERV
-#define NI_MAXSERV 32
-#endif
-
 #ifdef NO_INITGROUPS
 #define initgroups(x, y) (0) /* nothing */
 #endif
diff --git a/git-compat-util.h b/git-compat-util.h
index b7eaaa9..2580c6b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -213,6 +213,17 @@ extern char *gitbasename(char *);
 #include <openssl/err.h>
 #endif

+/* On most systems <netdb.h> would have given us this, but
+ * not on some systems (e.g. z/OS).
+ */
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 1025
+#endif
+
+#ifndef NI_MAXSERV
+#define NI_MAXSERV 32
+#endif
+
 /* On most systems <limits.h> would have given us this, but
  * not on some systems (e.g. GNU/Hurd).
  */
--
1.8.1.2
Next: Junio C Hamano
Message 1 of 2 in “git-compat-util.h: Provide missing netdb.h definitions”
  1. git-compat-util.h: Provide missing netdb.h definitionsDavid Michael, Feb 25, 2013
  2. Junio C HamanoFeb 25, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.