From: Stefan Sperling Subject: Re: gotwebd: delete redundant check (+ free) To: Omar Polo Cc: gameoftrees@openbsd.org Date: Tue, 31 Jan 2023 21:26:51 +0100 On Tue, Jan 31, 2023 at 09:06:02PM +0100, Omar Polo wrote: > 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? Yes, ok by me. > 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; > } > >