David, please review the patch in attachment. It corrects the code consistency that was broken by my previous patch. Following your comments, it restores the invariants as in the original code.
Best Regards Antonio Borneo
From 7839f71092e0a89ad22a070fc6613feba44d80f9 Mon Sep 17 00:00:00 2001 From: Antonio Borneo <[email protected]> Date: Tue, 16 Mar 2010 17:42:20 +0800 Subject: [PATCH] NOR CORE: fix code consistency with comments Commit 17d437a7a193e783e8daeb0837e6dad5e6811213 makes code not consistent with existing comments and breaks invariants. Signed-off-by: Antonio Borneo <[email protected]> --- src/flash/nor/core.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c index 8b581b0..b69adfe 100644 --- a/src/flash/nor/core.c +++ b/src/flash/nor/core.c @@ -90,10 +90,10 @@ scan: * REVISIT we could handle discontiguous regions by issuing * more than one driver request. How much would that matter? */ - if (i == first) { + if (i == first && i != last) { updated = true; first++; - } else if (i == last) { + } else if (i == last && i != first) { updated = true; last--; } @@ -108,10 +108,13 @@ scan: } /* Single sector, already protected? Nothing to do! */ - if (first > last) + if (first == last && bank->sectors[first].is_protected == set) return ERROR_OK; + /* Note that we don't pass illegal parameters to drivers; any + * trimming just turns one valid range into another one. + */ retval = bank->driver->protect(bank, set, first, last); if (retval != ERROR_OK) { -- 1.5.2.2
_______________________________________________ Openocd-development mailing list [email protected] https://lists.berlios.de/mailman/listinfo/openocd-development
