Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Feb 2017 19:35:20 -0500
From:      Pedro Giffuni <pfg@FreeBSD.org>
To:        cem@freebsd.org
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r313982 - in head/sys/dev: agp al_eth an arcmsr bce beri/virtio bhnd/cores/usb buslogic ce cm cp ctau cx de ed fatm fe firewire hptiop hptmv iicbus isp le md ncr netmap ofw patm pccard ...
Message-ID:  <1d213a3f-ea84-256c-e08b-e5e100ef83ba@FreeBSD.org>
In-Reply-To: <CAG6CVpUSxaQkq%2B7siKQPOW4FuaVpoY5uMcSb6jMvrROqSiqzGA@mail.gmail.com>
References:  <201702200343.v1K3hCk3060716@repo.freebsd.org> <CAG6CVpUSxaQkq%2B7siKQPOW4FuaVpoY5uMcSb6jMvrROqSiqzGA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello;

Just been discussing the same issue in private as well ...

On 2/20/2017 6:40 PM, Conrad Meyer wrote:
> On Sun, Feb 19, 2017 at 7:43 PM, Pedro F. Giffuni <pfg@freebsd.org> wrote:
>> Author: pfg
>> Date: Mon Feb 20 03:43:12 2017
>> New Revision: 313982
>> URL: https://svnweb.freebsd.org/changeset/base/313982
>>
>> Log:
>>    sys/dev: Replace zero with NULL for pointers.
>>
>>    Makes things easier to read, plus architectures may set NULL to something
>>    different than zero.
> Hi Pedro,
>
> I like the change for style reasons.
>
> The comment about architectures with non-zero NULL is a little
> misleading, though.  This change has no impact on non-zero bit pattern
> NULL architectures.  The zero pointer value in C is NULL and NULL is
> the zero pointer value in C.  It may have a bit pattern other than
> zero (i.e., printf("%p", NULL) may be non-zero and memset(&p, 0,
> sizeof(p)) is bogus in portable code) but assigning the logical zero
> value is always legitimate.

Grrr ... yes the comment is/was misleading: I would undo it if I didn't 
have to revert the commit with it. Other project have SVN configured to 
permit changing the log message BTW.

> After all, NULL is just a casted zero value:
>
> #define NULL    ((void *)0)

The compiler is pretty good at detecting when the value is a pointer though.
The change has few (if any) effect on real life but coming  from the 
days where most computer languages were somewhat stronger typed I really 
like to be able to distinguish between a zero valued pointer and a zero 
valued int.


> Maybe this is moot.  I don't believe any architecture FreeBSD actually
> supports has non-zero bitpattern NULL, but something weird like CHERI
> might.

Such "weird" platforms are starting to appear:

https://reviews.llvm.org/D26196
Regards,

Pedro.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1d213a3f-ea84-256c-e08b-e5e100ef83ba>