build: eliminate all unused-variable/function warnings in our code

Deduped census insight: the earlier "730 warnings" figure counted per-TU
echoes of the same source line (white-box textual inclusion recompiles
scheduler.c/limit.c/etc. dozens of times, each copy re-reporting). The
distinct warning sites in our code were 24 unused-variable + 11
unused-function + 2 Wcomment. This commit removes all of them; a clean
full rebuild now reports zero warnings outside the format-truncation
family (125 sites, deferred to its own pass) and vendored capnpc-c.

Notable non-mechanical fixes (the rest is dead-code deletion):

- schedobj.c make_sched_obj() silently swallowed its sub-constructor's
  rc (ENOMEM/-EINVAL) and returned 1 unconditionally -- a half-built
  schedobj with a NULL union payload could escape to callers. It now
  propagates the failure, and make_sched_job() frees and returns NULL
  on it instead of continuing with a broken schedobj.
- scheduler.c make_allocs(): vget() rc was set-but-unused; the r==NULL
  skip below is the intended handling, so the call is now (void)'ed with
  a comment saying so.
- commit.c highest_appended_lsn(): kept but scoped #ifdef XCE_TESTING --
  it backs the never-beyond-the-log assert; it had no production caller.
- limit.c get_vres_value(): deleted -- its only call site sits inside a
  #if 0 block and its own body was #if 0'ed to a constant.
- group.c update_group_dirty(): deleted recursive dead subtree, no
  callers outside itself.
- test_sim_reconcile_unaccounted.c: test_reconcile_respects_host_
  capacity_under_contention() was never registered in RUN_TEST; removed
  with an NB pointing at the registered bug-1836 coverage.

Verified: clean full rebuild = 0 unused/Wcomment/implicit warnings in
our code (89 unique sites remain, all -Wformat-truncation or vendored);
controller_unit_test 1342/1342, xcelib_test 758/758, 126 scheduler
suites and 18 worker suites all green.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
lei.chen 2026-10-21 09:28:34 +00:00
parent f1801fbef9
commit d167923632
20 changed files with 67 additions and 350 deletions

View file

@ -1431,7 +1431,7 @@ static void test_upgrade_materialization_verify_no_marker_clears_fence(void)
TEST_ASSERT_EQUAL_INT(0,
commit_engine_init(&c->commit, &c->persist, 1, 8));
repl_set_commit_engine(&c->persist.repl, &c->commit);
myconf_t *mc = t43_attach_myconf(c, tmp);
(void)t43_attach_myconf(c, tmp);
TEST_ASSERT_EQUAL_INT(0, upgrade_materialization_verify(c));
TEST_ASSERT_EQUAL_INT(0, upgrade_materialization_fenced(c));
@ -6127,23 +6127,6 @@ static void snap_recv_ha_init(ha_state_t *ha)
ha_init(ha, &cfg, 0);
}
/* Helper: write a minimal valid snapshot file to path (XCESNAP header + body) */
static void write_test_snapshot(const char *path, uint64_t lsn, size_t body_size)
{
FILE *f = fopen(path, "wb");
TEST_ASSERT_NOT_NULL_MESSAGE(f, "Failed to create test snapshot file");
char header[16];
memcpy(header, "XCESNAP\0", 8);
memcpy(header + 8, &lsn, 8);
fwrite(header, 1, 16, f);
if (body_size > 16) {
char *zeros = calloc(1, body_size - 16);
fwrite(zeros, 1, body_size - 16, f);
free(zeros);
}
fclose(f);
}
/* Test 3.5c-A: receive 2 chunks, verify snap.part assembled and renamed correctly,
* applied_lsn set to checkpoint_lsn.
* Requirements: 4.2, 4.3 */