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/5365

-- gerrit

commit 0cda3c21622148eb326af6e9b7e07f3cbb7f4279
Author: Tomas Vanek <[email protected]>
Date:   Fri Dec 20 23:18:37 2019 +0100

    src/flash/nor/at91sam3|4l|7: fix clang static analyzer warnings
    
    Change-Id: I5cd2b2ebb2bd1980bdd1632b5c35bda9718a1089
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c
index 2457c15..af0b50b 100644
--- a/src/flash/nor/at91sam3.c
+++ b/src/flash/nor/at91sam3.c
@@ -3653,7 +3653,8 @@ showall:
                }
                if ((who >= 0) && (((unsigned)(who)) < 
pChip->details.n_gpnvms)) {
                        r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), who, &v);
-                       command_print(CMD, "sam3-gpnvm%u: %u", who, v);
+                       if (r == ERROR_OK)
+                               command_print(CMD, "sam3-gpnvm%u: %u", who, v);
                        return r;
                } else {
                        command_print(CMD, "sam3-gpnvm invalid GPNVM: %u", who);
diff --git a/src/flash/nor/at91sam4l.c b/src/flash/nor/at91sam4l.c
index d356398..d4bfe53 100644
--- a/src/flash/nor/at91sam4l.c
+++ b/src/flash/nor/at91sam4l.c
@@ -601,6 +601,7 @@ static int sam4l_write(struct flash_bank *bank, const 
uint8_t *buffer,
 
        /* There's at least one aligned page to write out. */
        if (count >= chip->page_size) {
+               assert(chip->page_size > 0);
                int np = count / chip->page_size + ((count % chip->page_size) ? 
1 : 0);
 
                for (int i = 0; i < np; i++) {
diff --git a/src/flash/nor/at91sam7.c b/src/flash/nor/at91sam7.c
index 232260b..039746c 100644
--- a/src/flash/nor/at91sam7.c
+++ b/src/flash/nor/at91sam7.c
@@ -711,8 +711,6 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
        uint16_t page_size;
        uint16_t num_nvmbits;
 
-       char *target_name_t;
-
        int bnk, sec;
 
        at91sam7_info = malloc(sizeof(struct at91sam7_flash_bank));
@@ -753,9 +751,6 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
                return ERROR_OK;
        }
 
-       target_name_t = calloc(strlen(CMD_ARGV[7]) + 1, sizeof(char));
-       strcpy(target_name_t, CMD_ARGV[7]);
-
        /* calculate bank size  */
        bank_size = num_sectors * pages_per_sector * page_size;
 
@@ -794,7 +789,7 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
 
                at91sam7_info = t_bank->driver_priv;
 
-               at91sam7_info->target_name  = target_name_t;
+               at91sam7_info->target_name = strdup(CMD_ARGV[7]);
                at91sam7_info->flashmode = 0;
                at91sam7_info->ext_freq  = ext_freq;
                at91sam7_info->num_nvmbits = num_nvmbits;

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to