From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLa3F-0005E3-02 for qemu-devel@nongnu.org; Tue, 19 Jan 2016 12:26:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLa3E-0006DF-6q for qemu-devel@nongnu.org; Tue, 19 Jan 2016 12:26:40 -0500 References: <1453179117-17909-1-git-send-email-jsnow@redhat.com> <1453179117-17909-2-git-send-email-jsnow@redhat.com> <569E2283.9070904@redhat.com> <569E6C99.6020308@redhat.com> From: Laszlo Ersek Message-ID: <569E71C5.2060601@redhat.com> Date: Tue, 19 Jan 2016 18:26:29 +0100 MIME-Version: 1.0 In-Reply-To: <569E6C99.6020308@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/5] ide: Prohibit RESET on IDE drives List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: kwolf@redhat.com, Paolo Bonzini , stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org On 01/19/16 18:04, John Snow wrote: > > > On 01/19/2016 06:48 AM, Paolo Bonzini wrote: >> >> >> On 19/01/2016 05:51, John Snow wrote: >>> + /* Only RESET is allowed to an ATAPI device while BSY and/or DRQ are set. */ >>> + if (s->status & (BUSY_STAT|DRQ_STAT)) { >>> + if (!(val == WIN_DEVICE_RESET) && (s->drive_kind == IDE_CD)) { >> >> I was going to complain about Pascal-ish parentheses, but actually I >> think there is a bug here; the expression just looks weird. >> >> Did you mean >> >> if (!(val == WIN_DEVICE_RESET && s->drive_kind == IDE_CD)) >> >> or equivalently applying de Morgan's law: >> >> if (s->drive_kind != IDE_CD || val != WIN_DEVICE_RESET) >> >> ? >> >> Paolo >> >>> + return; >> > > ugh, yes, I typo'd. Thank you. > > If you're still up, which do you find more readable? > The (!(A && B)) form or the (!A || !B) form? You didn't ask me, but that's no problem for me. :) The logical negation operator "!" has much-much stronger binding than the logical "and" and logical "or" ones. If you use the first form, !(A && B) it works, but spacetime will curl every time someone sees those parentheses overriding the nice n' tight binding of "!". So, for me, only the second form *exists* -- for me, the operand of the logical negation operator must always be as "indivisible" an expression as possible :) So, (!A || !B) without a doubt. Thanks Laszlo