From owner-freebsd-standards@FreeBSD.ORG Sat Oct 9 12:40:08 2010 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4DEE2106566C for ; Sat, 9 Oct 2010 12:40:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E84F58FC13 for ; Sat, 9 Oct 2010 12:40:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o99Ce7J6048190 for ; Sat, 9 Oct 2010 12:40:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o99Ce7AM048178; Sat, 9 Oct 2010 12:40:07 GMT (envelope-from gnats) Date: Sat, 9 Oct 2010 12:40:07 GMT Message-Id: <201010091240.o99Ce7AM048178@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Jilles Tjoelker Cc: Subject: Re: standards/151316: lib/libc/string/strerror.c r1.9 breaks POSIX X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jilles Tjoelker List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Oct 2010 12:40:08 -0000 The following reply was made to PR standards/151316; it has been noted by GNATS. From: Jilles Tjoelker To: Jeremy Huddleston Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: standards/151316: lib/libc/string/strerror.c r1.9 breaks POSIX Date: Sat, 9 Oct 2010 14:37:31 +0200 On Fri, Oct 08, 2010 at 04:28:55PM +0000, Jeremy Huddleston wrote: > >Number: 151316 > >Category: standards > >Synopsis: lib/libc/string/strerror.c r1.9 breaks POSIX > >Description: > r1.9 of strerror.c did the following (from the changeslog) > strerror()'s semantics have changed slightly such that an argument of > 0 is now considered invalid and errno is set to EINVAL. > This introduces a regression in SUS conformance. Please explain why. As far as I understand, 0 is not a valid error number, and therefore it is appropriate to set errno = EINVAL while still returning a string. Hints to 0 being an invalid error number are the requirement that all E* constants from be positive and the requirement that no POSIX-defined function shall set errno to 0. If I'm wrong, please provide a reference such as to a specific section in the standard. In any case, this is of little practical effect since few programs check the value of errno set by strerror(). If the patch is accepted, sys_errlist[0] will probably be changed to "Unknown error: 0" so the only difference is errno set by strerror(). > >How-To-Repeat: > >Fix: > In strerror.c's strerror_r > - if (errnum < 1 || errnum >= sys_nerr) { > + if (errnum < 0 || errnum >= sys_nerr) { > And here's a man page change: > @@ -110,7 +118,7 @@ > .Er EINVAL > as a warning. > Error numbers recognized by this implementation fall in > -the range 0 < > +the range 0 <= > .Fa errnum > < > .Fa sys_nerr . -- Jilles Tjoelker