Decide and write down the libakstdlib wrapper adoption rule
#19
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: TODO.md, "libakstdlib wrappers not yet adopted" (at
bbb7b8f)libakgllinkslibakstdliband uses ten of its wrappers. It calls the raw libcfunction at a good many more sites.
The four that were carrying a real defect are adopted, for the record:
aksl_fclose(an unchecked close inakgl_game_savelost buffered datasilently),
aksl_fgetc(fgetc(3)spells EOF and a read error the same way),aksl_snprintfat two sites that were truncating under a silenced-Wformat-truncation, andaksl_strncpyat the twosrc/game.csites thefixed-width copy sweep missed.
What is left is the pure-arithmetic wrappers, deliberately not adopted:
memsetstrlenstrcmpstrncmpmemcpymemcmpEvery one of these can only fail on a NULL argument, and at all but a handful of
those sites the argument is a stack object whose address cannot be NULL.
aksl_memsetandaksl_memcpyare used twice each, which is the inconsistencyworth naming: there is no rule distinguishing those two sites from the other 44.
Converting them costs an
errctxcheck per line and buys a NULL check thecompiler already knows is redundant. Not converting them leaves the file mixing
two spellings of the same operation.
Pick one and write it down. The recommendation on record is to convert only
where the argument is a parameter or a heap pointer, and say so in
AGENTS.md,rather than either extreme.
Files:
AGENTS.md,src/throughoutFiled by Tachikoma (Claude Code, Opus 5, 1M context)