Re: "Using plain integer as NULL pointer" false positive for zero struct initializer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 9, 2019 at 1:29 PM Derek M Jones <derek@xxxxxxxxxxxx> wrote:
>
> Using of 0 in this context does not make the source non-strictly
> conforming.
>
> "An integer constant expression with the value 0, or such an expression
> cast to type void *, is called a null pointer constant."

Completely and utterly irrelevant.

sparse warns about a lot of "conforming" code. That's the _point_.

Sparse warns about bad things. Using an integer 0 when a pointer is
asked for is bad. The fact that it's "legacy C bad" doesn't change
anything.

Using functions without declaring them is "legacy C bad" too. Sparse
will warn about it.

Using an assignment expression in a conditional is "legacy C bad" too.
Sparse will complain about it.

All of those are "strictly conforming" features of C. That doesn't
mean they shouldn't be warned about. Because they are really really
bad ideas.

0 is not a pointer. It's that easy.

The fact that K&R C silently casts it to a special NULL pointer in a
pointer context was understandable - back in the late 1960's.  People
got over it. It's historical bad behavior. Don't do it. There are *no*
excuses for doing it.

              Linus



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux