From: David Miller <davem@davemloft.net>
To: akpm@linux-foundation.org
Cc: roel.kluin@gmail.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] qlogicpti: Add missing parentheses
Date: Fri, 20 Feb 2009 00:51:28 -0800 (PST) [thread overview]
Message-ID: <20090220.005128.240701957.davem@davemloft.net> (raw)
In-Reply-To: <20090219130142.4442c1a5.akpm@linux-foundation.org>
From: Andrew Morton <akpm@linux-foundation.org>
Date: Thu, 19 Feb 2009 13:01:42 -0800
> On Wed, 18 Feb 2009 14:39:16 -0800 (PST)
> David Miller <davem@davemloft.net> wrote:
>
> > From: Roel Kluin <roel.kluin@gmail.com>
> > Date: Wed, 18 Feb 2009 13:48:11 +0100
> >
> > > Add missing parentheses
> > >
> > > Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> >
> > So what bug does this cause?
> >
> > > #define QLOGICPTI_REQ_QUEUE_LEN 255 /* must be power of two - 1 */
> > > -#define QLOGICPTI_MAX_SG(ql) (4 + ((ql) > 0) ? 7*((ql) - 1) : 0)
> > > +#define QLOGICPTI_MAX_SG(ql) (4 + (((ql) > 0) ? 7*((ql) - 1) : 0))
> >
> > The "ql > 0" bids to the "?" operator, so this expression
> > does the right thing as-is as far as I can tell.
> >
> > Do you think that "4 + ((ql > 0)" binds to "?", I don't think
> > it does.
>
> The code is crap, and buggy if passed an expression with side-effects.
Thank got it never is called that way :-)
> Now, 4 plus a boolean can only ever evaluate to 4 or 5, so this
> function can never return zero. So yeah, I assume that this was meant:
>
> static inline int qlogicpti_max_sg(int ql)
> {
> if (ql > 0)
> return 7 * (ql - 1) + 4;
> else
> return 4;
> }
>
I think this doesn't even match the intention, and I wrote
the code so...
We want to return 0 if the queue has no free entries.
But if it does have free slots, we want "4 + xxx"
These problems probably explain the mysterious workaround
in update_can_queue().
next prev parent reply other threads:[~2009-02-20 8:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-18 12:48 [PATCH] qlogicpti: Add missing parentheses Roel Kluin
2009-02-18 22:39 ` David Miller
2009-02-19 21:01 ` Andrew Morton
2009-02-20 8:51 ` David Miller [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-11-03 23:38 [PATCH] qlogicpti: add " Roel Kluin
2009-11-03 23:51 ` James Bottomley
2009-11-04 0:19 ` David Miller
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=20090220.005128.240701957.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=akpm@linux-foundation.org \
--cc=linux-scsi@vger.kernel.org \
--cc=roel.kluin@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox