Skip to content

Commit a47551c

Browse files
René Scharfegitster
authored andcommitted
daemon: deglobalize variable 'directory'
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 49ba83f. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d433ed0 commit a47551c

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

daemon.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ static char *hostname;
5757
static char *canon_hostname;
5858
static char *ip_address;
5959
static char *tcp_port;
60-
static char *directory;
6160

6261
static void logreport(int priority, const char *err, va_list params)
6362
{
@@ -147,7 +146,7 @@ static int avoid_alias(char *p)
147146
}
148147
}
149148

150-
static char *path_ok(void)
149+
static char *path_ok(char *directory)
151150
{
152151
static char rpath[PATH_MAX];
153152
static char interp_path[PATH_MAX];
@@ -296,20 +295,20 @@ static int git_daemon_config(const char *var, const char *value, void *cb)
296295
return 0;
297296
}
298297

299-
static int run_service(struct daemon_service *service)
298+
static int run_service(char *dir, struct daemon_service *service)
300299
{
301300
const char *path;
302301
int enabled = service->enabled;
303302

304-
loginfo("Request %s for '%s'", service->name, directory);
303+
loginfo("Request %s for '%s'", service->name, dir);
305304

306305
if (!enabled && !service->overridable) {
307306
logerror("'%s': service not enabled.", service->name);
308307
errno = EACCES;
309308
return -1;
310309
}
311310

312-
if (!(path = path_ok()))
311+
if (!(path = path_ok(dir)))
313312
return -1;
314313

315314
/*
@@ -555,8 +554,7 @@ static int execute(struct sockaddr *addr)
555554
free(canon_hostname);
556555
free(ip_address);
557556
free(tcp_port);
558-
free(directory);
559-
hostname = canon_hostname = ip_address = tcp_port = directory = NULL;
557+
hostname = canon_hostname = ip_address = tcp_port = NULL;
560558

561559
if (len != pktlen)
562560
parse_extra_args(line + len + 1, pktlen - len - 1);
@@ -571,9 +569,7 @@ static int execute(struct sockaddr *addr)
571569
* Note: The directory here is probably context sensitive,
572570
* and might depend on the actual service being performed.
573571
*/
574-
free(directory);
575-
directory = xstrdup(line + namelen + 5);
576-
return run_service(s);
572+
return run_service(line + namelen + 5, s);
577573
}
578574
}
579575

0 commit comments

Comments
 (0)