From 39411262485837b9cfc3042b034117f213d3d415 Mon Sep 17 00:00:00 2001 From: comex Date: Tue, 24 Feb 2015 22:51:48 -0500 Subject: fix (and make more robust) strerror.c --- lib/strerror.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/strerror.c') 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); -- cgit v1.2.3