Re: [PATCH 2/2] mmc: fix integer assignments to pointer

Sam Ravnborg
2011-08-23T20:22:27Z

On Tue, Aug 23, 2011 at 02:28:42PM -0400, Chris Ball wrote:
> Hi,
>
> On Tue, Aug 23 2011, Josh Triplett wrote:
> > {} produces the same effect, as far as I know.
>
> Yeah. I prefer {0}, because {} is a gcc-ism (the ANSI grammar demands
> initializer-lists be non-empty) and is less readable for people who
> haven't seen the idiom before and are wondering what's going on.
>
> I'm still a little confused -- the {0} or memset(0, struct ..);
> formations are used often in the kernel, even with pointers involved.
> Is the warning (Wnon_pointer_null) run against the kernel by default,
> or did Venkatraman add it manually? If default, is it catching bugs?

It is default enabled - and trigger a lot of warnings.
But the kernel idiom is to use NULL for a null pointer - and not to use 0.

Which is why the warning was introduced.

Sam