[PATCH 16/28] daemon.c cleanup
From: David Rientjes <rientjes@google.com>
Date: 2016-06-15 22:42:37
Subsystem:
the rest · Maintainer:
Linus Torvalds
Makes execute and upload void and cleans up function calls. David Signed-off-by: David Rientjes <rientjes@google.com> --- daemon.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/daemon.c b/daemon.c
index 810837f..53ef514 100644
--- a/daemon.c
+++ b/daemon.c@@ -229,7 +229,7 @@ static char *path_ok(char *dir) return NULL; /* Fallthrough. Deny by default */ } -static int upload(char *dir) +static void upload(char *dir) { /* Timeout as string */ char timeout_buf[64];
@@ -238,7 +238,7 @@ static int upload(char *dir) loginfo("Request for '%s'", dir); if (!(path = path_ok(dir))) - return -1; + return; /* * Security on the cheap.
@@ -254,7 +254,7 @@ static int upload(char *dir) if (!export_all_trees && access("git-daemon-export-ok", F_OK)) { logerror("'%s': repository not exported.", path); errno = EACCES; - return -1; + return; } /*
@@ -267,10 +267,9 @@ static int upload(char *dir) /* git-upload-pack only ever reads stuff, so this is safe */ execl_git_cmd("upload-pack", "--strict", timeout_buf, ".", NULL); - return -1; } -static int execute(struct sockaddr *addr) +static void execute(struct sockaddr *addr) { static char line[1000]; int pktlen, len;
@@ -310,11 +309,11 @@ #endif if (len && line[len-1] == '\n') line[--len] = 0; - if (!strncmp("git-upload-pack ", line, 16)) - return upload(line+16); - - logerror("Protocol error: '%s'", line); - return -1; + if (!strncmp("git-upload-pack ", line, 16)) { + upload(line+16); + } else { + logerror("Protocol error: '%s'", line); + } }
@@ -463,7 +462,8 @@ static void handle(int incoming, struct dup2(incoming, 1); close(incoming); - exit(execute(addr)); + execute(addr); + exit(-1); } static void child_handler(int signo)
@@ -820,7 +820,8 @@ int main(int argc, char **argv) if (getpeername(0, peer, &slen)) peer = NULL; - return execute(peer); + execute(peer); + return -1; } if (detach)
--
1.4.2.g89bb-dirty