From: Florian Weimer <fw-d32yF4oPJVt0XxTmqZlbVQ@public.gmane.org>
To: Andy Lutomirski <luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Ted Ts'o <tytso-3s7WtUTddSA@public.gmane.org>,
Heinrich Schuchardt <xypron.glpk-Mmb7MZpHnFY@public.gmane.org>,
linux-man <linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Linux API <linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: Return type of getrandom(2)
Date: Wed, 12 Oct 2016 08:30:16 +0200 [thread overview]
Message-ID: <87eg3mw03r.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <CALCETrWgc0Wwd5AQ8fk3qPabsXKAgFZmH5O6w0CrcXEx+Pwy-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> (Andy Lutomirski's message of "Sun, 9 Oct 2016 09:53:48 -0700")
* Andy Lutomirski:
> On Oct 8, 2016 4:17 PM, "Theodore Ts'o" <tytso-3s7WtUTddSA@public.gmane.org> wrote:
>>
>> On Sat, Oct 08, 2016 at 02:28:27PM +0200, Florian Weimer wrote:
>> > 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.
Thanks for your input. I'm leaning towards ssize_t now as well.
Ted's getentropy example was helpful as well.
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2016-10-12 6:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-08 12:28 Return type of getrandom(2) Florian Weimer
[not found] ` <87mvifnhxw.fsf-ZqZwdwZz9NfTBotR3TxKnbNAH6kLmebB@public.gmane.org>
2016-10-08 19:40 ` Theodore Ts'o
[not found] ` <20161008194005.uo7uwiaukgk4y7ku-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2016-10-09 9:47 ` Florian Weimer
2016-10-09 16:53 ` Andy Lutomirski
[not found] ` <CALCETrWgc0Wwd5AQ8fk3qPabsXKAgFZmH5O6w0CrcXEx+Pwy-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-12 6:30 ` Florian Weimer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eg3mw03r.fsf@mid.deneb.enyo.de \
--to=fw-d32yf4opjvt0xxtmqzlbvq@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=tytso-3s7WtUTddSA@public.gmane.org \
--cc=xypron.glpk-Mmb7MZpHnFY@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox