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 ...

Conrad Meyer cem at freebsd.org
Tue Feb 21 00:03:21 UTC 2017


On Sun, Feb 19, 2017 at 7:43 PM, Pedro F. Giffuni <pfg at 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.

After all, NULL is just a casted zero value:

#define NULL    ((void *)0)

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

Best,
Conrad


More information about the svn-src-head mailing list