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

From:
Omar Polo <op@omarpolo.com>
Subject:
gotwebd: delete redundant check (+ free)
To:
gameoftrees@openbsd.org
Date:
Tue, 31 Jan 2023 21:06:02 +0100

Download raw body.

Thread
The "if (commit)" check is reduntant since reached here commit is
guaranteed to be not-NULL.  we could also delete the cleanup of the
commit, we're going to "goto done" anyway and it'll be cleared there,
but I'd prefer to keep explicit that it's cleaned.

ok?

diff /tmp/got
commit - 407521c004a585e93d6e493eb0d5193f67197edd
path + /tmp/got
blob - 480db657495cca3ac7c1561072761f06f1e16a98
file + gotwebd/got_operations.c
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
@@ -421,14 +421,12 @@ got_get_repo_commits(struct request *c, int limit)
 				t->next_id = strdup(repo_commit->commit_id);
 				if (t->next_id == NULL) {
 					error = got_error_from_errno("strdup");
 					goto done;
 				}
-				if (commit) {
-					got_object_commit_close(commit);
-					commit = NULL;
-				}
+				got_object_commit_close(commit);
+				commit = NULL;
 				TAILQ_REMOVE(&t->repo_commits, repo_commit,
 				    entry);
 				gotweb_free_repo_commit(repo_commit);
 				goto done;
 			}