[PATCH v14 03/21] unix-socket.c: add stub implementation when unix sockets are not supported
- From
David Turner <novalis@novalis.org>
- Date
- Jul 3, 2016, 07:57 UTC
- Message-ID
- <1467532693-20017-4-git-send-email-novalis@novalis.org>
- In-Reply-To
- <1467532693-20017-1-git-send-email-novalis@novalis.org>
From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
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 <pclouds@gmail.com> --- Makefile | 2 ++ unix-socket.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+)
diff --git a/Makefile b/Makefile index 2742a69..7920609 100644 --- a/Makefile +++ b/Makefile @@ -1341,6 +1341,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 */
-- 1.9.1