From: Felix Domke <tmbinc@elitedvb.net>
To: ppc-dev <linuxppc-dev@ozlabs.org>
Subject: Re: [PATCH] Infinite loop/always true check possible with unsigned counter.
Date: Tue, 10 Jul 2007 02:41:21 +0200 [thread overview]
Message-ID: <4692D5B1.2040209@elitedvb.net> (raw)
In-Reply-To: <18066.53384.449544.952545@cargo.ozlabs.ibm.com>
Paul Mackerras wrote:
>> Fix to correct a possible infinite loop or an always true check when the
>> unsigned long counter "i" is used in
>> lmb_add_region() in the following for loop:
>> for (i = rgn->cnt-1; i >= 0; i--)
> Unfortunately this won't fix the bug. Since rgn->cnt is unsigned
> long, the comparison will be done as an unsigned comparison even if i
> is signed.
> Instead, change the loop to go from rgn->cnt down to 1, and in the
> loop body, change all instances of "i+1" to "i", and "i" to "i-1".
What's about
i = rgn->cnt;
while (i--)
...
?
(or for (i=rgn->cnt; i--; ), if you want a for-loop)
Felix
next prev parent reply other threads:[~2007-07-10 1:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-09 17:31 [PATCH] Infinite loop/always true check possible with unsigned counter Manish Ahuja
2007-07-09 19:03 ` Manish Ahuja
2007-07-10 0:19 ` Paul Mackerras
2007-07-10 0:41 ` Felix Domke [this message]
2007-07-10 9:46 ` Andreas Schwab
2007-07-10 9:49 ` Paul Mackerras
2007-07-10 9:55 ` Andreas Schwab
2007-07-10 10:08 ` Paul Mackerras
2007-07-10 18:39 ` Manish Ahuja
2007-07-10 23:19 ` Paul Mackerras
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=4692D5B1.2040209@elitedvb.net \
--to=tmbinc@elitedvb.net \
--cc=linuxppc-dev@ozlabs.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 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.