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

[PATCH] Add a local implementation of hstrerror for the system which do not have it

From
Alex Riesen <raa.lkml@gmail.com>
Date
Jun 12, 2007, 21:31 UTC
Message-ID
<20070612213129.GD2459@steel.home>
In-Reply-To
<20070612205210.GC2459@steel.home>

The function converts the value of h_errno (last error of name resolver library, see netdb.h). One of systems which supposedly do not have the function is SunOS. POSIX does not mandate its presence.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

Randal, you seem to have access to a SunOS system. Could you try to compile your git with NO_IPV6 (if you already applied the previous fix, which removed superflous calls to hstrerror), and than again without it (just to be sure)?

 Makefile           |    5 +++++
 compat/hstrerror.c |   21 +++++++++++++++++++++
 git-compat-util.h  |    5 +++++
 3 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100644 compat/hstrerror.c
diff --git a/Makefile b/Makefile
index 0f6540c..e054bc7 100644
--- a/Makefile
+++ b/Makefile
@@ -410,6 +410,7 @@ ifeq ($(uname_S),SunOS)
 	NEEDS_NSL = YesPlease
 	SHELL_PATH = /bin/bash
 	NO_STRCASESTR = YesPlease
+	NO_HSTRERROR = YesPlease
 	ifeq ($(uname_R),5.8)
 		NEEDS_LIBICONV = YesPlease
 		NO_UNSETENV = YesPlease
@@ -654,6 +655,10 @@ endif
 ifdef NO_PERL_MAKEMAKER
 	export NO_PERL_MAKEMAKER
 endif
+ifdef NO_HSTRERROR
+	COMPAT_CFLAGS += -DNO_HSTRERROR
+	COMPAT_OBJS += compat/hstrerror.o
+endif
 
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK=NoThanks
diff --git a/compat/hstrerror.c b/compat/hstrerror.c
new file mode 100644
index 0000000..c59b808
--- /dev/null
+++ b/compat/hstrerror.c
@@ -0,0 +1,21 @@
+#include <string.h>
+#include <stdio.h>
+#include <netdb.h>
+
+const char *githstrerror(int err)
+{
+	static char buffer[32];
+	switch (err)
+	{
+	case HOST_NOT_FOUND:
+		return "Authoritative answer: host not found";
+	case NO_DATA:
+		return "Valid name, no data record of requested type";
+	case NO_RECOVERY:
+		return "Non recoverable errors, FORMERR, REFUSED, NOTIMP";
+	case TRY_AGAIN:
+		return "Non-authoritative \"host not found\", or SERVERFAIL";
+	}
+	sprintf(buffer, "Name resolution error %d", err);
+	return buffer;
+}
diff --git a/git-compat-util.h b/git-compat-util.h
index 6bd8987..b2ab3f8 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -167,6 +167,11 @@ extern size_t gitstrlcpy(char *, const char *, size_t);
 extern uintmax_t gitstrtoumax(const char *, char **, int);
 #endif
 
+#ifdef NO_HSTRERROR
+#define hstrerror githstrerror
+extern const char *githstrerror(int herror);
+#endif
+
 extern void release_pack_memory(size_t, int);
 
 static inline char* xstrdup(const char *str)
-- 
1.5.2.1.191.gc01a
Previous: Alex RiesenNext: Johannes Sixt
Message 4 of 11 in “[BUG] 75d8ff1 fails on SunOS 5.9 (missing hsterror) from ba505322”
  1. Randal L. SchwartzJun 12, 2007
  2. Alex RiesenJun 12, 2007
  3. Do not use h_errno after connect(2): the function does not set itAlex Riesen, Jun 12, 2007
  4. Add a local implementation of hstrerror for the system which do not have itAlex Riesen, Jun 12, 2007
  5. Johannes SixtJun 13, 2007
  6. Brandon CaseyJun 18, 2007
  7. Brandon CaseyJun 18, 2007
  8. Alex RiesenJun 18, 2007
  9. Brandon CaseyJun 18, 2007
  10. Add a local implementation of hstrerror for the system which do not have itAlex Riesen, Jun 13, 2007
  11. Randal L. SchwartzJun 16, 2007

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.