All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] man/: SYNOPSIS: Remove GNU forward-declarations of parameters for lengths of array parameters
@ 2026-10-22 16:44 Alejandro Colomar
  2026-10-22 17:11 ` Martin Uecker
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From: Alejandro Colomar @ 2026-10-22 16:44 UTC (permalink / raw)
  To: linux-man
  Cc: Alejandro Colomar, Michael Kerrisk, Christopher Bazley, Sam James,
	Carlos O'Donell, Joseph S. Myers, Martin Uecker,
	Alejandro Colomar

[-- Attachment #1: Type: text/plain, Size: 11702 bytes --]

From: Alejandro Colomar <alx+linux-man@kernel.org>

From: Alejandro Colomar <alx@kernel.org>

I'm not fully convinced of this patch.  But I'm open to being convinced.
I've written the patch, as Michael asked me to do, but am willing to
hear everyone's opinion before applying the patch.

As Michael reminded me recently, and as I've defended in other cases, it
is true that the SYNOPSIS of the manual pages does not need to be
strictly valid C.  It only needs to be useful enough for readers to
understand the interface.  Thus, if using lengths without declaring them
would improve the usefulness of the documentation, even if becoming
invalid C, it would be okay.

However, I still have doubts, because this change comes with risks:

Programmers might think it is valid C to refer to parameters that have
not been declared yet, and use that in their code, and if they are
unlucky, it might compile for them, which might result in UB at some
point.

One valid point is that this is rather unlikely to happen, and most of
the time it will just result in a compiler error, because no global
variables with the name of the parameter exist.

However, with local (nested) functions, this might be easier to happen,
as variables declared in the outer function are more likely to share a
name with a length parameter.  Given that the C Committee is working
hard to standardize local functions, it might be a very bad idea to have
this combination of events going on.

Concerns that have been raised against using the GNU C syntax in the
manual pages:

Very very few programmers know this syntax, and thus they are confused
when reading it for the first time.

This is obviously true.  However, this is true of any innovative syntax.
We should consider whether the confusion is dangerous or not, and
whether programmers can learn it easily or not.

I believe once you've been exposed to this syntax, after some research,
or asking the right people, one would easily learn to read it, and then
we'd have overcome the issue.  I don't think the syntax is inherently
difficult to understand once you've seen the documentation and seen it
a few times.

Also, this syntax is not very dangerous: a programmer thinking
that a forward declaration is actually a normal parameter will pass a
wrong number of arguments to the function, and thus will have compiler
errors.  This syntax is quite robust, as it requires several bugs to
happen in the same code to pass compilation silently.  If one replaces
';' with ',', the parameter will be declared twice, which is an error.
If one renames a forward declaration, it will not match a parameter, and
will result in a compiler error.  Only if both mistakes happen at once,
the compilation would pass, but then the call sites would also have to
match the bogus declaration.  And also, the function definition would
have unused parameters, which would trigger diagnostics.  So, concerning
safety, this feature is not very dangerous, even if used by someone who
is very confused.

Do we think programmers are unable to ever learn this new syntax?
Are we ready to accept the risks of using the dangerous invalid syntax,
but which is more intuitive to programmers?

Reported-by: Michael Kerrisk <mtk.manpages@gmail.com>
Not-yet-Signed-off-by: Alejandro Colomar <alx@kernel.org>
---

I've cut the diff below to just a single page, because this is just for
discussion; the actual diff is huge and uninteresting.  It's just a
removal of all uses of fwd decls of parameters in the manual pages.


Have a lovely day!
Alex

 man/man2/add_key.2                       |  2 +-
 man/man2/alloc_hugepages.2               |  2 +-
 man/man2/cacheflush.2                    |  2 +-
 man/man2/epoll_wait.2                    |  6 +++---
 man/man2/futex_waitv.2                   |  2 +-
 man/man2/get_mempolicy.2                 |  2 +-
 man/man2/getdents.2                      |  2 +-
 man/man2/getdomainname.2                 |  4 ++--
 man/man2/getrandom.2                     |  2 +-
 man/man2/getsockopt.2                    |  4 ++--
 man/man2/getunwind.2                     |  2 +-
 man/man2/getxattr.2                      |  6 +++---
 man/man2/init_module.2                   |  2 +-
 man/man2/listmount.2                     |  2 +-
 man/man2/lookup_dcookie.2                |  2 +-
 man/man2/madvise.2                       |  2 +-
 man/man2/mbind.2                         |  2 +-
 man/man2/mincore.2                       |  2 +-
 man/man2/mlock.2                         |  6 +++---
 man/man2/mmap.2                          |  4 ++--
 man/man2/modify_ldt.2                    |  2 +-
 man/man2/mprotect.2                      |  4 ++--
 man/man2/mremap.2                        |  2 +-
 man/man2/msgop.2                         |  4 ++--
 man/man2/msync.2                         |  2 +-
 man/man2/outb.2                          | 12 ++++++------
 man/man2/perfmonctl.2                    |  2 +-
 man/man2/pread.2                         |  4 ++--
 man/man2/query_module.2                  |  2 +-
 man/man2/read.2                          |  2 +-
 man/man2/readlink.2                      |  4 ++--
 man/man2/recv.2                          |  4 ++--
 man/man2/recvmmsg.2                      |  2 +-
 man/man2/remap_file_pages.2              |  2 +-
 man/man2/s390_pci_mmio_write.2           |  4 ++--
 man/man2/send.2                          |  4 ++--
 man/man2/sendmmsg.2                      |  2 +-
 man/man2/setxattr.2                      |  6 +++---
 man/man2/write.2                         |  2 +-
 man/man2const/KEYCTL_DESCRIBE.2const     |  2 +-
 man/man2const/KEYCTL_DH_COMPUTE.2const   |  2 +-
 man/man2const/KEYCTL_GET_SECURITY.2const |  2 +-
 man/man2const/KEYCTL_INSTANTIATE.2const  |  4 ++--
 man/man2const/KEYCTL_READ.2const         |  2 +-
 man/man2const/KEYCTL_UPDATE.2const       |  2 +-
 man/man2const/PR_GET_AUXV.2const         |  2 +-
 man/man3/aio_suspend.3                   |  2 +-
 man/man3/arc4random.3                    |  2 +-
 man/man3/backtrace.3                     |  6 +++---
 man/man3/bcmp.3                          |  2 +-
 man/man3/bcopy.3                         |  2 +-
 man/man3/bsearch.3                       |  2 +-
 man/man3/bzero.3                         |  2 +-
 man/man3/cfree.3                         |  4 ++--
 man/man3/confstr.3                       |  2 +-
 man/man3/des_crypt.3                     |  4 ++--
 man/man3/explicit_bzero.3                |  2 +-
 man/man3/fgets.3                         |  2 +-
 man/man3/fgetws.3                        |  2 +-
 man/man3/fmemopen.3                      |  2 +-
 man/man3/fread.3                         |  4 ++--
 man/man3/getcwd.3                        |  2 +-
 man/man3/getdirentries.3                 |  2 +-
 man/man3/getentropy.3                    |  2 +-
 man/man3/getgrent_r.3                    |  4 ++--
 man/man3/getgrnam.3                      |  4 ++--
 man/man3/gethostbyname.3                 | 10 +++++-----
 man/man3/getipnodebyname.3               |  2 +-
 man/man3/getlogin.3                      |  2 +-
 man/man3/getmntent.3                     |  2 +-
 man/man3/getnameinfo.3                   |  2 +-
 man/man3/getnetent_r.3                   |  6 +++---
 man/man3/getprotoent_r.3                 |  6 +++---
 man/man3/getpwent_r.3                    |  4 ++--
 man/man3/getpwnam.3                      |  4 ++--
 man/man3/getrpcent_r.3                   |  6 +++---
 man/man3/getservent_r.3                  |  6 +++---
 man/man3/getspnam.3                      |  8 ++++----
 man/man3/inet_net_pton.3                 |  4 ++--
 man/man3/inet_ntop.3                     |  2 +-
 man/man3/lio_listio.3                    |  2 +-
 man/man3/lsearch.3                       |  4 ++--
 man/man3/mblen.3                         |  2 +-
 man/man3/mbrlen.3                        |  2 +-
 man/man3/mbrtowc.3                       |  2 +-
 man/man3/mbsnrtowcs.3                    |  2 +-
 man/man3/mbsrtowcs.3                     |  2 +-
 man/man3/mbstowcs.3                      |  2 +-
 man/man3/mbtowc.3                        |  2 +-
 man/man3/memccpy.3                       |  2 +-
 man/man3/memchr.3                        |  2 +-
 man/man3/memcmp.3                        |  2 +-
 man/man3/memcpy.3                        |  2 +-
 man/man3/memfrob.3                       |  2 +-
 man/man3/memmem.3                        |  2 +-
 man/man3/memmove.3                       |  2 +-
 man/man3/mempcpy.3                       |  2 +-
 man/man3/memrchr.3                       |  2 +-
 man/man3/memset.3                        |  2 +-
 man/man3/memset_explicit.3               |  2 +-
 man/man3/mq_receive.3                    |  4 ++--
 man/man3/mq_send.3                       |  4 ++--
 man/man3/posix_madvise.3                 |  2 +-
 man/man3/pthread_attr_setstack.3         |  2 +-
 man/man3/pthread_setname_np.3            |  2 +-
 man/man3/ptsname.3                       |  2 +-
 man/man3/qsort.3                         |  4 ++--
 man/man3/random.3                        |  2 +-
 man/man3/regex.3                         |  2 +-
 man/man3/resolver.3                      | 24 ++++++++++++------------
 man/man3/setaliasent.3                   |  4 ++--
 man/man3/setbuf.3                        |  4 ++--
 man/man3/setnetgrent.3                   |  2 +-
 man/man3/snprintf.3                      |  4 ++--
 man/man3/stpncpy.3                       |  2 +-
 man/man3/strerror.3                      |  4 ++--
 man/man3/strfmon.3                       |  4 ++--
 man/man3/strfromd.3                      |  6 +++---
 man/man3/strftime.3                      |  4 ++--
 man/man3/strlcpy.3                       |  4 ++--
 man/man3/strncat.3                       |  2 +-
 man/man3/strncpy.3                       |  2 +-
 man/man3/strndup.3                       |  2 +-
 man/man3/strndupa.3                      |  2 +-
 man/man3/strxfrm.3                       |  2 +-
 man/man3/swab.3                          |  2 +-
 man/man3/ttyname.3                       |  2 +-
 man/man3/unlocked_stdio.3                |  8 ++++----
 man/man3/wcpncpy.3                       |  2 +-
 man/man3/wcsncat.3                       |  2 +-
 man/man3/wcsncpy.3                       |  2 +-
 man/man3/wcsnrtombs.3                    |  2 +-
 man/man3/wcsrtombs.3                     |  2 +-
 man/man3/wcstombs.3                      |  2 +-
 man/man3/wmemchr.3                       |  2 +-
 man/man3/wmemcmp.3                       |  2 +-
 man/man3/wmemcpy.3                       |  2 +-
 man/man3/wmemmove.3                      |  2 +-
 man/man3/wmempcpy.3                      |  2 +-
 man/man3/wmemset.3                       |  2 +-
 man/man3/wprintf.3                       |  4 ++--
 man/man7/man-pages.7                     |  2 +-
 man/man7/string_copying.7                | 16 ++++++++--------
 man/man9/strscpy.9                       |  2 +-
 144 files changed, 228 insertions(+), 228 deletions(-)

diff --git a/man/man2/add_key.2 b/man/man2/add_key.2
index 19bc5d40ae76..908c63a10fbb 100644
--- a/man/man2/add_key.2
+++ b/man/man2/add_key.2
@@ -14,7 +14,7 @@ .SH SYNOPSIS
 .nf
 .B #include <keyutils.h>
 .P
-.BR key_serial_t\~add_key( size_t\~size;
+.B key_serial_t\~add_key(
 .BI "                     const char *" type ", const char *" description ,
 .BI "                     const void " payload [ size "], size_t " size ,
 .BI "                     key_serial_t " keyring ");"
-- 
2.55.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2026-10-29 21:24 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22 16:44 [PATCH] man/: SYNOPSIS: Remove GNU forward-declarations of parameters for lengths of array parameters Alejandro Colomar
2026-10-22 17:11 ` Martin Uecker
2026-10-22 20:01   ` Alejandro Colomar
2026-10-22 20:27     ` Alejandro Colomar
2026-10-22 17:37 ` Christopher Bazley
     [not found] ` <CAEHU8x9jET+vcrR0NpDz6t57egQG8TZqx5XtV52srH9ZRvdxSQ@mail.gmail.com>
2026-10-22 19:54   ` Alejandro Colomar
2026-10-23 11:53     ` Michael Kerrisk (man7.org)
2026-10-23 12:42       ` Alejandro Colomar
2026-10-23 15:51       ` Christopher Bazley
2026-10-24 12:45         ` Michael Kerrisk (man7.org)
2026-10-24 13:38           ` Alejandro Colomar
2026-10-24 16:16             ` Christopher Bazley
2026-10-24 16:37               ` Alejandro Colomar
2026-10-24 18:11                 ` Martin Uecker
2026-10-25  6:59                   ` Alejandro Colomar
2026-10-25  7:22                     ` Martin Uecker
2026-10-25  7:38                       ` Alejandro Colomar
2026-10-25  8:29                         ` G. Branden Robinson
2026-10-25  8:40                         ` Martin Uecker
2026-10-25  8:57                           ` Alejandro Colomar
2026-10-25  9:05                             ` Martin Uecker
2026-10-29 21:24                           ` Christopher Bazley
2026-10-23 12:11     ` Alejandro Colomar
2026-10-22 22:03 ` Mark Harris
2026-10-23  9:43   ` Alejandro Colomar
2026-10-23 19:32     ` Mark Harris
2026-10-23 20:06       ` Alejandro Colomar
2026-10-24  7:53   ` Martin Uecker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.