Re: drivers: Probable misuses of ||

From: Mark Brown
Date: Fri May 04 2012 - 18:13:35 EST


On Fri, May 04, 2012 at 03:09:38PM -0700, Joe Perches wrote:
> On Fri, 2012-05-04 at 23:02 +0100, Mark Brown wrote:
> > On Fri, May 04, 2012 at 02:54:37PM -0700, Joe Perches wrote:

> > > > drivers/media/rc/fintek-cir.c: if ((chip != 0x0408) || (chip != 0x0804))

> > It'd probably help if you were to supply more analysis as to what the
> > issues you think you're seeing are - in the cases quoted above
> > (especially the last one) there's no obvious bug without further
> > analysis.

> Likely the || should be &&.

> if (val != foo || test != bar)

> is always true when foo != bar

Right, but you need to look at the code and explain why this is a
problem. For example, the case I've left quoted above reads to me like
the intention is "If the chip isn't one I know doesn't like this then
let's do it" which is a perfectly sensible thing to write.

Attachment: signature.asc
Description: Digital signature