This is an automated email from Gerrit.

?yvind Harboe ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/178

-- gerrit

commit c4213655531caae774f6d2fdaa718728da9b9a02
Author: Øyvind Harboe <[email protected]>
Date:   Mon Nov 7 21:02:48 2011 +0100

    str7x: fix error propagation
    
    stick to convention of "retval" being used as error value to
    be propagated and use "flash_flags" local variable for flash
    flags read from how.
    
    Change-Id: I63f1f2248b4f4538d6cd7634ae277f7c0aadc346
    Signed-off-by: Øyvind Harboe <[email protected]>

diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c
index b872bc3..0084c67 100644
--- a/src/flash/nor/str7x.c
+++ b/src/flash/nor/str7x.c
@@ -284,45 +284,45 @@ static int str7x_waitbusy(struct flash_bank *bank)
 static int str7x_result(struct flash_bank *bank)
 {
        struct target *target = bank->target;
-       uint32_t retval;
+       uint32_t flash_flags;
 
-       int err;
-       err = target_read_u32(target, str7x_get_flash_adr(bank, FLASH_ER), 
&retval);
-       if (err != ERROR_OK)
-               return err;
+       int retval;
+       retval = target_read_u32(target, str7x_get_flash_adr(bank, FLASH_ER), 
&flash_flags);
+       if (retval != ERROR_OK)
+               return retval;
 
-       if (retval & FLASH_WPF)
+       if (flash_flags & FLASH_WPF)
        {
                LOG_ERROR("str7x hw write protection set");
-               err = ERROR_FAIL;
+               retval = ERROR_FAIL;
        }
-       if (retval & FLASH_RESER)
+       if (flash_flags & FLASH_RESER)
        {
                LOG_ERROR("str7x suspended program erase not resumed");
-               err = ERROR_FAIL;
+               retval = ERROR_FAIL;
        }
-       if (retval & FLASH_10ER)
+       if (flash_flags & FLASH_10ER)
        {
                LOG_ERROR("str7x trying to set bit to 1 when it is already 0");
-               err = ERROR_FAIL;
+               retval = ERROR_FAIL;
        }
-       if (retval & FLASH_PGER)
+       if (flash_flags & FLASH_PGER)
        {
                LOG_ERROR("str7x program error");
-               err = ERROR_FAIL;
+               retval = ERROR_FAIL;
        }
-       if (retval & FLASH_ERER)
+       if (flash_flags & FLASH_ERER)
        {
                LOG_ERROR("str7x erase error");
-               err = ERROR_FAIL;
+               retval = ERROR_FAIL;
        }
-       if (err == ERROR_OK)
+       if (retval == ERROR_OK)
        {
-               if (retval & FLASH_ERR)
+               if (flash_flags & FLASH_ERR)
                {
                        /* this should always be set if one of the others are 
set... */
                        LOG_ERROR("str7x write operation failed / bad setup");
-                       err = ERROR_FAIL;
+                       retval = ERROR_FAIL;
                }
        }
 
@@ -335,7 +335,7 @@ static int str7x_protect_check(struct flash_bank *bank)
        struct target *target = bank->target;
 
        int i;
-       uint32_t retval;
+       uint32_t flash_flags;
 
        if (bank->target->state != TARGET_HALTED)
        {
@@ -343,11 +343,14 @@ static int str7x_protect_check(struct flash_bank *bank)
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       target_read_u32(target, str7x_get_flash_adr(bank, FLASH_NVWPAR), 
&retval);
+       int retval;
+       retval = target_read_u32(target, str7x_get_flash_adr(bank, 
FLASH_NVWPAR), &flash_flags);
+       if (retval != ERROR_OK)
+               return retval;
 
        for (i = 0; i < bank->num_sectors; i++)
        {
-               if (retval & str7x_info->sector_bits[i])
+               if (flash_flags & str7x_info->sector_bits[i])
                        bank->sectors[i].is_protected = 0;
                else
                        bank->sectors[i].is_protected = 1;

-- 

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Openocd-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to