All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: kwolf@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
	stefanha@redhat.com, qemu-devel@nongnu.org,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/5] ide: Prohibit RESET on IDE drives
Date: Tue, 19 Jan 2016 18:26:29 +0100	[thread overview]
Message-ID: <569E71C5.2060601@redhat.com> (raw)
In-Reply-To: <569E6C99.6020308@redhat.com>

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

  reply	other threads:[~2016-01-19 17:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19  4:51 [Qemu-devel] [PATCH 0/5] ide: fix atapi software reset John Snow
2016-01-19  4:51 ` [Qemu-devel] [PATCH 1/5] ide: Prohibit RESET on IDE drives John Snow
2016-01-19 11:48   ` Paolo Bonzini
2016-01-19 17:04     ` John Snow
2016-01-19 17:26       ` Laszlo Ersek [this message]
2016-01-19  4:51 ` [Qemu-devel] [PATCH 2/5] ide: code motion John Snow
2016-01-19  4:51 ` [Qemu-devel] [PATCH 3/5] ide: move buffered DMA cancel to core John Snow
2016-01-19 11:50   ` Paolo Bonzini
2016-01-19  4:51 ` [Qemu-devel] [PATCH 4/5] ide: Add silent DRQ cancellation John Snow
2016-01-19  4:51 ` [Qemu-devel] [PATCH 5/5] ide: fix device_reset to not ignore pending AIO John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=569E71C5.2060601@redhat.com \
    --to=lersek@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.