diff options
author | jilles <jilles@FreeBSD.org> | 2011-04-05 21:56:05 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-04-05 21:56:05 +0000 |
commit | c902a38c4a1577f5b9a27832540f1a955ea78038 (patch) | |
tree | 9ba493ad554e8b08e9a294a55e6d6e571583a3e2 /lib/libc | |
parent | bb9f2459b8a1d6a5aca6101af345c3ed3ccabc83 (diff) | |
download | FreeBSD-src-c902a38c4a1577f5b9a27832540f1a955ea78038.zip FreeBSD-src-c902a38c4a1577f5b9a27832540f1a955ea78038.tar.gz |
Allow strerror(0) and strerror_r(0, ...).
Of course, strerror_r() may still fail with ERANGE.
Although the POSIX specification said this could fail with EINVAL and
doing this likely indicates invalid use of errno, most other
implementations permitted it, various POSIX testsuites require it to
work (matching the older sys_errlist array) and apparently some
applications depend on it.
PR: standards/151316
MFC after: 1 week
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/errlst.c | 2 | ||||
-rw-r--r-- | lib/libc/string/strerror.3 | 5 | ||||
-rw-r--r-- | lib/libc/string/strerror.c | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/lib/libc/gen/errlst.c b/lib/libc/gen/errlst.c index b105cc8..d817823 100644 --- a/lib/libc/gen/errlst.c +++ b/lib/libc/gen/errlst.c @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> const char *const sys_errlist[] = { - "Undefined error: 0", /* 0 - ENOERROR */ + "No error: 0", /* 0 - ENOERROR */ "Operation not permitted", /* 1 - EPERM */ "No such file or directory", /* 2 - ENOENT */ "No such process", /* 3 - ESRCH */ diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3 index 2d6d206..0ec6cb0 100644 --- a/lib/libc/string/strerror.3 +++ b/lib/libc/string/strerror.3 @@ -32,7 +32,7 @@ .\" @(#)strerror.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd October 12, 2004 +.Dd April 5, 2011 .Dt STRERROR 3 .Os .Sh NAME @@ -114,6 +114,9 @@ the range 0 < .Fa errnum < .Fa sys_nerr . +The number 0 is also recognized, although applications that take advantage of +this are likely to use unspecified values of +.Va errno . .Pp If insufficient storage is provided in .Fa strerrbuf diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c index 890ed21..57d253d 100644 --- a/lib/libc/string/strerror.c +++ b/lib/libc/string/strerror.c @@ -87,7 +87,7 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen) catd = catopen("libc", NL_CAT_LOCALE); #endif - if (errnum < 1 || errnum >= sys_nerr) { + if (errnum < 0 || errnum >= sys_nerr) { errstr(errnum, #if defined(NLS) catgets(catd, 1, 0xffff, UPREFIX), |