standards/186028: incorrect return values for posix_fallocate()

Matthew Fleming mdf at FreeBSD.org
Thu Jan 23 15:36:22 UTC 2014


On Thu, Jan 23, 2014 at 7:08 AM, Bruce Evans <brde at optusnet.com.au> wrote:

> On Thu, 23 Jan 2014, Konstantin Belousov wrote:
>
>  Indeed.  Linux also seems to have the conforming behaviour, according
>> to their man page, which also explicitely states that errno is not set.
>>
>> Try this.
>>
>> diff --git a/lib/libc/sys/posix_fallocate.2 b/lib/libc/sys/posix_
>> fallocate.2
>> index 087c68c..ee6fcc4 100644
>> --- a/lib/libc/sys/posix_fallocate.2
>> +++ b/lib/libc/sys/posix_fallocate.2
>> @@ -83,9 +83,9 @@ that reduces the file size to a size smaller than
>> If successful,
>> .Fn posix_fallocate
>> returns zero.
>> -It returns -1 on failure, and sets
>> +It returns error on failure, without setting
>> .Va errno
>> -to indicate the error.
>> +variable.
>>
>
> "returns error" is hard to parse.  Only values can be returned.
>
> The old text would have had a style bug if it had been correct.  Normal
> man pages use the mdoc markup ".Rv -std" instead of repeating the above
> boilerplate ad nauseum to describe standard error handling.  In libc/sys,
> the macro is used in 106 man pages and the style bug is used in about
> 50 man pages.


Oops!  I guess I didn't read the POSIX spec very carefully; my mental model
is that only the pthread_* functions directly return the error, and others
follow the old UNIX behaviour of returning -1 and setting errno.

Anyways, the patch looks fine to me.  Sorry for any errors in the man page
as well; I never was able to find a guide to all the various mdoc macros so
I had to work from examples.

Cheers,
matthew


More information about the freebsd-standards mailing list