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

@ -62,36 +62,6 @@ static void teardown_persist(persist_t *p)
free(p);
}
/* Write a minimal wal_entry_hdr_t with the given lsn to an open fd at offset */
static int write_wal_entry(int fd, uint64_t lsn, off_t offset)
{
wal_entry_hdr_t hdr;
memset(&hdr, 0, sizeof(hdr));
hdr.type = WAL_JOB_SUBMIT;
hdr.lsn = lsn;
hdr.payload_len = 0;
hdr.crc = 0;
hdr.prev_crc = 0;
ssize_t n = pwrite(fd, &hdr, sizeof(hdr), offset);
return (n == (ssize_t)sizeof(hdr)) ? 0 : -EIO;
}
/* Count .wal files in the WAL directory */
static int count_wal_segments(const char *wal_dir)
{
DIR *d = opendir(wal_dir);
if (!d) return 0;
int count = 0;
struct dirent *e;
while ((e = readdir(d)) != NULL) {
size_t len = strlen(e->d_name);
if (len > 4 && strcmp(e->d_name + len - 4, ".wal") == 0)
count++;
}
closedir(d);
return count;
}
/* ── Test 1: truncation at segment boundary deletes whole segment ──────────── */
static void test_truncate_at_segment_boundary_deletes_segment(void)