2011-12-12 23:44:56

by Joe Perches

[permalink] [raw]
Subject: drivers/crypto/picoxcell_crypto.c: boolean and / or confusion

On Tue, 2011-12-13 at 00:06 +0100, roel wrote:
> The test not [val1] or not [val2] always evaluates to true

Hey Jamie and Roel

Looking at drivers with:

$ grep -rP --include=*.[ch] "(\b[\w\[\]\>\._\-]+)\s*\!\=\s*[\w\[\]\>\._\-]+\s*\|\|\s*\1\s*\!\=" drivers

drivers/crypto/picoxcell_crypto.c: if ((len != AES_KEYSIZE_128 || len != AES_KEYSIZE_256) &&
drivers/crypto/picoxcell_crypto.c: } else if ((len != AES_KEYSIZE_128 || len != AES_KEYSIZE_256) &&

Most likely these should be && not ||.


2011-12-12 23:55:26

by Joe Perches

[permalink] [raw]
Subject: drivers/media/video/s5p-fimc/fimc-capture.c: boolean and / or confusion

On Tue, 2011-12-13 at 00:06 +0100, roel wrote:
> The test not [val1] or not [val2] always evaluates to true

Hello

Looking at drivers with:

$ grep -rP --include=*.[ch] "(\b[\w\[\]\>\._\-]+)\s*\!\=\s*[\w\[\]\>\._\-]+\s*\|\|\s*\1\s*\!\=" drivers

drivers/media/video/s5p-fimc/fimc-capture.c: if (mf->width != tfmt->width || mf->width != tfmt->width) {
drivers/media/video/s5p-fimc/fimc-capture.c: if (mf->width != tfmt->width || mf->width != tfmt->width)

Most likely these tests should be:
if (mf->height != tfmt->height || mf->width != tfmt->width)

2011-12-13 09:50:46

by Jamie Iles

[permalink] [raw]
Subject: Re: drivers/crypto/picoxcell_crypto.c: boolean and / or confusion

Hi Joe,

On Mon, Dec 12, 2011 at 03:44:53PM -0800, Joe Perches wrote:
> On Tue, 2011-12-13 at 00:06 +0100, roel wrote:
> > The test not [val1] or not [val2] always evaluates to true
>
> Hey Jamie and Roel
>
> Looking at drivers with:
>
> $ grep -rP --include=*.[ch] "(\b[\w\[\]\>\._\-]+)\s*\!\=\s*[\w\[\]\>\._\-]+\s*\|\|\s*\1\s*\!\=" drivers
>
> drivers/crypto/picoxcell_crypto.c: if ((len != AES_KEYSIZE_128 || len != AES_KEYSIZE_256) &&
> drivers/crypto/picoxcell_crypto.c: } else if ((len != AES_KEYSIZE_128 || len != AES_KEYSIZE_256) &&
>
> Most likely these should be && not ||.

Yup, the original code was incorrect. Patch to follow. Thanks Joe!

Jamie

2011-12-13 14:26:34

by Sylwester Nawrocki

[permalink] [raw]
Subject: Re: drivers/media/video/s5p-fimc/fimc-capture.c: boolean and / or confusion

On 12/13/2011 12:55 AM, Joe Perches wrote:
> On Tue, 2011-12-13 at 00:06 +0100, roel wrote:
>> The test not [val1] or not [val2] always evaluates to true
>
> Hello
>
> Looking at drivers with:
>
> $ grep -rP --include=*.[ch] "(\b[\w\[\]\>\._\-]+)\s*\!\=\s*[\w\[\]\>\._\-]+\s*\|\|\s*\1\s*\!\=" drivers
>
> drivers/media/video/s5p-fimc/fimc-capture.c: if (mf->width != tfmt->width || mf->width != tfmt->width) {
> drivers/media/video/s5p-fimc/fimc-capture.c: if (mf->width != tfmt->width || mf->width != tfmt->width)
>
> Most likely these tests should be:
> if (mf->height != tfmt->height || mf->width != tfmt->width)

Indeed. I'll prepare a patch fixing this.

--
Thank you,
Sylwester