Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Drop dead checks and a repeated filter cleanup
build_snapshot_setting always returns a buffer, both commit-sort values are tested on their own, authenticate_post ends the process, and the filters are cleaned up by the atexit handler once cmd_main returns.
Diffstat (limited to '')
-rw-r--r--source/cgit.c19
1 file changed, 7 insertions, 12 deletions
diff --git a/source/cgit.c b/source/cgit.c
index 10ed536..c1c9fbc 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -250,7 +250,7 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
cgit_fprintf_filter(repo->trailer_filter, f, "repo.trailer-filter=");
if (repo->snapshots != ctx.cfg.snapshots) {
char *formats = build_snapshot_setting(repo->snapshots);
- fprintf(f, "repo.snapshots=%s\n", formats ? formats : "");
+ fprintf(f, "repo.snapshots=%s\n", formats);
free(formats);
}
if (repo->snapshot_prefix)
@@ -267,12 +267,10 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
fprintf(f, "repo.enable-html-serving=%d\n", repo->enable_html_serving);
if (repo->branch_sort == 1)
fprintf(f, "repo.branch-sort=age\n");
- if (repo->commit_sort) {
- if (repo->commit_sort == 1)
- fprintf(f, "repo.commit-sort=date\n");
- else if (repo->commit_sort == 2)
- fprintf(f, "repo.commit-sort=topo\n");
- }
+ if (repo->commit_sort == 1)
+ fprintf(f, "repo.commit-sort=date\n");
+ else if (repo->commit_sort == 2)
+ fprintf(f, "repo.commit-sort=topo\n");
fprintf(f, "repo.hide=%d\n", repo->hide);
fprintf(f, "repo.ignore=%d\n", repo->ignore);
fprintf(f, "\n");
@@ -788,7 +786,7 @@ static void open_auth_filter(const char *action)
* The filter answers the login POST itself, writing the status line and every
* header, so nothing here prints any and the process ends before this returns.
*/
-static void authenticate_post(void)
+static NORETURN void authenticate_post(void)
{
char buffer[MAX_AUTHENTICATION_POST_BYTES];
size_t len;
@@ -821,10 +819,8 @@ static void authenticate_cookie(void)
!ctx.repo &&
!strcmp(ctx.env.request_method, "POST") &&
!strcmp(ctx.qry.page, "login")
- ) {
+ )
authenticate_post();
- return;
- }
open_auth_filter("authenticate-cookie");
ctx.env.authenticated = cgit_close_filter(ctx.cfg.auth_filter);
@@ -1319,7 +1315,6 @@ int cmd_main(int argc, const char **argv)
max_bytes, process_request);
strbuf_release(&cache_key);
- cgit_cleanup_filters();
// A slot that could not be sent because the client went away is not
// worth an error page nobody will read.
if (err && err != EPIPE)