mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Sam James <sam@gentoo.org>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: libc-coord@lists.openwall.com, Rich Felker <dalias@libc.org>,
	linux-man@vger.kernel.org, musl@lists.openwall.com,
	libc-alpha@sourceware.org
Subject: [musl] Re: [libc-coord] Re: regression in man pages for interfaces using loff_t
Date: Fri, 30 Jun 2023 09:30:57 +0100	[thread overview]
Message-ID: <87a5wh2vvc.fsf@gentoo.org> (raw)
In-Reply-To: <CACb0b4=uq=Sa=SdqbAu4KovfsJfowm6cz4tjyQ-YYaHX9z_Fxg@mail.gmail.com>


Jonathan Wakely via Libc-alpha <libc-alpha@sourceware.org> writes:

> On Fri, 30 Jun 2023 at 09:02, Jonathan Wakely wrote:
>>
>> On Fri, 30 Jun 2023 at 08:11, Paul Eggert wrote:
>>>
>>> On 2023-06-28 12:15, Rich Felker wrote:
>>>
>>> > There's also the problem that off64_t is "exactly 64-bit" which makes
>>> > it unsuitable as an interface type for cross-platform functions where
>>> > one could imagine the native type being larger (rather horrifying but
>>> > possible).
>>>
>>> Although we won't have files with 2**63 bytes any time soon, this is the
>>> best argument for preferring "loff_t" to "off64_t".
>>>
>>> But come to think of it, it'd be better to document the type simply as
>>> "off_t", with a footnote saying the equivalent of "this assumes that on
>>> 32-bit glibc platforms you compile with -DFILE_OFFSET_BITS=64 like any
>>> sane person would." The intent really is off_t here, and that will
>>> remain true even if off_t ever widens past 64 bits.
>>>
>>> All the apps I know that use the syscalls in question simply pass
>>> values that fit in off_t to these functions, and this will work
>>> regardless of whether these apps are compiled with 64- or (horrors!)
>>> 32-bit off_t. Admittedly the footnote solution would not be perfect, but
>>> it's good enough, and it would sidestep the loff_t vs off64_t confusion.
>>
>>
>> For APIs like copy_file_range(2) and splice(2) the arguments are
>> loff_t* so you can't just "pass arguments that fit in off_t" to
>> them. You have to get the pointer type correct, because writing
>> 64-bits through a 32-bit off_t would be bad. And in C++ it won't
>> even compile unless you get the pointer types exactly right (C
>> compilers will typically allow the mismatch with just a warning).
>>
>> People miss footnotes. I would really prefer if the signature shown
>> in the man page used a type that will actually compile. If it shows
>> off_t, that won't compile for 32-bit systems without LFS support
>> enabled.
>
> Apologies for sending the mail above as HTML - replying as text/plain
> for those it didn't reach.

Yes, please. The footnote is likely to be misunderstood at best (if
people even see it, they'll think it's some obscure portability issue
and try to #ifdef or something).

Apparently we got confused by this before as well: https://github.com/gentoo/portage/commit/1a7aeb58c4e687e4d4012054b56373f27941a067
(https://bugs.gentoo.org/617778), so I'll need to look at that now too.

  reply	other threads:[~2023-06-30  8:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28 17:53 [musl] " Rich Felker
2023-06-28 18:21 ` [musl] " Paul Eggert
2023-06-28 19:15   ` Rich Felker
2023-06-30  7:11     ` Paul Eggert
2023-06-30  8:02       ` [musl] Re: [libc-coord] " Jonathan Wakely
2023-06-30  8:14         ` Jonathan Wakely
2023-06-30  8:30           ` Sam James [this message]
2023-06-30 19:44         ` Paul Eggert
2023-07-02  1:18           ` A. Wilcox
2023-07-02 19:21             ` Paul Eggert
2023-07-03 18:16               ` Jakub Wilk
2023-07-03 21:35                 ` Paul Eggert
2023-07-08 17:03                   ` Alejandro Colomar
2023-07-09  6:07                     ` [musl] [PATCH v4] off64_t: prefer off_t for splice, etc Paul Eggert
2023-07-09  6:16                       ` [musl] Re: [libc-coord] " Sam James
2023-07-15 15:08                         ` Alejandro Colomar
2023-07-15 18:35                           ` Rich Felker
2023-07-15 20:01                             ` Paul Eggert
2023-07-16  0:35                             ` Alejandro Colomar
2023-07-16  0:39                               ` Alejandro Colomar
2023-06-30 23:37       ` [musl] Re: regression in man pages for interfaces using loff_t Rich Felker
2023-07-01  7:24         ` [musl] Re: [libc-coord] " Paul Eggert
2023-07-01 13:36           ` Szabolcs Nagy
2023-07-01 23:02             ` Paul Eggert
2023-07-01 14:32           ` Rich Felker
2023-07-01 18:45             ` Alejandro Colomar
2023-07-01 23:06             ` Paul Eggert
2023-06-28 19:19   ` Szabolcs Nagy
2023-06-28 19:28   ` Rich Felker

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=87a5wh2vvc.fsf@gentoo.org \
    --to=sam@gentoo.org \
    --cc=dalias@libc.org \
    --cc=jwakely@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-coord@lists.openwall.com \
    --cc=linux-man@vger.kernel.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).