Skip to contentSkip to conversation

&&//|| typo ?

DISCUSSION Jörg-Volker Peetz 4 participants 4 messages Feb 16, 2009 – Mar 5, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

inspired by the mail http://lkml.org/lkml/2009/2/15/159
I did

grep -Ern '\!=.*\|\|.*\!=' linux-2.6.28.5

and found the following tests which are always true if the tested variable is not NaN:

linux-2.6.28.5/sound/pci/au88x0/au88x0_core.c:2792: if ((bits != 8) || (bits != 16))

linux-2.6.28.5/sound/oss/ad1848.c:283: if ( (devc->model != MD_1845) ||
(devc->model != MD_1845_SSCAPE))
linux-2.6.28.5/sound/oss/ad1848.c:2110: if (devc->model != MD_1845 ||
devc->model != MD_1845_SSCAPE)

linux-2.6.28.5/arch/x86/kvm/vmx.c:1794:	if ((ss.type != 3) || (ss.type != 7))
linux-2.6.28.5/arch/x86/kvm/vmx.c:1837:	if ((tr.type != 3) || (tr.type != 11))

/* TODO: Check if guest is in IA32e mode */

linux-2.6.28.5/net/sunrpc/auth_unix.c:122: if (cred->uc_uid != acred->uid ||
cred->uc_gid != acred->gid)

linux-2.6.28.5/net/sunrpc/svcauth_unix.c:747: if (svc_getu32(argv) !=
htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
linux-2.6.28.5/net/sunrpc/svcauth_unix.c:833: if (svc_getu32(argv) !=
htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {

linux-2.6.28.5/net/sunrpc/auth_gss/gss_krb5_seqnum.c:78: if ((plain[4] !=
plain[5]) || (plain[4] != plain[6])
linux-2.6.28.5/net/sunrpc/auth_gss/gss_krb5_seqnum.c:79: || (plain[4] !=
plain[7]))

linux-2.6.28.5/drivers/block/paride/pf.c:569: if ((buf[k + offs] != 0x20) ||
(buf[k + offs] != l))

already known:

linux-2.6.28.5/drivers/block/paride/pg.c:425: if (c != ' ' || c != l)

linux-2.6.28.5/drivers/block/paride/pt.c:506: if ((buf[k + offs] != 0x20) ||
(buf[k + offs] != l))

linux-2.6.28.5/drivers/misc/sgi-gru/grukservices.c:612: if (word0 != word1 ||
word0 != MAGIC) {

linux-2.6.28.5/drivers/scsi/gvp11.c:283: if (qq != q || qq != 0xff) /* should be
read only, all 1's */

linux-2.6.28.5/drivers/scsi/FlashPoint.c:6045: if(bit_cnt != 0 || bit_cnt != 8)

Signature · 2 lines
Regards,
Jörg-Volker.
#1 lore raw

At Mon, 16 Feb 2009 22:35:54 +0100,

Quoted 11 lines · Jörg-Volker Peetz

Hi,

inspired by the mail http://lkml.org/lkml/2009/2/15/159
I did

grep -Ern '\!=.*\|\|.*\!=' linux-2.6.28.5

and found the following tests which are always true if the tested variable is not NaN:

Quoted 6 lines

linux-2.6.28.5/sound/pci/au88x0/au88x0_core.c:2792: if ((bits != 8) || (bits != 16))

linux-2.6.28.5/sound/oss/ad1848.c:283: if ( (devc->model != MD_1845) ||
(devc->model != MD_1845_SSCAPE))
linux-2.6.28.5/sound/oss/ad1848.c:2110: if (devc->model != MD_1845 ||
devc->model != MD_1845_SSCAPE)

I fixed above three on sound git tree now.

Thanks!

Takashi

#2 lore raw
In reply to Jörg-Volker Peetz

2009/2/16 Jörg-Volker Peetz <[email protected]>:

Quoted 5 lines

Hi,

inspired by the mail http://lkml.org/lkml/2009/2/15/159
I did

Quoted 8 lines

grep -Ern '\!=.*\|\|.*\!=' linux-2.6.28.5

and found the following tests which are always true if the tested variable is not NaN:

linux-2.6.28.5/arch/x86/kvm/vmx.c:1794: if ((ss.type != 3) || (ss.type != 7))
linux-2.6.28.5/arch/x86/kvm/vmx.c:1837: if ((tr.type != 3) || (tr.type != 11))

/* TODO: Check if guest is in IA32e mode */

Ok, I sent a patch

Quoted 8 lines

linux-2.6.28.5/net/sunrpc/auth_unix.c:122: if (cred->uc_uid != acred->uid ||
cred->uc_gid != acred->gid)

linux-2.6.28.5/net/sunrpc/svcauth_unix.c:747: if (svc_getu32(argv) !=
htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
linux-2.6.28.5/net/sunrpc/svcauth_unix.c:833: if (svc_getu32(argv) !=
htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {

Quoted 4 lines

linux-2.6.28.5/net/sunrpc/auth_gss/gss_krb5_seqnum.c:78: if ((plain[4] !=
plain[5]) || (plain[4] != plain[6])
linux-2.6.28.5/net/sunrpc/auth_gss/gss_krb5_seqnum.c:79: || (plain[4] !=
plain[7]))

I don't think this is a bug, this tests whether all are the same.

Quoted 2 lines

linux-2.6.28.5/drivers/block/paride/pf.c:569: if ((buf[k + offs] != 0x20) ||
(buf[k + offs] != l))

I am not sure this is a bug: l can become 0x20.

Quoted 1 line

linux-2.6.28.5/drivers/block/paride/pg.c:425: if (c != ' ' || c != l)

also c can become ' '

Quoted 2 lines

linux-2.6.28.5/drivers/block/paride/pt.c:506: if ((buf[k + offs] != 0x20) ||
(buf[k + offs] != l))

again

Quoted 2 lines

linux-2.6.28.5/drivers/misc/sgi-gru/grukservices.c:612: if (word0 != word1 || word0 != MAGIC) {

Not sure either.

Quoted 3 lines

linux-2.6.28.5/drivers/scsi/gvp11.c:283: if (qq != q || qq != 0xff) /* should be
read only, all 1's */

again

Quoted 1 line

linux-2.6.28.5/drivers/scsi/FlashPoint.c:6045: if(bit_cnt != 0 || bit_cnt != 8)

I also spotted this but it's in comment and a pretty old driver, so I didn't bother.

#3 lore raw
In reply to Jörg-Volker Peetz
Quoted 17 lines · Jörg-Volker Peetz

Hi,

inspired by the mail http://lkml.org/lkml/2009/2/15/159
I did

grep -Ern '\!=.*\|\|.*\!=' linux-2.6.28.5

and found the following tests which are always true if the tested variable is not NaN:

linux-2.6.28.5/sound/pci/au88x0/au88x0_core.c:2792: if ((bits != 8) || (bits != 16))

linux-2.6.28.5/sound/oss/ad1848.c:283: if ( (devc->model != MD_1845) ||
(devc->model != MD_1845_SSCAPE))
linux-2.6.28.5/sound/oss/ad1848.c:2110: if (devc->model != MD_1845 ||
devc->model != MD_1845_SSCAPE)

Quoted 6 lines
linux-2.6.28.5/arch/x86/kvm/vmx.c:1794:	if ((ss.type != 3) || (ss.type != 7))
linux-2.6.28.5/arch/x86/kvm/vmx.c:1837:	if ((tr.type != 3) || (tr.type != 11))

/* TODO: Check if guest is in IA32e mode */

linux-2.6.28.5/net/sunrpc/auth_unix.c:122: if (cred->uc_uid != acred->uid ||
cred->uc_gid != acred->gid)

This is OK. The left leg compares uids and the right one - gids.

Quoted 5 lines

linux-2.6.28.5/net/sunrpc/svcauth_unix.c:747: if (svc_getu32(argv) !=
htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
linux-2.6.28.5/net/sunrpc/svcauth_unix.c:833: if (svc_getu32(argv) !=
htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {

These two are fine since svc_getu32 will get the next u32 from the argv kvec every time it's being called.

Benny

Quoted 24 lines

linux-2.6.28.5/net/sunrpc/auth_gss/gss_krb5_seqnum.c:78: if ((plain[4] !=
plain[5]) || (plain[4] != plain[6])
linux-2.6.28.5/net/sunrpc/auth_gss/gss_krb5_seqnum.c:79: || (plain[4] !=
plain[7]))

linux-2.6.28.5/drivers/block/paride/pf.c:569: if ((buf[k + offs] != 0x20) ||
(buf[k + offs] != l))

already known:

linux-2.6.28.5/drivers/block/paride/pg.c:425: if (c != ' ' || c != l)

linux-2.6.28.5/drivers/block/paride/pt.c:506: if ((buf[k + offs] != 0x20) ||
(buf[k + offs] != l))

linux-2.6.28.5/drivers/misc/sgi-gru/grukservices.c:612: if (word0 != word1 ||
word0 != MAGIC) {

linux-2.6.28.5/drivers/scsi/gvp11.c:283: if (qq != q || qq != 0xff) /* should be
read only, all 1's */

linux-2.6.28.5/drivers/scsi/FlashPoint.c:6045: if(bit_cnt != 0 || bit_cnt != 8)