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

From:
Omar Polo <op@omarpolo.com>
Subject:
gotwebd: gc unused opendir
To:
gameoftrees@openbsd.org
Date:
Tue, 21 Feb 2023 16:24:53 +0100

Download raw body.

Thread
noticed almost by mistake.  `d' is opened and then unused.  scandir
already takes care of opening the directory.

ok?

diff -s /home/op/w/gotwebd
commit - 92e48697fbbd62dbe4f1330698c13c1a93065b5e
path + /home/op/w/gotwebd (staged changes)
blob - 950bf547dcb54bd4de647bdc2afae1716e5ea0f3
blob + 2ed6735a30264d09cf3010f9aa71887a25d9a6b6
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
@@ -855,18 +855,11 @@ gotweb_render_index(struct request *c)
 	struct transport *t = c->t;
 	struct querystring *qs = t->qs;
 	struct repo_dir *repo_dir = NULL;
-	DIR *d;
 	struct dirent **sd_dent = NULL;
 	unsigned int d_cnt, d_i, d_disp = 0;
 	unsigned int d_skipped = 0;
 	int type;
 
-	d = opendir(srv->repos_path);
-	if (d == NULL) {
-		error = got_error_from_errno2("opendir", srv->repos_path);
-		return error;
-	}
-
 	d_cnt = scandir(srv->repos_path, &sd_dent, NULL, alphasort);
 	if (d_cnt == -1) {
 		sd_dent = NULL;
@@ -947,8 +940,6 @@ done:
 			free(sd_dent[d_i]);
 		free(sd_dent);
 	}
-	if (d != NULL && closedir(d) == EOF && error == NULL)
-		error = got_error_from_errno("closedir");
 	return error;
 }