Add collision-safe status code registry

Replace the consumer-sized status-name array with private sparse storage and accept arbitrary integer status values. Add explicit range reservations with overlap diagnostics, reserve the library's 0-255 compatibility band, and harden pointer and string boundary handling.

Update regression coverage and document the required migration for custom status-code consumers.
This commit is contained in:
2026-07-30 13:53:39 -04:00
parent 0bb3a4d52c
commit 11d21068df
9 changed files with 250 additions and 260 deletions

View File

@@ -6,7 +6,7 @@
* The library imports system errno codes and their descriptions at build time
* (scripts/generrno.sh -> akerr_init_errno). Verify:
* - a system errno (EACCES) has a registered, non-empty name;
* - an out-of-range status returns the "Unknown Error" sentinel;
* - an unregistered status returns the "Unknown Error" sentinel;
* - a system errno can be raised, propagated and handled like any AKERR_* code.
*/
@@ -28,7 +28,7 @@ int main(void)
AKERR_CHECK(nm[0] != '\0');
AKERR_CHECK(strcmp(nm, "Unknown Error") != 0);
AKERR_CHECK(strcmp(akerr_name_for_status(AKERR_MAX_ERR_VALUE + 5000, NULL),
AKERR_CHECK(strcmp(akerr_name_for_status(1000000, NULL),
"Unknown Error") == 0);
PREPARE_ERROR(e);