git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Jon Loeliger <jdl@freescale.com>
Subject: [PATCH 3.2/4] daemon: deglobalize variable 'directory'
Date: Sun, 23 Nov 2008 00:21:52 +0100	[thread overview]
Message-ID: <49289410.2080001@lsrfire.ath.cx> (raw)
In-Reply-To: <4928936D.8010404@lsrfire.ath.cx>

Remove the global variable 'directory' and pass it as a parameter of
the two functions that use it instead, (almost) restoring their
interface to how it was before 49ba83fb67d9e447b86953965ce5f949c6a93b81.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 daemon.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/daemon.c b/daemon.c
index fbf61ca..1cef309 100644
--- a/daemon.c
+++ b/daemon.c
@@ -57,7 +57,6 @@ static char *hostname;
 static char *canon_hostname;
 static char *ip_address;
 static char *tcp_port;
-static char *directory;
 
 static void logreport(int priority, const char *err, va_list params)
 {
@@ -147,7 +146,7 @@ static int avoid_alias(char *p)
 	}
 }
 
-static char *path_ok(void)
+static char *path_ok(char *directory)
 {
 	static char rpath[PATH_MAX];
 	static char interp_path[PATH_MAX];
@@ -296,12 +295,12 @@ static int git_daemon_config(const char *var, const char *value, void *cb)
 	return 0;
 }
 
-static int run_service(struct daemon_service *service)
+static int run_service(char *dir, struct daemon_service *service)
 {
 	const char *path;
 	int enabled = service->enabled;
 
-	loginfo("Request %s for '%s'", service->name, directory);
+	loginfo("Request %s for '%s'", service->name, dir);
 
 	if (!enabled && !service->overridable) {
 		logerror("'%s': service not enabled.", service->name);
@@ -309,7 +308,7 @@ static int run_service(struct daemon_service *service)
 		return -1;
 	}
 
-	if (!(path = path_ok()))
+	if (!(path = path_ok(dir)))
 		return -1;
 
 	/*
@@ -555,8 +554,7 @@ static int execute(struct sockaddr *addr)
 	free(canon_hostname);
 	free(ip_address);
 	free(tcp_port);
-	free(directory);
-	hostname = canon_hostname = ip_address = tcp_port = directory = NULL;
+	hostname = canon_hostname = ip_address = tcp_port = NULL;
 
 	if (len != pktlen)
 		parse_extra_args(line + len + 1, pktlen - len - 1);
@@ -571,9 +569,7 @@ static int execute(struct sockaddr *addr)
 			 * Note: The directory here is probably context sensitive,
 			 * and might depend on the actual service being performed.
 			 */
-			free(directory);
-			directory = xstrdup(line + namelen + 5);
-			return run_service(s);
+			return run_service(line + namelen + 5, s);
 		}
 	}
 
-- 
1.6.0.4.755.g6e139

  reply	other threads:[~2008-11-22 23:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-22 23:09 [PATCH 1/4] add strbuf_expand_dict_cb(), a helper for simple cases René Scharfe
2008-11-22 23:13 ` [PATCH 2/4] merge-recursive: use strbuf_expand() instead of interpolate() René Scharfe
2008-11-22 23:15   ` [PATCH 3/4] daemon: " René Scharfe
2008-11-22 23:16     ` [PATCH 4/4] remove the unused files interpolate.c and interpolate.h René Scharfe
2008-11-22 23:19     ` [PATCH 3.1/4] daemon: inline fill_in_extra_table_entries() René Scharfe
2008-11-22 23:21       ` René Scharfe [this message]
2008-12-04 20:30 ` [PATCH 1/4] add strbuf_expand_dict_cb(), a helper for simple cases Jon Loeliger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49289410.2080001@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jdl@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).