unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alejandro Colomar via Libc-alpha <libc-alpha@sourceware.org>
To: Xi Ruoyao <xry111@xry111.site>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: bind(2): Missing [[gnu::nonnull]]
Date: Sat, 3 Dec 2022 17:41:36 +0100	[thread overview]
Message-ID: <8d45edac-9282-3cb1-b8fe-320549757e41@gmail.com> (raw)
In-Reply-To: <8292ef824696e0fbac4f4ed036aad43c0458b8a2.camel@xry111.site>


[-- Attachment #1.1: Type: text/plain, Size: 1600 bytes --]

Hi Xi,

On 12/3/22 16:55, Xi Ruoyao wrote:
> On Sat, 2022-12-03 at 16:33 +0100, Alejandro Colomar via Libc-alpha
> wrote:
>> Hi!
>>
>> I'm documenting NULLness of parameters in the Linux man-pages.  While doing
>> that, I noticed bind(2) is not prototyped with nonnull, but I don't think it
>> makes sense to accept NULL.  Is it a mistake?  Should I send a patch for adding it?
> 
> Hi Alejandro,
> 
> Currently the man page says:
> 
> EFAULT: addr points outside the user's accessible address space.
> 
> And bind(2) indeed sets errno to EFAULT and return -1 when NULL is
> passed as addr.
> 
> gnu::nonnull is not only a diagnostic attribute: it also allows the
> compiler to assume addr is never NULL.  i. e. if addr was gnu::nonnull
> and bind(2) is called with addr == NULL, the behavior would be
> undefined.
> 
> So this will be an API change.  Yes I agree calling bind with NULL does
> not make any sense, but I guess we still need to keep API
> "compatibility" with those nonsense code...
> 

Hmmm, makes sense.  What I'll do (unless someone opposes and suggests that I do 
otherwise), though, is ignore that problem in the man-pages.  I'm documenting 
_Nullable instead of _Nonnull, since there are much less places where it needs 
to be added, so what I'll do is be silent in the case of bind(2).  I'm not 
specifying _Nonnull, so it's not a lie, but I'm not suggesting programmers that 
they should be careless about NULL, which I wouldn't want to do.

Thanks for the prompt answer!

Cheers,

Alex


-- 
<http://www.alejandro-colomar.es/>

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

  reply	other threads:[~2022-12-03 16:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-03 15:33 bind(2): Missing [[gnu::nonnull]] Alejandro Colomar via Libc-alpha
2022-12-03 15:55 ` Xi Ruoyao via Libc-alpha
2022-12-03 16:41   ` Alejandro Colomar via Libc-alpha [this message]
2022-12-03 19:05   ` Andreas Schwab
2022-12-03 19:12     ` Alejandro Colomar via Libc-alpha
2022-12-04  5:59     ` Xi Ruoyao via Libc-alpha
2022-12-04 11:14       ` Alejandro Colomar via Libc-alpha
2022-12-04 18:46         ` Florian Weimer via Libc-alpha
2022-12-05 18:53           ` Zack Weinberg via Libc-alpha

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=8d45edac-9282-3cb1-b8fe-320549757e41@gmail.com \
    --to=libc-alpha@sourceware.org \
    --cc=alx.manpages@gmail.com \
    --cc=xry111@xry111.site \
    /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).