kern/140690: [libc] [patch] swab(3) with negative len should do nothing

Bruce Evans brde at
Sat Nov 21 10:00:16 UTC 2009

The following reply was made to PR kern/140690; it has been noted by GNATS.

From: Bruce Evans <brde at>
To: Paul Procacci <pprocacci at>
Cc: bug-followup at
Subject: Re: kern/140690: [libc] [patch] swab(3) with negative len should do
Date: Sat, 21 Nov 2009 20:59:35 +1100 (EST)

 On Sat, 21 Nov 2009, Paul Procacci wrote:
 > I'd like to add to this.
 > As for the length argument.  Is there really ever a time it would have
 > to be signed?
 > If not, then I would suggest declaring the type as size_t and not
 > ssize_t much like the read/write/etc syscalls.
 The type should be unsigned (size_t), and was unsigned (size_t) in
 BSD, but it is broken in POSIX (ssize_t), and FreeBSD changed the API
 to be not even bug for bug compatible with POSIX in 2004 (since POSIX
 requires nothing to be done when the length is negative, like the patch
 in the PR implements).
 The type was implicit int in V7, but BSD changed it to size_t in Net/2
 or earlier; thus the type and the the code were correct in all versions
 of FreeBSD between 1993 and 2004.

More information about the freebsd-bugs mailing list