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

From:
Tracey Emery <tracey@traceyemery.net>
Subject:
Re: refactor gotweb_load_got_path
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Fri, 1 Dec 2023 07:18:39 -0700

Download raw body.

Thread
On Thu, Nov 30, 2023 at 06:42:06PM +0100, Omar Polo wrote:
> no functional change intended, just getting rid of the goto open_repo.
> 
> ok?
> 

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);
>