Re: [PATCH] Intel Manageability Engine Interface driver

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

 



On Tue, 23 Oct 2007 11:04:29 -0400 [email protected] (Lennart Sorensen) wrote:

> On Mon, Oct 22, 2007 at 11:40:01AM -0700, Andrew Morton wrote:
> > - Here:
> > 
> > +		if (0 == memcmp(&heci_wd_guid,
> > 
> >   we boringly prefer "if (foo == 0)" rather than "if (0 == foo)".  (lots
> >   of places).
> 
> But 0 == blah is safer.  If you accidentally do 0 = blah the compiler
> will tell you.

If you do 'if (blah = 0)' then compiler will tell you too.  To all intents
and purposes this invalidates the reasons for doing `if (0 == blah)'.

>  Just because people have always done it the other way
> around doesn't make it the right way to do it.  I have noticed many
> people have started to realize this in the last few years.
> 
> It is also much clearer that you are comparing against a constant and
> not doing an assignment when the constant comes before the variable.
> 
> I think to encourage people doing it the less safe way is just silly.

It isn't less safe.

> Some places in the kernel that already uses the constant first are:

It impacts readability.  All the aio code was implemented that way for a
few years and it drove everyone so batty that we undid it.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux