From c13168e4b762e0d3808d1c60190a7eb70e27ee8a Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Fri, 1 Dec 2023 16:45:13 +0000 Subject: [PATCH] refactor gotweb_load_got_path; no functional change ok tracey@ --- gotwebd/gotweb.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/gotwebd/gotweb.c b/gotwebd/gotweb.c index 4c1f36d7..88fdbf3c 100644 --- a/gotwebd/gotweb.c +++ b/gotwebd/gotweb.c @@ -1125,28 +1125,20 @@ gotweb_load_got_path(struct request *c, struct repo_dir *repo_dir) dt = opendir(dir_test); if (dt == NULL) { free(dir_test); - } else { - repo_dir->path = dir_test; - dir_test = NULL; - goto open_repo; - } - - if (asprintf(&dir_test, "%s/%s", srv->repos_path, - repo_dir->name) == -1) { - error = got_error_from_errno("asprintf"); - goto err; + if (asprintf(&dir_test, "%s/%s", srv->repos_path, + repo_dir->name) == -1) + return got_error_from_errno("asprintf"); + dt = opendir(dir_test); + if (dt == NULL) { + free(dir_test); + return got_error_path(repo_dir->name, + GOT_ERR_NOT_GIT_REPO); + } } - dt = opendir(dir_test); - if (dt == NULL) { - error = got_error_path(repo_dir->name, GOT_ERR_NOT_GIT_REPO); - goto err; - } else { - repo_dir->path = dir_test; - dir_test = NULL; - } + repo_dir->path = dir_test; + dir_test = NULL; -open_repo: if (srv->respect_exportok && faccessat(dirfd(dt), "git-daemon-export-ok", F_OK, 0) == -1) { error = got_error_path(repo_dir->name, GOT_ERR_NOT_GIT_REPO); -- 2.11.4.GIT