"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
refactor gotweb_load_got_path
To:
gameoftrees@openbsd.org
Date:
Thu, 30 Nov 2023 18:42:06 +0100

Download raw body.

Thread
no functional change intended, just getting rid of the goto open_repo.

ok?

diff /home/op/w/got
commit - edc930eb84ed02c76531f9db419b1d6477805eef
path + /home/op/w/got
blob - af7ddea86d0f5f5e689b53e6aa57e44387ec4a1c
file + gotwebd/gotweb.c
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
@@ -1126,28 +1126,20 @@ gotweb_load_got_path(struct request *c, struct repo_di
 	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)
+			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);
+		}
 	}
 
-	if (asprintf(&dir_test, "%s/%s", srv->repos_path,
-	    repo_dir->name) == -1) {
-		error = got_error_from_errno("asprintf");
-		goto err;
-	}
+	repo_dir->path = dir_test;
+	dir_test = NULL;
 
-	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;
-	}
-
-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);