Roughly 180 redundant pointer casts, and the -Wall precondition is now met #65

Closed
opened 2026-08-02 18:35:10 -04:00 by tachikoma · 1 comment
Collaborator

Source: TODO.md, "Internal consistency", item 37 (at bbb7b8f)

Roughly 180 pointer casts across src/, a large majority of them no-ops, densest
in src/tilemap.c and src/character.c.

This item used to say the benefit only arrives once the build turns on the
warnings those casts suppress, and that doing it first buys nothing but churn.
-Wall is on now (AGENTS.md, "Compiler warnings"), so the sweep can proceed as
its own commit.

The argument turned out to be right, with evidence. Turning -Wall on found
three genuine signedness mismatches in src/sprite.c: obj->width, obj->height
and obj->speed are uint32_t and were being passed straight to
akgl_get_json_integer_value(..., int *). A cast would have silenced all three.
They were fixed by reading into an int, range-checking, and assigning -- which
also turned up that speed is scaled by 1,000,000 into a 32-bit field, so
anything past 4294 ms overflowed rather than being held.

Method: remove a cast, rebuild, and read what the compiler says. A cast that
was load-bearing will say so. Its own commit, no behaviour changes mixed in.

Files: src/tilemap.c, src/character.c, and the rest of src/


Filed by Tachikoma (Claude Code, Opus 5, 1M context)

**Source:** TODO.md, "Internal consistency", item 37 (at bbb7b8f) Roughly 180 pointer casts across `src/`, a large majority of them no-ops, densest in `src/tilemap.c` and `src/character.c`. This item used to say the benefit only arrives once the build turns on the warnings those casts suppress, and that doing it first buys nothing but churn. `-Wall` is on now (`AGENTS.md`, "Compiler warnings"), so the sweep can proceed as its own commit. **The argument turned out to be right, with evidence.** Turning `-Wall` on found three genuine signedness mismatches in `src/sprite.c`: `obj->width`, `obj->height` and `obj->speed` are `uint32_t` and were being passed straight to `akgl_get_json_integer_value(..., int *)`. A cast would have silenced all three. They were fixed by reading into an `int`, range-checking, and assigning -- which also turned up that `speed` is scaled by 1,000,000 into a 32-bit field, so anything past 4294 ms overflowed rather than being held. **Method:** remove a cast, rebuild, and read what the compiler says. A cast that was load-bearing will say so. Its own commit, no behaviour changes mixed in. **Files:** `src/tilemap.c`, `src/character.c`, and the rest of `src/` --- Filed by Tachikoma (Claude Code, Opus 5, 1M context)
tachikoma added this to the 0.9.x milestone 2026-08-02 18:35:10 -04:00
tachikoma added the hygieneblast-radius:low labels 2026-08-02 18:35:10 -04:00
Author
Collaborator

Duplicate of #5, filed twice by a paging bug in the script that created these -- the forge caps an issue listing at 50 per page and the de-duplication check read only the first page. Closing; #5 is the live one.

Duplicate of #5, filed twice by a paging bug in the script that created these -- the forge caps an issue listing at 50 per page and the de-duplication check read only the first page. Closing; #5 is the live one.
Sign in to join this conversation.