# daemon.c fails to build on Darwin

4 messages from 2006-09-28 to 2006-09-28. Participants: Randal L. Schwartz, Alex Riesen, Shawn Pearce, Junio C Hamano.
Thread: https://gitlist.dev/t/5737

## Randal L. Schwartz, 2006-09-28 15:48

Subject: daemon.c fails to build on Darwin
Message-ID: <86ejtw3sbv.fsf@blue.stonehenge.com>
URL: https://gitlist.dev/e/86ejtw3sbv.fsf%40blue.stonehenge.com

```

If this is obvious, can someone fix it?  If not, I'll try to sort it out later
tonight.

    gcc -o daemon.o -c -g -O2 -Wall -I/sw/include -I/opt/local/include -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRLCPY daemon.c
    daemon.c: In function 'fill_in_extra_table_entries':
    daemon.c:460: error: 'HOST_NAME_MAX' undeclared (first use in this function)
    daemon.c:460: error: (Each undeclared identifier is reported only once
    daemon.c:460: error: for each function it appears in.)
    daemon.c:460: warning: unused variable 'addrbuf'
    make: *** [daemon.o] Error 1

This is with 2d5b459107cf07bbb307cfb196c2007c497a6dd2.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

```

## Alex Riesen, 2006-09-28 16:01

Subject: Re: daemon.c fails to build on Darwin
Message-ID: <81b0412b0609280901q109961cfydeaea7ff305eca67@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0609280901q109961cfydeaea7ff305eca67%40mail.gmail.com
In-Reply-To: <86ejtw3sbv.fsf@blue.stonehenge.com>

```
On 28 Sep 2006 08:48:36 -0700, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>
> If this is obvious, can someone fix it?  If not, I'll try to sort it out later
> tonight.
>

I used the patch attached.

BTW, could we please _use_ the const keyword?


diff --git a/daemon.c b/daemon.c
index 5335d21..8b54c63 100644
--- a/daemon.c
+++ b/daemon.c
@@ -830,7 +830,7 @@ #endif
 
 #else /* NO_IPV6 */
 
-static int socksetup(char *lisen_addr, int listen_port, int **socklist_p)
+static int socksetup(char *listen_addr, int listen_port, int **socklist_p)
 {
 	struct sockaddr_in sin;
 	int sockfd;
diff --git a/git-compat-util.h b/git-compat-util.h
index 7ed18e1..a5429d1 100755
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -33,6 +33,10 @@ #ifndef PATH_MAX
 #define PATH_MAX 4096
 #endif
 
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 256
+#endif
+
 #ifdef __GNUC__
 #define NORETURN __attribute__((__noreturn__))
 #else
diff --git a/interpolate.c b/interpolate.c
index 62701d8..5d9d188 100644
--- a/interpolate.c
+++ b/interpolate.c
@@ -8,10 +8,10 @@ #include "git-compat-util.h"
 #include "interpolate.h"
 
 
-void interp_set_entry(struct interp *table, int slot, char *value)
+void interp_set_entry(struct interp *table, int slot, const char *value)
 {
 	char *oldval = table[slot].value;
-	char *newval = value;
+	char *newval = NULL;
 
 	if (oldval)
 		free(oldval);
diff --git a/interpolate.h b/interpolate.h
index a55fb8e..190a180 100644
--- a/interpolate.h
+++ b/interpolate.h
@@ -16,7 +16,7 @@ struct interp {
 	char *value;
 };
 
-extern void interp_set_entry(struct interp *table, int slot, char *value);
+extern void interp_set_entry(struct interp *table, int slot, const char *value);
 extern void interp_clear_table(struct interp *table, int ninterps);
 
 extern int interpolate(char *result, int reslen,

```

## Shawn Pearce, 2006-09-28 16:06

Subject: Re: daemon.c fails to build on Darwin
Message-ID: <20060928160652.GC2947@spearce.org>
URL: https://gitlist.dev/e/20060928160652.GC2947%40spearce.org
In-Reply-To: <86ejtw3sbv.fsf@blue.stonehenge.com>

```
"Randal L. Schwartz" <merlyn@stonehenge.com> wrote:
> 
> If this is obvious, can someone fix it?  If not, I'll try to sort it out later
> tonight.
> 
>     gcc -o daemon.o -c -g -O2 -Wall -I/sw/include -I/opt/local/include -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRLCPY daemon.c
>     daemon.c: In function 'fill_in_extra_table_entries':
>     daemon.c:460: error: 'HOST_NAME_MAX' undeclared (first use in this function)
>     daemon.c:460: error: (Each undeclared identifier is reported only once
>     daemon.c:460: error: for each function it appears in.)
>     daemon.c:460: warning: unused variable 'addrbuf'
>     make: *** [daemon.o] Error 1
> 
> This is with 2d5b459107cf07bbb307cfb196c2007c497a6dd2.

According to pickaxe it was dd4676299dde0a4c6f8a471e6353170f86a78c8a.

Looks like HOST_NAME_MAX isn't defined on Darwin.  Looking at how
daemon.c is using it this just needs to be defined to a suitable
length if its not already defined.  Sort of like PATH_MAX on some
other systems...

-- 
Shawn.

```

## Junio C Hamano, 2006-09-28 16:15

Subject: Re: daemon.c fails to build on Darwin
Message-ID: <7vbqp0vuff.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vbqp0vuff.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <86ejtw3sbv.fsf@blue.stonehenge.com>

```
merlyn@stonehenge.com (Randal L. Schwartz) writes:

> If this is obvious, can someone fix it?  If not, I'll try to sort it out later
> tonight.
>
>     gcc -o daemon.o -c -g -O2 -Wall -I/sw/include -I/opt/local/include -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRLCPY daemon.c
>     daemon.c: In function 'fill_in_extra_table_entries':
>     daemon.c:460: error: 'HOST_NAME_MAX' undeclared (first use in this function)
>     daemon.c:460: error: (Each undeclared identifier is reported only once
>     daemon.c:460: error: for each function it appears in.)
>     daemon.c:460: warning: unused variable 'addrbuf'
>     make: *** [daemon.o] Error 1
>
> This is with 2d5b459107cf07bbb307cfb196c2007c497a6dd2.

Sorry about that.  Johannes sent a fix which I'll apply.

From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [PATCH/RFC] daemon: default to 256 for HOST_NAME_MAX if it is not defined
Date: Thu, 28 Sep 2006 12:00:35 +0200 (CEST)
Message-ID: <Pine.LNX.4.63.0609281200200.14200@wbgn013.biozentrum.uni-wuerzburg.de>

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
	... or should we make it wider available, by putting it into
	cache.h?

 daemon.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/daemon.c b/daemon.c
index 5335d21..fc3951c 100644
--- a/daemon.c
+++ b/daemon.c
@@ -15,6 +15,10 @@ #include "cache.h"
 #include "exec_cmd.h"
 #include "interpolate.h"
 
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 256
+#endif
+
 static int log_syslog;
 static int verbose;
 static int reuseaddr;
-- 
1.4.2.1.g430572-dirty

```
