Subject: [PATCH v13 21/20] unix-socket.c: add stub implementation when unix sockets are not supported

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Sun, 26 Jun 2016 14:09:28 +0200

This keeps #ifdef at the callee instead of caller, it's less messier.

The caller in question is in read-cache.c which, unlike other
unix-socket callers so far, is always built regardless of unix socket
support. No extra handling (for ENOSYS) is needed because in this
build, index-helper does not exist, $GIT_DIR/index-helper.sock does
not exist, so no unix socket call is made by read-cache.c in the first
place.

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 BTW 20/20 didn't seem to make it to the list (or my mailbox). And you
 probably want to update .mailmap with @novalis.org as main address
 too.

 Makefile      |  2 ++
 unix-socket.h | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/Makefile b/Makefile
index d1309b8..d8cfc51 100644
--- a/Makefile
+++ b/Makefile
@@ -1337,6 +1337,8 @@ ifndef NO_UNIX_SOCKETS
 	LIB_OBJS += unix-socket.o
 	PROGRAM_OBJS += credential-cache.o
 	PROGRAM_OBJS += credential-cache--daemon.o
+else
+	BASIC_CFLAGS += -DNO_UNIX_SOCKETS
 endif
 
 ifdef NO_ICONV
diff --git a/unix-socket.h b/unix-socket.h
index e271aee..f1cba70 100644
--- a/unix-socket.h
+++ b/unix-socket.h
@@ -1,7 +1,25 @@
 #ifndef UNIX_SOCKET_H
 #define UNIX_SOCKET_H
 
+#ifndef NO_UNIX_SOCKETS
+
 int unix_stream_connect(const char *path);
 int unix_stream_listen(const char *path);
 
+#else
+
+static inline int unix_stream_connect(const char *path)
+{
+	errno = ENOSYS;
+	return -1;
+}
+
+static inline int unix_stream_listen(const char *path)
+{
+	errno = ENOSYS;
+	return -1;
+}
+
+#endif
+
 #endif /* UNIX_SOCKET_H */
-- 
2.8.2.531.gd073806