From: Alejandro Colomar <alx@kernel.org>
To: "Dirk Müller" <dmueller@suse.com>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>,
linux-man@vger.kernel.org
Subject: Re: [BUG] typo in man2/readlink.2
Date: Wed, 15 Apr 2026 23:36:28 +0200 [thread overview]
Message-ID: <aeADVnt6NpZ8qC9E@devuan> (raw)
In-Reply-To: <CAN6Ha9YYK7jD6D-_eKhHQA0dT3kfkGZuka31Pg+ka=mzt+QtxA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2400 bytes --]
Hi Dirk,
On 2026-04-15T22:00:52+0200, Dirk Müller wrote:
> Hi Branden,
>
> On Wed, Apr 15, 2026 at 8:24 PM G. Branden Robinson
> <g.branden.robinson@gmail.com> wrote:
>
> > > ssize_t readlink(size_t bufsiz;
> > > const char *restrict path,
> > > char buf[restrict bufsiz], size_t bufsiz);
> > >
> > > I believe this is a typo and it should be:
> > >
> > > ssize_t readlink(const char *restrict path,
> > > char buf[restrict bufsiz], size_t bufsiz);
> > This is something of a FAQ on this mailing list.
> > https://lore.kernel.org/linux-man/adupQhfJQ7kws17U@debian/
> > It's a GCC syntax extension.
> >
> > https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html
Look at the very bottom of that page.
>
> Oh, I understand that part.
I believe you didn't.
> let me try again. The Synpsis shows 4
> parameters to the readlink() call:
>
> ssize_t readlink(size_t, const char*, char buf[], size_t);
That's not what readlink(2) documents. readlink(2) has a semicolon (;)
after the fisrt 'size_t bufsiz'. That means it's a forward declaration
of a function parameter, and not a real parameter declaration.
>
> I believe it should actually be 3 parameters instead:
>
> ssize_t readlink(const char*, char buf[], size_t);
>
> with other words, the first argument is a pointer to the source link,
> not a repetition of bufsiz (which is at the end).
>
> This page has the, what I consider correct synposis:
>
> https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html
>
> ssize_t readlink(const char *restrict path, char *restrict buf,
> size_t bufsize);
This synopsis is compatible with the one from readlink(2). See by
yourself:
alx@devuan:~/tmp$ cat rl.c
#include <sys/types.h>
ssize_t readlink(
const char *path, char *buf, size_t bufsiz);
ssize_t readlink(size_t bufsiz;
const char *path, char buf[bufsiz], size_t bufsiz);
alx@devuan:~/tmp$ gcc -Wall -Wextra -Wno-vla-parameter -S rl.c
alx@devuan:~/tmp$
> Again, I'm only commenting on the number of parameters, not the
> variadic length expression on parameter two (three in the original).
Both prototypes have 3 parameters.
Have a lovely night!
Alex
>
> Thanks,
> Dirk
>
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-04-15 21:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 18:12 [BUG] typo in man2/readlink.2 Dirk Müller
2026-04-15 18:24 ` G. Branden Robinson
2026-04-15 20:00 ` Dirk Müller
2026-04-15 21:36 ` Alejandro Colomar [this message]
2026-04-15 21:57 ` Dirk Müller
2026-04-15 23:26 ` Alejandro Colomar
2026-04-17 6:41 ` Dirk Müller
2026-04-17 13:28 ` Alejandro Colomar
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=aeADVnt6NpZ8qC9E@devuan \
--to=alx@kernel.org \
--cc=dmueller@suse.com \
--cc=g.branden.robinson@gmail.com \
--cc=linux-man@vger.kernel.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