From: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx> The static helper function `unix_stream_socket()` calls `die()`. This is not appropriate for all callers. Eliminate the wrapper function and move the existing error handling to the callers in preparation for adapting specific callers. Signed-off-by: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx> --- unix-socket.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/unix-socket.c b/unix-socket.c index 19ed48be990..ef2aeb46bcd 100644 --- a/unix-socket.c +++ b/unix-socket.c @@ -1,14 +1,6 @@ #include "cache.h" #include "unix-socket.h" -static int unix_stream_socket(void) -{ - int fd = socket(AF_UNIX, SOCK_STREAM, 0); - if (fd < 0) - die_errno("unable to create socket"); - return fd; -} - static int chdir_len(const char *orig, int len) { char *path = xmemdupz(orig, len); @@ -79,7 +71,10 @@ int unix_stream_connect(const char *path) if (unix_sockaddr_init(&sa, path, &ctx) < 0) return -1; - fd = unix_stream_socket(); + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) + die_errno("unable to create socket"); + if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) goto fail; unix_sockaddr_cleanup(&ctx); @@ -103,7 +98,9 @@ int unix_stream_listen(const char *path) if (unix_sockaddr_init(&sa, path, &ctx) < 0) return -1; - fd = unix_stream_socket(); + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) + die_errno("unable to create socket"); if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) goto fail; -- gitgitgadget