On Tuesday 09 March 2010, Antonio Borneo wrote: > On Wed, Mar 10, 2010 at 8:16 AM, David Brownell <[email protected]> wrote: > >> @@ -108,7 +108,7 @@ scan: > >> } > >> > >> /* Single sector, already protected? Nothing to do! */ > >> - if (first == last) > >> + if (first > last) > > > > ... not. the loop previously maintained the "first <= last" invariant, > > and should still have done so. "first > last" is clearly an error case. > Dave, > if only one sector is required to protect (first == last), and it is > already protected, the loop will "++first".
Your modified one will. But it shouldn't. (And it didn't before. Your change to the loop continuation test is what broke that invariant... as a side effect of not updating tests inside the loop.) > When the loop exits with "first > last" it means no sector need to > change protection. No, it means something is very confused. That's an error condition, which is tested on procedure entry. > Anyway, this code is really ugly. > I'm planning to rewrite the whole loop. I'll send patch in few hours. I can think of a much simpler patch than rewriting. Look at the two tests in the loop core ... you can re-order them and fix the bug where your modified loop runs past the end of the region. _______________________________________________ Openocd-development mailing list [email protected] https://lists.berlios.de/mailman/listinfo/openocd-development
