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.
25 lines
695 B
C
25 lines
695 B
C
#include "akerror.h"
|
|
#include "err_capture.h"
|
|
#include <string.h>
|
|
|
|
/* Unregistered status values return the sentinel regardless of magnitude. */
|
|
|
|
int main(void)
|
|
{
|
|
akerr_init();
|
|
|
|
/* Below range. */
|
|
AKERR_CHECK(strcmp(akerr_name_for_status(-1, NULL), "Unknown Error") == 0);
|
|
AKERR_CHECK(strcmp(akerr_name_for_status(-9999, NULL), "Unknown Error") == 0);
|
|
|
|
AKERR_CHECK(strcmp(akerr_name_for_status(1000000, NULL),
|
|
"Unknown Error") == 0);
|
|
|
|
/* A valid code must still resolve to its real name. */
|
|
AKERR_CHECK(strcmp(akerr_name_for_status(AKERR_NULLPOINTER, NULL),
|
|
"Null Pointer Error") == 0);
|
|
|
|
fprintf(stderr, "err_name_bounds ok\n");
|
|
return 0;
|
|
}
|