From: Eric Wong Date: Fri, 28 Nov 2025 10:09:45 +0000 (+0000) Subject: *.h: reduce variable scopes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c9f18ddb27e978c51a4f85098cb67c1d75ba687;p=thirdparty%2Fpublic-inbox.git *.h: reduce variable scopes Reducing scopes of local variables improves readability and should help the compiler make better decisions about register allocation and reporting possible errors. --- diff --git a/lib/PublicInbox/lg2_cfg.h b/lib/PublicInbox/lg2_cfg.h index f8fa48294..deb23001f 100644 --- a/lib/PublicInbox/lg2_cfg.h +++ b/lib/PublicInbox/lg2_cfg.h @@ -19,16 +19,16 @@ void cfgwr_commit(const char *f, AV *todo) { I32 i, todo_max = av_len(todo); - SV **sv; git_config *cfg; const git_error *e; const char *cmd0, *name, *val, *re; int rc = git_config_open_ondisk(&cfg, f); STRLEN dlen; - AV *cmd; for (i = 0; rc == GIT_OK && i <= todo_max; i++) { - sv = av_fetch(todo, i, 0); + SV **sv = av_fetch(todo, i, 0); + AV *cmd; + /* leaks on internal bugs: */ if (!SvROK(*sv)) croak("BUG: not a ref"); cmd = (AV *)SvRV(*sv); diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h index 8d153065a..4a45c3aae 100644 --- a/lib/PublicInbox/xap_helper.h +++ b/lib/PublicInbox/xap_helper.h @@ -682,7 +682,6 @@ static void srch_init_extra(struct srch *srch, struct req *req) static void srch_init(struct req *req) { - int i; struct srch *srch = req->srch; const unsigned FLAG_PHRASE = Xapian::QueryParser::FLAG_PHRASE; srch->qp_flags = Xapian::QueryParser::FLAG_BOOLEAN | @@ -697,8 +696,8 @@ static void srch_init(struct req *req) shard_nfd = nfd; } for (int retried = 0; retried < 2; retried++) { + int i = 0; srch->qp_flags |= FLAG_PHRASE; - i = 0; try { AUTO_UNLOCK struct open_locks *lk = lock_shared_maybe(req);