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:
parent
f1801fbef9
commit
d167923632
20 changed files with 67 additions and 350 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -127,42 +127,6 @@ static void ps_gate_park(ps_gate_t *g)
|
|||
pthread_mutex_unlock(&g->mu);
|
||||
}
|
||||
|
||||
/* Poll until at least n bodies have parked at the gate; 0 on success, -1 on
|
||||
* timeout (2s bound). */
|
||||
static int ps_gate_wait_entered(ps_gate_t *g, int n, int timeout_ms)
|
||||
{
|
||||
struct timespec deadline;
|
||||
clock_gettime(CLOCK_REALTIME, &deadline);
|
||||
deadline.tv_sec += timeout_ms / 1000;
|
||||
deadline.tv_nsec += (long)(timeout_ms % 1000) * 1000000L;
|
||||
if (deadline.tv_nsec >= 1000000000L) { deadline.tv_sec++; deadline.tv_nsec -= 1000000000L; }
|
||||
|
||||
pthread_mutex_lock(&g->mu);
|
||||
int entered;
|
||||
for (;;) {
|
||||
entered = atomic_load(&g->entered);
|
||||
if (entered >= n) break;
|
||||
int rc = pthread_cond_timedwait(&g->entered_cv, &g->mu, &deadline);
|
||||
if (rc != 0) {
|
||||
entered = atomic_load(&g->entered);
|
||||
break;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&g->mu);
|
||||
return entered >= n ? 0 : -1;
|
||||
}
|
||||
|
||||
/* Bounded poll until *a >= want; returns the observed value. */
|
||||
static int poll_atomic_ge(_Atomic int *a, int want, int timeout_ms)
|
||||
{
|
||||
for (int i = 0; i < timeout_ms; i++) {
|
||||
if (atomic_load(a) >= want) break;
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000L };
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
return atomic_load(a);
|
||||
}
|
||||
|
||||
/* ── Partition primitive ─────────────────────────────────────────────────────
|
||||
*
|
||||
* The in-process blackhole works by:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue