From: Alejandro Colomar via Libc-alpha <libc-alpha@sourceware.org>
To: "Seija K." <doremylover123@gmail.com>, libc-alpha@sourceware.org
Cc: Mike Frysinger <vapier@gentoo.org>,
Michael Kerrisk <mtk.manpages@gmail.com>,
Szabolcs Nagy <Szabolcs.Nagy@arm.com>,
"Joseph S. Myers" <joseph@codesourcery.com>,
Ulrich Drepper <drepper@redhat.com>,
Florian Weimer <fweimer@redhat.com>,
Andreas Schwab <schwab@suse.de>
Subject: Re: Add restrict annotations to all functions that require it
Date: Sun, 27 Nov 2022 13:39:02 +0100 [thread overview]
Message-ID: <2999b905-bf2c-9ca3-08d8-cf75a3dfcb77@gmail.com> (raw)
In-Reply-To: <86b3224b-84d4-ed5f-4699-de89b25cc66a@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 3258 bytes --]
[CC += Andreas]
On 11/27/22 13:30, Alejandro Colomar wrote:
> [CC += all CCs from man-pages patches]
>
> Hi Seija,
>
> On 11/27/22 01:56, Seija K. via Libc-alpha wrote:
>> The format value has to be a string literal, every time. Otherwise, you are
>> not using these functions correctly. To reinforce this fact, I put
>> __restrict over every example of this I could find.
>
>
> I like this change. In fact, when I added 'restrict' to the Linux man-pages, I
> had to check that in some cases POSIX and glibc matched, but in others, either
> glibc or POSIX had restrict while the other didn't:
>
> Linux man-pages commits:
>
> - 746d60af802a4462055c4f87a62681f7254325d8 [strptime(3)]
> - You fixed this one in the patch; fine.
> - 0864c240797e3b793a88ee6be5710dd9a8df9b45 [posix_spawnp(3)]
> - This one hasn't been changed in you patch; please check.
> - Bug reported here: <https://sourceware.org/bugzilla/show_bug.cgi?id=27529>
> - See some proof below.
> - c445280cf371cda66916c4e5e0fdb168db3a5ad6 [lio_listio(3)]
> - This one hasn't been changed in you patch; please check.
> - Bug reported here: <https://sourceware.org/bugzilla/show_bug.cgi?id=16747>
> - See some proof below.
>
> I might have missed other cases by accident, but I think those 3 are all the
> cases where POSIX uses restrict and glibc doesn't (there are many more cases of
> the opposite, but that's OK for your patch), as far as I documented back then
> when I added restrict to the man-pages.
>
> Cheers,
>
> Alex
>
> P.S.: I'm neutral to having the 'restrict' keyword in function definitions, if
> they are already in function prototypes (Mike reported this).
>
> --- posix_spawnp(3):
>
> $ man 3p posix_spawnp |sed -n '/^SYNOPSIS/,/;/p'
> SYNOPSIS
> #include <spawn.h>
>
> int posix_spawnp(pid_t *restrict pid, const char *restrict file,
> const posix_spawn_file_actions_t *file_actions,
> const posix_spawnattr_t *restrict attrp,
> char *const argv[restrict], char *const envp[restrict]);
> $ grepc posix_spawnp /usr/include
> /usr/include/spawn.h:85:
> extern int posix_spawnp (pid_t *__pid, const char *__file,
> const posix_spawn_file_actions_t *__file_actions,
> const posix_spawnattr_t *__attrp,
> char *const __argv[], char *const __envp[])
> __nonnull ((2, 5));
>
> --- lio_listio(3):
>
> $ man 3p lio_listio |sed -n '/^SYNOPSIS/,/;/p'
> SYNOPSIS
> #include <aio.h>
>
> int lio_listio(int mode, struct aiocb *restrict const list[restrict],
> int nent, struct sigevent *restrict sig);
> $ grepc lio_listio /usr/include
> /usr/include/aio.h:148:
> extern int lio_listio (int __mode,
> struct aiocb *const __list[__restrict_arr],
> int __nent, struct sigevent *__restrict __sig)
> __THROW __nonnull ((2));
>
>
> /usr/include/aio.h:214:
> # define lio_listio lio_listio64
--
<http://www.alejandro-colomar.es/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-11-27 12:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-27 0:56 Add restrict annotations to all functions that require it Seija K. via Libc-alpha
2022-11-27 11:44 ` Mike Frysinger via Libc-alpha
2022-11-27 12:00 ` Alejandro Colomar via Libc-alpha
2022-12-03 14:32 ` Alejandro Colomar via Libc-alpha
2022-12-06 23:57 ` Joseph Myers
2022-12-07 11:59 ` Alejandro Colomar via Libc-alpha
2022-12-07 19:05 ` Joseph Myers
2022-11-27 12:04 ` Alejandro Colomar via Libc-alpha
2022-11-27 12:30 ` Alejandro Colomar via Libc-alpha
2022-11-27 12:39 ` Alejandro Colomar via Libc-alpha [this message]
2022-11-28 21:17 ` Joseph Myers
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2999b905-bf2c-9ca3-08d8-cf75a3dfcb77@gmail.com \
--to=libc-alpha@sourceware.org \
--cc=Szabolcs.Nagy@arm.com \
--cc=alx.manpages@gmail.com \
--cc=doremylover123@gmail.com \
--cc=drepper@redhat.com \
--cc=fweimer@redhat.com \
--cc=joseph@codesourcery.com \
--cc=mtk.manpages@gmail.com \
--cc=schwab@suse.de \
--cc=vapier@gentoo.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).