Thread (1 message) 1 message, 1 author, 2016-10-09

Re: Return type of getrandom(2)

From: Andy Lutomirski <hidden>
Date: 2016-10-09 16:53:48
Also in: linux-man

On Oct 8, 2016 4:17 PM, "Theodore Ts'o" [off-list ref] wrote:
On Sat, Oct 08, 2016 at 02:28:27PM +0200, Florian Weimer wrote:
quoted
The manual page says the return type of getrandom(2) is int, but
ssize_t would be more natural (see read(2) for comparison).  The
kernel uses ssize_t internally, which is converted to long on the
system call boundary.

The difference does not currently matter because the return value is
limited to much less than INT_MAX in the implementation.

Should we use int or ssize_t in the glibc system call wrapper?
I think it should be ssize_t.  Having the types mismatched across the
syscall boundary is just confusing.

(b) the maximum number of bytes returned will *always* be well
under INT_MAX.
I would argue that this particular ship sailed when the len parameter
was given the type size_t.  The door is open for requests bigger than
2GiB.  Even if Linux will never honor those requests, I see no reason
to make their return value have a nonsensical type.

--Andy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help