Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Apr 2003 12:37:16 -0600
From:      Warner Losh <imp@harmony.village.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/dev/pccard pccard.c pccardvar.h 
Message-ID:  <200304101837.h3AIbGA7021295@harmony.village.org>
In-Reply-To: Your message of "Thu, 10 Apr 2003 12:42:02 EDT." <XFMail.20030410124202.jhb@FreeBSD.org> 
References:  <XFMail.20030410124202.jhb@FreeBSD.org>  

next in thread | previous in thread | raw e-mail | index | archive | help
In message <XFMail.20030410124202.jhb@FreeBSD.org> John Baldwin writes:
: At this point it doesn't matter since you only check one field now, but
: there was definitely a logic bug in both 1.76 and 1.78.  If you want to
: terminate a loop when both a and b are zero, you can do either:
: 
:         for (...; a != 0 || b != 0; ...)
: 
: or:
: 
:         for (...; !(a == 0 && b == 0); ...)
: 
: However, both 1.76 and 1.78 did:
: 
:         for (...; a != 0 && b != 0; ...)
: 
: Which will terminate the first time either a or b is zero, not when
: both are zero.  The fact that my wavelan card didn't probe until
: 1.77 should help to prove that.

Actually, this is the classic problem of the contrapositive:

(!(a == 0 && b == 0))) ==  (a != 0 || b != 0)

So there was a logic bug.

Warner



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304101837.h3AIbGA7021295>