build: eliminate all remaining compile warnings

Production (hand-fixed, semantics preserved with width-limited %.*s):
- persist.c (33 sites): workdir/name joins share the destination budget;
  WAL segment/snapshot paths via a WAL_SEG_WALPATH_MAX macro derived from
  seg_path's own declared size; trim loops use d_name's NAME_MAX (255) cap.
- config_repl.c (16 sites) and ha.c's config-hash twin: same half-split
  and fixed-literal-tail budgets, byte-identical path construction kept
  between ha.c and conf_save_config.
- main.c: certdir/key/cert paths leave room for their fixed suffixes.

Test suites (-Wno-format-truncation, rationale in-tree): the 68 remaining
sites are all snprintf(dir, 4096, "%s/<literal>") fixture scratch paths
under mkdtemp /tmp/xce_* dirs that never approach PATH_MAX -- gcc cannot
prove the tail fits, but every one is a false positive. Applied as a
compile_args declare_dependency on each suite's shared deps list.

Vendored c-capnproto: -Wno-switch (~40 exhaustive-dispatch false
positives), -Wno-unused-function (empty define_encode_function stub),
-Wno-format-overflow (255-byte uniontag + 3-byte prefix vs 256-byte buf,
unreachable schema lengths). Both the wrap checkout and the
packagefiles overlay patched identically.

Also: test_worker_launch_type_dispatch removes its fixed-path fake-xrun
/tmp fixture at exit (bug-924 /tmp hygiene; the mkdtemp shim can't see it).

Verified: fresh full recompile of every source = 0 warnings (gcc 13.3,
-Wall asan profile); meson test 134/134 green; no /tmp/xce_* residue.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
lei.chen 2026-10-21 15:38:42 +00:00
parent d4957bd290
commit e723c9c234
9 changed files with 186 additions and 53 deletions

View file

@ -421,11 +421,16 @@ int main(int argc, char* argv[])
char certdir_buf[XCE_MAXPATH_LEN + 1];
if (!certdir) {
snprintf(certdir_buf, sizeof(certdir_buf),
"%s/certs", arguments.workdir);
"%.*s/certs",
(int)(sizeof(certdir_buf) - sizeof("/certs")),
arguments.workdir);
certdir = certdir_buf;
}
snprintf(key_file, XCE_MAXPATH_LEN, "%s/xce.key", certdir);
snprintf(cert_file, XCE_MAXPATH_LEN, "%s/xce.crt", certdir);
/* %.*s bounds certdir so the fixed "/xce.key" / "/xce.crt" tails fit */
snprintf(key_file, XCE_MAXPATH_LEN, "%.*s/xce.key",
(int)(XCE_MAXPATH_LEN - sizeof("/xce.key")), certdir);
snprintf(cert_file, XCE_MAXPATH_LEN, "%.*s/xce.crt",
(int)(XCE_MAXPATH_LEN - sizeof("/xce.crt")), certdir);
myconf.cluster_config = NULL;
myconf.conffile = NULL; /* set by load_primary_config() or fetch_config_from_primary() */