This is an automated email from Gerrit.

Tomas Vanek ([email protected]) just uploaded a new patch set to Gerrit, which you 
can find at http://openocd.zylin.com/4355

-- gerrit

commit 9c24c1986c8d9e941ce0e7fb73fc14376ee783ca
Author: Tomas Vanek <[email protected]>
Date:   Thu Jan 18 09:42:41 2018 +0100

    flash/nor/core: fix warning in flash_iterate_address_range_inner
    
    Refactor the code to improve readability.
    
    Reported by Clang static analyzer.
    
    Change-Id: I671447050e93c6f067917c4456b36ac11abb4663
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index ab69a32..e525628 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -399,18 +399,21 @@ static int flash_iterate_address_range_inner(struct 
target *target,
                return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
        }
 
-       addr -= c->base;
-       last_addr -= c->base;
+       if (c->prot_blocks == NULL || c->num_prot_blocks == 0) {
+               /* flash driver does not define protect blocks, use sectors 
instead */
+               iterate_protect_blocks = false;
+       }
 
-       if (iterate_protect_blocks && c->prot_blocks && c->num_prot_blocks) {
+       if (iterate_protect_blocks) {
                block_array = c->prot_blocks;
                num_blocks = c->num_prot_blocks;
        } else {
                block_array = c->sectors;
                num_blocks = c->num_sectors;
-               iterate_protect_blocks = false;
        }
 
+       addr -= c->base;
+       last_addr -= c->base;
 
        for (i = 0; i < num_blocks; i++) {
                struct flash_sector *f = &block_array[i];

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to