From nobody Mon Mar 24 15:59:20 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZLyRM6jpjz5s4yw; Mon, 24 Mar 2025 15:59:27 +0000 (UTC) (envelope-from olce@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZLyRM5kJdz3vWk; Mon, 24 Mar 2025 15:59:27 +0000 (UTC) (envelope-from olce@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1742831967; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=La21LZPWlDF0KZGpfolShJma4MAor55llO4s+56WvVU=; b=Ac6D/vlBYU/jWU0oPW1PAI/gJRf5y/EJNPdPk1zT2AjGC0iyD9PIZJT6f7wK07TC3LGsHE YfllHJ5MMP7m9Hyz/PWzTxnF/TFf/M6/287MqN9Zhj9GmjVoOU92L1fwzNlig57h8TEqvp uim4UJbcufaZNhyVMJ9t+Ql8atN/D4kHadvoE7l6z5uJ/b0jExZ15bnjdkN4Xu0I0AouYy OtiaoYMI4MdZtGViGOHsLH4WHvUH3ipWKYxClxlR/I6PXdAKZUXMw/f+Hd+s8vOgKLdd+6 MYtjECNzHuZ27dBcnWjpDKL6A6Pih55No3RqP7k+pu6KBfvmzKtbiKYpEMWaTw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1742831967; a=rsa-sha256; cv=none; b=gwzdnKeiSbxHNAVDfaORR6pQRhyT2N5R4NXmKIF1qWR+FbQlb8g6RzuSAm2Ot475xnbINf WFieFmPNa8vfCp7YeF2Qf0ErFwL8BH7Ea3Qfw2cL9w8eFh39x52PP200+kSv9jQMUxX8FB 4ZeC+5QVdi/8Vg9cbL4G5x87PhgbPf3Jt4DLjGnal/Ja3jjn3QWzkUZJzJMulxTQ2tL/4b OXkYYqD0r/MjbZYPIDxnZTvNKPHSLfyyLv5TMEOiPjiFmpRqVV7fiHcvPUS2040BTHpHP9 27wAwEErMQIVblQ5G5169JKIQiskiVpF+/e30U+9kSAqbHQvMLVbLpDiK9I2oA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1742831967; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=La21LZPWlDF0KZGpfolShJma4MAor55llO4s+56WvVU=; b=UxoDvdtiXQOI8xBoAcoTUA9T/Lc3Gszs86TKSPs1WWR5la+W2I/CptJXeiuKX233gKzbUi n06Vd0Qb03cSqGZcRWfCGlxT0JaFigf7upzy+pvrYjskYaKYtgADZth1lsFDtsp82xG/sL SI5oB7TFHseAFsBlvuTgIFU6GpIT0I8aXXZDQz/1cgzW/rcvyUPE2H8qOa+Ktera6HsD+A a0aYfODN611YX5DAAPqAW0I+Avjml5PGLpZ+tG6TYBlMnWMUyjp07E/YgIG4VGV6ZmvxW7 C0ejMgbchlpBKL7CBsmonNpJ2YQii2IEZs9pXBPAliLxPTGsaWaTEqQBcq9fKg== Received: from ravel.localnet (aclermont-ferrand-653-1-222-123.w90-14.abo.wanadoo.fr [90.14.66.123]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: olce/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4ZLyRM0S6qzDsF; Mon, 24 Mar 2025 15:59:26 +0000 (UTC) (envelope-from olce@freebsd.org) From: Olivier Certner To: Konstantin Belousov , Ronald Klop Cc: dev-commits-src-all@freebsd.org, src-committers@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: c18a16ebcf5b - main - kern_proc_kqueues_out(): maxlen == -1 means there is no maxlen Date: Mon, 24 Mar 2025 16:59:20 +0100 Message-ID: <8229058.iDzAj6rjnq@ravel> In-Reply-To: <1305725331.9507.1742828788168@localhost> References: <202503240454.52O4s0Xi051381@gitrepo.freebsd.org> <1305725331.9507.1742828788168@localhost> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2149079.x0N0T6uNKo"; micalg="pgp-sha384"; protocol="application/pgp-signature" --nextPart2149079.x0N0T6uNKo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8"; protected-headers="v1" From: Olivier Certner Date: Mon, 24 Mar 2025 16:59:20 +0100 Message-ID: <8229058.iDzAj6rjnq@ravel> In-Reply-To: <1305725331.9507.1742828788168@localhost> MIME-Version: 1.0 Hi, > (snip) =20 > > + if (maxlen =3D=3D -1 || maxlen =3D=3D 0) > As maxlen is of the unsigned type size_t, how can it be -1? > Or am I mistaken on this? It's of course true that 'maxlen' can't be -1 mathematically as it has an u= nsigned type, but that's not what 'maxlen =3D=3D -1' tests. In this exampl= e, 'maxlen' is an unsigned type of size at least equal to 'unsigned int', w= hose values cannot all be represented in a signed 'int' (well, that last pa= rt is true but not the real reason, which has to do with integer ranks). A= ccording to the standard promotion rules, and because -1 as an integer cons= tant is interpreted as of type 'int', both arguments of '=3D=3D' will be co= nverted to 'unsigned int', and conversion of a signed type to an unsigned o= ne is done by computing its congruence to the number of values the latter c= an represent (this is the mathematical description; with two-complement rep= resentation, that's basically just truncating the bits that are "too high",= or sign-extending if the unsigned type destination is wider, and in this p= recise case, just keeping the same exact representation bits). So, basicall= y, this test is equivalent to 'maxlen =3D=3D UINT_MAX' on 32-bit machines o= r 'maxlen =3D=3D ULONG_MAX' on 64-bit ones. Relevant C standard passages are, in section Language > Conversions > Arith= metic operands, the "Boolean, characters, and integers", "Signed and unsign= ed integers" and "Usual arithmetic conversions" chapters, and, under Langua= ge > Expressions, the chapter about equality operators (in particular, the = fact that it states that the usual arithmetic conversions apply), and chapt= er Language > Lexical elements > Constants > Integer constants. Regards. =2D-=20 Olivier Certner --nextPart2149079.x0N0T6uNKo Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQIzBAABCQAdFiEEmNCxHjkosai0LYIujKEwQJceJicFAmfhgVgACgkQjKEwQJce JicMug/8DXuApknJ9/MpLLBj6QZ3TICmietYFg3OYjHGVkluxu9nmRoSDlre3Het d/9csBgriOiW8MJHgkq9FiJsmq6kwvLdh3cEeUjcdwGWdqapY7+gm5h1K3I9Pm3O hW3dJne9lJL1aSlbz189QdA70aCf3+Mu91d1pVGVtzctXman7nkDUI1l6JTri3hu 0VOD/FsirlOt6JWSyVGuYRbMRCR7ViaGks9ahjo9aRyV1wCmUCaysG1JevvYyDLh o14vECCOPZltsuDA8XbV9uDjCon4KR0wTL2nFNwAPTI0DnobQ8Y2ntGcuJdBP1p0 r0ZWNjFrCOsxutpep2N6ODaiIhXMrKcsD6VPgSLcOcd4oCYvf60EgkCQiE5HG+HQ 7JrLfVvldqo4oXNJtzlXRTe8ODZ37gd6mFZtiJ611fA9pZ23ZFWy4aQ/1iWLyFEN S7lvBo9Pbyi/qhD8SHvMDrZraP3DpD+HDzJDmoAs5Z4MtGO02YSX7eZ6LLeoq4Pw /y7rrj/AdyDfAopseR5go0tPr3Mw1ToRH8HPsL0igluKuQ8vX/6lcve97Z4K+6D1 IFFooTh7OvCjb/R5o0w2ScNJsuKBBeHafadd2I7zg1Z5ih7QD8PHQCiKhKByOF+4 nG/gaSrGiqsmOkSfKSUbfJrmLFX7aOf7oF6rmvZeZEuvRLg3qVs= =V36y -----END PGP SIGNATURE----- --nextPart2149079.x0N0T6uNKo--