From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mmci: calculate remaining bytes at error correctly
Date: Mon, 31 Jan 2011 12:25:20 +0000 [thread overview]
Message-ID: <20110131122520.GA11694@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <4D46A44C.3030609@ru.mvista.com>
On Mon, Jan 31, 2011 at 03:00:12PM +0300, Sergei Shtylyov wrote:
>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>> index b6fd6dc..175a623 100644
>> --- a/drivers/mmc/host/mmci.c
>> +++ b/drivers/mmc/host/mmci.c
>> @@ -319,7 +319,7 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
>> if (status& MCI_DATABLOCKEND)
>> dev_err(mmc_dev(host->mmc), "stray MCI_DATABLOCKEND interrupt\n");
>>
>> - if (status & MCI_DATAEND) {
>> + if (status & MCI_DATAEND
>
> Shouldn't 'status & MCI_DATAEND' be enclosed in parens?
No. Only people who don't want to know operator precedence enclose
everything in parens. Here's the grammar:
logical-OR-expression:
logical-AND-expression
logical-OR-expression || logical-AND-expression
logical-AND-expression:
inclusive-OR-expression
logical-AND-expression && inclusive-OR-expression
inclusive-OR-expression:
exclusive-OR-expression
inclusive-OR-expression | exclusive-OR-expression
exclusive-OR-expression:
AND-expression
exclusive-OR-expression ^ AND-expression
AND-expression:
equality-expression
AND-expression & equality-expression
So, a & b || c gives:
logical-OR-expression := a & b || c
+-logical-OR-expression := a & b
| `-logical-AND-expression := a & b
| `-inclusive-OR-expression := a & b
| `-exclusive-OR-expression := a & b
| `-AND-expression := a & b
| +-AND-expression := a
| | `-equality-expression := a
| `-equality-expression := b
+-logical-AND-expression := c
`-inclusive-OR-expression := c
`-exclusive-OR-expression := c
`-AND-expression := c
`-equality-expression := c
So, a & b || c is evaluated as ((a) & (b)) || (c), which is exactly what
we want it to be.
If it were && and ||, then there is reason to use parens as people often
get the relative precedence of && and || mixed up.
If you insist on putting parens around a & b there, then for the sake of
consistency, you should be putting parens around every sub-expression
involving || and && - as if you think that a & b || c could be incorrectly
evaluated, a < b || c falls into exactly the same category, as does
a < b || c < d.
next prev parent reply other threads:[~2011-01-31 12:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-27 14:14 [PATCH] mmci: calculate remaining bytes at error correctly Linus Walleij
2011-01-27 16:36 ` Russell King - ARM Linux
2011-01-27 16:43 ` Linus Walleij
2011-01-27 16:47 ` Russell King - ARM Linux
2011-01-30 21:28 ` Russell King - ARM Linux
2011-01-30 21:29 ` Russell King - ARM Linux
2011-01-31 10:24 ` Linus Walleij
2011-02-03 0:30 ` Russell King - ARM Linux
2011-02-03 14:00 ` Russell King - ARM Linux
2011-02-04 13:24 ` Linus Walleij
2011-01-31 10:17 ` Linus Walleij
2011-01-31 10:27 ` Russell King - ARM Linux
2011-01-31 10:31 ` Linus Walleij
2011-01-31 10:40 ` Russell King - ARM Linux
2011-01-31 13:53 ` Linus Walleij
2011-01-31 14:00 ` Russell King - ARM Linux
2011-01-31 12:00 ` Sergei Shtylyov
2011-01-31 12:25 ` Russell King - ARM Linux [this message]
2011-01-31 12:31 ` Sergei Shtylyov
2011-02-01 23:40 ` Russell King - ARM Linux
-- strict thread matches above, loose matches on Subject: below --
2011-01-27 14:02 Linus Walleij
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=20110131122520.GA11694@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).