flash/nor/fm4,tms470: fix clang static analyzer warnings 66/5366/2
authorTomas Vanek <vanekt@fbl.cz>
Fri, 20 Dec 2019 22:23:26 +0000 (23:23 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Sat, 7 Mar 2020 15:28:53 +0000 (15:28 +0000)
Change-Id: I18c1501918d40453fea6aeeb6f035e46d41fc524
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5366
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
src/flash/nor/fm4.c
src/flash/nor/tms470.c

index a8877b4fbbd2b48a75070c21a3ac14ce8cbfdf22..7e3a1c51fa3e6fe6d3abcc9f395747a88b860f82 100644 (file)
@@ -207,7 +207,7 @@ static int fm4_flash_write(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t halfword_count = DIV_ROUND_UP(byte_count, 2);
        uint32_t result;
        unsigned i;
-       int retval;
+       int retval, retval2 = ERROR_OK;
        const uint8_t write_block_code[] = {
 #include "../../../contrib/loaders/flash/fm4/write.inc"
        };
@@ -327,7 +327,7 @@ static int fm4_flash_write(struct flash_bank *bank, const uint8_t *buffer,
 err_run_ret:
 err_run:
 err_write_data:
-       retval = fm4_enter_flash_cpu_rom_mode(target);
+       retval2 = fm4_enter_flash_cpu_rom_mode(target);
 
 err_flash_mode:
        for (i = 0; i < ARRAY_SIZE(reg_params); i++)
@@ -338,7 +338,9 @@ err_alloc_data:
 err_write_code:
        target_free_working_area(target, code_workarea);
 
-       return retval;
+       if (retval != ERROR_OK)
+               return retval;
+       return retval2;
 }
 
 static int mb9bf_probe(struct flash_bank *bank)
index 90557b8f166473c2d7ff294f72ebe5679d6f0eee..bc16acab52fbcc57ebfb54ef8565934e597772db 100644 (file)
@@ -709,6 +709,7 @@ static int tms470_erase_sector(struct flash_bank *bank, int sector)
         * Select one or more bits in FMBSEA or FMBSEB to disable Level 1
         * protection for the particular sector to be erased/written.
         */
+       assert(sector >= 0);
        if (sector < 16) {
                target_read_u32(target, 0xFFE88008, &fmbsea);
                target_write_u32(target, 0xFFE88008, fmbsea | (1 << sector));

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)