commit 341fa7cacc77a0a56e7e6eebec0b591ea6d8003b from: Omar Polo date: Thu Sep 01 10:18:34 2022 UTC gotwebd: minor tweaks drop: - a tautological s[strlen(s)] == '\0' - a few duplicates checks - a lone if (error) when it's always NULL - an extra NULL check part of a bigger diff that's ok stsp@ commit - 40a95f4f726567f73ee83d4866608f7ea0654eaa commit + 341fa7cacc77a0a56e7e6eebec0b591ea6d8003b blob - 85594b289ee57c52802a8fa7745f70d2a9bb3e77 blob + 2a02d38ffccd0d8d1fa5492ee3b3d193e0811efe --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -227,8 +227,7 @@ got_get_repo_commit(struct request *c, struct repo_com name += 6; if (strncmp(name, "remotes/", 8) == 0) { name += 8; - s = strstr(name, "/" GOT_REF_HEAD); - if (s != NULL && s[strlen(s)] == '\0') + if (strstr(name, "/" GOT_REF_HEAD) != NULL) continue; } error = got_ref_resolve(&ref_id, t->repo, re->ref); @@ -522,10 +521,6 @@ got_get_repo_commits(struct request *c, int limit) if (commit) { got_object_commit_close(commit); commit = NULL; - } - if (t->next_id == NULL) { - error = got_error_from_errno("strdup"); - goto done; } TAILQ_REMOVE(&t->repo_commits, new_repo_commit, entry); @@ -585,9 +580,6 @@ got_get_repo_tags(struct request *c, int limit) repo_dir->name) == -1) return got_error_from_errno("asprintf"); - if (error) - return error; - if (qs->commit == NULL && qs->action == TAGS) { error = got_ref_open(&ref, repo, qs->headref, 0); if (error) @@ -724,10 +716,6 @@ got_get_repo_tags(struct request *c, int limit) got_object_commit_close(commit); commit = NULL; } - if (t->next_id == NULL) { - error = got_error_from_errno("strdup"); - goto err; - } TAILQ_REMOVE(&t->repo_tags, new_repo_tag, entry); gotweb_free_repo_tag(new_repo_tag); goto done; blob - 06b0e06e2d7ebf7f9abe95e13bf22731f0389295 blob + 2cf872b749f021dc0d5851cce281f8c10c5ebafc --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -606,10 +606,8 @@ gotweb_free_transport(struct transport *t) } gotweb_free_repo_dir(t->repo_dir); gotweb_free_querystring(t->qs); - if (t != NULL) { - free(t->next_id); - free(t->prev_id); - } + free(t->next_id); + free(t->prev_id); free(t); }