From fc6e3f432826fe9d9a9d2d05e295a7c7d11d259e Mon Sep 17 00:00:00 2001 From: wes Date: Fri, 7 Dec 2001 06:28:58 +0000 Subject: Make strerror and strerror_r use sys_errlist[0] for errnum = 0. Be more careful about reporting truncation with ERANGE in strerror_r. Set errno to EINVAL for "unknown" errnum in strerror as required by P1003.1-200x Draft June 14, 2001. More carefully document the handling of strerrbuf when errors (ERANGE, EINVAL) are encountered in strerror_r. Reviewed by: bde (ongoing discussion) --- lib/libc/string/strerror.3 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/libc/string/strerror.3') diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3 index 037b138..2ed92d6 100644 --- a/lib/libc/string/strerror.3 +++ b/lib/libc/string/strerror.3 @@ -110,8 +110,15 @@ returns an error message string containing .Dq Li "Unknown error:\ " followed by the error number in decimal, while .Fn strerror_r -returns +leaves +.Fa strerrbuf +unchanged and returns .Er EINVAL . +Error numbers recognized by this implementation fall in +the range 0 <= +.Fa errnum +< +.Fa sys_nerr . .Pp If insufficient storage is provided in .Fa strerrbuf @@ -121,9 +128,11 @@ to contain the error string, .Fn strerror_r returns .Er ERANGE -and the contents of +and .Fa strerrbuf -are indeterminate. +will contain an error message that has been truncated and nul +terminated to fit the length specified by +.Fa buflen . .Pp The message strings can be accessed directly using the external array -- cgit v1.1