Skip to contentSkip to conversation

daemon.c fails to build on Darwin

DISCUSSION Randal L. Schwartz 4 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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.

Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <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!
#1 lore raw
Quoted 12 lines · Randal L. Schwartz

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

Quoted 1 line

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...

Signature · 1 line
Shawn.
#2 lore raw
In reply to Randal L. Schwartz
Quoted 11 lines · [email protected] (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

Quoted 1 line

This is with 2d5b459107cf07bbb307cfb196c2007c497a6dd2.

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

From: Johannes Schindelin <[email protected]>
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>

---
... or should we make it wider available, by putting it into cache.h?

 daemon.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
daemon.c +4 -0
index 5335d21..fc3951c 100644
@@ -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;
Signature · 1 line
1.4.2.1.g430572-dirty
#3 lore raw
In reply to Randal L. Schwartz
Quoted 4 lines · Randal L. Schwartz

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?

daemon.c +1 -1
index 5335d21..8b54c63 100644
@@ -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;
git-compat-util.h +4 -0
index 7ed18e1..a5429d1 100755
@@ -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
interpolate.c +2 -2
index 62701d8..5d9d188 100644
@@ -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);
interpolate.h +1 -1
index a55fb8e..190a180 100644
@@ -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,