From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 5A8833858D39 for ; Sat, 3 Dec 2022 15:55:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A8833858D39 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1670082916; bh=lwZYRF24fJ/TzPgX//M7Rwef3oeDnsxsNa6BAKIAq7s=; h=Subject:From:To:Date:In-Reply-To:References:From; b=TueFIuAXDh7QJMr2xuYRm7jFdyUNGG49pSlDsF0qhHxgzsCokrQ6zw7A7EmMqOzWv HiOIRYtISVMuVLJspji2DQHHY+Kt1XI2NswCYaCPDqjdxG9zgWINsmSjnzywZ7ITtU 0OhRhDTl+XMnbUAGujTLkE8/+glhM6GDG4NfOT5Q= Received: from [IPv6:240e:358:1159:3000:dc73:854d:832e:3] (unknown [IPv6:240e:358:1159:3000:dc73:854d:832e:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 17BED65B0A; Sat, 3 Dec 2022 10:55:13 -0500 (EST) Message-ID: <8292ef824696e0fbac4f4ed036aad43c0458b8a2.camel@xry111.site> Subject: Re: bind(2): Missing [[gnu::nonnull]] From: Xi Ruoyao To: Alejandro Colomar , GNU C Library Date: Sat, 03 Dec 2022 23:55:06 +0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD,LIKELY_SPAM_FROM,SPF_HELO_PASS,SPF_PASS,TXREP,T_PDS_OTHER_BAD_TLD autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sat, 2022-12-03 at 16:33 +0100, Alejandro Colomar via Libc-alpha wrote: > Hi! >=20 > I'm documenting NULLness of parameters in the Linux man-pages.=C2=A0 Whil= e doing=20 > that, I noticed bind(2) is not prototyped with nonnull, but I don't think= it=20 > makes sense to accept NULL.=C2=A0 Is it a mistake?=C2=A0 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 =3D=3D 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... --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University