diff options
author | comex | 2015-02-24 22:51:48 -0500 |
---|---|---|
committer | comex | 2015-02-24 22:51:48 -0500 |
commit | 39411262485837b9cfc3042b034117f213d3d415 (patch) | |
tree | dbcf48680124953ccb06595ad7de3dfd47efdc12 /lib/strerror.c | |
parent | Add unaligned read/write functions. (diff) | |
download | substitute-39411262485837b9cfc3042b034117f213d3d415.tar.gz |
fix (and make more robust) strerror.c
Diffstat (limited to 'lib/strerror.c')
-rw-r--r-- | lib/strerror.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/strerror.c b/lib/strerror.c index 3cdecae..3720f57 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -3,12 +3,14 @@ EXPORT const char *substitute_strerror(int err) { - #define CASE(code) case code: return #code + #define CASE(code) case code: (void) __COUNTER__; return #code switch (err) { /* substitute.h */ + enum { _start = __COUNTER__ }; CASE(SUBSTITUTE_OK); CASE(SUBSTITUTE_ERR_FUNC_TOO_SHORT); CASE(SUBSTITUTE_ERR_FUNC_BAD_INSN_AT_START); + CASE(SUBSTITUTE_ERR_FUNC_CALLS_AT_START); CASE(SUBSTITUTE_ERR_FUNC_JUMPS_TO_START); CASE(SUBSTITUTE_ERR_OOM); CASE(SUBSTITUTE_ERR_VM); @@ -18,6 +20,9 @@ const char *substitute_strerror(int err) { CASE(SUBSTITUTE_ERR_UNKNOWN_RELOCATION_TYPE); CASE(SUBSTITUTE_ERR_NO_SUCH_SELECTOR); CASE(SUBSTITUTE_ERR_ADJUSTING_THREADS); + _Static_assert(__COUNTER__ - _start == + _SUBSTITUTE_CURRENT_MAX_ERR_PLUS_ONE + 1, + "not all errors named in strerror.c"); /* substitute-internal.h */ CASE(SUBSTITUTE_ERR_TASK_FOR_PID); CASE(SUBSTITUTE_ERR_MISC); |