From owner-svn-src-head@freebsd.org Thu Aug 9 21:46:16 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DBFDE10747BE for ; Thu, 9 Aug 2018 21:46:15 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x242.google.com (mail-io0-x242.google.com [IPv6:2607:f8b0:4001:c06::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6E4E189B36 for ; Thu, 9 Aug 2018 21:46:15 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x242.google.com with SMTP id y10-v6so6019530ioa.10 for ; Thu, 09 Aug 2018 14:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=OhxqssZh8iDIvyrUE7Fx7pvHFBrbafoYnSoXYPYoUEA=; b=WTLbiMqANN/9Au6OtWT1MSa6GabMer/AHQ6+RfeBfKAF4VYadqEwMhU9r0aL/wx5YA TRHy4+R7EPqt0jGNTjAVJGOCIT6waYxaDIdD7Quc02fHHHDb3ykKtHS9GLCVwr9ukHY5 kfWv9kc9sXwE4qvV3b6RT5anrkvWSv/PWt8q4CB5AR1eLajQAW9QBxKCBeRM8gOX0qrm X2ipuxVih8awfdDgosrrX4E9z8UhHm9nMnKJuTx0qihntg2ghVY+8R+VCW5sZllIAvad fA9OAVq7MJOhNtPJNvr352GLKliJ7wOTVv0ADf62FayBCQwFqStG7Bq8axDNct1eVqW4 Mwgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=OhxqssZh8iDIvyrUE7Fx7pvHFBrbafoYnSoXYPYoUEA=; b=S5eKo3Kopt3jKufKeF9IscGse7xxj8oWtXX6UUjrau4IX8xGnSrRML32UzNc519XiN +Evf07DLUjvR8WsFklVvfYfvstvc6GtEldf29dLlgvG/ez0i3zAtXGR6FDMky76URJqT dakn0S2Ep+4GfqiAsp5d1iKozy3/wpFt0CQ07KJbShGnilDMfngH9wcWD1Nvb1S5X4en DuB3wuVsrgkBNKR003bL96JFSb2HqyI10jldixxgHy5BmfqsKb7DP7kluHfmKQ4bgoRO 1Low83QqlpCpjJ8dlzf6qpIOvUcdvOUnK2KusU20pEpw/zsj+3DnsDIJ14fFAPBYS0ir eE3A== X-Gm-Message-State: AOUpUlEUNpcV30vyZZzjZbkAjwBvjV4Vyq05Entb0O5Iy3ERXAD8S+Nc Bytaq5aamH130NgyipKiJipy177A37cboggfoPpMQjiIjcU= X-Google-Smtp-Source: AA+uWPzgf9TgJmkH3r3finTsczXd74gBCLMPui1DDPOXI57eoggE2W6Y6KimtodhEYYOy53Fg8182c7zhkAi0zQPTVE= X-Received: by 2002:a6b:f70f:: with SMTP id k15-v6mr3329482iog.37.1533851174688; Thu, 09 Aug 2018 14:46:14 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 2002:a4f:381a:0:0:0:0:0 with HTTP; Thu, 9 Aug 2018 14:46:14 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: References: <201808091217.w79CH3gO096411@repo.freebsd.org> From: Warner Losh Date: Thu, 9 Aug 2018 15:46:14 -0600 X-Google-Sender-Auth: SPHOGHWTZSb114tZOqaFX6LVU44 Message-ID: Subject: Re: svn commit: r337535 - head/sbin/init To: Benjamin Kaduk Cc: "cem@FreeBSD.org" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 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, 09 Aug 2018 21:46:16 -0000 On Thu, Aug 9, 2018 at 3:41 PM, Benjamin Kaduk wrote: > On Thu, Aug 9, 2018 at 11:03 AM, Conrad Meyer wrote: > >> On Thu, Aug 9, 2018 at 5:52 AM, Benjamin Kaduk wrote= : >> > On Thu, Aug 9, 2018 at 7:17 AM, Edward Tomasz Napierala < >> trasz@freebsd.org> >> > wrote: >> >> Use NULLs instead of casted zeroes, for consistency. >> > >> > It's probably helpful to note explicitly that these are not in >> arguments to >> > varargs functions, >> >> I don't think it's helpful. >> >> > in which case the explicit cast is needed in order to produce a progra= m >> that >> > will have >> > correct behavior on all compliant compilers/systems. >> >> Here "compliant" means "minimally compliant to the C standard." Use >> of NULL in varargs is functionally correct on all FreeBSD systems. >> >> > (We do define NULL to >> > be a zero-with-cast, >> > but programs >> >> (Ones that care about portability to weird systems.) I don't think >> BSD's 500 line init =E2=80=94 hyper local to FreeBSD =E2=80=94 is a stro= ng candidate >> for portability. >> >> > should not assume that NULL will be of pointer type -- "An >> > integer constant >> > expression with the value 0, or such an expression cast to type void *= , >> is >> > called a null pointer constant".) >> >> Right. The problem only arises when both conditions are met: >> >> 1. The system's varargs representation is smaller than the pointer >> representation, and >> 2. The runtime headers do not defined NULL as a pointer-typed value. >> (3. The function being invoked is actually varargs?) >> >> Neither is true on FreeBSD and v7-style init is not a useful place to >> call for portability. >> > > I don't really feel a need to continue the discussion that was already > started in response > to r336835 (in addition to the current thread), so I'll limit myself to > asking whether we > want to be writing standard C or a FreeBSD-specific dialect of C. My > understanding was > that we had some experience with the latter (e.g., heavy patching of the > compiler) and > it ended up with us in a bad place, which would tend to support writing > standard C or > as close to it as we can. (Yes, I know that we have non-standard printf > specifiers and the like.) > The conventional wisdom is code as close to the standard(s) as we can, but not to the point of insanity. If there's a good reason to deviate, that's OK so long as it's intentional and the deviation makes sense. For example, we calloc a bunch of stuff, but that's not a strictly standards conforming way to initialize pointers to be NULL. While c->ptr =3D 0 is always standar= ds conforming, memset(&c->ptr, 0, sizeof(c->ptr)); isn't. Yet we do this everywhere because we know we'll never run on an architecture where the bitwise representation of a NULL pointer isn't all 0's. There's dozens of other similar examples. Warner