Zero C-compiler warnings on all three architectures; fix real restore_vm_state() bug

Maintainability sweep (prompted by "this is getting hard to maintain"):
fixed the remaining three warning classes after the missing-field-
initializers commit -- 2x -Wsign-compare (control_words.c, cast at the
comparison site rather than changing cf_last_mode's type, which
deliberately holds a -999 sentinel outside vm_mode_t's valid range),
2x -Wstringop-truncation (mkcapsule.c, strncpy+manual-null-terminate
replaced with the idiomatic snprintf equivalent), and 26x
-Wunused-parameter (mostly documented stubs, silenced with the repo's
existing (void)param; idiom).

One of the unused-parameter warnings was not a deliberate stub -- a
real bug. restore_vm_state() (test_common.c) is named, documented, and
called by nine real call sites (acl_words_test.c x8 plus its own
internal use) as "restore saved VM state", but ignored all four of its
parameters and hard-reset to a fixed baseline instead, silently not
restoring what any caller actually saved. Fixed to actually assign the
passed-in dsp/rsp/error/mode. Found while fixing warnings, reported
before touching it, fixed/tested/documented/committed on explicit
instruction.

Verified: all three architectures build with zero C-compiler warnings
(amd64: 3040 -> 0; aarch64's one remaining note is lld-link's own
unrelated linker warning, not a C warning). Full amd64 acceptance boot
post-fix: POST 1003/965/0/0/38 (total/passed/failed/errors/stubs),
"ALL IMPLEMENTED TESTS PASSED!", contract checks (A4'/A1) all passed,
dict_hash=0x24b4279f0670aa3a -- an exact match to this document's own
previously-recorded baseline hash.

.claude/CLAUDE.md corrected to describe the real -Wno-error= exemption
list instead of the "-Wall -Werror" oversimplification. FABRIC-2.md
Section J records the full sweep, including doc-tree staleness findings
flagged but not fixed this pass (docs/lithosananke/ROADMAP.md branch
topology, docs/03-architecture/word-acl/DESIGN.md's Phase 7 claim
contradicting CLAUDE.md, top-level ROADMAP.md's stale StarForth-era
status, the Isabelle pipeline-metrics model mismatch).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Robert Allan James
2026-08-18 22:31:57 -04:00
co-authored by Claude Sonnet 5
parent bf59c4916e
commit 1a2ec565e8
14 changed files with 248048 additions and 78506 deletions
+3
View File
@@ -443,6 +443,7 @@ uint32_t find_variance_inflection(
q48_16_t full_variance /* Unused in new algorithm */
)
{
(void)full_variance;
/* ========================================================================
* REDESIGNED: Levene's Test for Statistical Validity (2025-11-19)
* ========================================================================
@@ -632,6 +633,8 @@ static uint64_t compute_fit_quality(
uint64_t slope_q48
)
{
(void)heat_data;
(void)slope_q48;
if (length < 2) {
return q48_from_u64(1); /* Perfect fit if no data */
}
+2
View File
@@ -735,6 +735,8 @@ char *transition_metrics_context_accuracy_string(const WordTransitionMetrics *me
uint32_t transition_metrics_binary_chop_suggest_window(const WordTransitionMetrics *metrics,
uint32_t current_window,
double accuracy_at_current) {
(void)metrics;
(void)accuracy_at_current;
/* Phase 1: Stub - just return doubled window size per user's request
* Phase 2 will implement actual binary chop search:
* - Start at window=2
+10 -7
View File
@@ -147,13 +147,16 @@ void save_vm_state(VM* vm, int* dsp, int* rsp, int* error, vm_mode_t* mode)
*/
void restore_vm_state(VM* vm, int dsp, int rsp, int error, vm_mode_t mode)
{
/* For stress tests and error recovery, aggressively clear both stacks
* to prevent any stale state from affecting subsequent tests.
* This is safer than trying to selectively clear ranges. */
vm->dsp = -1;
vm->rsp = -1;
vm->error = 0;
vm->mode = MODE_INTERPRET;
/* Restore to the caller-supplied saved state -- every real caller
* (acl_words_test.c, this file's own save/restore pairs) captures
* dsp/rsp/error/mode before running a test specifically so it can be
* put back here. This previously ignored all four parameters and
* hard-reset to a fixed baseline instead, silently not restoring
* anything callers actually saved. */
vm->dsp = dsp;
vm->rsp = rsp;
vm->error = error;
vm->mode = mode;
/* Clear control flow flags to prevent stale state between tests */
vm->exit_colon = 0;
+1
View File
@@ -254,6 +254,7 @@ void run_module_tests(VM *vm, const char *module_name) {
* @param word_name Name of the Forth word to test
*/
void run_word_tests(VM *vm, const char *word_name) {
(void)vm;
log_message(LOG_INFO, "Searching for tests for word: %s", word_name);
int found = 0;
+1 -1
View File
@@ -124,7 +124,7 @@ static inline void cf_epoch_sync(VM *vm) {
cf_last_mode = vm->mode;
return;
}
if (vm->mode != cf_last_mode) {
if ((int)vm->mode != cf_last_mode) {
cf_sp = -1;
cf_last_mode = vm->mode;
log_message(LOG_DEBUG, "CF: reset (mode transition)");
+2
View File
@@ -71,6 +71,7 @@ static void io_word_emit(VM *vm) {
* Outputs a newline character to the terminal
*/
static void io_word_cr(VM *vm) {
(void)vm;
putchar('\n');
fflush(stdout);
}
@@ -146,6 +147,7 @@ static void io_word_type(VM *vm) {
* Outputs a single space character to terminal
*/
static void io_word_space(VM *vm) {
(void)vm;
putchar(' ');
fflush(stdout);
}
+1
View File
@@ -334,6 +334,7 @@ void string_word_bracket_tick(VM *vm) {
/* LITERAL / [LITERAL] are placeholders here */
void string_word_literal(VM *vm) {
(void)vm;
}
void string_word_bracket_literal(VM *vm) { string_word_literal(vm); }