From owner-svn-src-head@freebsd.org Thu Mar 16 04:55:06 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3FCAD0D7A5; Thu, 16 Mar 2017 04:55:06 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pf0-x231.google.com (mail-pf0-x231.google.com [IPv6:2607:f8b0:400e:c00::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AE3C51EC2; Thu, 16 Mar 2017 04:55:06 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pf0-x231.google.com with SMTP id v190so18596082pfb.1; Wed, 15 Mar 2017 21:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:mime-version:from:in-reply-to:date:cc:message-id:references :to; bh=veJhJ4aHWBusM41T0DvdEwDGcZjikpwIj6YIR9xd8XY=; b=h3t0fOoR+sjgOFmQHdsgW+Q7QgaQd1a8xXhNCcXZQQGeNOBtGHbz29tJPn5BhX+Sv6 KuHjADV7RQ9XAmLtQNHmHiqR2fr6RglB8ys+rjCObAg+dwB6Hp8OrW8CWRI2Sj588Ys/ d6GOZzc6BKBVqXMLUB1F5ZmRHLefa1t6XWwreiOF6gf4oM7l8SsiEvMH2aCGwAM25qao XT+/DtmNHHqtfy7Tp7xxkk28rj2ymMTlAd+xEBmdcIA1L8zIBkGnY0Wj3ZNHzu/Nx8HR BQ08a6UL1FH8WYSS6vUQlX4pZG3nSr0dn/B7XxCMf+xbEjrwmUVBikEHNWZtNai/5vzF vCvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :message-id:references:to; bh=veJhJ4aHWBusM41T0DvdEwDGcZjikpwIj6YIR9xd8XY=; b=j7onDfeIQ1cl6bfcTJFcQr0OEXnl4GX/ow+yDHeby/8rhx+t8lPY2xrMA1/HU4jw6v osVTzyv7G6efZ7oIR4Ei/3IVXndJIi14s+nF8Ax3TFVZWV9dLHoZ+CBbskEbHiX6FMCK zRbdrB+iVvlcH71SRDyhS0Lp1ZpJHYyAmVY95PQmMqNwWwUVjgYXMu6tN9zJAMEHiptz EKE+Y9GR6HUTicvhERfaE3/4o8es8QOnmobWz3hyYl3TMyOrpap4gqDGUzbN/z6Cc54y 47fsDyj1jBPmIQjVRXDA2hGq8CjVrOl7hEpGYSxexkdLggd24c2MjBhr4SuEqaKhSMrD +Nfg== X-Gm-Message-State: AFeK/H2aAd8uR1fxvk8dzO1lmprhJE7pl7G44KZ02YRwevAbH6dijvUs93s3pmEAciadKg== X-Received: by 10.98.75.28 with SMTP id y28mr8143253pfa.157.1489640106269; Wed, 15 Mar 2017 21:55:06 -0700 (PDT) Received: from pinklady.local (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id v4sm7177883pfb.36.2017.03.15.21.55.05 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Mar 2017 21:55:05 -0700 (PDT) Subject: Re: svn commit: r315360 - head/lib/libkvm Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_225A83DC-6257-47B4-9AED-1F841C82B4B4"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail From: "Ngie Cooper (yaneurabeya)" In-Reply-To: Date: Wed, 15 Mar 2017 21:55:04 -0700 Cc: Ngie Cooper , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Message-Id: <09597F88-6F43-4A9C-B89B-6B634928C7FC@gmail.com> References: <201703160231.v2G2VgxK082641@repo.freebsd.org> <58A53702-FFF6-45E7-ACCD-9B776530064E@gmail.com> To: Warner Losh X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Mar 2017 04:55:07 -0000 --Apple-Mail=_225A83DC-6257-47B4-9AED-1F841C82B4B4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Mar 15, 2017, at 21:53, Warner Losh wrote: >=20 > On Wed, Mar 15, 2017 at 10:44 PM, Ngie Cooper (yaneurabeya) > wrote: >>=20 >>> On Mar 15, 2017, at 21:32, Warner Losh wrote: >>>=20 >>> On Wed, Mar 15, 2017 at 8:31 PM, Ngie Cooper = wrote: >>>> Author: ngie >>>> Date: Thu Mar 16 02:31:42 2017 >>>> New Revision: 315360 >>>> URL: https://svnweb.freebsd.org/changeset/base/315360 >>>>=20 >>>> Log: >>>> Return NULL instead of 0 on failure in _kvm_open, = kvm_open{,2,files} >>>>=20 >>>> This is being done for the following reasons: >>>> - kvm_open(3), etc says they will return NULL. >>>> - NULL by definition is (void*)0 per POSIX, but can be redefined, >>>> depending on the compiler, etc. >>>=20 >>> No, it can't. The C language requires all integral expressions that >>> evaluate to zero to convert to the NULL pointer. This is independent >>> of the internal representation of the NULL pointer. >>>=20 >>> So this change is an NOP for all compilers. It's a good STYLE = change. >>=20 >> Someone made an argument a few weeks ago about NULL being definable = as a non-zero value on some esoteric architectures or OSes. >=20 > No. That's confused. NULL must always be 0. A conversion between 0 and > a pointer always must give a null-pointer. Always. You can't defined > NULL to -1 ever. Even if that happens to be the binary representation > of a NULL pointer, it must be 0. >=20 >> I agree though, this is largely stylistic/pedantic for a good cause. = If someone set NULL to something non-zero in value, they would be = looking for pain :). >=20 > You can never set NULL to non-zero integral value (possibly with a > cast). You can have the internal representation have non-zero bits, > but the compiler must hide that. >=20 > This does mean that M_ZERO and calloc() won't set pointers to null > pointers on such architectures, but this 0 that you replaced is > completely safe. >=20 > I can provide references to the appropriate standards. I made the same > point when someone made that (incorrect) argument. No worries =E2=80=94 I=E2=80=99ll take your word :). Thanks :)! -Ngie --Apple-Mail=_225A83DC-6257-47B4-9AED-1F841C82B4B4 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJYyhqoAAoJEPWDqSZpMIYVfroP/A7TCDC5ls3ntSS+3uMzN04S Q+4F1clYkgBCz0/T3WHCRixz85qyLUtCK1OS+nTp/HKu8M4N7ffS4Dw49lj+wWt1 Hm+HcGSWmupgwDSSZKRvtTZDP5zOse3tYbC+KR4PmNFtC5kNk7t2dA35RFQU4KdZ dbNnfpPC1I4+YoZ5pwjwTKKnFy9Slm1zaeNPZWNqE+OsUX2DBZLRbrePXbJPx4mb QwmDKcjEcUduRURwtYzlhzMmd0nL6OcGInQmZecLbOQ3AAiLXr2HcxGctZoJbPLe mzrhJIE55m/foQisKruxNVD/UH3k9SuxfvNSQeJwiD6rISiQX+pC6Jyl+ukcEDNA 3qa+FxUE4LULS7OgXYBh+wwNtM1+VBC9LkXBC7fMlcO55iy+dOgREqg0HuumHfTZ RjAQG2CD61oJjwiR1YnrQ0/s5gstnbacCHyAjmFvsxSvtHtl11b9585s9eXGFu33 lOcSRttPLDyzamaT1AyogDxJd1pjr7q3e/fsbtDUfEIrsmVR36sh7hMNIrSIg9qt wXcSIO+/gaA1MePOPggidOw4suwVKXLh+OrsCSo0Z2RkxginNLeLx1e4Oxtu4V3Y 21DlTgSDzpBZ4EwoltYz0Hkx47h8m23YgrAyujSp7DStPTehzTzTpnOrynZHsqoX 7Qw1QlXgUudPcyPccP50 =yg0I -----END PGP SIGNATURE----- --Apple-Mail=_225A83DC-6257-47B4-9AED-1F841C82B4B4--