Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Aug 2018 09:03:02 -0700
From:      Conrad Meyer <cem@freebsd.org>
To:        Benjamin Kaduk <bjkfbsd@gmail.com>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r337535 - head/sbin/init
Message-ID:  <CAG6CVpU8jwQJiNsf6B5Gq75QHEoGaT4K-dCK6Drc59ETPH4VRw@mail.gmail.com>
In-Reply-To: <CAJ5_RoBVWZgMgoNGkTkCMB9kU5Ci1GcN-p_Ad-FMMwhO%2BQX5VA@mail.gmail.com>
References:  <201808091217.w79CH3gO096411@repo.freebsd.org> <CAJ5_RoBVWZgMgoNGkTkCMB9kU5Ci1GcN-p_Ad-FMMwhO%2BQX5VA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 9, 2018 at 5:52 AM, Benjamin Kaduk <bjkfbsd@gmail.com> wrote:
> On Thu, Aug 9, 2018 at 7:17 AM, Edward Tomasz Napierala <trasz@freebsd.or=
g>
> 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 program t=
hat
> 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 strong =
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 *, i=
s
> 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.

All the best,
Conrad



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpU8jwQJiNsf6B5Gq75QHEoGaT4K-dCK6Drc59ETPH4VRw>